Elasticsearch NEST – Examples for mapping between Query and C#

During my training with Elasticsearch I would like to map a query with GET/POST method to C# syntax of NEST. It’s very helpful for me to see how NEST composes its internal queries and sends to Elasticsearch server. I just post my sample project here, maybe it’ll help you too.

Continue reading Elasticsearch NEST – Examples for mapping between Query and C#

Universal app – Windows 10 Action Center Toast Notification

Action Center is a new feature of Windows 10. It’s a collapsible panel on the right of the monitor where the software can notify his user about his status. It works exactly same as the notification of apps in smartphone. User can click on the notification to go directly to the apps. In this blog spot I will make a short demo showing how we can display a notification in Action Center. The demo contains a very simple email client working with IMAP server and notifies the user how many unread emails there are in his inbox. This email client works as an universal app.

Continue reading Universal app – Windows 10 Action Center Toast Notification

C# – An example of OCR web service

Years ago I wrote a small post about C# โ€“ OCR library candidates for comparing between OCR libraries of Tesseract and Microsoft Office Document Imaging. Tesseract is an open source OCR framework. Unfortunately, its inaccuracy is still high and can’t be used in commercial products. Last week I would like to make a small OCR web service for training myself and to test Tesseract again. The result is still as bad as last time (I guess FineReader of Abby may be the best OCR SDK but I have no full version for testing). Although Tesseract is not able to recognize complex documents, I also used it for this example because there is no other better candidate. The sample OCR web service works pretty simply, he receives a file which is uploaded from the client, runs OCR and returns text back. No big deal.

Continue reading C# – An example of OCR web service

C# – ASP.NET Web API and ASP.NET Identity

We got to know with Google, Flickr and Twitter API service in some of my previous posts. All these provide us an authentication scheme so that we can authenticate ourselves and get permissions to 3rd party resources. We have also created our own REST web services by using ASP.NET Web API for publishing data to our clients. However, until now, our web services are all simply public to everyone. Everyone can use them, even our competitors (if there’s any) ๐Ÿ™‚ That’s not good and I also received questions if a web service can be protected by using authentication. So in this post I would like to make an introduction about new technology of Microsoft : The ASP.NET Identity. We’ll build a very simple REST web service with ASP.NET Web API and ASP.NET Identity from Visual Studio template and try to access it from a .NET client.

The ASP.NET Identity system is designed to replace the previous ASP.NET Membership and Simple Membership systems. It includes profile support, OAuth integration, works with OWIN, and is included with the ASP.NET templates shipped with Visual Studio 2013.

Continue reading C# – ASP.NET Web API and ASP.NET Identity

Sqlite with Entity Framework Code First and Migration

Last month I’ve a chance to develop an app using Sqlite and Entity Framework Code First. Before I started with this project, I thought everything will be easy because Sqlite and Entity Framework are both popular framework. Maybe I just need to install some nuget packages and it will work like a charm. But… yes, there is always a ‘but’ later, it’s just not so easy. Especially when I usually work with NHibernate than Entity Framework. The installation doesn’t complete his job when configuring the .config file (or maybe it just happens for me or does the author do it with intentionally?) and the Migration for Sqlite Entity Framework Code First is not supported (please correct me if I’m wrong). There are, of course, commercial products for Sqlite Migration but I prefer an open source framework or something free :). So in this post I would like to write down the steps required when starting a project for Sqlite Entity Framework Code First and how I make my own simple Migration engine.

Continue reading Sqlite with Entity Framework Code First and Migration

C# – Lotus NotesSQL Driver install, configure and connect to server through ODBC

Lotus Notes and Lotus Domino are the client and server of a collaborative client-server software platform from IBM. The ecosystem provides business collaboration functionality, including email, calendars, to do lists, contacts management, discussion forums, file sharing, instant messaging, blogs, and user directories. Like other business applications, Lotus system conducts a database system behind to manage all data objects for sharing data between internal applications. To make the system itself more friendly to 3rd applications, Lotus also provides a driver – Lotus NotesSQL – so that 3rd applications can query data from Domino server. With Lotus NotesSQL, users and application developers can integrate Domino data with their applications through ODBC. IT professionals can enable their existing ODBC-enabled applications to access data stored in a Domino database. It allows ODBC-enabled data reporting tools, database tools, and application development tools to read, report, and update information that is stored in Domino databases (NSF files).

Continue reading C# – Lotus NotesSQL Driver install, configure and connect to server through ODBC

Tool,C# – Docx to Html library

A “big” project comes from a small requirement. That always happens in programming. What I really need is just the thumbnails of MS Office 2007/2010 files, but there is no reasonable way so that I can get them without having to install MS Office (or another 3rd party components) on server. The thumbnails are only generated and stored with Office files only if users set the option “Save thumbnail” intentionally. If they don’t set this option, I have no way to get thumbnail because it’s not available. Many suggestions are made on Internet such as using Open Office, using Share Point Word Automation Service, converting to PDF then getting thumbnail or using a 3rd party component…

Continue reading Tool,C# – Docx to Html library

C# – Use LINQ To XML to read XML report generated/created by Crystal Report

The requirement to read a XML file to Crystal Report is very common but how can we read a generated XML file by Crystal Report back to object class and why do we have to do that? Let’s consider this case, a company has SAP products and uses Crystal Report to create reports from databases of those products. Now he would like to export data from this SAP system to 3rd party product but this product has no idea about the database structure of SAP. He orders us to write a small program to do that. The question is what should we do now to keep process simple as it should be?

Continue reading C# – Use LINQ To XML to read XML report generated/created by Crystal Report

C# – Host Microsoft Chart in WPF application

How we provide our customers the way to display their data is a important feature of every software for data management. Maybe the users want to use Bar, Line, Pie, Pyramid chart… someone wants to display as 2D and the other wants 3D for his plotting. The financial prefer Kagi, Renko, Point and Figure chart… meanwhile the statisticians maybe use Bar and Column, Cylinder or just simple Line chart. Because of these numerously different requirements we need a stable chart library flexible for customizing and extending. We can make ourselves one or there are a lot of candidates out there in internet such as ZedGraph, Telerik component, DevExpress component… But my favor is Microsoft Chart included in .Net Framework. The components of Telerik, for example, are beautiful with their animations (in WPF) and have a lot of advance features. However the structure of this framework is not stable with breaking changes with new released versions. The Microsoft Chart provides us all simple features necessary for data representing and is very stable. We can use it on Windows Forms or WPF or even on ASP.NET website.

Continue reading C# – Host Microsoft Chart in WPF application

Tool – ProjectEuler Solution

After reading some reviews of interviews at Microsoft and Google, I am inspired to train myself for solving mathematical problems and writing algorithms. http://projecteuler.net/ is my first “mountain peak” to conquer. This website has until now more than 350 problems of many fields in mathematics. It’s suitable for training to write efficient algorithms to solve complicated computing tasks. I’m just at starter level and don’t have much time for it but when I have free time I’ll solve some of them. To manage all solved problems, I have written a GUI Tool which loads all problems as plugins, allow me to enter argument with its value and invoke the calculate method to get result back.
The tool will scan folder “Extensions” at its startup directory and load all plugins written for him. Therefore you can write your own plugin, copy to “Extensions” folder and use the tool as GUI to run your solution.
I also created a Web-version of this tool but the website version is very limited. It doesn’t permit to upload your solutions (I know you’re good hackers) and customize value of argument (I’ll improve the website version in next version so that you can customize the input).

  • Version:
  • Supported OS: All Windows

NOTE: If this tool doesnโ€™t work with your system, post here your errors.

LINK DOWN: http://hintdesk.com/Web/Tool/ProjectEulerSolution.zip

WEBSITE: http://projecteulersolutionweb.apphb.com/ (the website is pretty slow at first load. Sorry for that, I don’t have any Windows host to host my application)


  • [] : Beta Version


ProjectEuler Solution

– To write your own plugin which works with this GUI tool, you should create a library and add reference to libraries

  • RPESPlugIn.dll (which can be found in “Extensions” folder)
  • System.ComponentModel.Composition.dll
  • – Your solution class must implement the IProblemSolution interface and define some attributes as example below

    [ProblemSolutionAttribute("Problem 1", @"If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
    Find the sum of all the multiples of 3 or 5 below 1000.
    public class Problem1Solution : IProblemSolution
    	public string GetResult(List<ProblemArg> probArgs)
    		Stopwatch stopWatch = new Stopwatch();
    		double result = Calculate(probArgs);
    		return string.Format("Result: {0}\nTime elapsed: {1} ms", result, stopWatch.ElapsedMilliseconds);
    	public double Calculate(List<ProblemArg> probArgs)
    		int n = Convert.ToInt32(probArgs.First().Value) - 1;
    		return SumDivisibleBy(n, 3) + SumDivisibleBy(n, 5) - SumDivisibleBy(n, 15);
    	public double ProjectEulerCalculate(List<ProblemArg> probArgs)
    		throw new NotImplementedException();
    	private int SumDivisibleBy(int n, int factor)
    		int i = (n / factor);
    		return factor * i * (i + 1) / 2;
    	public List<ProblemArg> RequiredInputArgs
    			return new List<ProblemArg>() { new ProblemArg { DefaultValue = "1000", Name = "Integer n", RegularExpression = "^[0-9.]+$", MaxLength = Int32.MaxValue.ToString().Length } };

    – There are 2 required attributes for your class solution. One is the name of problem which should be shown in combo box and the other is the description of problem which should be displayed in text box.

    – If you want to allow user enter value of argument, you should define the RequiredInputArgs property to give a list of argument back. The list can contain more arguments which will be show in list box under problem description.

    – The GetResult(List probArgs) gives you a signal that the user want to invoke your solution with his defined value (if any). In this function you can make your calculation (which can be in Calculate(List probArgs) function but it must not) and give the result back with type of string.

    So it’s pretty easy to write extension for this GUI tool. Try yourself to write your own solution and let this tool manages all solution for you.