Thursday, September 21, 2017

Create windows service application (Step By Step) using C# .

In this tutorial we’ll create a windows service application. Suppose we’ve service which gives us notification in a text file when it starts and stop. Let’s create the service. 

And you can download full file form Slideshare By clicking in this  Link
............................................................................................................
1. Create a project with your visual studio.



2. Now select Windows Service application as shown below.




3. Now add an installer.



4. After selection “Add Installer”, a file named “ProjectInstaller.cs” will be added in your solutions. And there will be to things like label named “serviceInstaller1” and “serviceProcessInstaller1”. First select “serviceInstaller1” and go to properties. Then change the marked values as shown in image.





5. Now right click on “serviceProcessInstaller1” and go to properties then change the values as shown in image







6. Now Right click on your project and Create Public static class Named “Library.cs”. Like shown in image. And paste the following code inside the class.

using System.IO;
 using System.IO;

public static void WriteErrorLog(Exception ex)
{
  StreamWriter sw = null;
  try
  {
   sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\LogFile.txt", true);
   sw.WriteLine(DateTime.Now.ToString() + ": " + ex.Source.ToString().Trim() + "; " + ex.Message.ToString().Trim());
   sw.Flush();
   sw.Close();
         
  }
  catch
    {
//nothting
    }
  }

public static void WriteErrorLog(string Message)
{
   StreamWriter sw = null;
try
{
  sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\LogFile.txt", true);
  sw.WriteLine(DateTime.Now.ToString() + ": " + Message);
  sw.Flush();
  sw.Close();
      }
      catch
      {
//nothing
       }
     }



7. Now Right Click on your project > then select “Open Folder in File Explorer” > bin> Debug> Create a text file named “LogFile.txt”.



8.  Now Expand your Service (Ex. Here is Service1.cs) and double click on Service1.cs and write the code showed in image.



9. Now Save all changes and build your application. And Run Visual Studio Command Prompt as Administrator mode. Change the directory to application’s drive as showed the following image (Ex.:  here our directory is “G”) and hit enter key.



10. Now Right Click on your project > then select “Open Folder in File Explorer” > bin> Debug> and copy the directory from address bar. And then type cd <space> then paste the directory you copied and hit enter key. As like the following image.



11. Right Click on your project > then select “Open Folder in File Explorer” > bin> Debug>
Then copy your service name (Ex. Here our service name is “MyFirstServiceApp.exe”).


Now type “installutil.exe” <space> paste your service name you copied (in this case our service name is “MyFirstServiceApp.exe”) from Debug folder in your project as same as showed in following picture And hit enter key.





12. If everything are ok then you will get this type of result in your cmd and it means your service is ready to work.



13. Now navigate to windows services from start menu and run is as administrator.



14.  Now follow the find your services (i.e.: Here our service Name is “MyFirstService” ) and click on it then click on Start from left side of the service window.



15. Right Click on your project > then select “Open Folder in File Explorer” > bin> Debug> and open the text file Name “LogFile.txt”. You will see the following text has written in your text file. That means your service is working as your expectation. Close the text file.




16. Now once again go to service as described in 13 step. And stop your service as shown in picture bellow.



17. Open your text file named “LogFile.txt” as described in step 15. Now you will see another line has added in your text file which tells your service has stopped as same as following picture.




Download Full File From This Link

                  ====================== (~_~)(~_~)(~_~)======================

Thursday, February 23, 2017

crystal report export to pdf not working??? Or kb3102429 crystal reports problem?

crystal report export to pdf not working??? Or kb3102429 crystal reports problem?

Crystal report pdf export font problem...???



If You've Got in problem for exporting your crystal report, Or When your  barcode size problem for export to PDF in Crystal Report, Your solution is Here. 


Just follow the following steps ...


To Solve the problem, just follow steps  by adding 2 registry keys as i showed or as my guide line.

1. Go To Start => Run
2.Then Type "regedit" and click OK(case sensetive).

3. Chose any one, which is goes with your system...
  a. If your are using Crystal Reports 2008, Expand HKEY_CURRENT_USER=>Software=>Business Objects=>Suite 12.0=>Crystal Reports=>Export.

  b. If your are using  Crystal Reports 11.0, Expand HKEY_CURRENT_USER=>Software=>Business Objects=>Crystal Reports.

  c. If your are using  Crystal Reports 10.0, Expand HKEY_CURRENT_USER=>SOFTWARE=>Crystal Decisions=>10.0=>Crystal Reports=>Export

  d. If your are using  Crystal Reports 9,0, Expand HKEY_CURRENT_USER=>software=>crystal decisions=>9.0=>Crystal Reports=>Export  

4.Then  Right-click the Export folder and select New => Key. This will  creates a new folder. 

5.Then Name the new folder PDF  => Right-click the PDF folder and then select New => DWORD Value.

6.Then Name this "ForceLargerFonts" with no quotes and note that it is case sensitive(Just copy as same without any quoets).

7.Then Double-click ForceLargerFonts => change the Value data to 1 => Just click OK.

8.After completing all those things at earlyer Then => Close all the registry folders.

9.Now Expand the following registry(Chose any one, which is goes with your system...).


 a. If your are using  Crystal Reports 2008, HKEY_LOCAL_MACHINE=>Software=>Business Objects=>Suite 12.0=>Crystal Reports.

 b. If your are using  Crystal Reports 11.0, HKEY_LOCAL_MACHINE=>Software=>Business Objects=>Suite 11.0.

 c. If your are using  Crystal Reports 10.0, HKEY_LOCAL_MACHINE=>SOFTWARE=>Crystal Decisions=>10.0=>Crystal Reports

 d. If your are using  Crystal Reports 9.0, HKEY_LOCAL_MACHINE=>Software=>Crystal Decisions=>9.0=>Crystal Reports

10. Then Right-click the Crystal Reports folder => select New => Key. Name this key Export.

11. Then Right-click the Export folder =>select New => Key. This creates a new folder 

12. Then => Name this folder to PDF => Right-click the PDF folder and then select New => DWORD Value.

13.Then Name this "ForceLargerFonts" with no quotes and note that it is case sensitive(Just copy as same without any quoets).

14.Then Double-click ForceLargerFonts => change the Value data to 1 => Just click OK.

11. Close the Registry Editor Which you opend and restart Crystal Reports once again.


After successfully adding these two registry keys,You'll able to export your report with using any  font and
Crystal Reports will Not  have Any Kind of  font size problem for barcode also.


Another Things, If you wanna generate barcode in crystal reports from your Internet Information Services(IIS) then you've to modify or change
the permission of these registry keys. By default IIS Prevents the the application pool identity to read those registry entries.


Now Open your windows application regedit and then just go as i show..... 

=> HKEY_LOCAL_MACHINE => SOFTWARE => Business Objects => Suite 12.0 => Crystal Reports => Export => PDF
=> then Right click on the key and then choose "Permissions" from the menu 
=> And at last add in default IIS user account(Usually it's IUSR_MachineName).

Stay Connected  And  Stay Blessed.... Happy Coding.

How To Make JQuery Data Table From Asp.Net Grid\View....?

Jquery Data Table is a Jquery plugin which enables you to manipulate your data in web browser such a cool way. which attract your your client. And It's also provides you a lot of functionality  such as Searching, Sorting, Paging , How Many Number of Row you want to see etc.

This article gives a walk-through of jQuery Datatables plugin to display the data stored in database using ASP.NET web services.
Here is the cdn of datatables plugin, which you've embed in your html/aspx page.
  1.  <script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
  2.     <link  href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css" rel="stylesheet"/>
After embedded this two line  You've write another simple code. Like the following code
  <script>
        $(function () {
            $("#yourGridId").prepend($("<thead></thead>").append($(this).find("tr:first"))).dataTable();
        });
    </script>




Here is a video tutorial, which will help you to give you a deep knowledge About the Asp Grid and jquery data table......

Stay Blessed And Stay Connected... Happy Coding,
.