Beispiel #1
0
        /// <summary>
        /// Creates a new workflow instance and returns the page name
        /// of the initial state to go to (which is default.aspx).
        /// </summary>
        /// <returns></returns>
        public string StartNewWorkflow()
        {
            // create and start the navigational workflow instance

            WorkflowInstance instance = _WorkflowRuntime.CreateWorkflow(typeof(WorkflowEmployment));

            instance.Start();

            // execute the workflow synchronously on the current thread
            this.CurrentWorkflowInstanceId = instance.InstanceId;

            RunWorkflow(instance.InstanceId);

            // put the workflow instance id in session for this user
            this.CurrentWorkflowInstanceId = instance.InstanceId;

            // execute the workflow on the current thread and return the page to go to
            return(this._PageToGoTO); //GetPageToGoTo(instance.InstanceId);
        }
Beispiel #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //Creamos una instancia del workflow
            Type type = typeof(IntegrationSample.wfIntegrationAndRouting);

            workflowInstance = workflowRuntime.CreateWorkflow(type);
            workflowInstance.Start();

            //Creamos un objeto para pasar los parametros necesarios en la
            //llamada al evento
            WorkflowInitEventArgs eventArgs = new WorkflowInitEventArgs(workflowInstance.InstanceId, txtUser.Text,
                                                                        txtTE.Text, cmbType.Text, txtObs.Text);

            //Llamada al evento que comunica la aplicacion con el workflow
            if (WorkflowInitialization != null)
            {
                WorkflowInitialization(null, eventArgs);
            }
        }
        /// <exclude />
        public static void Initialize()
        {
            WorkflowFacade.RunWhenInitialized(() =>
            {
                lock (_lock)
                {
                    if (_initialized == false)
                    {
                        WorkflowInstance workflowInstance = WorkflowFacade.CreateNewWorkflow(WorkflowFacade.GetWorkflowType("Composite.C1Console.Actions.Workflows.FlowInformationScavengerWorkflow"));
                        workflowInstance.Start();
                        WorkflowFacade.RunWorkflow(workflowInstance);

                        Log.LogVerbose(LogTitle, "Flow scavenger started");

                        _initialized = true;
                    }
                }
            });
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            WorkflowRuntime workflowRuntime = new WorkflowRuntime();

            AutoResetEvent waitHandle = new AutoResetEvent(false);

            workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
            workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
            {
                Console.WriteLine(e.Exception.Message);
                waitHandle.Set();
            };

            WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication1.Workflow1));

            instance.Start();

            waitHandle.WaitOne();
        }
        /// <summary>
        /// Create and start a workflow using markup (xoml)
        /// </summary>
        /// <param name="markupFileName"></param>
        /// <param name="rulesMarkupFileName"></param>
        /// <param name="parameters"></param>
        /// <returns>A wrapped workflow instance</returns>
        public WorkflowInstanceWrapper StartWorkflow(String markupFileName,
                                                     String rulesMarkupFileName,
                                                     Dictionary <String, Object> parameters)
        {
            WorkflowInstance        instance = null;
            WorkflowInstanceWrapper wrapper  = null;
            XmlReader wfReader    = null;
            XmlReader rulesReader = null;

            try
            {
                wfReader = XmlReader.Create(markupFileName);
                if (!String.IsNullOrEmpty(rulesMarkupFileName))
                {
                    rulesReader = XmlReader.Create(rulesMarkupFileName);
                    //create the workflow with workflow and rules
                    instance = _workflowRuntime.CreateWorkflow(
                        wfReader, rulesReader, parameters);
                }
                else
                {
                    //create the workflow with workflow markup only
                    instance = _workflowRuntime.CreateWorkflow(
                        wfReader, null, parameters);
                }

                wrapper = AddWorkflowInstance(instance);
                instance.Start();
            }
            finally
            {
                if (wfReader != null)
                {
                    wfReader.Close();
                }
                if (rulesReader != null)
                {
                    rulesReader.Close();
                }
            }
            return(wrapper);
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            string conn = "Initial Catalog=WF;Data Source=.;Integrated Security=SSPI";

            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
            {
                workflowRuntime.AddService(new SqlWorkflowPersistenceService(conn, true, new TimeSpan(1, 0, 0), new TimeSpan(0, 10, 0)));

                AutoResetEvent waitHandle = new AutoResetEvent(false);
                workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
                {
                    Console.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                workflowRuntime.WorkflowIdled += delegate(object sender, WorkflowEventArgs e)
                {
                    Console.WriteLine("Workflow idled: {0}", e.WorkflowInstance.InstanceId);
                };

                workflowRuntime.WorkflowPersisted += delegate(object sender, WorkflowEventArgs e)
                {
                    Console.WriteLine("Workflow persisted: {0}", e.WorkflowInstance.InstanceId);
                };

                workflowRuntime.WorkflowUnloaded += delegate(object sender, WorkflowEventArgs e)
                {
                    Console.WriteLine("Workflow unloaded: {0}", e.WorkflowInstance.InstanceId);
                };

                workflowRuntime.WorkflowLoaded += delegate(object sender, WorkflowEventArgs e)
                {
                    Console.WriteLine("Workflow loaded: {0}", e.WorkflowInstance.InstanceId);
                };

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowPersistence.Workflow1));
                instance.Start();

                waitHandle.WaitOne();
            }
        }
    public Request Execute(Action action)
    {
        var request = new Request();

        var workflowRuntime = WorkflowFactory.GetWorkflowRuntime();

        workflowRuntime.StartRuntime();
        var waitHandle            = new AutoResetEvent(false);
        WorkflowInstance instance = null;

        workflowRuntime.WorkflowCompleted += ((sender, e) =>
        {
            if (e.WorkflowInstance != instance)
            {
                return;
            }
            waitHandle.Set();
            request = e.OutputParameters["gRequest"] as Request;
        });
        workflowRuntime.WorkflowTerminated += ((sender, e) =>
        {
            if (e.WorkflowInstance != instance)
            {
                return;
            }
            waitHandle.Set();
            Logger.LogError(e.Exception, true, action.Serialize());
        });

        var parameters = new Dictionary <string, object>
        {
            { "RepositoryInstance", Repository },
            { "RequestID", action.RequestID.ToString() },
            { "ActionCode", action.ToString() }
        };

        instance = workflowRuntime.CreateWorkflow(typeof(ApprovalFlow), parameters);
        instance.Start();
        waitHandle.WaitOne();

        return(request);
    }
Beispiel #8
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            _workflowInstance = SampleWorkflowRuntime.Current.CreateStateMachineWorkflow();
            _workflowInstance.Start();

            try
            {
                btnCreate.Enabled = false;
                SampleWorkflowRuntime.Current.RunWorkflow(_workflowInstance.InstanceId);
                btnComplete.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unexpected error: {0}", ex.ToString());

                _workflowInstance   = null;
                btnCreate.Enabled   = true;
                btnComplete.Enabled = false;
            }
        }
Beispiel #9
0
        public void StartWorkflow(Type workflowType, Dictionary <string, object> inparms, Guid caller, IComparable qn)
        {
            WorkflowRuntime  wr = this.Runtime;
            WorkflowInstance wi = wr.CreateWorkflow(workflowType, inparms);

            wi.Start();

            var instanceId = wi.InstanceId;

            _WorkflowQueue[instanceId] = new WorkflowInfo {
                Caller = caller, qn = qn
            };

            ManualWorkflowSchedulerService ss = wr.GetService <ManualWorkflowSchedulerService>();

            if (ss != null)
            {
                ss.RunWorkflow(wi.InstanceId);
            }
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
            {
                AutoResetEvent waitHandle = new AutoResetEvent(false);
                workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
                {
                    Console.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(SimpleWorkflow.Workflow1));
                instance.Start();

                waitHandle.WaitOne();
                Console.WriteLine("Press any key to exit");
                Console.ReadLine();
            }
        }
Beispiel #11
0
        static void Main()
        {
            try
            {
                waitHandle = new AutoResetEvent(false);
                version    = GetTrackingProfileVersion(new Version("3.0.0.0"));
                CreateAndInsertTrackingProfile();
                using (WorkflowRuntime runtime = new WorkflowRuntime())
                {
                    SqlTrackingService trackingService = new SqlTrackingService(connectionString);
                    runtime.AddService(trackingService);
                    runtime.StartRuntime();
                    runtime.WorkflowCompleted  += OnWorkflowCompleted;
                    runtime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
                    {
                        Console.WriteLine(e.Exception.Message);
                        waitHandle.Set();
                    };

                    WorkflowInstance instance = runtime.CreateWorkflow(typeof(SimpleWorkflow));
                    instance.Start();
                    waitHandle.WaitOne();

                    runtime.StopRuntime();
                    OutputWorkflowTrackingEvents(instance.InstanceId);
                    OutputActivityTrackingEvents(instance.InstanceId);
                    Console.WriteLine("\nDone running the workflow.");
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    Console.WriteLine(ex.InnerException.Message);
                }
                else
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// Runs a new workflow. Used mainly to save the workflow as a template.
        /// </summary>
        /// <param name="wfType">The type of the workflow</param>
        /// <param name="parameters">The parameters to use in the workflow</param>
        /// <param name="conditionValues">The condition values to use in the workflow</param>
        public void RunNewFlow(Type wfType, Hashtable parameters, Hashtable conditionValues)
        {
            Console.WriteLine("Running New Flow. Type: " + wfType.ToString());
            using (WorkflowRuntime runtime = new WorkflowRuntime())
            {
                AutoResetEvent waitHandle = new AutoResetEvent(false);
                runtime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
                runtime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
                {
                    Console.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                SqlWorkflowPersistenceService persistanceService =
                    new SqlWorkflowPersistenceService(_connectionString);

                runtime.AddService(persistanceService);
                runtime.StartRuntime();

                //Fill the parameters .
                Dictionary <string, object> paramsD = new Dictionary <string, object>();
                paramsD.Add("Parameters", parameters);
                paramsD.Add("ConditionValues", conditionValues);

                WorkflowInstance instance = runtime.CreateWorkflow(wfType, paramsD);

                //This is a new workflow. Save it into the database.
                BaseSequentialWorkflow esw = (BaseSequentialWorkflow)Activator.CreateInstance(wfType);
                esw.WorkflowGUID     = instance.InstanceId;
                esw.ConditionValues  = conditionValues;
                esw.Parameters       = parameters;
                esw.ConnectionString = _connectionString;
                esw.Template         = true;
                esw.WorkflowType     = wfType;
                esw.Serialize();

                instance.Start();

                waitHandle.WaitOne();
            }
        }
        static void Main(string[] args)
        {
            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())

            {
                LocalService = new ReviewService();
                workflowRuntime.AddService(LocalService);
                AutoResetEvent waitHandle = new AutoResetEvent(false);
                workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
                {
                    Console.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(CCommunicationSequentialConsoleApplication.Workflow1));
                instance.Start();

                waitHandle.WaitOne();
            }
        }
Beispiel #14
0
        private void CreateWorkflowCore(Guid userId, TimeSpan frequency)
        {
            // Create new workflow instance.

            var parameters = new Dictionary <string, object>
            {
                { "UserId", userId },
                { "Delay", frequency },
                { "LastRunTime", DateTime.MinValue },
            };

            WorkflowInstance workflow = CreateWorkflow <Design.PeriodicWorkflow.PeriodicWorkflow>(parameters);

            // Record workflow instance in LinkMe database.

            _worker.AttachWorkflow(userId, workflow.InstanceId);

            // Start running the workflow.

            workflow.Start();
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            WorkflowRuntime workflowRuntime = new WorkflowRuntime();

            AutoResetEvent waitHandle = new AutoResetEvent(false);

            workflowRuntime.WorkflowCompleted  += OnWorkflowCompleted;
            workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;


            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters["Input1"] = 45;
            parameters["Input2"] = 45;

            WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(CFirstStateMachineWFConsoleApplication.Workflow1));

            instance.Start();

            waitHandle.WaitOne();
        }
Beispiel #16
0
        /// <exclude />
        public static void Initialize()
        {
            WorkflowFacade.RunWhenInitialized(() =>
            {
                lock (_lock)
                {
                    if (!_initialized)
                    {
                        WorkflowInstance workflowInstance = WorkflowFacade.CreateNewWorkflow(WorkflowFacade.GetWorkflowType("Composite.C1Console.Events.Workflows.UserConsoleInformationScavengerWorkflow"));
                        workflowInstance.Start();
                        WorkflowFacade.RunWorkflow(workflowInstance);

                        if (RuntimeInformation.IsDebugBuild)
                        {
                            Log.LogVerbose(LogTitle, "Scavenger started");
                        }
                        _initialized = true;
                    }
                }
            });
        }
Beispiel #17
0
        static void Main()
        {
            try
            {
                using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
                {
                    workflowRuntime.AddService(new SqlTrackingService(connectionString));

                    workflowRuntime.WorkflowCompleted  += OnWorkflowCompleted;
                    workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;

                    WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(typeof(SimpleTrackingWorkflow));
                    Guid             instanceId       = workflowInstance.InstanceId;

                    workflowRuntime.StartRuntime();

                    workflowInstance.Start();

                    waitHandle.WaitOne();

                    workflowRuntime.StopRuntime();

                    GetInstanceTrackingEvents(instanceId);
                    GetActivityTrackingEvents(instanceId);

                    Console.WriteLine("\nDone running the workflow.");
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    Console.WriteLine(ex.InnerException.Message);
                }
                else
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Beispiel #18
0
    /// <summary>
    /// The calculate button was pressed
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCalculate_Click(object sender, EventArgs e)
    {
        //retrieve the workflow runtime
        WorkflowRuntime workflowRuntime
            = Application["WorkflowRuntime"] as WorkflowRuntime;
        //retrieve the scheduler that is used to execute workflows
        ManualWorkflowSchedulerService scheduler =
            workflowRuntime.GetService(
                typeof(ManualWorkflowSchedulerService))
            as ManualWorkflowSchedulerService;

        //handle the WorkflowCompleted event in order to
        //retrieve the output parameters from the completed workflow
        workflowRuntime.WorkflowCompleted
            += new EventHandler <WorkflowCompletedEventArgs>(
                   workflowRuntime_WorkflowCompleted);

        //get the input parameters
        Double dividendValue;
        Double divisorValue;

        Double.TryParse(dividend.Text, out dividendValue);
        Double.TryParse(divisor.Text, out divisorValue);

        //pass the input parameters to the workflow
        Dictionary <String, Object> wfArguments
            = new Dictionary <string, object>();

        wfArguments.Add("Dividend", dividendValue);
        wfArguments.Add("Divisor", divisorValue);

        //create and start the workflow
        WorkflowInstance instance = workflowRuntime.CreateWorkflow(
            typeof(SharedWorkflows.DivideNumbersWorkflow), wfArguments);

        instance.Start();

        //execute the workflow synchronously on our thread
        scheduler.RunWorkflow(instance.InstanceId);
    }
Beispiel #19
0
        static void Main()
        {
            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
            {
                try
                {
                    Int32 orderAmount = 14000;
                    Console.WriteLine("Order amount = {0:c}, approved amount = {1:c}", orderAmount, 10000);

                    // Start the engine.
                    workflowRuntime.StartRuntime();

                    // Load the workflow type.
                    Type type = typeof(Microsoft.Samples.Workflow.ChangingRules.DynamicRulesWorkflow);

                    workflowRuntime.WorkflowCompleted           += OnWorkflowCompleted;
                    workflowRuntime.WorkflowIdled               += OnWorkflowIdle;
                    workflowRuntime.WorkflowTerminated          += OnWorkflowTerminated;
                    workflowRuntime.ServicesExceptionNotHandled += OnExceptionNotHandled;

                    // The "OrderValueParameter" parameter is used to determine which branch of the IfElse should be executed
                    // a value less than 10,000 will execute branch 1 - Get Manager Approval; any other value will execute branch 2 - Get VP Approval
                    Dictionary <string, object> parameters = new Dictionary <string, object>();
                    parameters.Add("Amount", orderAmount);
                    WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type, parameters);
                    workflowInstance.Start();

                    waitHandle.WaitOne();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception \n\tSource: {0} \n\tMessage: {1}", e.Source, e.Message);
                }
                finally
                {
                    workflowRuntime.StopRuntime();
                    Console.WriteLine("Workflow runtime stopped, program exiting...");
                }
            }
        }
Beispiel #20
0
        static void Main(string[] args)
        {
            WorkflowServiceHost host = new WorkflowServiceHost(typeof(CustomerWorkflow));

            host.Description.Behaviors.Find <WorkflowRuntimeBehavior>().WorkflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { Console.WriteLine("WorkflowTerminated: " + e.Exception.Message); };
            host.Description.Behaviors.Find <WorkflowRuntimeBehavior>().WorkflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { Console.WriteLine("WorkflowCompleted."); };
            host.Open();

            Console.WriteLine("Role: Customer");
            Console.WriteLine("Press <enter> to submit order.");
            Console.ReadLine();

            WorkflowInstance workflow = host.Description.Behaviors.Find <WorkflowRuntimeBehavior>().WorkflowRuntime.CreateWorkflow(typeof(CustomerWorkflow));

            workflow.Start();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Press <enter> to exit");
            Console.ResetColor();
            Console.ReadLine();
            host.Close();
        }
Beispiel #21
0
    public static Guid StartWorkflow()
    {
        // Get a reference to the System.Type for the OrderWorkflows.Workflow1
        Type workflowType = typeof(IgrssWorkflowLibrary.ValuationProcess);

        if (workflowType == null)
        {
            return(Guid.Empty);
        }

        WorkflowInstance instance = runtime.CreateWorkflow(workflowType);

        StateMachineWorkflowInstance stateMachineInstance = new StateMachineWorkflowInstance(runtime, instance.InstanceId);

        instance.Start();
        // Add the StateMachineInstance object for our Workflow to our dictionary
        stateMachineInstances.Add(instance.InstanceId.ToString(), stateMachineInstance);
        lastWf = instance.InstanceId;

        // Return the WorkflowInstanceId
        return(lastWf);
    }
Beispiel #22
0
        static void Main(string[] args)
        {
            try
            {
                //Set up event log source if it doesn't already exist
                if (!EventLog.SourceExists(eventSource))
                {
                    EventLog.CreateEventSource(eventSource, "Application");
                }
            }
            catch (SecurityException)
            {
                // Administrator privileges are needed to create an event log source.
                Console.WriteLine("Please run this application once with Administrator privileges to create event source.");
                return;
            }

            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
            {
                AutoResetEvent      waitHandle = new AutoResetEvent(false);
                NameValueCollection parameters = new NameValueCollection();
                parameters.Add("EventSource", eventSource);

                workflowRuntime.AddService(new TerminationTrackingService(parameters));
                workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
                {
                    Console.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(SampleWorkflow));
                instance.Start();

                waitHandle.WaitOne();

                workflowRuntime.StopRuntime();
            }
        }
Beispiel #23
0
 protected void btnLUStart_Click(object sender, EventArgs e)
 {
     try
     {
         WorkflowRuntime  workflowRuntime = (WorkflowRuntime)Application["WokflowRuntime"]; //System.Web.HttpContext.Current.Items["WokflowRuntime"];
         WorkflowInstance instance        = workflowRuntime.CreateWorkflow(typeof(LeaveUpLoadWF));
         Application["LeaveUpLoadWF"] = instance.InstanceId.ToString();
         instance.Start();
         GetWorkFlowStatus();
     }
     catch (V2Exceptions ex)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         Application["LeaveUpLoadWF"] = "";
         FileLog objFileLog = FileLog.GetLogger();
         objFileLog.WriteLine(LogType.Error, ex.Message, "LeaveApplicationForm.aspx.cs", "StartWorkflow", ex.StackTrace);
         throw new V2Exceptions(ex.ToString(), ex);
     }
 }
Beispiel #24
0
        public Cobase6000Bi()
        {
            try
            {
                _clsHRecord = new CobasE6000HeaderRecord();
                _clsPRecord = new CobasE6000PatientInformationRecord();
                _clsORecord = new CobasE6000TestOrderRecord();
                _clsQRecord = new CobasE6000RequestInformationRecord();
                _clsRRecord = new CobasE6000ResultRecord();
                _clsTRecord = new CobasE6000TerminationRecord();

                _prvRequestArray = new Queue <List <string> >();
                _objService      = new ExternalDataExchangeService();
                _failSending     = 0;

                _instanceId = Guid.NewGuid();
                _objWorkFlowRuntime.AddService(_objService);
                _objAstm = new ClsAstm();
                _objService.AddService(_objAstm);
                _objAstm.SendACKEvent += objASTM_SendACKEvent;
                _objAstm.SendNAKEvent += objASTM_SendNAKEvent;
                _objAstm.SendENQEvent += objASTM_SendENQEvent;
                _objAstm.SendEOTEvent += objASTM_SendEOTEvent;
                //_objAstm.ACKTimeoutEvent += new EventHandler(_objAstm_ACKTimeoutEvent);
                _objWorkFlowInstance = _objWorkFlowRuntime.CreateWorkflow(typeof(ASTMWorkflow), null, _instanceId);
                _objWorkFlowInstance.Start();
                Console.WriteLine(@"Work flow started");

                _objDataEventArgs = new ExternalDataEventArgs(_instanceId)
                {
                    WaitForIdle = true
                };
                DumpStateMachine(_objWorkFlowRuntime, _instanceId);
            }
            catch (Exception ex)
            {
                Log.Error("Fatal Error: {0}", ex);
            }
        }
        public FlowToken Execute(string serializedEntityToken, string serializedActionToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            WorkflowActionToken workflowActionToken = (WorkflowActionToken)actionToken;

            WorkflowInstance workflowInstance = WorkflowFacade.CreateNewWorkflow(
                workflowActionToken.WorkflowType,
                new Dictionary <string, object> {
                { "SerializedEntityToken", serializedEntityToken },
                { "SerializedActionToken", serializedActionToken },
                { "ParentWorkflowInstanceId", workflowActionToken.ParentWorkflowInstanceId }
            }
                );

            workflowInstance.Start();

            WorkflowFacade.SetFlowControllerServicesContainer(workflowInstance.InstanceId, flowControllerServicesContainer);
            WorkflowFacade.RunWorkflow(workflowInstance);

            WorkflowFacade.SetEventHandlerFilter(workflowInstance.InstanceId, workflowActionToken.EventHandleFilterType);

            return(new WorkflowFlowToken(workflowInstance.InstanceId));
        }
Beispiel #26
0
        public Centaur()
        {
            try
            {
                _clsHRecord              = new CentaurHeaderRecord();
                _clsPRecord              = new CentaurPatientRecord();
                _clsORecord              = new CentaurOrderRecord();
                _clsQRecord              = new CentaurQueryRecord();
                _clsRRecord              = new CentaurResultRecord();
                _clsTRecord              = new CentaurTerminationRecord();
                PrvRequestArray          = new Queue <string>();
                _failSending             = 0;
                _timeoutManager          = new Timer(30000);
                _timeoutManager.Elapsed += _timeoutManager_Elapsed;
                objService = new ExternalDataExchangeService();

                InstanceId = Guid.NewGuid();
                objWorkFlowRuntime.AddService(objService);
                objASTM = new ClsAstm();
                objService.AddService(objASTM);
                objASTM.SendACKEvent += objASTM_SendACKEvent;
                objASTM.SendNAKEvent += objASTM_SendNAKEvent;
                objASTM.SendENQEvent += objASTM_SendENQEvent;
                objASTM.SendEOTEvent += objASTM_SendEOTEvent;
                //objASTM.ACKTimeoutEvent += new EventHandler(objASTM_ACKTimeoutEvent);
                objWorkFlowInstance = objWorkFlowRuntime.CreateWorkflow(typeof(ASTMWorkflow), null, InstanceId);
                objWorkFlowInstance.Start();
                Console.WriteLine(@"Work flow started");

                objDataEventArgs             = new ExternalDataEventArgs(InstanceId);
                objDataEventArgs.WaitForIdle = true;
                DumpStateMachine(objWorkFlowRuntime, InstanceId);
            }
            catch (Exception ex)
            {
                Log.FatalException("Fatal Error: ", ex);
            }
        }
Beispiel #27
0
        private void EnsureWorkflowStarted()
        {
            if (instance == null)
            {
                // we need to manage the service's subscription to the dataexchangeservice with the lifetime of the workflow

                // Aquire the callback from the current OperationContext
                callback = OperationContext.Current.GetCallbackChannel <ICalculatorCallback>();
                //grab the version of the incoming message in case we need to create a fault later
                version = OperationContext.Current.IncomingMessageVersion;

                // retrieve the WorkflowRuntime from our WFServiceHostExtension
                WorkflowRuntime workflowRuntime = OperationContext.Current.Host.Extensions.Find <WFServiceHostExtension>().WorkflowRuntime;

                // grab a reference to our mathService
                ExternalDataExchangeService dataExchangeService = workflowRuntime.GetService <ExternalDataExchangeService>();
                mathService = (MathDataExchangeService)dataExchangeService.GetService(typeof(MathDataExchangeService));

                // if it is null set it up
                if (mathService == null)
                {
                    mathService = new MathDataExchangeService();
                    dataExchangeService.AddService(mathService);
                }

                //register with the ResultReceived event
                mathService.ResultReceived += HandleResultReceived;

                //register to get signaled when the workflow completes
                workflowRuntime.WorkflowCompleted  += this.OnWorkflowCompleted;
                workflowRuntime.WorkflowTerminated += this.OnWorkflowTerminated;

                //create and start the Workflow
                instance = workflowRuntime.CreateWorkflow(typeof(Workflow1));

                instance.Start();
            }
        }
Beispiel #28
0
        static void Main(string[] args)
        {
            WorkflowRuntime workflowRuntime = new WorkflowRuntime();

            AutoResetEvent waitHandle = new AutoResetEvent(false);

            workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
            workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
            {
                Console.WriteLine(e.Exception.Message);
                waitHandle.Set();
            };
            Dictionary <string, object> parms = new Dictionary <string, object>();

            Console.WriteLine("Input Value");

            parms["InputValue"] = System.Convert.ToInt32(Console.ReadLine());
            WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(CIfElseSequentialExample.Workflow1), parms);

            instance.Start();

            waitHandle.WaitOne();
        }
Beispiel #29
0
    static void Main()
    {
        // Create the WorkflowRuntime
        WorkflowRuntime workflowRuntime = new WorkflowRuntime();

        workflowRuntime.AddService((object)new ourDefaultWorkflowSchedulerService());

        workflowRuntime.StartRuntime();
        Type type = typeof(SequentialWorkflow);

        // Listen for the workflow events
        workflowRuntime.WorkflowCompleted  += OnWorkflowCompleted;
        workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
        WorkflowInstance wi = workflowRuntime.CreateWorkflow(type);

        wi.Start();

        waitHandle.WaitOne();

        // Stop the runtime
        Console.WriteLine("Program Complete.");
        //workflowRuntime.Dispose ();
    }
Beispiel #30
0
        static void Main(string[] args)
        {
            using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
            {
                ExternalDataExchangeService edes = new ExternalDataExchangeService();

                workflowRuntime.AddService(edes);
                edes.AddService(new ExpenseApprovalService());

                AutoResetEvent waitHandle = new AutoResetEvent(false);
                workflowRuntime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); };
                workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
                {
                    Console.WriteLine(e.Exception.Message);
                    waitHandle.Set();
                };

                WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(_2_Listen.Workflow1));
                instance.Start();

                waitHandle.WaitOne();
            }
        }