示例#1
0
        /// <summary>
        /// This method is an example of how to add a service to the workflow runtime.
        /// </summary>
        /// <param name="action"></param>
        /// <param name="data"></param>
        public override void DoAction(Microsoft.Ccf.Csr.Action action, string data)
        {
            Microsoft.Ccf.Samples.CcfWorkflows.UserInteractionServiceImpl.SetFocusTarget    = SetFocusReceive;
            Microsoft.Ccf.Samples.CcfWorkflows.UserInteractionServiceImpl.SetDoActionTarget = DoActionReceive;

            base.DoAction(action, data);

            if (action.Name == "Human Workflow Automation")
            {
                XmlDocument xmlDocument = new XmlDocument();
                XmlNode     node;

                this.AddServices(workflowService);

                // Prepare parameters from data sent with action
                xmlDocument.LoadXml(data);

                // Fill in the parameters
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                parameters.Add("WFControlHandle", this.Handle);
                node = xmlDocument.SelectSingleNode("Workflow/StepName");
                parameters.Add("StepName", node.InnerText);

                node = xmlDocument.SelectSingleNode("Workflow/HostedApplicationId");
                parameters.Add("HostedApplicationId", Int32.Parse(node.InnerText));

                node = xmlDocument.SelectSingleNode("Workflow/HostedApplicationName");
                parameters.Add("HostedApplicationName", node.InnerText);

                node = xmlDocument.SelectSingleNode("Workflow/Action");
                parameters.Add("Action", node.InnerText);

                this.StartRuntime();

                System.Workflow.Runtime.WorkflowInstance instance = WorkflowManager.WorkflowManager.WorkflowRuntime.CreateWorkflow(typeof(CcfWorkflowStep), parameters);
                instance.Start();
            }
        }
 internal WorkflowEventArgs(System.Workflow.Runtime.WorkflowInstance instance)
 {
     this._instance = instance;
 }
 internal void Reload(Activity rootActivity, System.Workflow.Runtime.WorkflowInstance workflowInstance)
 {
     this._workflowInstance = workflowInstance;
     this.ReloadHelper(rootActivity);
 }
 internal void Initialize(Activity rootActivity, WorkflowExecutor invokerExec, string invokeActivityID, Guid instanceId, IDictionary<string, object> namedArguments, System.Workflow.Runtime.WorkflowInstance workflowInstance)
 {
     this.rootActivity = rootActivity;
     this.InstanceId = instanceId;
     this.rootActivity.SetValue(ContextIdProperty, 0);
     this.rootActivity.SetValue(WorkflowInstanceIdProperty, instanceId);
     this.WorkflowStatus = System.Workflow.Runtime.WorkflowStatus.Created;
     this.rootActivity.SetValue(Activity.ActivityExecutionContextInfoProperty, new ActivityExecutionContextInfo(this.rootActivity.QualifiedName, this.GetNewContextId(), instanceId, -1));
     this.rootActivity.SetValue(Activity.ActivityContextGuidProperty, instanceId);
     this.rootActivity.SetValue(IsIdleProperty, true);
     this.isInstanceIdle = true;
     this.rootActivity.SetValue(WorkflowExecutorProperty, this);
     this.RefreshWorkflowDefinition();
     Activity workflowDefinition = this.WorkflowDefinition;
     if (workflowDefinition == null)
     {
         throw new InvalidOperationException("workflowDefinition");
     }
     ((IDependencyObjectAccessor) this.rootActivity).InitializeActivatingInstanceForRuntime(null, this);
     this.rootActivity.FixUpMetaProperties(workflowDefinition);
     this._runtime = workflowInstance.WorkflowRuntime;
     if (invokerExec != null)
     {
         List<string> list = new List<string>();
         System.Workflow.Runtime.TrackingCallingState state = (System.Workflow.Runtime.TrackingCallingState) invokerExec.rootActivity.GetValue(TrackingCallingStateProperty);
         if ((state != null) && (state.CallerActivityPathProxy != null))
         {
             foreach (string str in state.CallerActivityPathProxy)
             {
                 list.Add(str);
             }
         }
         list.Add(invokeActivityID);
         System.Workflow.Runtime.TrackingCallingState state2 = new System.Workflow.Runtime.TrackingCallingState {
             CallerActivityPathProxy = list,
             CallerWorkflowInstanceId = invokerExec.InstanceId,
             CallerContextGuid = ((ActivityExecutionContextInfo) ContextActivityUtils.ContextActivity(invokerExec.CurrentActivity).GetValue(Activity.ActivityExecutionContextInfoProperty)).ContextGuid
         };
         if (invokerExec.CurrentActivity.Parent == null)
         {
             state2.CallerParentContextGuid = state2.CallerContextGuid;
         }
         else
         {
             state2.CallerParentContextGuid = ((ActivityExecutionContextInfo) ContextActivityUtils.ContextActivity(invokerExec.CurrentActivity.Parent).GetValue(Activity.ActivityExecutionContextInfoProperty)).ContextGuid;
         }
         this.rootActivity.SetValue(TrackingCallingStateProperty, state2);
     }
     this._setInArgsOnCompanion(namedArguments);
     this.schedulingContext = new System.Workflow.Runtime.Scheduler(this, true);
     this._schedulerLock = LockFactory.CreateWorkflowSchedulerLock(this.InstanceId);
     this.qService = new WorkflowQueuingService(this);
     this._workflowInstance = workflowInstance;
     this.TimerQueue = new TimerEventSubscriptionCollection(this, this.InstanceId);
     using (new ServiceEnvironment(this.rootActivity))
     {
         using (this.SetCurrentActivity(this.rootActivity))
         {
             this.RegisterDynamicActivity(this.rootActivity, false);
         }
     }
 }
 internal void Initialize(Activity rootActivity, System.Workflow.Runtime.WorkflowRuntime runtime, WorkflowExecutor previousWorkflowExecutor)
 {
     this._workflowInstance = previousWorkflowExecutor.WorkflowInstance;
     this.ReloadHelper(rootActivity);
     this.IsInstanceValid = true;
     this._runtime = runtime;
     this._runtime.WorkflowExecutorCreated(this, true);
     this.TimerQueue.Executor = this;
     this.TimerQueue.ResumeDelivery();
     this._executorLock = previousWorkflowExecutor._executorLock;
     this._msgDeliveryLock = previousWorkflowExecutor._msgDeliveryLock;
     this._schedulerLock = previousWorkflowExecutor._schedulerLock;
     ScheduleWork.Executor = this;
 }
 internal WorkflowEventArgs(System.Workflow.Runtime.WorkflowInstance instance)
 {
     this._instance = instance;
 }