StrataFrame Forum

How do I write a Windows Service using Strataframe BOs

http://forum.strataframe.net/Topic19681.aspx

By Peter Denton - 9/24/2008

G'day

We have a continuous task that checks a database table for the existence of unprocessed records, and if it finds any processes them. This is done without user interaction, and doesn't need a user interface. We have previously handled this by running a form on the console of the Server (started in the logon script of a user which is automatically logged in). However It would seem preferable to do this as a service.

Can Strataframe BOs be used in a service, and is there an example of how it is accomplished somewhere? I've had a look in the documentation, demos and forum but didn't find anything.

Peter

By Trent L. Taylor - 9/25/2008

Absolutely.  Our medical software has a critical component which is a service.  We have a server to which all clients connect to manage database connections, licensing, automated tasks, and a whole lot more.  Bottom line is that our software won't work without this server.  So it is the hub of all operations.  And it is written using StrataFrame and BOs, etc.

The reason that we do not have a sample is because there is not a whole lot to add past creating a service.  It is just a matter of adding the SF assemblies and then start programming as though it were a class library or a program without UI.

We have a UI console that talks to the service so that certain things can be setup, status seen, etc.  But as for the service, it is obviously non-UI (as you will want to be sure that it is...even if you intend for your service to "Interact with desktop").

But there really isn't a whole lot to add past that...just add your SF references and get to work.  One other piece of advice that I might share is that we used Http requests and responses versus having sockets open all of the time for communication between the client and server which has worked out very nicely, but this doesn't have anything to do with SF...just a suggestion.

By Keith Chisarik - 9/25/2008

I haven't specifically done windows services with SF, but I have done web services implementing SF with great success, and I think they are very similar.
By Peter Denton - 9/26/2008

Thanks Guys,

I'm not sure that I'm out of the woods yet, but I've got my service to install, start and stop, now I only have to get it to do something useful.

I've copied the SetSources out of the AppMain of one of my StrataFrame projects, put it in my service.vb, and called it directly from the sub main (in the designer code). I haven't got anything from the database yet, but i found the error in the event log about the account NT AUTHORITY\LOCAL SERVICE not having access to MSSQL strangely encouraging.

Peter

By Dustin Taylor - 9/26/2008

Sounds like you are on the right track Smile. That is just a permissions issue, but it looks as though you are on top of it. Let us know if you hit any speed bumps!
By Trent L. Taylor - 9/26/2008

Just FYI, within the service you are generally better off providing a user name authentication that integrated security...it makes deployment easier and more reliable depending on the environment in which it is being installed.  But really either will work, but I have seen this cause issues before in the field with trying to use integrated security via a server and having a hard time connection to the server.