Exemple #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);
        }
Exemple #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;
        }
        public Object GetService(Type serviceType)
        {
            if (this.currentActivity == null)
            {
                throw new ObjectDisposedException("ActivityExecutionContext");
            }

            if (serviceType == typeof(IStartWorkflow))
            {
                if (this.startWorkflowService == null)
                {
                    this.startWorkflowService = new StartWorkflow(this);
                }

                return(this.startWorkflowService);
            }
            else
            {
                if (schedulerServiceType != null && schedulerServiceType.IsAssignableFrom(serviceType))
                {
                    return(null);
                }

                if (persistenceServiceType != null && persistenceServiceType.IsAssignableFrom(serviceType))
                {
                    return(null);
                }

                if (trackingServiceType != null && trackingServiceType.IsAssignableFrom(serviceType))
                {
                    return(null);
                }

                if (transactionServiceType != null && transactionServiceType.IsAssignableFrom(serviceType))
                {
                    return(null);
                }

                if (loaderServiceType != null && loaderServiceType.IsAssignableFrom(serviceType))
                {
                    return(null);
                }
            }

            return(this.currentActivity.WorkflowCoreRuntime.GetService(this.currentActivity, serviceType));
        }
Exemple #4
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);
        }