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); } }
internal void Initialize(HandleInitializationContext context) { this.owner = context.OwningActivityInstance; this.isUninitialized = false; OnInitialize(context); }
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; }
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); }
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))); }
// 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(); }
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; }
// 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); } }
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); } } }
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); } }
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(); }
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(); } } }
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); }
/// <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(); }
/// <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; } }
/// <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); }
internal NativeActivityTransactionContext(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarks, RuntimeTransactionHandle handle) : base(instance, executor, bookmarks) { this.executor = executor; this.transactionHandle = handle; }
public void Initialize(CompletionCallbackWrapper callbackWrapper, System.Activities.ActivityInstance completedInstance) { base.Reinitialize(callbackWrapper.ActivityInstance); this.callbackWrapper = callbackWrapper; this.completedInstance = completedInstance; }
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); }
private void OnBodyCompleted(NativeActivityContext context, ActivityInstance instance) { RemoveProperties(context); }
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); }
sealed internal override void InternalCancel(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) { Fx.Assert("Cancel should never be called on CodeActivity since it's synchronous"); }
internal void DeclareHandle(LocationReference locationReference, Location location, System.Activities.ActivityInstance activityInstance) { this.hasHandles = true; this.Declare(locationReference, location, activityInstance); }
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); }
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; } }
public DelegateCompletionCallbackWrapper(DelegateCompletionCallback callback, System.Activities.ActivityInstance owningInstance) : base(callback, owningInstance) { base.NeedsToGatherOutputs = true; }
// optional "fast-path" for arguments that can be resolved synchronously internal abstract bool TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor);
public BookmarkCallbackWrapper(BookmarkCallback callback, System.Activities.ActivityInstance owningInstance) : this(callback, owningInstance, BookmarkOptions.None) { }
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 }
private void OnGetNextVectorsCompleted(NativeActivityContext context, ActivityInstance instance, NeuralVectors[] result) { ProcessNextVectors(context, result); }
protected CompletionWorkItem(CompletionCallbackWrapper callbackWrapper, System.Activities.ActivityInstance completedInstance) : base(callbackWrapper.ActivityInstance) { this.callbackWrapper = callbackWrapper; this.completedInstance = completedInstance; }
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; }
public CompletionWithCancelationCheckWorkItem(CompletionCallbackWrapper callbackWrapper, System.Activities.ActivityInstance completedInstance) : base(callbackWrapper, completedInstance) { }
public void CancelChild(ActivityInstance activityInstance) { throw new NotImplementedException(); }
public ActivityExecutionWorkItem(System.Activities.ActivityInstance activityInstance) : base(activityInstance) { }
internal abstract void Declare(LocationEnvironment targetEnvironment, ActivityInstance activityInstance);
internal AsyncCodeActivityContext(AsyncOperationContext asyncContext, ActivityInstance instance, ActivityExecutor executor) : base(instance, executor) { this.asyncContext = asyncContext; }
public BookmarkCallbackWrapper(BookmarkCallback callback, System.Activities.ActivityInstance owningInstance, BookmarkOptions bookmarkOptions) : base(callback, owningInstance) { this.Options = bookmarkOptions; }
protected override void OnInitialize(HandleInitializationContext context) { this.owningInstance = context.OwningActivityInstance; this.executor = context.Executor; PerformDefaultRegistration(); }
/// <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); }
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; }
public void AbortChildInstance(ActivityInstance activity) { throw new NotImplementedException(); }
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); }
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); }
public CompleteAsyncCodeActivityWorkItem(AsyncOperationContext asyncContext, ActivityInstance instance, IAsyncResult result) : base(instance) { this.result = result; this.asyncContext = asyncContext; this.ExitNoPersistRequired = true; }
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); }
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); } } }
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); }
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); }
protected internal abstract void Invoke(NativeActivityContext context, System.Activities.ActivityInstance completedInstance);
private void OnBodyFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom) { RemoveProperties(faultContext); }
protected virtual void GatherOutputs(System.Activities.ActivityInstance completedInstance) { }
private void OnExecuteConditionCompleted(NativeActivityContext context, ActivityInstance instance, bool result) { if (result) ExecuteBody(context); }
protected CompletionCallbackWrapper(Delegate callback, System.Activities.ActivityInstance owningInstance) : base(callback, owningInstance) { }
// optional "fast-path" for initial value expressions that can be resolved synchronously internal abstract void PopulateDefault(ActivityExecutor executor, ActivityInstance parentInstance, Location location);