Exemple #1
0
        public void ExecuteWorkflow_NullWorkflow_RaisesException()
        {
            IWorkflowServer workflowServer = new WorkflowServer(Substitute.For <IWorkflowStore>());
            TestDelegate    del            = () => workflowServer.ExecuteWorkflow(null);

            Assert.Throws <NullReferenceException>(del);
        }
Exemple #2
0
        public void ExecuteWorkflows_OnDelayedAction_ResumesAfterDelay()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            DelayedWorkflow workflow = new DelayedWorkflow(DelayedWorkflow.State.Start);

            workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = DelayedWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);

            // execute
            workflowServer.ExecuteWorkflows(5);
            workflow = workflowStore.Get <DelayedWorkflow>(workflow.Id);
            Assert.AreEqual(DelayedWorkflow.State.DoingStuff.ToString(), workflow.CurrentState);

            // execute again - nothing should have changed
            workflowServer.ExecuteWorkflows(5);
            workflow = workflowStore.Get <DelayedWorkflow>(workflow.Id);
            Assert.AreEqual(DelayedWorkflow.State.DoingStuff.ToString(), workflow.CurrentState);

            // delay and run - should be now be complete
            Thread.Sleep(3100);
            workflowServer.ExecuteWorkflows(5);
            Assert.IsNull(workflowStore.GetOrDefault(workflow.Id));
            Assert.IsNotNull(workflowStore.GetCompletedOrDefault(workflow.Id));
        }
        private void Start_(string connectionString, string applicationName) {
            var serverApplication = new ServerApplication();
            //            moduleBases.Each(@base => serverApplication.Modules.Add(@base));
            serverApplication.ApplicationName = applicationName;
            serverApplication.ConnectionString = connectionString;
            Type securityType = typeof(SecurityComplex).MakeGenericType(new[] { SecuritySystem.UserType, ((ISecurityComplex)SecuritySystem.Instance).RoleType });
            serverApplication.Security = (ISecurity)Activator.CreateInstance(securityType, new WorkflowServerAuthentication(new BinaryOperator("UserName", "WorkflowService")));
            //            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["WorkflowServerUrl"], objectSpaceProvider, objectSpaceProvider);
            server.CustomizeHost += delegate(object sender, CustomizeHostEventArgs e) {
                e.WorkflowInstanceStoreBehavior.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(2);
            };
            //            server.WorkflowDefinitionProvider = new WorkflowVersionedDefinitionProvider<XpoWorkflowDefinition, XpoUserActivityVersion>(objectSpaceProvider, null);
            server.WorkflowDefinitionProvider = new XpandWorkflowDefinitionProvider(typeof(XpoWorkflowDefinition), new List<Type> { typeof(ScheduledWorkflow), typeof(ObjectChangedWorkflow) });
            server.StartWorkflowListenerService.DelayPeriod = TimeSpan.FromSeconds(5);
            server.StartWorkflowByRequestService.RequestsDetectionPeriod = TimeSpan.FromSeconds(5);
            server.RefreshWorkflowDefinitionsService.DelayPeriod = TimeSpan.FromSeconds(30);

            server.Start();
            server.CustomHandleException += delegate(object sender, DevExpress.ExpressApp.Workflow.ServiceModel.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;
            };
        }
Exemple #4
0
        public void ExecuteWorkflow_OnWorkflowSuspension_WorkflowSuspendedEventRaised()
        {
            string initialState = Guid.NewGuid().ToString();
            bool   eventRaised  = false;

            Workflow workflow = Substitute.For <Workflow>();

            workflow.ResumeTrigger  = "Test";
            workflow.RetryIntervals = new int[] { };
            workflow.CurrentState.Returns(initialState);
            workflow.WhenForAnyArgs(x => x.Fire(Arg.Any <string>())).Do(x => { throw new Exception(); });

            // make sure the workflow is suspended
            IWorkflowExceptionHandler workflowExceptionHandler = Substitute.For <IWorkflowExceptionHandler>();

            workflowExceptionHandler.WhenForAnyArgs(x => x.HandleWorkflowException(Arg.Any <Workflow>(), Arg.Any <Exception>())).Do(x => { workflow.IsSuspended = true; });

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(Substitute.For <IWorkflowStore>(), Substitute.For <IWorkflowRegistrationService>(), workflowExceptionHandler);

            workflowServer.WorkflowSuspended += delegate(object sender, WorkflowEventArgs e) {
                eventRaised = true;
            };
            workflowServer.ExecuteWorkflow(workflow);

            Assert.IsTrue(eventRaised);
        }
Exemple #5
0
        public void IsSingleInstanceWorkflowRegistered_OnExecute_UsesService()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore            = Substitute.For <IWorkflowStore>();
            IWorkflowRegistrationService regService = Substitute.For <IWorkflowRegistrationService>();

            IWorkflowServer workflowServer = new WorkflowServer(workflowStore, regService, Substitute.For <IWorkflowExceptionHandler>());

            workflowServer.IsSingleInstanceWorkflowRegistered <BasicWorkflow>();
            regService.Received(1).IsSingleInstanceWorkflowRegistered <BasicWorkflow>(workflowStore);
        }
Exemple #6
0
        public void RegisterWorkflow_OnRegister_UsesService()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore            = Substitute.For <IWorkflowStore>();
            IWorkflowRegistrationService regService = Substitute.For <IWorkflowRegistrationService>();

            BasicWorkflow   workflow       = new BasicWorkflow(BasicWorkflow.State.Start);
            IWorkflowServer workflowServer = new WorkflowServer(workflowStore, regService, Substitute.For <IWorkflowExceptionHandler>());

            workflowServer.RegisterWorkflow(workflow);

            regService.Received(1).RegisterWorkflow(workflowStore, workflow);
        }
        public void RegisterWorkflow_OnRegister_UsesService()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = Substitute.For<IWorkflowStore>();
            IWorkflowRegistrationService regService = Substitute.For<IWorkflowRegistrationService>();

            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.Start);
            IWorkflowServer workflowServer = new WorkflowServer(workflowStore, regService, Substitute.For<IWorkflowExceptionHandler>());
            workflowServer.RegisterWorkflow(workflow);

            regService.Received(1).RegisterWorkflow(workflowStore, workflow);

        }
        public async Task <IActionResult> Create(WorkflowServerEditModel model, CancellationToken cancellationToken)
        {
            var workflowServer = new WorkflowServer
            {
                WorkflowServerId = _idGenerator.GenerateUniqueId(),
                Name             = model.Name.Trim(),
                Url = model.Url
            };

            await _store.SaveAsync(workflowServer, cancellationToken);

            _notifier.Success(T["Remote workflow server has been created."]);
            return(RedirectToAction("Index"));
        }
Exemple #9
0
    public static void WebStart(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime lifetime)
    {
        SignumServer.Start(app, env, typeof(Startup).Assembly);

        AuthServer.Start(app, () => Starter.Configuration.Value.AuthTokens, "IMPORTANT SECRET FROM Southwind. CHANGE THIS STRING!!!");
        CacheServer.Start(app);
        FilesServer.Start(app);
        UserQueryServer.Start(app);
        DashboardServer.Start(app);
        WordServer.Start(app);
        ExcelServer.Start(app);
        ChartServer.Start(app);
        MapServer.Start(app);
        ToolbarServer.Start(app);
        TranslationServer.Start(app,
                                new AlreadyTranslatedTranslator(),
                                new AzureTranslator(
                                    () => Starter.Configuration.Value.Translation.AzureCognitiveServicesAPIKey,
                                    () => Starter.Configuration.Value.Translation.AzureCognitiveServicesRegion),
                                new DeepLTranslator(() => Starter.Configuration.Value.Translation.DeepLAPIKey)
                                ); //TranslationServer
        SchedulerServer.Start(app, lifetime);
        ProcessServer.Start(app);
        MailingServer.Start(app);
        ProfilerServer.Start(app);
        DiffLogServer.Start(app);
        RestServer.Start(app);
        RestLogServer.Start(app);
        PredictorServer.Start(app);
        WorkflowServer.Start(app);
        AlertsServer.Start(app);
        DynamicServer.Start(app);

        OmniboxServer.Start(app,
                            new EntityOmniboxResultGenenerator(),
                            new DynamicQueryOmniboxResultGenerator(),
                            new ChartOmniboxResultGenerator(),
                            new DashboardOmniboxResultGenerator(DashboardLogic.Autocomplete),
                            new UserQueryOmniboxResultGenerator(UserQueryLogic.Autocomplete),
                            new UserChartOmniboxResultGenerator(UserChartLogic.Autocomplete),
                            new MapOmniboxResultGenerator(type => OperationLogic.TypeOperations(type).Any()),
                            new ReactSpecialOmniboxGenerator()
                               //new HelpModuleOmniboxResultGenerator(),
                            ); //Omnibox

        ReflectionServer.RegisterLike(typeof(RegisterUserModel), () => true);

        SignumCultureSelectorFilter.GetCurrentCulture = (ctx) => GetCulture(ctx);
    }
        public void ExecuteWorkflow_OnExecution_InitialisesAndFiresTriggers()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.Start);
            workflow.CreatedOn = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);
            workflowServer.ExecuteWorkflow(workflow);

            Assert.AreEqual(BasicWorkflow.State.Complete.ToString(), workflow.CurrentState);

        }
        public void ExecuteWorkflow_OnSuccessfulExecution_RetryCountIsZero()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.Start);
            workflow.CreatedOn = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            // execute
            IWorkflowServer workflowEngine = new WorkflowServer(workflowStore);
            workflowEngine.ExecuteWorkflow(workflow);

            Assert.AreEqual(0, workflow.RetryCount);

        }
Exemple #12
0
        public void ExecuteWorkflow_OnStepExceptionAndMultipleInstanceWorkflow_CorrectMethodCalled()
        {
            Workflow workflow = Substitute.For <Workflow>();

            workflow.ResumeTrigger    = "Test";
            workflow.IsSingleInstance = false;
            workflow.WhenForAnyArgs(x => x.Fire(Arg.Any <string>())).Do(x => { throw new Exception(); });

            IWorkflowExceptionHandler exceptionHandler = Substitute.For <IWorkflowExceptionHandler>();

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(Substitute.For <IWorkflowStore>(), Substitute.For <IWorkflowRegistrationService>(), exceptionHandler);

            workflowServer.ExecuteWorkflow(workflow);

            exceptionHandler.Received(1).HandleWorkflowException(Arg.Any <Workflow>(), Arg.Any <Exception>());
        }
Exemple #13
0
        public void ExecuteWorkflow_OnStepException_StateReset()
        {
            string initialState = Guid.NewGuid().ToString();

            Workflow workflow = Substitute.For <Workflow>();

            workflow.ResumeTrigger = "Test";
            workflow.CurrentState.Returns(initialState);
            workflow.WhenForAnyArgs(x => x.Fire(Arg.Any <string>())).Do(x => { throw new Exception(); });

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(Substitute.For <IWorkflowStore>(), Substitute.For <IWorkflowRegistrationService>(), Substitute.For <IWorkflowExceptionHandler>());

            workflowServer.ExecuteWorkflow(workflow);

            // make sure the property was set
            workflow.Received(1).CurrentState = initialState;
        }
Exemple #14
0
        public void ExecuteWorkflow_OnExecution_InitialisesAndFiresTriggers()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.Start);

            workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);

            workflowServer.ExecuteWorkflow(workflow);

            Assert.AreEqual(BasicWorkflow.State.Complete.ToString(), workflow.CurrentState);
        }
        public void ExecuteWorkflow_OnCompletion_MovesWorkflowIntoCompletedArchive()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.DoingStuff);
            workflow.CreatedOn = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.Complete.ToString();
            workflowStore.Save(workflow);

            // execute
            IWorkflowServer workflowEngine = new WorkflowServer(workflowStore);
            workflowEngine.ExecuteWorkflow(workflow);

            Assert.IsNull(workflowStore.GetOrDefault(workflow.Id));
            Assert.IsNotNull(workflowStore.GetCompleted(workflow.Id));

        }
Exemple #16
0
        public void ExecuteWorkflow_OnStepCompletion_ExecutesNextStep()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            BasicWorkflow workflow = new BasicWorkflow("Start");

            workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            // execute
            IWorkflowServer workflowEngine = new WorkflowServer(workflowStore);

            workflowEngine.ExecuteWorkflow(workflow);

            Assert.AreEqual("Complete", workflow.CurrentState);
        }
Exemple #17
0
        public void ExecuteWorkflow_OnWorkflowError_OnErrorCalled()
        {
            string initialState = Guid.NewGuid().ToString();

            Workflow workflow = Substitute.For <Workflow>();

            workflow.ResumeTrigger  = "Test";
            workflow.RetryIntervals = new int[] { };
            workflow.CurrentState.Returns(initialState);
            workflow.WhenForAnyArgs(x => x.Fire(Arg.Any <string>())).Do(x => { throw new Exception(); });

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(Substitute.For <IWorkflowStore>(), Substitute.For <IWorkflowRegistrationService>(), Substitute.For <IWorkflowExceptionHandler>());

            workflowServer.ExecuteWorkflow(workflow);

            workflow.Received(1).OnError(Arg.Any <Exception>());
        }
Exemple #18
0
        public void ExecuteWorkflow_OnSuccessfulExecution_RetryCountIsZero()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.Start);

            workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            // execute
            IWorkflowServer workflowEngine = new WorkflowServer(workflowStore);

            workflowEngine.ExecuteWorkflow(workflow);

            Assert.AreEqual(0, workflow.RetryCount);
        }
Exemple #19
0
        public void OnWorkflowStateEntry_OnStateChange_Persisted()
        {
            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.Start);

            workflow.ResumeTrigger = BasicWorkflow.Trigger.DoStuff.ToString();

            // set up the workflow store
            IWorkflowStore workflowStore = Substitute.For <IWorkflowStore>();

            workflowStore.GetActive(Arg.Any <int>()).Returns(new[] { workflow });

            IWorkflowServer workflowEngine = new WorkflowServer(workflowStore);

            workflowEngine.ExecuteWorkflows(10);

            // We should have received TWO saves as the workflow moves between the states
            workflowStore.Received(2).Save(workflow);
        }
Exemple #20
0
        public void ExecuteWorkflow_OnCompletion_MovesWorkflowIntoCompletedArchive()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.DoingStuff);

            workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.Complete.ToString();
            workflowStore.Save(workflow);

            // execute
            IWorkflowServer workflowEngine = new WorkflowServer(workflowStore);

            workflowEngine.ExecuteWorkflow(workflow);

            Assert.IsNull(workflowStore.GetOrDefault(workflow.Id));
            Assert.IsNotNull(workflowStore.GetCompleted(workflow.Id));
        }
Exemple #21
0
        private void Start_(string connectionString, string applicationName)
        {
            ServerApplication serverApplication = new ServerApplication();

            serverApplication.ApplicationName = applicationName;
            serverApplication.Modules.Add(new WorkflowDemoEFModule());
            serverApplication.ConnectionString = connectionString;
            WorkflowModule workflowModule = serverApplication.Modules.FindModule <WorkflowModule>();

            serverApplication.Setup();
            serverApplication.Logon();

            IObjectSpaceProvider objectSpaceProvider = serverApplication.ObjectSpaceProvider;

            server = new WorkflowServer("http://localhost:46232", objectSpaceProvider, objectSpaceProvider);
            server.StartWorkflowListenerService.DelayPeriod      = TimeSpan.FromSeconds(10);
            server.StartWorkflowByRequestService.DelayPeriod     = TimeSpan.FromSeconds(10);
            server.RefreshWorkflowDefinitionsService.DelayPeriod = TimeSpan.FromSeconds(15);
            server.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(10);
                e.WorkflowIdleBehavior.TimeToUnload = TimeSpan.FromSeconds(10);
                e.WorkflowInstanceStoreBehavior.WorkflowInstanceStore.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(1);
            };

            server.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().FullName + "' service"));
                }
                e.Handled = true;
            };
            server.Start();
        }
Exemple #22
0
        public void ExecuteWorkflow_OnCompletion_WorkflowOnCompleteCalled()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            BasicWorkflow workflow = Substitute.For <BasicWorkflow>(BasicWorkflow.State.DoingStuff);

            workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.Complete.ToString();
            workflowStore.Save(workflow);

            workflow.When(x => x.Fire("Complete")).Do(x => workflow.IsComplete = true);

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);

            workflowServer.ExecuteWorkflow(workflow);

            workflow.Received(1).OnComplete();
        }
        protected override void OnStart(string[] args)
        {
            if (server == null)
            {
                ServerApplication serverApplication = new ServerApplication();
                serverApplication.ApplicationName        = "WKLearn";
                serverApplication.CheckCompatibilityType = CheckCompatibilityType.DatabaseSchema;
                // The service can only manage workflows for those business classes that are contained in Modules specified by the serverApplication.Modules collection.
                // So, do not forget to add the required Modules to this collection via the serverApplication.Modules.Add method.
                serverApplication.Modules.BeginInit();
                serverApplication.Modules.Add(new WorkflowModule());
                serverApplication.Modules.Add(new WKLearn.Module.WKLearnModule());
                serverApplication.Modules.Add(new WKLearn.Module.Win.WKLearnWindowsFormsModule());
                serverApplication.Modules.Add(new WKLearn.Module.Web.WKLearnAspNetModule());
                if (ConfigurationManager.ConnectionStrings["ConnectionString"] != null)
                {
                    serverApplication.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
                }
                serverApplication.Setup();
                serverApplication.Logon();

                IObjectSpaceProvider objectSpaceProvider = serverApplication.ObjectSpaceProvider;

                WorkflowCreationKnownTypesProvider.AddKnownType(typeof(DevExpress.Xpo.Helpers.IdList));

                server = new WorkflowServer("http://localhost:46232", new BasicHttpBinding(), objectSpaceProvider, objectSpaceProvider);
                server.StartWorkflowListenerService.DelayPeriod      = TimeSpan.FromSeconds(15);
                server.StartWorkflowByRequestService.DelayPeriod     = TimeSpan.FromSeconds(15);
                server.RefreshWorkflowDefinitionsService.DelayPeriod = TimeSpan.FromMinutes(15);

                server.CustomizeHost += delegate(object sender, CustomizeHostEventArgs e) {
                    e.WorkflowInstanceStoreBehavior.WorkflowInstanceStore.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(15);
                };

                server.CustomHandleException += delegate(object sender, CustomHandleServiceExceptionEventArgs e) {
                    Tracing.Tracer.LogError(e.Exception);
                    e.Handled = false;
                };
            }
            server.Start();
        }
Exemple #24
0
        public void PrintBCUCode()
        {
            if (WorkflowServer != null)
            {
                SortedList parameters = new SortedList();
                if (string.IsNullOrEmpty(_bcuCode))
                {
                    _bcuCode = WorkflowServer.Get_BCU_Code(PdCode, Convert.ToString(setNameTxt.Tag));
                }
                DateTime createDate = DateTime.Now;

                parameters.Add("BarcodeValue", _bcuCode);
                parameters.Add("P014", _bcuCode);
                parameters.Add("P017", _createDate.ToString("yyyy-MM-dd"));
                parameters.Add("P018", _createDate.AddDays(_expirationTime).ToString("yyyy-MM-dd"));
                parameters.Add("P019", userNameTxt.Text.Trim());
                parameters.Add("P020", txtConfirmName.Text.Trim());
                parameters.Add("P013", Convert.ToString(setNameTxt.Text));
                parameters.Add("P016", Convert.ToString(useLocationTxt.Text));
                string printResult = BarCodeHelper.PrintBarCode(_bcuCode, parameters);
                if (!string.IsNullOrEmpty(printResult))
                {
                    MessageBox.Show(printResult, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    _isPrintedBCU = true;
                }

                string key = CnasUtilityTools.ConcatTwoString(_bcuCode, Convert.ToString(setNameTxt.Tag));
                if (ScanBarCodes.ContainsKey(Convert.ToString(setNameTxt.Tag)))
                {
                    ScanBarCodes.Remove(Convert.ToString(setNameTxt.Tag));
                }
                if (!ScanBarCodes.ContainsKey(key))
                {
                    ScanBarCodes.Add(key, "BCU");
                }
            }
        }
Exemple #25
0
        public WorkflowServerService2()
        {
            //InitializeComponent();

            ServerApplication serverApplication = new ServerApplication();

            serverApplication.ApplicationName = "Solution1";
            // The service can only manage workflows for those business classes that are contained in Modules specified by the serverApplication.Modules collection.
            // So, do not forget to add the required Modules to this collection via the serverApplication.Modules.Add method.
            serverApplication.Modules.Add(new WorkflowModule());
            serverApplication.Modules.Add(new Solution1WindowsFormsModule());

            if (ConfigurationManager.ConnectionStrings["ConnectionString"] != null)
            {
                serverApplication.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            }
            serverApplication.CreateCustomObjectSpaceProvider += delegate(object sender, CreateCustomObjectSpaceProviderEventArgs e) {
                e.ObjectSpaceProvider = new XPObjectSpaceProvider(e.ConnectionString, e.Connection);
            };
            serverApplication.Setup();
            serverApplication.Logon();

            IObjectSpaceProvider objectSpaceProvider = serverApplication.ObjectSpaceProvider;

            server = new WorkflowServer("http://localhost:46232", objectSpaceProvider, objectSpaceProvider);

            server.StartWorkflowListenerService.DelayPeriod = TimeSpan.FromSeconds(15);
            server.StartWorkflowByRequestService.RequestsDetectionPeriod = TimeSpan.FromSeconds(15);
            server.RefreshWorkflowDefinitionsService.DelayPeriod         = TimeSpan.FromMinutes(15);

            server.CustomizeHost += delegate(object sender, CustomizeHostEventArgs e) {
                e.WorkflowInstanceStoreBehavior.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(15);
            };

            server.CustomHandleException += delegate(object sender, CustomHandleServiceExceptionEventArgs e) {
                Tracing.Tracer.LogError(e.Exception);
                Console.WriteLine(e.Exception.Message);
                e.Handled = false;
            };
        }
Exemple #26
0
        void WorkerThreadFunc()
        {
            // fire up the server, this will run as part of the service (you can set the workflow store here)
            IWorkflowStore workflowStore = BootStrapper.MongoDbStore();
            //IWorkflowStore workflowStore = BootStrapper.MemoryStore();
            //IWorkflowStore workflowStore = BootStrapper.RavenDbEmbeddedStore();

            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);

            workflowServer.RegisterWorkflowType <FileCreationWorkflow>();

            // create a new example workflow if it hasn't been registered already
            FileCreationWorkflow workflow = new FileCreationWorkflow(FileCreationWorkflow.State.Start);

            workflow.RootFolder    = "C:\\Temp\\";
            workflow.ResumeTrigger = FileCreationWorkflow.Trigger.WriteFirstFile.ToString();
            workflow.Priority      = 5;
            workflowServer.RegisterWorkflow(workflow);

            while (!_shutdownEvent.WaitOne(0))
            {
                int executedCount = 0;

                try
                {
                    executedCount = workflowServer.ExecuteWorkflows(5);
                }
                catch (Exception)
                {
                    // do some logging!
                }

                // if no workflows were found, sleepy sleep - you should create an app setting for the poll
                // interval appropriate to you
                if (executedCount == 0)
                {
                    Thread.Sleep(1000);
                }
            }
        }
        private void Start_(string connectionString, string applicationName)
        {
            var serverApplication = new ServerApplication();

            //            moduleBases.Each(@base => serverApplication.Modules.Add(@base));
            serverApplication.ApplicationName  = applicationName;
            serverApplication.ConnectionString = connectionString;
            Type securityType = typeof(SecurityComplex).MakeGenericType(new[] { SecuritySystem.UserType, ((ISecurityComplex)SecuritySystem.Instance).RoleType });

            serverApplication.Security = (ISecurity)Activator.CreateInstance(securityType, new WorkflowServerAuthentication(new BinaryOperator("UserName", "WorkflowService")));
            //            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["WorkflowServerUrl"], objectSpaceProvider, objectSpaceProvider);
            server.CustomizeHost += delegate(object sender, CustomizeHostEventArgs e) {
                e.WorkflowInstanceStoreBehavior.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(2);
            };
            //            server.WorkflowDefinitionProvider = new WorkflowVersionedDefinitionProvider<XpoWorkflowDefinition, XpoUserActivityVersion>(objectSpaceProvider, null);
            server.WorkflowDefinitionProvider = new XpandWorkflowDefinitionProvider(typeof(XpoWorkflowDefinition), new List <Type> {
                typeof(ScheduledWorkflow), typeof(ObjectChangedWorkflow)
            });
            server.StartWorkflowListenerService.DelayPeriod = TimeSpan.FromSeconds(5);
            server.StartWorkflowByRequestService.RequestsDetectionPeriod = TimeSpan.FromSeconds(5);
            server.RefreshWorkflowDefinitionsService.DelayPeriod         = TimeSpan.FromSeconds(30);

            server.Start();
            server.CustomHandleException += delegate(object sender, DevExpress.ExpressApp.Workflow.ServiceModel.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;
            };
        }
Exemple #28
0
        public void ExecuteWorkflows_ActionWithNoDefaultConstructorAndNoDependencyResolver_ThrowsException()
        {
            // set up the store and the workflows
            IWorkflowStore  workflowStore  = new MemoryWorkflowStore();
            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);

            DependencyInjectionWorkflow workflow = new DependencyInjectionWorkflow(DependencyInjectionWorkflow.State.Start);

            workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeOn      = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = DependencyInjectionWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            Assert.AreEqual(0, workflow.RetryCount);

            // execute
            workflowServer.ExecuteWorkflows(10);

            // we won't get an error, but check the workflow to see if any error occurred
            Assert.AreEqual(1, workflow.RetryCount);
            Assert.IsTrue(workflow.LastException.Contains("MissingMethodException"));
        }
Exemple #29
0
        protected override void OnStart(string[] args)
        {
            if (server == null)
            {
                ServerApplication serverApplication = new ServerApplication();
                serverApplication.ApplicationName = "WorkflowExample";
                // The service can only manage workflows for those business classes that are contained in Modules specified by the serverApplication.Modules collection.
                // So, do not forget to add the required Modules to this collection via the serverApplication.Modules.Add method.

                serverApplication.Modules.Add(new WorkflowModule());
                serverApplication.Modules.Add(new WorkflowExampleModule());

                if (ConfigurationManager.ConnectionStrings["ConnectionString"] != null)
                {
                    serverApplication.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
                }
                serverApplication.Setup();
                serverApplication.Logon();

                IObjectSpaceProvider objectSpaceProvider = serverApplication.ObjectSpaceProvider;

                server = new WorkflowServer("http://localhost:46232", objectSpaceProvider, objectSpaceProvider);

                server.StartWorkflowListenerService.DelayPeriod      = TimeSpan.FromSeconds(15);
                server.StartWorkflowByRequestService.DelayPeriod     = TimeSpan.FromSeconds(15);
                server.RefreshWorkflowDefinitionsService.DelayPeriod = TimeSpan.FromMinutes(15);
                server.HostManager.CloseHostTimeout = System.TimeSpan.FromSeconds(20);

                server.CustomizeHost += delegate(object sender, CustomizeHostEventArgs e) {
                    e.WorkflowInstanceStoreBehavior.WorkflowInstanceStore.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(15);
                };

                server.CustomHandleException += delegate(object sender, CustomHandleServiceExceptionEventArgs e) {
                    Tracing.Tracer.LogError(e.Exception);
                    e.Handled = false;
                };
            }
            server.Start();
        }
Exemple #30
0
        public static void WebStart(HttpConfiguration config)
        {
            SignumServer.Start(config, typeof(Global).Assembly);
            AuthServer.Start(config, () => Starter.Configuration.Value.AuthTokens, "IMPORTANT SECRET FROM Southwind. CHANGE THIS STRING!!!");
            CacheServer.Start(config);
            FilesServer.Start(config);
            UserQueryServer.Start(config);
            DashboardServer.Start(config);
            WordServer.Start(config);
            ExcelServer.Start(config);
            ChartServer.Start(config);
            MapServer.Start(config);
            ToolbarServer.Start(config);
            TranslationServer.Start(config, new AlreadyTranslatedTranslator(new AzureTranslator("Your API Key for Azure Translate")));
            SchedulerServer.Start(config);
            ProcessServer.Start(config);
            DisconnectedServer.Start(config);
            MailingServer.Start(config);
            ProfilerServer.Start(config);
            DiffLogServer.Start(config);
            PredictorServer.Start(config);
            WorkflowServer.Start(config);
            DynamicServer.Start(config);

            OmniboxServer.Start(config,
                                new EntityOmniboxResultGenenerator(),
                                new DynamicQueryOmniboxResultGenerator(),
                                new ChartOmniboxResultGenerator(),
                                new DashboardOmniboxResultGenerator(DashboardLogic.Autocomplete),
                                new UserQueryOmniboxResultGenerator(UserQueryLogic.Autocomplete),
                                new UserChartOmniboxResultGenerator(UserChartLogic.Autocomplete),
                                new MapOmniboxResultGenerator(type => OperationLogic.TypeOperations(type).Any()),
                                new ReactSpecialOmniboxGenerator()
                                   //new HelpModuleOmniboxResultGenerator(),
                                ); //Omnibox

            SignumAuthenticationFilterAttribute.GetCurrentCultures = (ac) => GetCulture(ac.Request);
        }
        private void Start_(string connectionString, string applicationName)
        {
            ServerApplication serverApplication = new ServerApplication();

            serverApplication.ApplicationName = applicationName;
            serverApplication.Modules.Add(new WorkflowDemoModule());
            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 WorkflowServer("http://localhost:46232", objectSpaceProvider, objectSpaceProvider);
            server.WorkflowDefinitionProvider = new WorkflowVersionedDefinitionProvider <XpoWorkflowDefinition, XpoUserActivityVersion>(objectSpaceProvider, null);
            server.StartWorkflowListenerService.DelayPeriod      = TimeSpan.FromSeconds(5);
            server.StartWorkflowByRequestService.DelayPeriod     = TimeSpan.FromSeconds(5);
            server.RefreshWorkflowDefinitionsService.DelayPeriod = TimeSpan.FromSeconds(30);
            server.CustomizeHost += delegate(object sender, CustomizeHostEventArgs e) {
                e.WorkflowInstanceStoreBehavior = null;
                System.ServiceModel.Activities.Description.SqlWorkflowInstanceStoreBehavior sqlWorkflowInstanceStoreBehavior = new System.ServiceModel.Activities.Description.SqlWorkflowInstanceStoreBehavior("Integrated Security=SSPI;Pooling=false;Data Source=.\\SqlExpress;Initial Catalog=SqlWorkflowInstanceStoreDB");
                sqlWorkflowInstanceStoreBehavior.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(2);
                e.Host.Description.Behaviors.Add(sqlWorkflowInstanceStoreBehavior);
                e.WorkflowIdleBehavior.TimeToPersist = TimeSpan.FromSeconds(1);
                //e.WorkflowInstanceStoreBehavior.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(2);
            };

            server.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;
            };
            server.Start();
        }
Exemple #32
0
        public void ExecuteWorkflows_ActionWithNoDefaultConstructorAndDependencyResolver_ExecutesAction()
        {
            // set up the store and the workflows
            IWorkflowStore  workflowStore  = new MemoryWorkflowStore();
            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);

            DependencyInjectionWorkflow workflow = new DependencyInjectionWorkflow(DependencyInjectionWorkflow.State.Start);

            workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeOn      = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = DependencyInjectionWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            MyDependencyResolver resolver = new MyDependencyResolver();// Substitute.For<IWorkflowEngineDependencyResolver>();

            //resolver.GetInstance<NoDefaultConstructorAction>().Returns(new NoDefaultConstructorAction("test", 1));
            workflowServer.DependencyResolver = resolver;

            // execute
            Assert.AreEqual(0, resolver.RunCount);
            workflowServer.ExecuteWorkflows(10);
            Assert.AreEqual(1, resolver.RunCount);
        }
Exemple #33
0
        public void ExecuteWorkflows_OnExecution_ReturnsNumberOfWorkflowsExecuted(int activeWorkflowCount)
        {
            const int executeCount   = 10;
            int       expectedResult = Math.Min(executeCount, activeWorkflowCount);
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            for (int i = 0; i < activeWorkflowCount; i++)
            {
                BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.Start);
                workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
                workflow.ResumeOn      = DateTime.UtcNow.AddMinutes(-2);
                workflow.ResumeTrigger = BasicWorkflow.Trigger.DoStuff.ToString();
                workflowStore.Save(workflow);
            }

            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);

            // execute
            int result = workflowServer.ExecuteWorkflows(10);

            Assert.AreEqual(expectedResult, result);
        }
        void WorkerThreadFunc()
        {
            // fire up the server, this will run as part of the service (you can set the workflow store here)
            //IWorkflowStore workflowStore = BootStrapper.MongoDbStore();
            //IWorkflowStore workflowStore = BootStrapper.MemoryStore();
            IWorkflowStore workflowStore = BootStrapper.RavenDbEmbeddedStore();
            
            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);
            workflowServer.RegisterWorkflowType<FileCreationWorkflow>();

            // create a new example workflow if it hasn't been registered already
            FileCreationWorkflow workflow = new FileCreationWorkflow(FileCreationWorkflow.State.Start);
            workflow.RootFolder = "C:\\Temp\\";
            workflow.ResumeTrigger = FileCreationWorkflow.Trigger.WriteFirstFile.ToString();
            workflowServer.RegisterWorkflow(workflow);


            while (!_shutdownEvent.WaitOne(0))
            {

                try
                {
                    workflowServer.ExecuteWorkflows(5);
                }
                catch (Exception)
                {
                    Thread.Sleep(1000);
                }

                // sleepy sleep
                Thread.Sleep(1000);
            }



        }
Exemple #35
0
        public void ExecuteWorkflow_OnCompletion_WorkflowCompletedEventRaised()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();
            bool           eventRaised   = false;

            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.DoingStuff);

            workflow.CreatedOn     = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.Complete.ToString();
            workflowStore.Save(workflow);

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);

            workflowServer.WorkflowCompleted += delegate(object sender, WorkflowEventArgs e)
            {
                eventRaised = true;
            };

            workflowServer.ExecuteWorkflow(workflow);

            Assert.IsTrue(eventRaised);
        }
 public AllApplicants(WorkflowServer.Foundation.Documents.DocumentFactory factory) : 
         base(factory) {
     return;
 }
 public message_queue(WorkflowServer.Foundation.Documents.DocumentFactory factory) : 
         base(factory) {
     return;
 }
        public void ExecuteWorkflows_OnDelayedAction_ResumesAfterDelay()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            DelayedWorkflow workflow = new DelayedWorkflow(DelayedWorkflow.State.Start);
            workflow.CreatedOn = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = DelayedWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            IWorkflowServer workflowServer = new WorkflowServer(workflowStore);

            // execute
            workflowServer.ExecuteWorkflows(5);
            workflow = workflowStore.Get<DelayedWorkflow>(workflow.Id);
            Assert.AreEqual(DelayedWorkflow.State.DoingStuff.ToString(), workflow.CurrentState);

            // execute again - nothing should have changed
            workflowServer.ExecuteWorkflows(5);
            workflow = workflowStore.Get<DelayedWorkflow>(workflow.Id);
            Assert.AreEqual(DelayedWorkflow.State.DoingStuff.ToString(), workflow.CurrentState);

            // delay and run - should be now be complete
            Thread.Sleep(3100);
            workflowServer.ExecuteWorkflows(5);
            Assert.IsNull(workflowStore.GetOrDefault(workflow.Id));
            Assert.IsNotNull(workflowStore.GetCompletedOrDefault(workflow.Id));

        }
 public Postings(WorkflowServer.Foundation.Documents.DocumentFactory factory) : 
         base(factory) {
     return;
 }
 public ContactRequest(WorkflowServer.Foundation.Documents.DocumentFactory factory) : 
         base(factory) {
     return;
 }
 public messageNode_Node(WorkflowServer.Foundation.Documents.MetaInfo.DocumentMetaNode metaNode, WorkflowServer.Foundation.Documents.DocumentNode parent, WorkflowServer.Foundation.Documents.DocumentNode.InitMode initFor) : 
         base(metaNode, parent, initFor) {
     return;
 }
        public void ExecuteWorkflow_OnStepException_StateReset()
        {
            string initialState = Guid.NewGuid().ToString();

            Workflow workflow = Substitute.For<Workflow>();
            workflow.ResumeTrigger = "Test";
            workflow.CurrentState.Returns(initialState);
            workflow.WhenForAnyArgs(x => x.Fire(Arg.Any<string>())).Do(x => { throw new Exception(); });

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(Substitute.For<IWorkflowStore>(), Substitute.For<IWorkflowRegistrationService>(), Substitute.For<IWorkflowExceptionHandler>());
            workflowServer.ExecuteWorkflow(workflow);

            // make sure the property was set
            workflow.Received(1).CurrentState = initialState;
        }
Exemple #43
0
        private void Start_(string connectionString, string applicationName) {
            ServerApplication serverApplication = new ServerApplication();
            serverApplication.ApplicationName = applicationName;
            serverApplication.Modules.Add(new WorkflowDemoModule());
            serverApplication.ConnectionString = connectionString;
            serverApplication.Setup();
            serverApplication.Logon();

            IObjectSpaceProvider objectSpaceProvider = serverApplication.ObjectSpaceProvider;

            server = new WorkflowServer("http://localhost:46232", objectSpaceProvider, objectSpaceProvider);
            server.WorkflowDefinitionProvider = new WorkflowVersionedDefinitionProvider<XpoWorkflowDefinition, XpoUserActivityVersion>(objectSpaceProvider, null);
            server.StartWorkflowListenerService.DelayPeriod = TimeSpan.FromSeconds(5);
            server.StartWorkflowByRequestService.DelayPeriod = TimeSpan.FromSeconds(5);
            server.RefreshWorkflowDefinitionsService.DelayPeriod = TimeSpan.FromSeconds(600);
            server.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.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;
            };
            server.Start();
        }
        public void ExecuteWorkflow_OnStepCompletion_ExecutesNextStep()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = new MemoryWorkflowStore();

            BasicWorkflow workflow = new BasicWorkflow("Start");
            workflow.CreatedOn = DateTime.UtcNow.AddMinutes(-2);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.DoStuff.ToString();
            workflowStore.Save(workflow);

            // execute
            IWorkflowServer workflowEngine = new WorkflowServer(workflowStore);
            workflowEngine.ExecuteWorkflow(workflow);

            Assert.AreEqual("Complete", workflow.CurrentState);

        }
 public data_NodeCollection(WorkflowServer.Foundation.Documents.MetaInfo.DocumentMetaNode metaNode, WorkflowServer.Foundation.Documents.DocumentNode parent) : 
         base(metaNode, parent) {
 }
 public UserAction(WorkflowServer.Foundation.Documents.DocumentFactory factory) : 
         base(factory) {
     return;
 }
 public userProfile(WorkflowServer.Foundation.Documents.DocumentFactory factory) : 
         base(factory) {
     return;
 }
 public ContentType(WorkflowServer.Foundation.Documents.DocumentFactory factory) : 
         base(factory) {
     return;
 }
 public userProfile(WorkflowServer.Foundation.Documents.DocumentFactory factory, WorkflowServer.Foundation.Documents.Session session) : 
         base(factory, session) {
     return;
 }
 public ContactRequest(WorkflowServer.Foundation.Documents.DocumentFactory factory, System.Xml.XmlReader content) : 
         base(factory, content) {
     return;
 }
Exemple #51
0
        protected override void OnStart(string[] args)
        {
            if (server == null)
            {
                ServerApplication serverApplication;

                try
                {
                    serverApplication = new ServerApplication();
                }
                catch (Exception)
                {
                    throw new Exception("Error i creating server application.");
                }

                try
                {
                    serverApplication.ApplicationName = "Tralus.Shell.WorkflowService";
                    // The service can only manage workflows for those business classes that are contained in Modules specified by the serverApplication.Modules collection.
                    // So, do not forget to add the required Modules to this collection via the serverApplication.Modules.Add method.
                    serverApplication.Modules.BeginInit();

                    var workflowModule = new WorkflowModule();

                    workflowModule.RunningWorkflowInstanceInfoType   = typeof(DevExpress.ExpressApp.Workflow.EF.EFRunningWorkflowInstanceInfo);
                    workflowModule.StartWorkflowRequestType          = typeof(DevExpress.ExpressApp.Workflow.EF.EFStartWorkflowRequest);
                    workflowModule.UserActivityVersionType           = typeof(DevExpress.ExpressApp.Workflow.Versioning.EFUserActivityVersion);
                    workflowModule.WorkflowControlCommandRequestType = typeof(DevExpress.ExpressApp.Workflow.EF.EFWorkflowInstanceControlCommandRequest);
                    workflowModule.WorkflowDefinitionType            = typeof(DevExpress.ExpressApp.Workflow.EF.EFWorkflowDefinition);
                    workflowModule.WorkflowInstanceKeyType           = typeof(DevExpress.Workflow.EF.EFInstanceKey);
                    workflowModule.WorkflowInstanceType = typeof(DevExpress.Workflow.EF.EFWorkflowInstance);

                    serverApplication.Modules.Add(workflowModule);
                    serverApplication.Modules.Add(new ShellModule());
                }
                catch (Exception ex)
                {
                    throw new Exception("Error in creating server", ex);
                }

                try
                {
                    IEnumerable <Type> loadedModuleTypes;
                    ReflectionHelper.GetImportedModules(out loadedModuleTypes, out _loadedContextTypes);

                    foreach (var loadedModuleType in loadedModuleTypes)
                    {
                        var loadedModule = (ModuleBase)Activator.CreateInstance(loadedModuleType);
                        serverApplication.Modules.Insert(0, loadedModule);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Error in loading modules", ex);
                }


                try
                {
                    if (ConfigurationManager.ConnectionStrings["Default"] != null)
                    {
                        serverApplication.ConnectionString = ConfigurationManager.ConnectionStrings["Default"].ConnectionString;
                    }
                    serverApplication.Setup();
                    serverApplication.Logon();
                }
                catch (Exception ex)
                {
                    throw new Exception("Error in setting up.", ex);
                }

                try
                {
                    IObjectSpaceProvider objectSpaceProvider = serverApplication.ObjectSpaceProvider;

                    //WorkflowCreationKnownTypesProvider.AddKnownType(typeof(DevExpress.Xpo.Helpers.IdList));

                    try
                    {
                        server = new WorkflowServer("http://localhost:46232", objectSpaceProvider, objectSpaceProvider);
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Error in creating WorkflowServer.", e);
                    }

                    try
                    {
                        server.StartWorkflowListenerService.DelayPeriod      = TimeSpan.FromSeconds(15);
                        server.StartWorkflowByRequestService.DelayPeriod     = TimeSpan.FromSeconds(15);
                        server.RefreshWorkflowDefinitionsService.DelayPeriod = TimeSpan.FromMinutes(15);
                    }
                    catch (Exception e)
                    {
                        throw new Exception(
                                  $"Error in configuring WorkflowServer. Server={server}, StartWorkflowListenerService={server.StartWorkflowListenerService}, StartWorkflowByRequestService={server.StartWorkflowByRequestService}, RefreshWorkflowDefinitionsService={server.RefreshWorkflowDefinitionsService}", e);
                    }

                    server.CustomizeHost += delegate(object sender, CustomizeHostEventArgs e)
                    {
                        e.WorkflowInstanceStoreBehavior.WorkflowInstanceStore.RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(15);
                    };

                    server.CustomHandleException += delegate(object sender, CustomHandleServiceExceptionEventArgs e)
                    {
                        Tracing.Tracer.LogError(e.Exception);
                        e.Handled = false;
                    };
                }
                catch (Exception ex)
                {
                    throw new Exception("Error in configuring server", ex);
                }
            }

            try
            {
                server.Start();
            }
            catch (Exception ex)
            {
                throw new Exception("Error in starting server", ex);
            }
        }
 public data_Node(WorkflowServer.Foundation.Documents.MetaInfo.DocumentMetaNode metaNode, WorkflowServer.Foundation.Documents.DocumentNodeCollection collection, WorkflowServer.Foundation.Documents.DocumentNode sibling, WorkflowServer.Foundation.Documents.DocumentNode.InitMode initFor) : 
         base(metaNode, collection, sibling, initFor) {
     return;
 }
 public message_queue(WorkflowServer.Foundation.Documents.DocumentFactory factory, System.Xml.XmlReader content) : 
         base(factory, content) {
     return;
 }
 public Postings(WorkflowServer.Foundation.Documents.DocumentFactory factory, System.Xml.XmlReader content) : 
         base(factory, content) {
     return;
 }
        public void IsSingleInstanceWorkflowRegistered_OnExecute_UsesService()
        {
            // set up the store and the workflows
            IWorkflowStore workflowStore = Substitute.For<IWorkflowStore>();
            IWorkflowRegistrationService regService = Substitute.For<IWorkflowRegistrationService>();

            IWorkflowServer workflowServer = new WorkflowServer(workflowStore, regService, Substitute.For<IWorkflowExceptionHandler>());
            workflowServer.IsSingleInstanceWorkflowRegistered<BasicWorkflow>();
            regService.Received(1).IsSingleInstanceWorkflowRegistered<BasicWorkflow>(workflowStore);
        }
        public void OnWorkflowStateEntry_OnStateChange_Persisted()
        {
            BasicWorkflow workflow = new BasicWorkflow(BasicWorkflow.State.Start);
            workflow.ResumeTrigger = BasicWorkflow.Trigger.DoStuff.ToString();

            // set up the workflow store
            IWorkflowStore workflowStore = Substitute.For<IWorkflowStore>();
            workflowStore.GetActive(Arg.Any<int>()).Returns(new[] { workflow });

            IWorkflowServer workflowEngine = new WorkflowServer(workflowStore);
            workflowEngine.ExecuteWorkflows(10);

            // We should have received TWO saves as the workflow moves between the states
            workflowStore.Received(2).Save(workflow);

        }
        public void ExecuteWorkflow_OnStepExceptionAndSingleInstanceWorkflow_CorrectMethodCalled()
        {
            Workflow workflow = Substitute.For<Workflow>();
            workflow.ResumeTrigger = "Test";
            workflow.IsSingleInstance = true;
            workflow.WhenForAnyArgs(x => x.Fire(Arg.Any<string>())).Do(x => { throw new Exception(); });

            IWorkflowExceptionHandler exceptionHandler = Substitute.For<IWorkflowExceptionHandler>();

            // execute
            IWorkflowServer workflowServer = new WorkflowServer(Substitute.For<IWorkflowStore>(), Substitute.For<IWorkflowRegistrationService>(), exceptionHandler);
            workflowServer.ExecuteWorkflow(workflow);

            exceptionHandler.Received(1).HandleSingleInstanceWorkflowException(Arg.Any<Workflow>(), Arg.Any<Exception>());
        }