有没有人知道是否可以在IIS中托管自托管的WorkflowServiceHost应用程序而不将其转换为XAMLX文件?如果是这样,怎么样?
此外,是否有人有任何关于将XAMLX文件部署到IIS 7的良好指导原则?
提前致谢
答案 0 :(得分:3)
您可以通过编写自己的托管引擎而不是XAMLX来执行相同的基本操作。然后,您可以通过ASP.NET加载应用程序,但可以完全控制它的生命周期/生命周期。
您必须创建自己的主机才能将.XAML
工作流加载到类似WorkflowApplication
的内容中,并管理该工作流的生命周期。它看起来像这样:
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();
除此之外还有更多内容,但它给出了它如何工作的基本概念。
编辑(3/23/2011)
如果有人想要基本代码的副本来执行此操作,请找到联系我的方法。