Bootstrap code in K2 WorkFlow server

  • 24 March 2011
  • 6 replies
  • 1 view

Badge +2

Hi,


 


Is there any way where we can execute some custom C# code during server startup like the application_start event in global.asax in ASP.NET?


 


Thanks,


lyf


6 replies

Badge +9

Not that I recall.  The K2 server doesn't work the same way as IIS.


Is there a specific thing you are trying to do?

Badge +2

I'm trying to use NHibernate for data access in my workflow. In IIS, I will load the nhibernate mappings during startup and it will be available throughout. Now I like to do the same in K2. Is there any way for me to do that?


If there is no way, how about I load the mappings whenever an instance of the WF is spawned but that will be costly overheads. I believe these mappings will be gone once workflow finishes and it will not be available to other instances.


Any advice?


 

Badge +9

Arr that makes sense.  However, I think at this point there is no way to hook this up with the K2 server startup.


I would think that maybe a possible workaround is to load the nhibernate mappings using a windows service.  The K2 process can then do a reference to this service and call your custom method to retrieve the settings.  You probably have to test this out to see if it is a valid approach.

Badge +2

Thanks, Johnny. I will try this approach and post the outcome.

Badge +2

Hi Johnny,


I'm new to K2 and have limited knowledge of windows service as well.


I was wondering what do you mean by "The K2 process can then do a reference to this service and call your custom method to retrieve the settings."?


Does it involve some sort of process-to-process communication? like WCF call? or .NET remoting?


Thanks

Badge +9

It is in a way some form of process to process communication as it does a function call across windows processes.  However, in terms of code, it is not any different from calling a .NET dll.


The only difference is that a windows service basically allows you to initialize the class during the service startup.  I probably won't go explain what a windows service is as this is a basic topic that is covered in any decent C# book and there should be lots of articles on the web covering this topic.


 

Reply