1

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?

William Gross
  • 2,083
  • 2
  • 17
  • 35
Greg Smalter
  • 6,571
  • 9
  • 42
  • 63

1 Answers1

1

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.

William Gross
  • 2,083
  • 2
  • 17
  • 35
  • If I don't currently have a Library/Configuration/General.xml and this is the first thing in my solution using EWL, can I have just the WindowsServices section? Do I need to set up any other EWL stuff that is unrelated to the service in order for Update Dependent Logic to work? – Greg Smalter Jul 18 '12 at 14:02
  • I don't think you need to have a web project, but you probably do need a Library project with a Configuration folder in it. Inside Configuration, you probably need `Development.xml`, `General.xml`, and `Installations/Development/Standard.xml`. – William Gross Jul 18 '12 at 17:11
  • @GregSmalter: Also, the schemas for those XML files will be online after the next EWL release. – William Gross Jul 18 '12 at 17:21