Beispiel #1
0
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext aec)
        {
            //get the services needed
            //custom service to run the workflow
            SubWorkflowService ws = aec.GetService <SubWorkflowService>();


            //Queuing service to setup the queue so the service can "callback"
            WorkflowQueuingService qs = aec.GetService <WorkflowQueuingService>();
            //create the queue the service can call back on when the child workflow is done
            //you might want the queuename to be something different
            string        qn = String.Format("{0}:{1}:{2}:ThisIsSubWorkflowSupportForkJoin", this.WorkflowInstanceId.ToString(), Type.Name, this.Name);
            WorkflowQueue q  = qs.CreateWorkflowQueue(qn, false);

            q.QueueItemAvailable += new EventHandler <QueueEventArgs>(q_QueueItemAvailable);

            //copy the params to a new collection
            Dictionary <string, object> inparams = new Dictionary <string, object>();

            foreach (WorkflowParameterBinding bp in this.Parameters)
            {
                PropertyInfo pi = Type.GetProperty(bp.ParameterName);
                if (pi.CanWrite)
                {
                    inparams.Add(bp.ParameterName, bp.Value);
                }
            }
            //ask the service to start the workflow

            ws.StartWorkflow(Type, inparams, this.WorkflowInstanceId, qn, aec);

            return(ActivityExecutionStatus.Executing);
        }
Beispiel #2
0
        protected void Application_Start(object sender, EventArgs e)
        {
            // create an instance of workflow runtime, loading settings from web.config
            WorkflowRuntime workflowRuntime = new WorkflowRuntime(WorkflowManager.WorkflowRuntimeKey);

            // add the external data exchange service to the runtime to allow for local services
            ExternalDataExchangeService exchangeService = new ExternalDataExchangeService(WorkflowManager.LocalServicesKey);

            CustomConditionsService condServ = new CustomConditionsService();

            SubWorkflowService serv = new SubWorkflowService(); // This is for Sub workflow service

            workflowRuntime.AddService(exchangeService);
            workflowRuntime.AddService(serv);
            workflowRuntime.AddService(condServ);

            // start the workflow runtime
            workflowRuntime.StartRuntime();

            // save the runtime for use by the entire application
            Application[WorkflowManager.WorkflowRuntimeKey] = workflowRuntime;
        }
Beispiel #3
0
        void q_QueueItemAvailable(object sender, QueueEventArgs e)
        {
            ActivityExecutionContext aec = sender as ActivityExecutionContext;

            if (aec != null)
            {
                WorkflowQueuingService qs = aec.GetService <WorkflowQueuingService>();

                WorkflowQueue q = qs.GetWorkflowQueue(e.QueueName);
                //get the outparameters from the workflow
                object o = q.Dequeue();
                //delete the queue
                Exception ex = o as Exception;
                if (ex != null)
                {
                    throw ex;
                }
                qs.DeleteWorkflowQueue(e.QueueName);
                Dictionary <string, object> outparams = o as Dictionary <string, object>;
                if (outparams != null)
                {
                    foreach (KeyValuePair <string, object> item in outparams)
                    {
                        if (this.Parameters.Contains(item.Key))
                        {
                            //modify the value
                            this.Parameters[item.Key].SetValue(WorkflowParameterBinding.ValueProperty, item.Value);
                        }
                    }
                }
                aec.CloseActivity();

                ///
                SubWorkflowService ws = aec.GetService <SubWorkflowService>();
                ws.OnFinishCallworkflowActivity(this.WorkflowInstanceId);
            }
        }