Hosting a self-hosted WF in IIS

本小妞迷上赌 提交于 2020-01-01 19:29:06

问题


Does anyone know if it's possible to host a self-hosted WorkflowServiceHost application in IIS without turning it into a XAMLX file? If so, how?

Furthermore, does anyone have any good guidelines for deploying XAMLX files in general to IIS 7?

Thanks in advance


回答1:


You can do the same basic thing by writing your own hosting engine instead of the XAMLX one. You can then load applications via ASP.NET, but have complete control on it's lifespan/lifecycle.

You have to create your own host to load the .XAML workflows into something like a WorkflowApplication and manage the lifespan of that workflow. It looks something like this:

private SqlWorkflowInstanceStore _InstanceStore { get; private set; }
private InstanceHandle _MyInstanceHandle { get; private set; }

_InstanceStore = new SqlWorkflowInstanceStore(DataStore.ConnectionString.Replace("MultipleActiveResultSets=True", "MultipleActiveResultSets=False"));
_InstanceStore.HostLockRenewalPeriod = new TimeSpan(0, 0, 30);
_InstanceStore.InstanceEncodingOption = InstanceEncodingOption.None;
_InstanceStore.InstanceLockedExceptionAction = InstanceLockedExceptionAction.BasicRetry;
_InstanceStore.InstanceCompletionAction = InstanceCompletionAction.DeleteNothing;

_MyInstanceHandle = _InstanceStore.CreateInstanceHandle();
var CreateOwnerCommand = new CreateWorkflowOwnerCommand();
var MyView = _InstanceStore.Execute(_MyInstanceHandle, CreateOwnerCommand, TimeSpan.FromSeconds(30));
_InstanceStore.DefaultInstanceOwner = MyView.InstanceOwner;

WorkflowApplication ThisApplication = null;

if (parameters == null)
    ThisApplication = new WorkflowApplication(activity);
else
    ThisApplication = new WorkflowApplication(activity, parameters);
ThisApplication.PersistableIdle = e => PersistableIdleAction.Unload;
ThisApplication.InstanceStore = this.InstanceStore;
ThisApplication.Run();

There is a bit more to it then just the above, but it gives the basic concepts of how it would work.

EDIT (3/23/2011)

If anyone wants a copy of the basic code to do this, find a way to contact me.



来源:https://stackoverflow.com/questions/5192466/hosting-a-self-hosted-wf-in-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!