コード例 #1
0
        void InternalExecute(NativeActivityContext context, ActivityInstance completedInstance)
        {
            CompensationExtension compensationExtension = context.GetExtension<CompensationExtension>();
            if (compensationExtension == null)
            {
                throw SA.FxTrace.Exception.AsError(new InvalidOperationException(SA.SR.CompensateWithoutCompensableActivity(this.DisplayName)));
            }

            CompensationToken token = Target.Get(context);
            CompensationTokenData tokenData = token == null ? null : compensationExtension.Get(token.CompensationId);

            Fx.Assert(tokenData != null, "CompensationTokenData must be valid");

            if (tokenData.ExecutionTracker.Count > 0)
            {
                if (this.onChildCompensated == null)
                {
                    this.onChildCompensated = new CompletionCallback(InternalExecute);
                }

                this.toCompensateToken.Set(context, new CompensationToken(tokenData.ExecutionTracker.Get()));

                Fx.Assert(Body != null, "Body must be valid");
                context.ScheduleActivity(Body, this.onChildCompensated);
            }     
        }
コード例 #2
0
        internal void Initialize(HandleInitializationContext context)
        {
            this.owner = context.OwningActivityInstance;
            this.isUninitialized = false;

            OnInitialize(context);
        }
コード例 #3
0
 internal WorkflowDataContext(ActivityExecutor executor, ActivityInstance activityInstance, bool includeLocalVariables)
 {
     this.executor = executor;
     this.activityInstance = activityInstance;
     this.IncludesLocalVariables = includeLocalVariables;
     this.properties = CreateProperties();
 }
 public FaultWorkItem(FaultCallbackWrapper callbackWrapper, Exception propagatedException, System.Activities.ActivityInstance propagatedFrom, ActivityInstanceReference originalExceptionSource) : base(callbackWrapper.ActivityInstance)
 {
     this.callbackWrapper = callbackWrapper;
     this.propagatedException = propagatedException;
     this.propagatedFrom = propagatedFrom;
     this.originalExceptionSource = originalExceptionSource;
 }
コード例 #5
0
ファイル: TrainingLoop.cs プロジェクト: nagyistoce/Neuroflow
        private void OnExecuteBodyCompleted(NativeActivityContext context, ActivityInstance instance)
        {
            var vars = ComputationContext.GetVariables(context, this);
            vars.Set(IterationNoVarName, vars.Get<int>(IterationNoVarName) + 1);

            context.ScheduleActivity(Condition, OnExecuteConditionCompleted);
        }
コード例 #6
0
ファイル: DialQueue.cs プロジェクト: wasabii/twilio-net
        void OnPickupCompleted(NativeActivityContext context, ActivityInstance completedInstance)
        {
            if (completedInstance.State != ActivityInstanceState.Executing)
                return;

            if (!GetElement(context).HasElements)
                GetElement(context).Add(new XElement("Pause",
                    new XAttribute("length", 0)));
        }
コード例 #7
0
 // TODO: we propagate an unhandled exception during an operation back to the task, should we handle it differently?
 private void BodyFaultCallback(NativeActivityFaultContext context, Exception propagatedException, ActivityInstance propagatedFrom)
 {
     if (!context.GetReceiveRequestSendResponseScopeExecutionProperty().TrySetTaskCompletionSourceException(propagatedException))
         // this will add a WorkflowInstanceAbortedRecord with the reason
         context.Abort(propagatedException);
     else
         // this won't add any WorkflowInstanceAbortedRecord at all
         context.Abort();
     context.HandleFault();
 }
コード例 #8
0
        internal NativeActivityFaultContext(ActivityInstance executingActivityInstance,
            ActivityExecutor executor, BookmarkManager bookmarkManager, Exception exception, ActivityInstanceReference source)
            : base(executingActivityInstance, executor, bookmarkManager)
        {
            Fx.Assert(exception != null, "There must be an exception.");
            Fx.Assert(source != null, "There must be a source.");

            this.exception = exception;
            this.source = source;
        }
コード例 #9
0
 // Called when the workflow is resumed after the activity is invoked, and the
 // workflow is resumed.
 public void OnWorkflowResumed(NativeActivityContext context, ActivityInstance instance)
 {
     // Check if the log file is still there. If it is, re-run this activity.
     // Otherwise, we're done.
     string logPath = LogPath.Get(context);
     if (System.IO.File.Exists(logPath))
     {
         Execute(context);
     }
 }
コード例 #10
0
ファイル: MyWhile.cs プロジェクト: tian1ll1/WPF_Examples
 void OnEvaluateConditionCompleted(NativeActivityContext context, ActivityInstance instance, bool result)
 {
     if (result)
     {
         if (this.Body != null)
         {
             //if the Condition evaluates to true and the Body is not null
             //schedule the Body with the InternalExecute as the CompletionCallback
             context.ScheduleActivity(this.Body, InternalExecute);
         }
     }
 }
コード例 #11
0
 sealed internal override void InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
 {
     CodeActivityContext context = executor.CodeActivityContextPool.Acquire();
     try
     {
         context.Initialize(instance, executor);
         Execute(context);
     }
     finally
     {
         context.Dispose();
         executor.CodeActivityContextPool.Release(context);
     }
 }
コード例 #12
0
ファイル: StreamBatcher.cs プロジェクト: nagyistoce/Neuroflow
        private void OnGetNextVectorsCompleted(NativeActivityContext context, ActivityInstance instance, NeuralVectors vectors)
        {
            var list = vectorList.Get(context);

            if (vectors != null) list.Add(vectors);

            if (vectors == null || list.Count == GetBatchSize(context))
            {
                GetNextVectorsDone(context, list.ToArray(), TrainingResetSchedule.None);
            }
            else if (vectors.IsEndOfStream)
            {
                GetNextVectorsDone(context, list.ToArray(), TrainingResetSchedule.AfterExecution);
            }
            else
            {
                ScheduleGetNextVectors(context);
            }

            list.Clear();
        }
コード例 #13
0
        sealed internal override void InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
        {
            // first set up an async context
            AsyncOperationContext asyncContext = executor.SetupAsyncOperationBlock(instance);
            instance.IncrementBusyCount();

            AsyncCodeActivityContext context = new AsyncCodeActivityContext(asyncContext, instance, executor);
            bool success = false;
            try
            {
                IAsyncResult result = BeginExecute(context, AsyncCodeActivity.OnExecuteComplete, asyncContext);

                if (result == null)
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.BeginExecuteMustNotReturnANullAsyncResult));
                }

                if (!object.ReferenceEquals(result.AsyncState, asyncContext))
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.BeginExecuteMustUseProvidedStateAsAsyncResultState));
                }

                if (result.CompletedSynchronously)
                {
                    EndExecute(context, result);
                    asyncContext.CompleteOperation();
                }
                success = true;
            }
            finally
            {
                context.Dispose();
                if (!success)
                {
                    asyncContext.CancelOperation();
                }
            }
        }
コード例 #14
0
ファイル: ParallelActivity.cs プロジェクト: blacklensama/1709
        void InternalExecute(NativeActivityContext context, ActivityInstance instance)
        {
            //grab the index of the current Activity
            int currentActivityIndex = this.currentIndex.Get(context);
            if (currentActivityIndex == Activities.Count)
            {
                //if the currentActivityIndex is equal to the count of MySequence's Activities
                //MySequence is complete
                return;
            }

            if (this.onChildComplete == null)
            {
                //on completion of the current child, have the runtime call back on this method
                this.onChildComplete = new CompletionCallback(InternalExecute);
            }

            //grab the next Activity in MySequence.Activities and schedule it
            Activity nextChild = Activities[currentActivityIndex];
            context.ScheduleActivity(nextChild, this.onChildComplete);

            //increment the currentIndex
            this.currentIndex.Set(context, ++currentActivityIndex);
        }
コード例 #15
0
 /// <summary>
 /// The on receive completed.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="completedInstance">
 /// The completed instance.
 /// </param>
 private void OnReceiveCompleted(
     NativeActivityContext context, ActivityInstance completedInstance)
 {
     // Cancel the remaining children
     context.CancelChildren();
 }
コード例 #16
0
        /// <summary>
        /// Respond to the completion callback of the status polling activity.
        /// </summary>
        /// <param name="context">The activity context.</param>
        /// <param name="instance">The current instance of the activity.</param>
        /// <param name="result">The result of the status inquiry.</param>
        private void OnGetStatusCompleted(NativeActivityContext context, ActivityInstance instance, string result)
        {
            // Check to see if the operation faulted
            if (this.AzureActivityExceptionCaught.Get(context))
            {
                context.ScheduleActivity(this.Failure);
                return;
            }

            // Determine what to do based on the status of the Azure operation.
            switch (result)
            {
                case OperationState.Succeeded:
                    context.ScheduleActivity(this.Success);
                    break;

                case OperationState.Failed:
                    context.ScheduleActivity(this.Failure);
                    break;

                case OperationState.InProgress:
                    // Test to see if we are within the timeout
                    if (context.GetValue(this.PollingEndTime).CompareTo(DateTime.UtcNow) <= 0)
                    {
                        context.ScheduleActivity(this.Failure);
                    }

                    // Otherwise delay for the requested interval
                    context.ScheduleAction(
                        this.DelayBody, 
                        this.PollingInterval,
                        this.OnDelayCompleted);
                    break;
            }            
        }
コード例 #17
0
        /// <summary>
        /// Respond to the fault callback, used for all scheduled activities.
        /// </summary>
        /// <param name="context">The activity context.</param>
        /// <param name="exception">An exception which was thrown by the activity.</param>
        /// <param name="instance">The current instance of the activity.</param>
        private void OnOperationFault(NativeActivityFaultContext context, Exception exception, ActivityInstance instance)
        {
            // Mark the fault handled, or else this activity will throw and will not contine after this method returns.
            context.HandleFault();

            // TODO: Make this logging dependent on the operation configuration
            LogBuildError(context, string.Format("AzureAsyncOperation Fault {0} during execution of {1}\r\n{2}", exception.GetType().Name, instance.Activity.GetType().Name, exception.Message));
            LogBuildMessage(context, exception.StackTrace, BuildMessageImportance.High);

            // Cancel the running activity
            context.CancelChild(instance);

            // Notify that an exception has been caught
            // The CompletionCallback will be called because we handled the exception.
            // This makes a better design choice to do any scheduling or further logic there.
            this.AzureActivityExceptionCaught.Set(context, true);
        }
コード例 #18
0
 internal NativeActivityTransactionContext(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarks, RuntimeTransactionHandle handle)
     : base(instance, executor, bookmarks)
 {
     this.executor = executor;
     this.transactionHandle = handle;
 }
コード例 #19
0
 public void Initialize(CompletionCallbackWrapper callbackWrapper, System.Activities.ActivityInstance completedInstance)
 {
     base.Reinitialize(callbackWrapper.ActivityInstance);
     this.callbackWrapper   = callbackWrapper;
     this.completedInstance = completedInstance;
 }
コード例 #20
0
        private void OnGetItemCountCompleted(NativeActivityContext context, ActivityInstance instance, int result)
        {
            // Item Count determinded, set to ItemCount global variable:
            var vars = ComputationContext.GetVariables(context, this);
            vars.Set(ItemCountVarName, result);

            // Continue from Begin:
            Begin(context);
        }
コード例 #21
0
 private void OnBodyCompleted(NativeActivityContext context, ActivityInstance instance)
 {
     RemoveProperties(context);
 }
コード例 #22
0
        private void ClientScheduleOnReceiveMessageCallback(NativeActivityContext executionContext, System.Activities.ActivityInstance completedInstance)
        {
            ReceiveMessageInstanceData instance = this.receiveMessageInstance.Get(executionContext).Instance;

            if (instance.CorrelationRequestContext.TryGetReply())
            {
                this.ClientScheduleOnReceiveMessageCore(executionContext, instance);
            }
            this.FinalizeScheduleOnReceivedMessage(executionContext, instance);
        }
コード例 #23
0
 sealed internal override void InternalCancel(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
 {
     Fx.Assert("Cancel should never be called on CodeActivity since it's synchronous");
 }
コード例 #24
0
 internal void DeclareHandle(LocationReference locationReference, Location location, System.Activities.ActivityInstance activityInstance)
 {
     this.hasHandles = true;
     this.Declare(locationReference, location, activityInstance);
 }
コード例 #25
0
        internal void DeclareTemporaryLocation <T>(LocationReference locationReference, System.Activities.ActivityInstance activityInstance, bool bufferGetsOnCollapse) where T : Location
        {
            Location location = new Location <T>();

            location.SetTemporaryResolutionData(this, bufferGetsOnCollapse);
            this.Declare(locationReference, location, activityInstance);
        }
コード例 #26
0
 internal void Declare(LocationReference locationReference, Location location, System.Activities.ActivityInstance activityInstance)
 {
     if (location.CanBeMapped)
     {
         this.hasMappableLocations = true;
         this.MappableObjectManager.Register(location, this.Definition, locationReference, activityInstance);
     }
     if (this.locations == null)
     {
         this.singleLocation = location;
     }
     else
     {
         this.locations[locationReference.Id] = location;
     }
 }
コード例 #27
0
 public DelegateCompletionCallbackWrapper(DelegateCompletionCallback callback, System.Activities.ActivityInstance owningInstance) : base(callback, owningInstance)
 {
     base.NeedsToGatherOutputs = true;
 }
コード例 #28
0
 // optional "fast-path" for arguments that can be resolved synchronously
 internal abstract bool TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor);
コード例 #29
0
 public BookmarkCallbackWrapper(BookmarkCallback callback, System.Activities.ActivityInstance owningInstance) : this(callback, owningInstance, BookmarkOptions.None)
 {
 }
コード例 #30
0
 sealed internal override void InternalAbort(ActivityInstance instance, ActivityExecutor executor, Exception terminationReason)
 {
     // no-op, this is only called if an exception is thrown out of execute
 }
コード例 #31
0
 private void OnGetNextVectorsCompleted(NativeActivityContext context, ActivityInstance instance, NeuralVectors[] result)
 {
     ProcessNextVectors(context, result);
 }
コード例 #32
0
 protected CompletionWorkItem(CompletionCallbackWrapper callbackWrapper, System.Activities.ActivityInstance completedInstance) : base(callbackWrapper.ActivityInstance)
 {
     this.callbackWrapper   = callbackWrapper;
     this.completedInstance = completedInstance;
 }
コード例 #33
0
 internal FaultPropagationRecord(Guid instanceId, System.Activities.ActivityInstance source, System.Activities.ActivityInstance faultHandler, bool isFaultSource, Exception fault) : base(instanceId)
 {
     this.FaultSource = new ActivityInfo(source);
     if (faultHandler != null)
     {
         this.FaultHandler = new ActivityInfo(faultHandler);
     }
     this.IsFaultSource = isFaultSource;
     this.Fault         = fault;
     base.Level         = TraceLevel.Warning;
 }
コード例 #34
0
 public CompletionWithCancelationCheckWorkItem(CompletionCallbackWrapper callbackWrapper, System.Activities.ActivityInstance completedInstance) : base(callbackWrapper, completedInstance)
 {
 }
コード例 #35
0
 public void CancelChild(ActivityInstance activityInstance)
 {
     throw new NotImplementedException();
 }
コード例 #36
0
 public ActivityExecutionWorkItem(System.Activities.ActivityInstance activityInstance) : base(activityInstance)
 {
 }
コード例 #37
0
 internal abstract void Declare(LocationEnvironment targetEnvironment, ActivityInstance activityInstance);
コード例 #38
0
 internal AsyncCodeActivityContext(AsyncOperationContext asyncContext, ActivityInstance instance, ActivityExecutor executor)
     : base(instance, executor)
 {
     this.asyncContext = asyncContext;
 }
コード例 #39
0
 public BookmarkCallbackWrapper(BookmarkCallback callback, System.Activities.ActivityInstance owningInstance, BookmarkOptions bookmarkOptions) : base(callback, owningInstance)
 {
     this.Options = bookmarkOptions;
 }
コード例 #40
0
ファイル: ExclusiveHandle.cs プロジェクト: wforney/corewf
 protected override void OnInitialize(HandleInitializationContext context)
 {
     this.owningInstance = context.OwningActivityInstance;
     this.executor       = context.Executor;
     PerformDefaultRegistration();
 }
コード例 #41
0
 /// <summary>
 /// Respond to the completion callback for the Delay activity.
 /// </summary>
 /// <param name="context">The activity context.</param>
 /// <param name="instance">The current instance of the activity.</param>
 private void OnDelayCompleted(NativeActivityContext context, ActivityInstance instance)
 {
     // Poll again
     context.ScheduleFunc(
         this.PollingBody,
         this.OperationId.Get(context),
         this.SubscriptionId.Get(context),
         this.CertificateThumbprintId.Get(context),
         this.OnGetStatusCompleted,
         this.OnOperationFault);
 }
コード例 #42
0
 internal abstract Location DeclareLocation(ActivityExecutor executor, ActivityInstance instance);
 public EmptyWithCancelationCheckWorkItem(System.Activities.ActivityInstance activityInstance, System.Activities.ActivityInstance completedInstance) : base(activityInstance)
 {
     this.completedInstance = completedInstance;
     base.IsEmpty = true;
 }
コード例 #44
0
 public void AbortChildInstance(ActivityInstance activity)
 {
     throw new NotImplementedException();
 }
コード例 #45
0
 protected override void OnInitialize(HandleInitializationContext context)
 {
     this.owningInstance = context.OwningActivityInstance;
     this.executor = context.Executor;
     PerformDefaultRegistration();
 }
コード例 #46
0
 internal CancelRequestedRecord(Guid instanceId, System.Activities.ActivityInstance instance, System.Activities.ActivityInstance child) : base(instanceId)
 {
     if (instance != null)
     {
         this.Activity = new ActivityInfo(instance);
     }
     this.Child = new ActivityInfo(child);
 }
コード例 #47
0
        private void OnGetBatchingStrategyFactoryCompleted(NativeActivityContext context, ActivityInstance instance, IFactory<BatchingStrategy> factory)
        {
            if (factory == null) throw new InvalidOperationException("Unordered Batcher '" + DisplayName + "' GetBatchingStrategyFactory method has returned a null value.");

            var strategy = factory.Create();
            var vars = ComputationContext.GetVariables(context, this);
            vars.Set(StrategyVarName, strategy);

            strategy.Initialize(vars.Get<int>(ItemCountVarName), GetBatchSize(context));
            strategyHasJustInited.Set(context, true);

            ScheduleGetNextVectors(context);
        } 
コード例 #48
0
ファイル: AsyncCodeActivity.cs プロジェクト: zheng1748/corewf
 public CompleteAsyncCodeActivityWorkItem(AsyncOperationContext asyncContext, ActivityInstance instance, IAsyncResult result)
     : base(instance)
 {
     this.result                = result;
     this.asyncContext          = asyncContext;
     this.ExitNoPersistRequired = true;
 }
コード例 #49
0
        private void OnReinitializeVectorProviderCompleted(NativeActivityContext context, ActivityInstance instance)
        {
            // Delete ItemCount globale variable.
            // This will be determined on next vector call schedule.
            var vars = ComputationContext.GetVariables(context, this);
            vars.Delete(ItemCountVarName);

            // Delete Batching Strategy (this will create new on next iteration)
            vars.Delete(StrategyVarName);

            // And delete cached stuff also:
            DeleteCache(context);
        }
コード例 #50
0
 public EmptyWithCancelationCheckWorkItem(System.Activities.ActivityInstance activityInstance, System.Activities.ActivityInstance completedInstance) : base(activityInstance)
 {
     this.completedInstance = completedInstance;
     base.IsEmpty           = true;
 }
コード例 #51
0
        private void OnStepCompleted(NativeActivityContext context, ActivityInstance completedInstance)
        {
            int completedInstanceIndex = this.LastIndex.Get(context);
            Step completedstep = completedInstance.Activity as Step;

            if (completedstep.Skipped)
            {
                int current = completedInstanceIndex + 1;
                Queue<int> currentposition = (Queue<int>)context.Properties.Find(Constants._CurrentPosition);
                if (currentposition.Count > 0) currentposition.Dequeue();
                currentposition.Enqueue(current);
                context.Properties.Update(Constants._CurrentPosition, currentposition);
                ScheduleStep(context, current);
            }
            else
            {
                if (!completedstep.ContainsChildWizard)
                {

                    Stack<CustomBookmark> bmlist = context.Properties.Find(Constants._BookmarkHistory) as Stack<CustomBookmark>;
                    Queue<int> currentPosition = context.Properties.Find(Constants._CurrentPosition) as Queue<int>;
                    CustomBookmark currentbookmark = new CustomBookmark();
                    currentbookmark.StepID = currentPosition.ToPlainString();
                    currentbookmark.StepName = completedInstance.Activity.DisplayName;
                    currentbookmark.HasBack = (bool)context.Properties.Find(Constants._HasBack);
                    currentbookmark.HasNext = (bool)context.Properties.Find(Constants._HasNext);
                    bmlist.Push(currentbookmark);
                    context.Properties.Update(Constants._BookmarkHistory, bmlist);

                }
            }
        }
コード例 #52
0
 private bool AttachPropertyManager(System.Activities.ActivityInstance instance, System.Activities.ActivityInstance previousOwner)
 {
     if ((instance.PropertyManager != null) && (instance.PropertyManager.owningInstance != previousOwner))
     {
         return(false);
     }
     instance.PropertyManager = this;
     return(true);
 }
コード例 #53
0
        private void SelfRestart(NativeActivityContext context, ActivityInstance target)
        {
            RestartActivityContext restartContext = restartActivityContext.Get(context);
            if (!restartContext.NeedsRestart)
            {
                _structuredTracer.DebugMessage("Executing activity '" + this.DisplayName + "', local machine (" + Environment.MachineName + ") has been restarted.");
                return;
            }

            _structuredTracer.DebugMessage("Executing activity '" + this.DisplayName + "', local machine (" + Environment.MachineName + ") is self-restarting");
            base.Execute(context);
        }
コード例 #54
0
 protected internal abstract void Invoke(NativeActivityContext context, System.Activities.ActivityInstance completedInstance);
コード例 #55
0
 private void OnBodyFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
 {
     RemoveProperties(faultContext);
 }
コード例 #56
0
 protected virtual void GatherOutputs(System.Activities.ActivityInstance completedInstance)
 {
 }
コード例 #57
0
ファイル: TrainingLoop.cs プロジェクト: nagyistoce/Neuroflow
 private void OnExecuteConditionCompleted(NativeActivityContext context, ActivityInstance instance, bool result)
 {
     if (result) ExecuteBody(context);
 }
コード例 #58
0
 protected CompletionCallbackWrapper(Delegate callback, System.Activities.ActivityInstance owningInstance) : base(callback, owningInstance)
 {
 }
コード例 #59
0
 // optional "fast-path" for initial value expressions that can be resolved synchronously
 internal abstract void PopulateDefault(ActivityExecutor executor, ActivityInstance parentInstance, Location location);
 internal NativeActivityTransactionContext(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarks, RuntimeTransactionHandle handle)
     : base(instance, executor, bookmarks)
 {
     this.executor          = executor;
     this.transactionHandle = handle;
 }