Exemplo n.º 1
0
        public void Run()
        {
            wfHostTypeName = XName.Get("Version" + Guid.NewGuid().ToString(),
                                       typeof(Workflow1).FullName);
            this.instanceStore  = SetupSqlpersistenceStore();
            this.instanceHandle = CreateInstanceStoreOwnerHandle(
                instanceStore, wfHostTypeName);
            WorkflowApplication wfApp = CreateWorkflowApp();

            wfApp.Run();
            while (true)
            {
                this.waitHandler.WaitOne();
                if (completed)
                {
                    break;
                }
                WaitForRunnableInstance(this.instanceHandle);
                wfApp = CreateWorkflowApp();
                try
                {
                    wfApp.LoadRunnableInstance();
                    waitHandler.Reset();
                    wfApp.Run();
                }
                catch (InstanceNotReadyException)
                {
                    Console.WriteLine("Handled expected InstanceNotReadyException, retrying...");
                }
            }
            Console.WriteLine("workflow completed.");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            InstanceStore store = CreateInstanceStore();

            WorkflowApplication wfApp = SetupInstance(store);
            Guid instanceId           = wfApp.Id;

            wfApp.Run();

            //wait for the wf to unload itself
            unloadedHandle.WaitOne(5000);
            Thread.Sleep(1000);
            wfApp = SetupInstance(store);
            wfApp.Load(instanceId);
            wfApp.Run();

            //wait for the wf to unload itself
            unloadedHandle.WaitOne(5000);
            Thread.Sleep(1000);
            wfApp = SetupInstance(store);
            wfApp.Load(instanceId);
            wfApp.Run();

            //wait for the wf to unload itself
            unloadedHandle.WaitOne(5000);
            Thread.Sleep(5000);
            wfApp = SetupInstance(store);
            wfApp.Load(instanceId);
            wfApp.Run();

            waitHandle.WaitOne(10000);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(persistenceConn);

            // Create a unique name that is used to associate instances in the instance store hosts that can load them. This is needed to prevent a Workflow host from loading
            // instances that have different implementations. The unique name should change whenever the implementation of the workflow changes to prevent workflow load exceptions.
            // For the purposes of the demo we create a unique name every time the program is run.
            XName wfHostTypeName = XName.Get("Version" + Guid.NewGuid().ToString(), typeof(Workflow1).FullName);

            // Create an InstanceStore owner that is associated with the workflow type
            InstanceHandle ownerHandle = CreateInstanceStoreOwner(store, wfHostTypeName);

            // Create a WorkflowApplication instance to start a new workflow
            WorkflowApplication wfApp = CreateWorkflowApplication(new Workflow1(), store, wfHostTypeName);

            // This will create the workflow and execute it until the delay is executed, the workflow goes idle, and is unloaded
            wfApp.Run();

            // This loop handles re-loading workflows that have been unloaded due to durable timers
            while (true)
            {
                // Wait for workflow to unload
                workflowUnloadedEvent.WaitOne();

                // Break the loop once the workflow has completed
                if (workflowCompleted)
                {
                    break;
                }

                // Wait for a timer registered by the delay to expire and the workflow instance to become "runnable" again
                WaitForRunnableInstance(store, ownerHandle);

                // Create a new WorkflowApplication instance to host the re-loaded workflow
                wfApp = CreateWorkflowApplication(new Workflow1(), store, wfHostTypeName);

                try
                {
                    // Re-load the runnable workflow instance and run it
                    wfApp.LoadRunnableInstance();

                    workflowUnloadedEvent.Reset();

                    wfApp.Run();
                }
                catch (InstanceNotReadyException)
                {
                    Console.WriteLine("Handled expected InstanceNotReadyException, retrying...");
                }
            }

            Console.WriteLine("Sample finished, hit enter to close");
            Console.ReadLine();
        }
Exemplo n.º 4
0
        public bool LoadAndRun(Guid id)
        {
            var app2 = new WorkflowApplication(new WaitForSignalOrDelayWorkflow())
            {
                Completed = e =>
                {
                    if (e.CompletionState == ActivityInstanceState.Closed)
                    {
                        System.Runtime.Caching.MemoryCache.Default.Add(id.ToString(), e.Outputs, DateTimeOffset.MaxValue);//Save outputs at the end of the workflow.
                    }
                },

                Unloaded = e =>
                {
                    System.Diagnostics.Debug.WriteLine("Unloaded in LoadAndRun.");
                },

                InstanceStore = WFDefinitionStore.Instance.Store,
            };

            try
            {
                app2.Load(id);
                app2.Run();
            }
            catch (System.Runtime.DurableInstancing.InstanceNotReadyException ex)
            {
                System.Diagnostics.Trace.TraceWarning(ex.Message);
                return(false);
            }

            System.Runtime.Caching.MemoryCache.Default.Add(id.ToString() + "Instance", app2, DateTimeOffset.MaxValue);//Keep the reference to a running instance
            return(true);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("***** Welcome to this amazing WF application *****");

            // Get data from user, to pass to workflow.
            Console.Write("Please enter the data to pass the workflow: ");
            string wfData = Console.ReadLine();

            // Package up the data as a dictionary.
            Dictionary <string, object> wfArgs = new Dictionary <string, object>();

            wfArgs.Add("MessageToShow", wfData);

            AutoResetEvent waitHandle = new AutoResetEvent(false);

            // Pass to the workflow.
            WorkflowApplication app = new WorkflowApplication(new Workflow1(), wfArgs);

            // Hook up an event with this app.
            app.Completed = (completedArgs) => {
                waitHandle.Set();
                Console.WriteLine("The workflow is done!");
            };

            // Start the workflow!
            app.Run();

            // Wait until we are notified the workflow is done.
            waitHandle.WaitOne();

            Console.WriteLine("Thanks for playing");
        }
            public void Run()
            {
                Guid id;

                Guid.TryParse(DataTransferObject.ParentInstanceID, out id);
                ID          = DataTransferObject.ResourceID;
                ParentID    = DataTransferObject.ParentID;
                WorkspaceID = DataTransferObject.WorkspaceID;

                // handle queuing
                WaitForSlot();

                // abort the execution - no space at the inn
                if (!ExecutableServiceRepository.Instance.DoesQueueHaveSpace())
                {
                    _instance.Abort();
                }
                else
                {
                    ExecutableServiceRepository.Instance.Add(this);
                    // here is space at the inn ;)
                    var wfappUtils = new WfApplicationUtils();

                    if (DataTransferObject.IsDebugMode())
                    {
                        ErrorResultTO invokeErrors;
                        wfappUtils.DispatchDebugState(DataTransferObject, StateType.Start, AllErrors.HasErrors(), AllErrors.MakeDisplayReady(), out invokeErrors, null, true);
                        AllErrors.MergeErrors(invokeErrors);
                    }

                    _previousNumberOfSteps           = DataTransferObject.NumberOfSteps;
                    DataTransferObject.NumberOfSteps = 0;
                    _instance.Run();
                }
            }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press [ENTER] to start the client once the service is running.");
            Console.ReadLine();

            Console.WriteLine("Starting the client");
            Console.WriteLine();

            //Start the client
            AutoResetEvent      syncEvent = new AutoResetEvent(false);
            WorkflowApplication app       = new WorkflowApplication(ClientWorkflow());

            app.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                Console.WriteLine("Completed");
                syncEvent.Set();
            };
            app.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
            {
                Console.WriteLine("Aborted");
                syncEvent.Set();
            };
            app.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
            {
                Console.WriteLine("UnhandledException: " + e.UnhandledException);
                return(UnhandledExceptionAction.Abort);
            };
            app.Run();
            syncEvent.WaitOne();

            Console.WriteLine("Press [ENTER] to exit");
            Console.ReadLine();
        }
Exemplo n.º 8
0
        /// <summary>
        /// 创建工作流
        /// </summary>
        /// <param name="flow"></param>
        /// <returns></returns>
        public static Guid CreateWorkflow(string OrderOID)
        {
            InstanceHandle instanceHandle = InstanceStoreObj.CreateInstanceHandle();
            InstanceView   view           = InstanceStoreObj.Execute(instanceHandle, new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));

            InstanceStoreObj.DefaultInstanceOwner = view.InstanceOwner;
            IDictionary <string, object> input = new Dictionary <string, object>
            {
                { "OrderOID", OrderOID }
            };

            //WorkflowApplication application = new WorkflowApplication(new AuthFlow(),input);
            WorkflowApplication application = new WorkflowApplication(new WorkflowService.OrderFlow.OrderFlow(), input);

            application.InstanceStore   = InstanceStoreObj;
            application.PersistableIdle = (e) =>
            {
                return(PersistableIdleAction.Unload);
            };
            application.Unloaded = (e) =>
            {
                //PersistableIdleAction.Unload;
            };
            application.Run();
            var deleteOwnerCmd = new DeleteWorkflowOwnerCommand();

            //InstanceStoreObj.Execute(instanceHandle, deleteOwnerCmd, TimeSpan.FromSeconds(30));
            InstanceStoreObj = null;
            return(application.Id);
        }
Exemplo n.º 9
0
        private static void Main()
        {
            // Получить от пользователя данные для передачи рабочему потоку
            Console.Write("Please enter the data to pass the workflow: ");
            var wfData = Console.ReadLine();

            // Упаковать данные в словарь
            var wfArgs = new Dictionary <string, object> {
                { "MessageToShow", wfData }
            };

            // Использовать для информирования первичного потока о необходимости ожидания
            var waitHandle = new AutoResetEvent(false);

            // Передать словарь рабочему потоку
            Activity activity = new FirstWorkflow();
            var      wfApp    = new WorkflowApplication(activity, wfArgs)
            {
                Completed = args =>
                {
                    waitHandle.Set();
                    Console.WriteLine("The workflow is done!");
                }
            };

            // Запустить рабочий поток
            wfApp.Run();

            // Ждем сигнал о завершении
            waitHandle.WaitOne();
            Console.WriteLine("Exit");
        }
Exemplo n.º 10
0
        static void Run()
        {
            AutoResetEvent      applicationUnloaded = new AutoResetEvent(false);
            WorkflowApplication application         = new WorkflowApplication(workflow);

            application.InstanceStore = instanceStore;
            SetupApplication(application, applicationUnloaded);

            StepCountExtension stepCountExtension = new StepCountExtension();

            application.Extensions.Add(stepCountExtension);

            application.Run();
            Guid id = application.Id;

            applicationUnloaded.WaitOne();

            while (stepCountExtension.CurrentCount < totalSteps)
            {
                application = new WorkflowApplication(workflow);
                application.InstanceStore = instanceStore;
                SetupApplication(application, applicationUnloaded);

                stepCountExtension = new StepCountExtension();
                application.Extensions.Add(stepCountExtension);
                application.Load(id);

                string input = Console.ReadLine();

                application.ResumeBookmark(echoPromptBookmark, input);
                applicationUnloaded.WaitOne();
            }
        }
Exemplo n.º 11
0
        public static IDictionary <string, object> RunWorkflow(WorkflowApplication instance)
        {
            ManualResetEvent             mre = new ManualResetEvent(false);
            Exception                    workflowException = null;
            IDictionary <string, object> outputs           = null;

            instance.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                if (e.TerminationException != null)
                {
                    workflowException = e.TerminationException;
                }

                outputs = e.Outputs;

                mre.Set();
            };


            instance.Run();
            mre.WaitOne();
            if (workflowException != null)
            {
                throw workflowException;
            }

            return(outputs);
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            var connStr = @"Data Source=.\sqlexpress;Initial Catalog=WorkflowInstanceStore;Integrated Security=True;Pooling=False";
            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore(connStr);

            Workflow1 w = new Workflow1();

            //instanceStore.
            //IDictionary<string, object> xx=WorkflowInvoker.Invoke(new Workflow1());
            //ICollection<string> keys=xx.Keys;

            WorkflowApplication a = new WorkflowApplication(w);

            a.InstanceStore = instanceStore;
            a.GetBookmarks();
            //a.ResumeBookmark("Final State", new object());

            a.Run();
            //a.ResumeBookmark(


            //a.Persist();
            //a.Unload();
            //Guid id = a.Id;
            //WorkflowApplication b = new WorkflowApplication(w);
            //b.InstanceStore = instanceStore;
            //b.Load(id);
            //WorkflowApplication a=new WorkflowApplication(
        }
        public void EmbraceWithCustomSequence()
        {
            int result = 0;

            // Definition der Ausführung
            CustomSequence activity = new CustomSequence()
            {
                Activities =
                {
                    new SayHelloActivity()
                    {
                        Message = "Ausführung in einer kombinierten Sequenz"
                    }
                }
            };

            WorkflowApplication workflowApplication = new WorkflowApplication(activity);

            ManualResetEvent workflowDone = new ManualResetEvent(false);

            workflowApplication.Completed += delegate(WorkflowApplicationCompletedEventArgs args)
            {
                workflowDone.Set();
            };

            workflowApplication.Aborted += delegate(WorkflowApplicationAbortedEventArgs args)
            {
                workflowDone.Set();
            };

            // Ausführen und warten
            workflowApplication.Run();
            workflowDone.WaitOne();
        }
Exemplo n.º 14
0
        static void Main()
        {
            bool           completed            = false;
            AutoResetEvent idleOrCompletedEvent = new AutoResetEvent(false);

            Activity            workflow    = CreateWorkflow();
            WorkflowApplication application = new WorkflowApplication(workflow);

            application.Idle += delegate(WorkflowApplicationIdleEventArgs e)
            {
                idleOrCompletedEvent.Set();
            };
            application.Completed += delegate(WorkflowApplicationCompletedEventArgs e)
            {
                completed = true;
                idleOrCompletedEvent.Set();
            };

            application.Run();

            while (true)
            {
                idleOrCompletedEvent.WaitOne();
                if (!completed)
                {
                    Interact(application);
                }
                else
                {
                    break;
                }
            }
        }
Exemplo n.º 15
0
        public static void Main(string[] args)
        {
            application = new WorkflowApplication(CreateWF());

            // Notify when the workflow completes.
            ManualResetEvent completedEvent = new ManualResetEvent(false);

            application.Completed += delegate(WorkflowApplicationCompletedEventArgs e)
            {
                completedEvent.Set();
            };

            // Run the workflow.
            application.Run();

            // Get user input from the console and send it to the workflow instance.
            // This is done in a separate thread in order to not block current execution.
            ThreadPool.QueueUserWorkItem(ReadName);

            // Wait until the workflow completes.
            completedEvent.WaitOne();

            Console.WriteLine("Workflow completed.  Waiting 10 seconds before exiting...");
            Thread.Sleep(10000);
        }
Exemplo n.º 16
0
        // resume execution of a workflow instance
        static void RunWorkflow(WorkflowApplication application, AutoResetEvent resetEvent)
        {
            application.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                Console.WriteLine("Workflow completed in state " + e.CompletionState);

                if (e.TerminationException != null)
                {
                    Console.WriteLine("Termination exception: " + e.TerminationException);
                }

                Console.WriteLine("-------------------------------");
                Console.WriteLine("- Input has been written to {0}\\out.txt", Environment.CurrentDirectory);
                Console.WriteLine("-------------------------------");

                resetEvent.Set();
            };
            application.Unloaded = delegate(WorkflowApplicationEventArgs e)
            {
                Console.WriteLine("Workflow unloaded");
                resetEvent.Set();
            };

            application.Run();
        }
Exemplo n.º 17
0
        object GenericInvoke(params object[] args)
        {
            if (args.Length != this.parameters.Length)
            {
                throw new ArgumentException("Wrong number of arguments");
            }

            SymbolResolver symbolResolver = environmentProvider();

            for (int i = 0; i < this.parameters.Length; i++)
            {
                ParameterInfo parameter = this.parameters[i];
                if (!parameter.IsOut)
                {
                    symbolResolver.Add(parameter.Name, args[i]);
                }
            }

            if (this.returnType != typeof(void))
            {
                symbolResolver.Add(Argument.ResultValue, new ValueHolder <object>());
            }

            WorkflowApplication application = new WorkflowApplication(this.Activity, new Dictionary <string, object>());

            application.SynchronizationContext = SynchronizationContext.Current;
            application.Extensions.Add(symbolResolver);

            application.Completed = OnWorkflowCompleted;
            application.Aborted   = OnWorkflowAborted;

            application.Run();

            return(null);
        }
Exemplo n.º 18
0
        public Guid Run(Activity activity, IDictionary <string, object> args = null)
        {
            var unloadedSignal = new AutoResetEvent(false);

            var app = new WorkflowApplication(activity, args ?? new Dictionary <string, object>())
            {
                InstanceStore   = _store,
                PersistableIdle = eventArgs => PersistableIdleAction.Unload,
                Aborted         = obj =>
                {
                    unloadedSignal.Set();
                    Trace.TraceError("abort");
                },
                OnUnhandledException = (a) =>
                {
                    Trace.TraceError($"exception:{a.UnhandledException.Message}");
                    return(UnhandledExceptionAction.Cancel);
                },
                Unloaded = a => unloadedSignal.Set(),
            };

            app.Run();
            unloadedSignal.WaitOne();
            return(app.Id);
        }
Exemplo n.º 19
0
        // creates a workflow application, binds parameters, links extensions and run it
        public WorkflowApplication CreateAndRun(RequestForProposal rfp)
        {
            // input parameters for the WF program
            IDictionary <string, object> inputs = new Dictionary <string, object>();

            inputs.Add("Rfp", rfp);

            // create and run the WF instance
            Activity            wf       = new PurchaseProcessWorkflow();
            WorkflowApplication instance = new WorkflowApplication(wf, inputs)
            {
                PersistableIdle = OnIdleAndPersistable,
                Completed       = OnWorkflowCompleted,
                Idle            = OnIdle
            };
            XmlWorkflowInstanceStore store = new XmlWorkflowInstanceStore(instance.Id);

            instance.InstanceStore = store;

            //Create the persistence Participant and add it to the workflow instance
            XmlPersistenceParticipant xmlPersistenceParticipant = new XmlPersistenceParticipant(instance.Id);

            instance.Extensions.Add(xmlPersistenceParticipant);

            // add a tracking participant
            instance.Extensions.Add(new SaveAllEventsToTestFileTrackingParticipant());

            // add instance to the host list of running instances
            this.instances.Add(instance.Id, instance);

            // continue executing this instance
            instance.Run();

            return(instance);
        }
Exemplo n.º 20
0
        protected override void StartInternal()
        {
            DynamicActivity activity;

            using (var stream = new MemoryStream(Encoding.Default.GetBytes(WorkflowDesigner.Text)))
            {
                activity = ActivityXamlServices.Load(stream) as DynamicActivity;
            }

            if (activity == null)
            {
                return;
            }

            WorkflowInspectionServices.CacheMetadata(activity);

            workflowApplication = new WorkflowApplication(activity);

            workflowApplication.Extensions.Add(OutputWriter);
            workflowApplication.Extensions.Add(InitialiseVisualTrackingParticipant(activity));

            workflowApplication.Completed            += Completed;
            workflowApplication.OnUnhandledException += OnUnhandledException;
            workflowApplication.Aborted += Aborted;

            try
            {
                workflowApplication.Run();
                OnRunningStateChanged(new WorkflowExecutingStateEventArgs(true));
            }
            catch (Exception e)
            {
                OutputWriter.WriteLine(e.StackTrace);
            }
        }
Exemplo n.º 21
0
        public void SetParametersToNull()
        {
            string wfName           = "TerminatingWorkflow";
            string exceptionMessage = string.Format(ErrorStrings.OneOfTwoPropertiesMustBeSet, "Reason", "Exception", "TerminateWorkflow", wfName);

            try
            {
                TerminateWorkflow terminate = new TerminateWorkflow()
                {
                    DisplayName = wfName,
                    Exception   = null,
                    Reason      = null
                };


                WorkflowApplication instance = new WorkflowApplication(terminate);
                instance.Run();
            }
            catch (Exception e)
            {
                if (e.GetType() != typeof(InvalidWorkflowException))
                {
                    throw new TestCaseFailedException("Exception is incorrect");
                }
            }
        }
Exemplo n.º 22
0
        public Boolean Start(ILog data)
        {
            Variable <ILog> log = new Variable <ILog>("log", data);


            this.workflow = new Sequence
            {
                Activities =
                {
                    new Caller()
                    {
                        BookmarkName = "Caller"
                    },
                    new NewOpen()
                    {
                        BookmarkName = "NewOpen"
                    },
                }
            };

            WorkflowApplication wfApp = new WorkflowApplication(workflow);

            AutoResetEvent idleEvent = new AutoResetEvent(false);

            wfApp.Idle = (WorkflowApplicationIdleEventArgs e) => { idleEvent.Set(); };

            wfApp.Run();

            BookmarkResumptionResult result = wfApp.ResumeBookmark("NewOpen", data);

            idleEvent.WaitOne();

            return(result == BookmarkResumptionResult.Success);
        }
        /// <summary>
        /// Creates a new Workflow Application instance and executes the Current Workflow
        /// </summary>
        private void CmdWorkflowRun(object sender, ExecutedRoutedEventArgs e)
        {
            //get workflow source from designer
            CustomWfDesigner.Instance.Flush();
            MemoryStream workflowStream = new MemoryStream(ASCIIEncoding.Default.GetBytes(CustomWfDesigner.Instance.Text));

            ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings()
            {
                CompileExpressions = true
            };

            DynamicActivity activityExecute = ActivityXamlServices.Load(workflowStream, settings) as DynamicActivity;

            //configure workflow application
            consoleExecutionLog.Text = String.Empty;
            consoleOutput.Text       = String.Empty;
            _executionLog            = new CustomTrackingParticipant();
            _wfApp = new WorkflowApplication(activityExecute);
            _wfApp.Extensions.Add(_executionLog);
            _wfApp.Completed = WfExecutionCompleted;

            //execute
            _wfApp.Run();

            //enable timer for real-time logging
            _timer.Start();
        }
Exemplo n.º 24
0
        private void StartWorkFlow()
        {
            WorkflowApplication wfApp = InitiateWorkFlow();

            ServiceLocator.Instance.CurrentWorkFlow = wfApp;
            Action action = () => StartWorkFlow();

            wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs ev)
            {
                ReadOutputs(NextWorkFlow, ev);
                Dispatcher.Invoke(action); //call startworkflow() through main thread
            };

            wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs ev)
            {
                NextWorkFlow = "LoginWorkFlow";
                Dispatcher.Invoke(action); //call startworkflow() through main thread
            };

            wfApp.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs ev)
            {
                Dispatcher.Invoke(action); //call startworkflow() through main thread
                Console.WriteLine(ev.UnhandledException.ToString());
                return(UnhandledExceptionAction.Terminate);
            };

            wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs ev)
            {
                //nothing. workflow is waiting screen input, service call, or db call
            };

            wfApp.Run();
        }
Exemplo n.º 25
0
    protected void Button1_Click(object sender, EventArgs e)

    {
        //设置参数
        Dictionary <string, object> para = new  Dictionary <string, object>();
        CrowdTask task = new CrowdTask(TextBox1.Text, TextBox2.Text);

        para.Add("task", task);

        //启动工作流
        WorkflowApplication crowdsourcing = new WorkflowApplication(new mainTask1(), para);

        task.taskType = TaskType.mainTask;
        crowdsourcing.Run();
        task.taskWorkflowId = crowdsourcing.Id.ToString();
        try
        {
            crowdTaskService = new CrowdTaskService();
            int result = crowdTaskService.insert(task);
            if (result == 1)
            {
                //插入成功,保存对应的工作流实例
                MyWorkflowInstance.setWorkflowApplication(crowdsourcing.Id.ToString(), crowdsourcing);
                crowdTaskService.mainTaskSetCrowdTaskMainTaskIdByWorkflowId(crowdsourcing.Id.ToString());
                Server.Transfer("viewMyTask.aspx?workflowId=" + task.taskWorkflowId);
            }
        }
        catch (Exception exception)
        {
            throw exception;
        }
    }
Exemplo n.º 26
0
        public void RunTest()
        {
            Sequence workflow = new Sequence
            {
                Activities =
                {
                    new InvokeMyWorkflowExtensionActivity()
                }
            };

            _completedEvent = new AutoResetEvent(false);
            MyWorkflowExtension myExtension = new MyWorkflowExtension();

            WorkflowApplication wfApp = new WorkflowApplication(workflow);

            wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                _terminationException = e.TerminationException;
                _completedEvent.Set();
            };
            wfApp.Extensions.Add(myExtension);

            Assert.True(!myExtension.ExtensionMethodInvoked);

            wfApp.Run();

            _completedEvent.WaitOne(TimeSpan.FromSeconds(2));

            Assert.True(myExtension.ExtensionMethodInvoked);
        }
Exemplo n.º 27
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(connectionString);

            WorkflowApplication wfApp = new WorkflowApplication(
                new StateMoneyActivity1xaml(),
                new Dictionary <string, object>()
            {
                { "InBookMarkName", this.txtBookMarkName.Text }
            });

            wfApp.InstanceStore = store;

            wfApp.Idle += OnWfAppIdel;
            wfApp.OnUnhandledException += OnWfAppException;
            wfApp.Unloaded              = a => { Console.WriteLine("工作流卸载了..."); };
            wfApp.Aborted = a => { Console.WriteLine("Aborted"); };

            //启用序列化必须使用此方法。
            wfApp.PersistableIdle = a => { return(PersistableIdleAction.Unload); };
            wfApp.Run();//启动工作流

            this.txtAppId.Text = wfApp.Id.ToString();

            WFApp = wfApp;
            //wfApp.ResumeBookmark();
        }
Exemplo n.º 28
0
 public Sequential()
 {
     _completedEvent = new AutoResetEvent(false);
     _idleEvent      = new AutoResetEvent(false);
     _failedEvent    = new AutoResetEvent(false);
     _wfApp          = new WorkflowApplication(new SequentialNumberGuess(),
                                               new Dictionary <string, object>()
     {
         { "GuessNumber", ActualGuess }
     });
     _wfApp.Completed = (WorkflowApplicationCompletedEventArgs e) =>
     {
         _isComplete = true;
         _completedEvent.Set();
     };
     _wfApp.Aborted = (WorkflowApplicationAbortedEventArgs e) =>
     {
         _failedEvent.Set();
     };
     _wfApp.OnUnhandledException = (WorkflowApplicationUnhandledExceptionEventArgs e) =>
     {
         Console.WriteLine(e.UnhandledException.ToString());
         return(UnhandledExceptionAction.Terminate);
     };
     _wfApp.Idle = (WorkflowApplicationIdleEventArgs e) =>
     {
         _idleEvent.Set();
     };
     _wfApp.Run();
 }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            var fileTrackingProfile = new TrackingProfile();

            fileTrackingProfile.Queries.Add(new WorkflowInstanceQuery
            {
                States = { "*" }
            });

            fileTrackingProfile.Queries.Add(new ActivityStateQuery
            {
                States = { ActivityStates.Executing, ActivityStates.Closed }
            });

            var fileTrackingParticipaint = new FileTrackingParticipant();

            fileTrackingParticipaint.TrackingProfile = fileTrackingProfile;
            var waitHandler = new AutoResetEvent(initialState: false);
            var wfApp       = new WorkflowApplication(new Workflow1());

            wfApp.Unloaded = (wfAppEventArg) => { waitHandler.Set(); };
            wfApp.Extensions.Add(fileTrackingParticipaint);
            wfApp.Run();
            waitHandler.WaitOne();
        }
        public void OutputEqualsInput()
        {
            string value = "Hans Mustermann";

            SayHelloActivity activity = new SayHelloActivity()
            {
                Name = new InArgument <string>(context => value)
            };

            WorkflowApplication workflowApplication = new WorkflowApplication(activity);


            string result = null;

            ManualResetEvent workflowDone = new ManualResetEvent(false);

            workflowApplication.Completed += delegate(WorkflowApplicationCompletedEventArgs args)
            {
                result = args.Outputs["Result"].ToString();
                workflowDone.Set();
            };

            workflowApplication.Aborted += delegate(WorkflowApplicationAbortedEventArgs args)
            {
                workflowDone.Set();
            };

            // Ausführen und warten
            workflowApplication.Run();
            workflowDone.WaitOne();

            Assert.Equal($"Hallo {value}", result);
        }