private void Start_(string connectionString, string applicationName) { var serverApplication = new ServerApplication(); serverApplication.Modules.Add(new XpandWorkFlowModule()); serverApplication.ApplicationName = applicationName; serverApplication.ConnectionString = connectionString; serverApplication.Security = new SecurityComplex<User, Role>( new WorkflowServerAuthentication(new BinaryOperator("UserName", "WorkflowService"))); serverApplication.Setup(); serverApplication.Logon(); IObjectSpaceProvider objectSpaceProvider = serverApplication.ObjectSpaceProvider; server = new XpandWorkflowServer(ConfigurationManager.AppSettings["WorkflowServerAddress"], objectSpaceProvider, objectSpaceProvider); server.CustomizeHost += delegate(object sender, CustomizeHostEventArgs e) { e.WorkflowInstanceStoreBehavior.WorkflowInstanceStore.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(2); }; // server.WorkflowDefinitionProvider = new XpandWorkflowVersionedDefinitionProvider<XpoWorkflowDefinition, XpoUserActivityVersion>(objectSpaceProvider, null, new List<Type> { typeof(ScheduledWorkflow), typeof(ObjectChangedWorkflow) }); server.WorkflowDefinitionProvider = new XpandWorkflowDefinitionProvider(typeof(XpoWorkflowDefinition), new List<Type> { typeof(ScheduledWorkflow), typeof(ObjectChangedWorkflow) }); server.StartWorkflowListenerService.DelayPeriod = TimeSpan.FromSeconds(5); server.StartWorkflowByRequestService.DelayPeriod = TimeSpan.FromSeconds(5); server.RefreshWorkflowDefinitionsService.DelayPeriod = TimeSpan.FromSeconds(30); server.Start(); server.CustomHandleException += (sender, e) => { Tracing.Tracer.LogError(e.Exception); if (OnCustomHandleException_ != null) { OnCustomHandleException_(this, new ExceptionEventArgs("Exception occurs:\r\n\r\n" + e.Exception.Message + "\r\n\r\n'" + e.Service.GetType() + "' service")); } e.Handled = true; }; }
private void Start_(string connectionString, string applicationName) { var securityComplex = new SecurityComplex<User, Role>(new WorkflowServerAuthentication(new BinaryOperator("UserName", "WorkflowService"))); var serverApplication = new XpandWorkflowApplication(securityComplex); serverApplication.Modules.Add(new WorkflowDemoWindowsFormsModule()); serverApplication.ApplicationName = applicationName; serverApplication.ConnectionString = connectionString; serverApplication.Security = securityComplex; serverApplication.Setup(); serverApplication.Logon(); IObjectSpaceProvider objectSpaceProvider = serverApplication.ObjectSpaceProvider; _xpandWorkflowServer = new XpandWorkflowServer("http://localhost:46232", objectSpaceProvider, objectSpaceProvider); _xpandWorkflowServer.CustomizeHost += delegate(object sender, CustomizeHostEventArgs e) { // // SqlWorkflowInstanceStoreBehavior // //e.WorkflowInstanceStoreBehavior = null; //System.ServiceModel.Activities.Description.SqlWorkflowInstanceStoreBehavior sqlWorkflowInstanceStoreBehavior = new System.ServiceModel.Activities.Description.SqlWorkflowInstanceStoreBehavior("Integrated Security=SSPI;Pooling=false;Data Source=(local);Initial Catalog=WorkflowsStore"); //sqlWorkflowInstanceStoreBehavior.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(2); //e.Host.Description.Behaviors.Add(sqlWorkflowInstanceStoreBehavior); //e.WorkflowIdleBehavior.TimeToPersist = TimeSpan.FromSeconds(1); e.WorkflowInstanceStoreBehavior.WorkflowInstanceStore.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(2); }; _xpandWorkflowServer.WorkflowDefinitionProvider = new XpandWorkflowDefinitionProvider(typeof(XpoWorkflowDefinition), new List<Type> { typeof(ScheduledWorkflow), typeof(ObjectChangedWorkflow) }); _xpandWorkflowServer.StartWorkflowListenerService.DelayPeriod = TimeSpan.FromSeconds(5); _xpandWorkflowServer.StartWorkflowByRequestService.DelayPeriod = TimeSpan.FromSeconds(5); _xpandWorkflowServer.RefreshWorkflowDefinitionsService.DelayPeriod = TimeSpan.FromSeconds(60); _xpandWorkflowServer.CustomHandleException += delegate(object sender, CustomHandleServiceExceptionEventArgs e) { Tracing.Tracer.LogError(e.Exception); if(OnCustomHandleException_ != null) { OnCustomHandleException_(this, new ExceptionEventArgs("Exception occurs:\r\n\r\n" + e.Exception.Message + "\r\n\r\n'" + e.Service.GetType() + "' service")); } e.Handled = true; }; _xpandWorkflowServer.Start(); }
private void StartOnServerDomain<TModulesProvider>(string connectionString, string applicationName) where TModulesProvider:ModuleBase{ var serverApplication = GetServerApplication(); serverApplication.Modules.Add(Activator.CreateInstance<TModulesProvider>()); serverApplication.ApplicationName = applicationName; serverApplication.ConnectionString = connectionString; serverApplication.Setup(); serverApplication.Logon(); var objectSpaceProvider = serverApplication.ObjectSpaceProvider; var xpoUserActivityVersionType = XpandModuleBase.GetDxBaseImplType("DevExpress.ExpressApp.Workflow.Versioning.XpoUserActivityVersion"); var engine=(WorkflowVersioningEngine) typeof(PersistentWorkflowVersioningEngine<>).MakeGenericType(xpoUserActivityVersionType).CreateInstance(objectSpaceProvider); var workflowDefinitionProvider = (IWorkflowDefinitionProvider)typeof(XpandWorkflowDefinitionProvider<>).MakeGenericType(xpoUserActivityVersionType).CreateInstance(XpandWorkFlowModule.WorkflowTypes.ToList(),engine); var xpandWorkflowServer = new XpandWorkflowServer("http://localhost:46232", workflowDefinitionProvider, objectSpaceProvider); xpandWorkflowServer.CustomizeHost += delegate (object sender, CustomizeHostEventArgs e) { // NOTE: Uncomment this section to use alternative workflow configuration. // // SqlWorkflowInstanceStoreBehavior // //e.WorkflowInstanceStoreBehavior = null; //System.ServiceModel.Activities.Description.SqlWorkflowInstanceStoreBehavior sqlWorkflowInstanceStoreBehavior = new System.ServiceModel.Activities.Description.SqlWorkflowInstanceStoreBehavior("Integrated Security=SSPI;Pooling=false;Data Source=(local);Initial Catalog=WorkflowsStore"); //sqlWorkflowInstanceStoreBehavior.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(2); //e.Host.Description.Behaviors.Add(sqlWorkflowInstanceStoreBehavior); //e.WorkflowIdleBehavior.TimeToPersist = TimeSpan.FromSeconds(1); //e.WorkflowIdleBehavior.TimeToPersist = TimeSpan.FromSeconds(10); //e.WorkflowIdleBehavior.TimeToUnload = TimeSpan.FromSeconds(10); e.WorkflowInstanceStoreBehavior.WorkflowInstanceStore.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(2); }; _server= xpandWorkflowServer; _server.CustomHandleException += delegate(object sender, CustomHandleServiceExceptionEventArgs e) { Tracing.Tracer.LogError(e.Exception); OnServerDomainCustomHandleException?.Invoke(this, new ExceptionEventArgs("Exception occurs:\r\n\r\n" + e.Exception.Message + "\r\n\r\n'" + e.Service.GetType() + "' service")); e.Handled = true; }; _server.Start(); }