Esempio n. 1
0
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }
            base.RaiseEvent(InvokingEvent, this, EventArgs.Empty);
            Dictionary <string, object> namedArgumentValues = new Dictionary <string, object>();

            foreach (WorkflowParameterBinding binding in this.ParameterBindings)
            {
                namedArgumentValues.Add(binding.ParameterName, binding.Value);
            }
            IStartWorkflow service = executionContext.GetService(typeof(IStartWorkflow)) as IStartWorkflow;

            if (service == null)
            {
                throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(IStartWorkflow).FullName }));
            }
            Guid guid = service.StartWorkflow(this.TargetWorkflow, namedArgumentValues);

            if (guid == Guid.Empty)
            {
                throw new InvalidOperationException(SR.GetString("Error_FailedToStartTheWorkflow"));
            }
            this.SetInstanceId(guid);
            return(ActivityExecutionStatus.Closed);
        }
Esempio n. 2
0
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            if (executionContext == null)
                throw new ArgumentNullException("executionContext");

            // raise event
            base.RaiseEvent(InvokeWorkflowActivity.InvokingEvent, this, EventArgs.Empty);

            // collect the [in] parameters
            Dictionary<string, object> namedArgumentValues = new Dictionary<string, object>();
            foreach (WorkflowParameterBinding paramBinding in this.ParameterBindings)
                namedArgumentValues.Add(paramBinding.ParameterName, paramBinding.Value);

            IStartWorkflow workflowInvoker = executionContext.GetService(typeof(IStartWorkflow)) as IStartWorkflow;
            if (workflowInvoker == null)
                throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(IStartWorkflow).FullName));

            Guid instanceId = workflowInvoker.StartWorkflow(this.TargetWorkflow, namedArgumentValues);
            if (instanceId == Guid.Empty)
                throw new InvalidOperationException(SR.GetString(SR.Error_FailedToStartTheWorkflow));

            this.SetInstanceId(instanceId);

            return ActivityExecutionStatus.Closed;
        }
Esempio n. 3
0
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            this.RaiseEvent(InvokeWorkflow.BeforeInvokedEvent, this, new EventArgs());

            if (this.TargetWorkflow == null)
            {
                throw new InvalidOperationException("TargetWorkflow property must be set to a valid Type that derives from Activity.");
            }

            IStartWorkflow startWorkflow = executionContext.GetService(typeof(IStartWorkflow)) as IStartWorkflow;

            this.InstanceId = startWorkflow.StartWorkflow(this.TargetWorkflow, this.Parameters);

            //base.SetValue(InstanceIdProperty, instanceId);
            this.RaiseEvent(InvokeWorkflow.AfterInvokedEvent, this, new EventArgs());

            return(ActivityExecutionStatus.Closed);
        }