Ejemplo n.º 1
0
        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 XpandWorkFlowModule());
            serverApplication.ApplicationName = applicationName;
            serverApplication.ConnectionString = connectionString;


            
            serverApplication.Security = securityComplex;
            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;

            };
        }
Ejemplo n.º 2
0
        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();
        }