简体   繁体   中英

How do I create and deploy a Windows service in EWL?

I know EWL has support for services, but I'm not sure what is different about them or what steps I have to take to create one.

Also, is it possible to manually deploy an EWL service in the same manner as a conventional service, or do I have to use the deployment utility?

EWL services give you a simple programming model, with only three places you can put your logic: the Init , CleanUp , and Tick methods. Besides deciding how to divide your logic among these methods, no thinking is required. There is also no flexibility beyond these three methods, so if your problem doesn't neatly fit into this model, don't use an EWL service.

To create an EWL service inside an existing EWL solution:

  1. Add a Windows Service project to your solution. Name it "Windows Service" or anything else. Set it to use the EWL NuGet package, just like the other projects in your solution.
  2. In Library/Configuration/General.xml, add a section like this beneath <WebApplications> :

     <WindowsServices> <Service> <Name>YOUR-SERVICE-PROJECT-NAME</Name> <NamespaceAndAssemblyName>YOUR-SERVICE-PROJECT-NAMESPACE</NamespaceAndAssemblyName> </Service> </WindowsServices> 
  3. Update dependent logic.

  4. Show hidden files in your service project, and add Generated Code/ISU.cs.
  5. Add a Program.cs file to the project, containing this class:

     internal partial class Program { static partial void initGlobalLogic( ref SystemLogic globalLogic ) { globalLogic = new GlobalLogic(); } } 
  6. Add a CAMEL-CASED-SERVICE-PROJECT-NAME.cs file to the project, containing a class similar to:

     internal partial class CAMEL-CASED-SERVICE-PROJECT-NAME { string WindowsServiceBase.Description { get { return "..."; } } void WindowsServiceBase.Init() {} void WindowsServiceBase.CleanUp() {} void WindowsServiceBase.Tick() {} } 
  7. Remove any boilerplate files in your project that seem unnecessary.

I believe you can install EWL services manually. Just do a build and do whatever you need to with the files in the bin directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM