當前位置: 首頁>>代碼示例>>C#>>正文


C# ActivityExecutionContext.CloseActivity方法代碼示例

本文整理匯總了C#中ActivityExecutionContext.CloseActivity方法的典型用法代碼示例。如果您正苦於以下問題:C# ActivityExecutionContext.CloseActivity方法的具體用法?C# ActivityExecutionContext.CloseActivity怎麽用?C# ActivityExecutionContext.CloseActivity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ActivityExecutionContext的用法示例。


在下文中一共展示了ActivityExecutionContext.CloseActivity方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Execute

 protected internal sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
 {
     executionContext.CloseActivity();
     string error = this.Error;
     executionContext.SuspendWorkflowInstance(error);
     return ActivityExecutionStatus.Closed;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:7,代碼來源:SuspendActivity.cs

示例2: Execute

        protected internal override sealed ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            executionContext.CloseActivity();

            string suspendReason = this.Error;
            executionContext.SuspendWorkflowInstance(suspendReason);
            return ActivityExecutionStatus.Closed;
        }
開發者ID:iskiselev,項目名稱:JSIL.NetFramework,代碼行數:8,代碼來源:Suspend.cs

示例3: Execute

        protected internal override sealed ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            executionContext.CloseActivity();

            string terminateReason = this.Error;
            executionContext.TerminateWorkflowInstance(new WorkflowTerminatedException(terminateReason));
            return ActivityExecutionStatus.Closed;
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:8,代碼來源:Terminate.cs

示例4: OnWorkflowChangesCompleted

 public static void OnWorkflowChangesCompleted(CompositeActivity activity, ActivityExecutionContext executionContext)
 {
     string str = activity.GetValue(ActiveChildQualifiedNameProperty) as string;
     bool flag = (bool) activity.GetValue(ActiveChildRemovedProperty);
     if (((str != null) && flag) && (((activity.ExecutionStatus == ActivityExecutionStatus.Canceling) || (activity.ExecutionStatus == ActivityExecutionStatus.Faulting)) || ((activity.ExecutionStatus == ActivityExecutionStatus.Executing) && !TryScheduleNextChild(activity, executionContext))))
     {
         activity.RemoveProperty(ActiveChildQualifiedNameProperty);
         executionContext.CloseActivity();
     }
     activity.RemoveProperty(ActiveChildRemovedProperty);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:11,代碼來源:SequenceHelper.cs

示例5: ExecuteNext

        // This function executes the ForEach activity.  It advances the current index of the collection.
        // If the end of the collection is reached, return false.  Otherwise, it executes any child activity
        // and return true.
        private bool ExecuteNext(ActivityExecutionContext context)
        {
            // First, move to the next position.
            if (!this.Enumerator.MoveNext())
                return false;

            // Fire the Iterating event.
            base.RaiseEvent(IteratingEvent, this, EventArgs.Empty);

            // Execute the child activity.
            if (this.EnabledActivities.Count > 0)
            {
                // Add the child activity to the execution context and setup the event handler to 
                // listen to the child Close event.
                // A new instance of the child activity is created for each iteration.
                ActivityExecutionContext innerContext = 
                    context.ExecutionContextManager.CreateExecutionContext(this.EnabledActivities[0]);
                innerContext.Activity.Closed += this.OnChildClose;

                // Execute the child activity again.  
                innerContext.ExecuteActivity(innerContext.Activity);
            }
            else
            {
                // an empty foreach loop. 
                // If the ForEach activity is still executing, then execute the next one.
                if (this.ExecutionStatus == ActivityExecutionStatus.Executing)
                {
                    if (!ExecuteNext(context))
                        context.CloseActivity();
                }
            }
            return true;
        }
開發者ID:spzenk,項目名稱:sfdocsamples,代碼行數:37,代碼來源:ForEach.cs

示例6: OnWorkflowChangesCompleted

        public static void OnWorkflowChangesCompleted(CompositeActivity activity, ActivityExecutionContext executionContext)
        {
            String activeChildQualifiedName = activity.GetValue(ActiveChildQualifiedNameProperty) as String;
            bool activeChildRemovedInDynamicUpdate = (bool)activity.GetValue(ActiveChildRemovedProperty);

            if (activeChildQualifiedName != null && activeChildRemovedInDynamicUpdate)
            {   //We have our active child removed.    
                if (activity.ExecutionStatus == ActivityExecutionStatus.Canceling ||
                activity.ExecutionStatus == ActivityExecutionStatus.Faulting ||
                activity.ExecutionStatus == ActivityExecutionStatus.Executing && !TryScheduleNextChild(activity, executionContext))
                {
                    activity.RemoveProperty(ActiveChildQualifiedNameProperty);
                    executionContext.CloseActivity();
                }
            }
            activity.RemoveProperty(ActiveChildRemovedProperty);
        }
開發者ID:iskiselev,項目名稱:JSIL.NetFramework,代碼行數:17,代碼來源:Sequence.cs

示例7: Run

        public override bool Run(IWorkflowCoreRuntime workflowCoreRuntime)
        {
            // get state reader
            Activity contextActivity = workflowCoreRuntime.GetContextActivityForId(this.ContextId);
            Activity activity = contextActivity.GetActivityByName(this.activityName);

            using (workflowCoreRuntime.SetCurrentActivity(activity))
            {
                using (ActivityExecutionContext activityExecutionContext = new ActivityExecutionContext(activity))
                {
                    ActivityExecutor activityExecutor = ActivityExecutors.GetActivityExecutor(activity);
                    switch (this.operation)
                    {
                        case ActivityOperationType.Execute:
                            if (activity.ExecutionStatus == ActivityExecutionStatus.Executing)
                            {
                                try
                                {
                                    workflowCoreRuntime.RaiseActivityExecuting(activity);

                                    ActivityExecutionStatus newStatus = activityExecutor.Execute(activity, activityExecutionContext);
                                    if (newStatus == ActivityExecutionStatus.Closed)
                                        activityExecutionContext.CloseActivity();
                                    else if (newStatus != ActivityExecutionStatus.Executing)
                                        throw new InvalidOperationException(SR.GetString(SR.InvalidExecutionStatus, activity.QualifiedName, newStatus.ToString(), ActivityExecutionStatus.Executing.ToString()));
                                }
                                catch (Exception e)
                                {
                                    System.Workflow.Runtime.WorkflowTrace.Runtime.TraceEvent(TraceEventType.Error, 1, "Execute of Activity {0} threw {1}", activity.QualifiedName, e.ToString());
                                    throw;
                                }
                            }
                            break;
                        case ActivityOperationType.Cancel:
                            if (activity.ExecutionStatus == ActivityExecutionStatus.Canceling)
                            {
                                try
                                {
                                    ActivityExecutionStatus newStatus = activityExecutor.Cancel(activity, activityExecutionContext);
                                    if (newStatus == ActivityExecutionStatus.Closed)
                                        activityExecutionContext.CloseActivity();
                                    else if (newStatus != ActivityExecutionStatus.Canceling)
                                        throw new InvalidOperationException(SR.GetString(SR.InvalidExecutionStatus, activity.QualifiedName, newStatus.ToString(), ActivityExecutionStatus.Canceling.ToString()));

                                }
                                catch (Exception e)
                                {
                                    System.Workflow.Runtime.WorkflowTrace.Runtime.TraceEvent(TraceEventType.Error, 1, "Cancel of Activity {0} threw {1}", activity.QualifiedName, e.ToString());
                                    throw;
                                }
                            }
                            break;
                        case ActivityOperationType.Compensate:
                            if (activity.ExecutionStatus == ActivityExecutionStatus.Compensating)
                            {
                                try
                                {
                                    ActivityExecutionStatus newStatus = activityExecutor.Compensate(activity, activityExecutionContext);
                                    if (newStatus == ActivityExecutionStatus.Closed)
                                        activityExecutionContext.CloseActivity();
                                    else if (newStatus != ActivityExecutionStatus.Compensating)
                                        throw new InvalidOperationException(SR.GetString(SR.InvalidExecutionStatus, activity.QualifiedName, newStatus.ToString(), ActivityExecutionStatus.Compensating.ToString()));
                                }
                                catch (Exception e)
                                {
                                    System.Workflow.Runtime.WorkflowTrace.Runtime.TraceEvent(TraceEventType.Error, 1, "Compensate of Activity {0} threw {1}", activity.QualifiedName, e.ToString());
                                    throw;
                                }
                            }
                            break;
                        case ActivityOperationType.HandleFault:
                            if (activity.ExecutionStatus == ActivityExecutionStatus.Faulting)
                            {
                                try
                                {
                                    ActivityExecutionStatus newStatus = activityExecutor.HandleFault(activity, activityExecutionContext, this.exceptionToDeliver);
                                    if (newStatus == ActivityExecutionStatus.Closed)
                                        activityExecutionContext.CloseActivity();
                                    else if (newStatus != ActivityExecutionStatus.Faulting)
                                        throw new InvalidOperationException(SR.GetString(SR.InvalidExecutionStatus, activity.QualifiedName, newStatus.ToString(), ActivityExecutionStatus.Faulting.ToString()));
                                }
                                catch (Exception e)
                                {
                                    System.Workflow.Runtime.WorkflowTrace.Runtime.TraceEvent(TraceEventType.Error, 1, "Compensate of Activity {0} threw {1}", activity.QualifiedName, e.ToString());
                                    throw;
                                }
                            }
                            break;
                    }
                }
            }
            return true;
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:93,代碼來源:ActivityExecutorOperation.cs

示例8: Run

        public override bool Run(IWorkflowCoreRuntime workflowCoreRuntime)
        {
            Activity activityByName = workflowCoreRuntime.GetContextActivityForId(base.ContextId).GetActivityByName(this.activityName);
            using (workflowCoreRuntime.SetCurrentActivity(activityByName))
            {
                using (ActivityExecutionContext context = new ActivityExecutionContext(activityByName))
                {
                    ActivityExecutor activityExecutor = ActivityExecutors.GetActivityExecutor(activityByName);
                    switch (this.operation)
                    {
                        case ActivityOperationType.Execute:
                            if (activityByName.ExecutionStatus != ActivityExecutionStatus.Executing)
                            {
                                goto Label_0309;
                            }
                            try
                            {
                                workflowCoreRuntime.RaiseActivityExecuting(activityByName);
                                ActivityExecutionStatus status = activityExecutor.Execute(activityByName, context);
                                if (status == ActivityExecutionStatus.Closed)
                                {
                                    context.CloseActivity();
                                }
                                else if (status != ActivityExecutionStatus.Executing)
                                {
                                    throw new InvalidOperationException(SR.GetString("InvalidExecutionStatus", new object[] { activityByName.QualifiedName, status.ToString(), ActivityExecutionStatus.Executing.ToString() }));
                                }
                                goto Label_0309;
                            }
                            catch (Exception exception)
                            {
                                WorkflowTrace.Runtime.TraceEvent(TraceEventType.Error, 1, "Execute of Activity {0} threw {1}", new object[] { activityByName.QualifiedName, exception.ToString() });
                                throw;
                            }
                            break;

                        case ActivityOperationType.Cancel:
                            break;

                        case ActivityOperationType.Compensate:
                            goto Label_01A4;

                        case ActivityOperationType.HandleFault:
                            goto Label_0248;

                        default:
                            goto Label_0309;
                    }
                    if (activityByName.ExecutionStatus != ActivityExecutionStatus.Canceling)
                    {
                        goto Label_0309;
                    }
                    try
                    {
                        ActivityExecutionStatus status2 = activityExecutor.Cancel(activityByName, context);
                        if (status2 == ActivityExecutionStatus.Closed)
                        {
                            context.CloseActivity();
                        }
                        else if (status2 != ActivityExecutionStatus.Canceling)
                        {
                            throw new InvalidOperationException(SR.GetString("InvalidExecutionStatus", new object[] { activityByName.QualifiedName, status2.ToString(), ActivityExecutionStatus.Canceling.ToString() }));
                        }
                        goto Label_0309;
                    }
                    catch (Exception exception2)
                    {
                        WorkflowTrace.Runtime.TraceEvent(TraceEventType.Error, 1, "Cancel of Activity {0} threw {1}", new object[] { activityByName.QualifiedName, exception2.ToString() });
                        throw;
                    }
                Label_01A4:
                    if (activityByName.ExecutionStatus != ActivityExecutionStatus.Compensating)
                    {
                        goto Label_0309;
                    }
                    try
                    {
                        ActivityExecutionStatus status3 = activityExecutor.Compensate(activityByName, context);
                        if (status3 == ActivityExecutionStatus.Closed)
                        {
                            context.CloseActivity();
                        }
                        else if (status3 != ActivityExecutionStatus.Compensating)
                        {
                            throw new InvalidOperationException(SR.GetString("InvalidExecutionStatus", new object[] { activityByName.QualifiedName, status3.ToString(), ActivityExecutionStatus.Compensating.ToString() }));
                        }
                        goto Label_0309;
                    }
                    catch (Exception exception3)
                    {
                        WorkflowTrace.Runtime.TraceEvent(TraceEventType.Error, 1, "Compensate of Activity {0} threw {1}", new object[] { activityByName.QualifiedName, exception3.ToString() });
                        throw;
                    }
                Label_0248:
                    if (activityByName.ExecutionStatus == ActivityExecutionStatus.Faulting)
                    {
                        try
                        {
                            ActivityExecutionStatus status4 = activityExecutor.HandleFault(activityByName, context, this.exceptionToDeliver);
                            if (status4 == ActivityExecutionStatus.Closed)
//.........這裏部分代碼省略.........
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:101,代碼來源:ActivityExecutorOperation.cs


注:本文中的ActivityExecutionContext.CloseActivity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。