private void ActivityCompleted(NativeActivityContext context, ActivityInstance instance, bool result) { var dataObject = context.GetExtension <IDSFDataObject>(); if (dataObject != null && operationalData != null) { if (operationalData.IndexIterator.HasMore()) { var idx = operationalData.IndexIterator.FetchNextIndex(); // Re-jigger the mapping ;) if (operationalData.ForEachType != enForEachType.NumOfExecution) { IterateIOMapping(idx); } dataObject.ParentInstanceID = UniqueID; // ReSharper disable RedundantTypeArgumentsOfMethod context.ScheduleFunc(DataFunc, UniqueID, ActivityCompleted); // ReSharper restore RedundantTypeArgumentsOfMethod return; } // that is all she wrote ;) dataObject.IsDataListScoped = false; // return it all to normal if (ForEachType != enForEachType.NumOfExecution) { RestoreHandlerFn(); } dataObject.ParentInstanceID = _previousParentId; dataObject.ForEachNestingLevel--; dataObject.IsDebugNested = false; } }
protected override void Execute(NativeActivityContext context) { if ((this.Func != null) && (this.Func.Handler != null)) { context.ScheduleFunc <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>(this.Func, this.Argument1.Get(context), this.Argument2.Get(context), this.Argument3.Get(context), this.Argument4.Get(context), this.Argument5.Get(context), this.Argument6.Get(context), this.Argument7.Get(context), this.Argument8.Get(context), this.Argument9.Get(context), this.Argument10.Get(context), this.Argument11.Get(context), new CompletionCallback <TResult>(this.OnActivityFuncComplete), null); } }
protected override void Execute(NativeActivityContext context) { if ((this.Func != null) && (this.Func.Handler != null)) { context.ScheduleFunc <T, TResult>(this.Func, this.Argument.Get(context), new CompletionCallback <TResult>(this.OnActivityFuncComplete), null); } }
private void OnStateComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance, string result) { if (StateMachineIdHelper.IsAncestor("0", result)) { int childStateIndex = StateMachineIdHelper.GetChildStateIndex("0", result); context.ScheduleFunc <StateMachineEventManager, string>(this.internalStateFuncs[childStateIndex], this.eventManager.Get(context), this.onStateComplete, null); } }
void OnStateComplete(NativeActivityContext context, ActivityInstance completedInstance, string result) { if (StateMachineHelper.IsAncestor(rootId, result)) { int index = StateMachineHelper.GetChildStateIndex(rootId, result); context.ScheduleFunc <string, StateMachineEventManager, string>(this.internalStateFuncs[index], result, this.eventManager.Get(context), onStateComplete); } }
protected override void Execute(NativeActivityContext context) { StateMachineEventManager argument = this.eventManager.Get(context); argument.OnTransition = true; int childStateIndex = StateMachineIdHelper.GetChildStateIndex("0", this.InitialState.StateId); context.ScheduleFunc <StateMachineEventManager, string>(this.internalStateFuncs[childStateIndex], argument, this.onStateComplete, null); }
protected override void Execute(NativeActivityContext context) { if (this.Func == null || this.Func.Handler == null) { return; } context.ScheduleFunc <TResult>(this.Func, new CompletionCallback <TResult>(this.OnActivityFuncComplete)); }
void ScheduleChildState(NativeActivityContext context, string id) { int index = StateMachineHelper.GetChildStateIndex(this.StateId, id); Debug.Assert(index >= 0 && index < this.internalStateFuncs.Count); context.ScheduleFunc <string, StateMachineEventManager, string>(this.internalStateFuncs[index], id, this.EventManager.Get(context), this.onChildStateComplete); this.hasRunningChildState.Set(context, true); }
/// <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 <string, string, string, string>( this.PollingBody, this.OperationId.Get(context), this.SubscriptionId.Get(context), this.CertificateThumbprintId.Get(context), new CompletionCallback <string>(OnGetStatusCompleted), new FaultCallback(OnOperationFault)); }
private void OnStateComplete(NativeActivityContext context, ActivityInstance completedInstance, string result) { if (StateMachineIdHelper.IsAncestor(RootId, result)) { int index = StateMachineIdHelper.GetChildStateIndex(RootId, result); context.ScheduleFunc <StateMachineEventManager, string>( _internalStateFuncs[index], _eventManager.Get(context), _onStateComplete); } }
/// <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); }
protected override void Execute(NativeActivityContext context) { //We view the duration before moving to initial state is on transition. StateMachineEventManager localEventManager = this.eventManager.Get(context); localEventManager.OnTransition = true; int index = StateMachineHelper.GetChildStateIndex(rootId, this.InitialState.StateId); context.ScheduleFunc <string, StateMachineEventManager, string>(this.internalStateFuncs[index], this.InitialState.StateId, localEventManager, onStateComplete); }
/// <summary> /// Receive Completed callback /// </summary> /// <remarks> /// Run soon after a message is received. /// </remarks> /// <param name="context">Context</param> /// <param name="completedInstance">ActivityInstance</param> private void ReceiveCompleted(NativeActivityContext context, ActivityInstance completedInstance) { if (OnCompleting != null) { context.ScheduleFunc(OnCompleting, _request.Get(context), ChildCompletionCallback); } else { context.ScheduleActivity(_sendReply); } }
protected override void Execute(NativeActivityContext context) { SendRequestReceiveResponseScopeExecutionPropertyWithoutResult executionProperty = context.GetSendRequestReceiveResponseScopeExecutionPropertyWithoutResult(); executionProperty.AssertIsStarted(); // Schedules an awaiter for the outgoing request, ie. the appropriate TWorkflowCallbackInterface operation. context.ScheduleFunc(responseResultWaiter, executionProperty.OnOperationTask, WaiterCompletionCallback); executionProperty.OnOperationTaskWaiterIsScheduled(); }
protected override void Execute(NativeActivityContext context) { if (CreateBodyText != null) { context.ScheduleFunc <string>( CreateBodyText, BodyCreated); } else { SendMailInternal(context, null); } }
// internal mapping function (schedules the ActivityFunc if it founds data in the datareader) void InternalMapRecord(NativeActivityContext context) { // map a record if (reader.Read()) { context.ScheduleFunc <DbDataReader, TResult>(this.MapperFunc, this.reader, this.OnRowMappingCompleted); } else { reader.Close(); dbHelper.Dispose(); } }
/// <summary> /// Execution of StateMachine /// </summary> /// <param name="context">NativeActivityContext reference</param> //[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", //Justification = "The context is used by workflow runtime. The parameter should be fine.")] protected override void Execute(NativeActivityContext context) { // We view the duration before moving to initial state is on transition. StateMachineEventManager localEventManager = _eventManager.Get(context); localEventManager.OnTransition = true; localEventManager.CurrentBeingProcessedEvent = null; int index = StateMachineIdHelper.GetChildStateIndex(RootId, this.InitialState.StateId); context.ScheduleFunc <StateMachineEventManager, string>( _internalStateFuncs[index], localEventManager, _onStateComplete); }
/// <summary> /// The receive callback. /// </summary> /// <param name="context"> /// The context. /// </param> /// <param name="bookmark"> /// The bookmark. /// </param> /// <param name="value"> /// The value. /// </param> private void ReceiveCallback(NativeActivityContext context, Bookmark bookmark, object value) { context.RemoveAllBookmarks(); this.receiveContext = (IHttpWorkflowReceiveContext)value; this.hostContext = context.GetExtension <IHttpWorkflowHostContext>(); // bind the parameters using the UriTemplate var match = this.hostContext.MatchSingle(this.receiveContext.Request); this.noPersistHandle.Get(context).Enter(context); // TODO: Consider fault handling - do we need to do anything special? context.ScheduleFunc( this.Body, this.receiveContext.Request, match.BoundVariables.AllKeys.ToDictionary(s => s, key => match.BoundVariables[key]), this.OnBodyCompleted); }
/// <summary> /// Executes after task approved/rejected /// </summary> /// <param name="context">Context</param> /// <param name="completedInstance">ActivityInstance</param> private void OnCompleteCallback(NativeActivityContext context, ActivityInstance completedInstance) { Log.Debug("OnCompleteCallback -> Start"); var workflowStatus = context.Properties.Find(WorkflowStateData.Name) as WorkflowStateData; if (workflowStatus == null) { throw new Exception("Cannot find WorkflowStateData"); } if (OnComplete != null) { context.ScheduleFunc(OnComplete, workflowStatus.Tasks[TaskCode], OnClientCompleteCallBack); } AssignResultTo.Set(context, workflowStatus.Tasks[TaskCode].Result); Log.Debug("OnCompleteCallback -> End"); }
/// <summary> /// Respond to the completion callback for the Operation activity. /// </summary> /// <param name="context">The activity context.</param> /// <param name="instance">The current instance of the activity.</param> /// <param name="result">The result returned by the activity at completion.</param> private void OnOperationCompleted(NativeActivityContext context, ActivityInstance instance, string result) { // Check to see if the operation faulted if (this.AzureActivityExceptionCaught.Get(context) == true) { context.ScheduleActivity(this.Failure); return; } // Store the results of the activity for later context.SetValue(this.PollingEndTime, DateTime.UtcNow.AddSeconds(this.TimeoutSeconds)); context.SetValue(this.OperationId, result); // Start the process of polling for status - kind of like a do/while context.ScheduleFunc <string, string, string, string>( this.PollingBody, this.OperationId.Get(context), this.SubscriptionId.Get(context), this.CertificateThumbprintId.Get(context), new CompletionCallback <string>(OnGetStatusCompleted), new FaultCallback(OnOperationFault)); }
/// <summary> /// Activity entry point /// </summary> /// <param name="context">Activity context</param> protected override void Execute(NativeActivityContext context) { Log.Debug("ApproveTask -> Start"); var workflowStatus = context.Properties.Find(WorkflowStateData.Name) as WorkflowStateData; if (workflowStatus == null) { workflowStatus = context.GetExtension <WorkflowStateData>(); if (workflowStatus == null) { throw new Exception("Cannot find WorkflowStateData"); } context.Properties.Add(WorkflowStateData.Name, workflowStatus); } // persist task data PersistTaskData(workflowStatus, TaskCode); // Start the process if (OnInit != null) { context.ScheduleFunc(OnInit, workflowStatus.Tasks[TaskCode], OnInitCallback); } else { // Set the expiry here before starting the approve SetExpiry(context, ExpiresWhen, ExpiresIn); context.ScheduleActivity(_approveSequence, OnCompleteCallback); } Log.Debug("ApproveTask -> End"); }
protected override void Execute(NativeActivityContext context) { var task = new UserTaskEntry() { Id = Guid.NewGuid(), Caption = Caption.Get(context), QueueName = QueueName.Get(context), ViewName = ViewName.Get(context), ViewInputModel = JsonConvert.SerializeObject(ViewInputModel.Get(context) ?? new object() , Formatting.None , new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), DateFormatString = "dd.MM.yyyy" }), WWFId = context.WorkflowInstanceId }; var db = context.GetExtension <Db>(); db.UserTasks.Add(task); UserTaskId.Set(context, task.Id); context.ScheduleFunc(Wizard, task.Id, OnChildComplete); }
/// <summary> /// Invoked when the action is completed. /// </summary> /// <param name="context"></param> /// <param name="completedInstance"></param> void OnActionCompleted(NativeActivityContext context, ActivityInstance completedInstance) { context.ScheduleFunc(Increment, current.Get(context), OnIncrementCompleted); }
void OnStateComplete(NativeActivityContext context, ActivityInstance completedInstance, string result) { if (StateMachineHelper.IsAncestor(rootId, result)) { int index = StateMachineHelper.GetChildStateIndex(rootId, result); context.ScheduleFunc<string, StateMachineEventManager, string>(this.internalStateFuncs[index], result, this.eventManager.Get(context), onStateComplete); } }
/// <summary> /// Implements the activity. /// </summary> /// <param name="context"></param> protected override void Execute(NativeActivityContext context) { // set index to starting position current.Set(context, Initial.Get(context)); context.ScheduleFunc(Condition, current.Get(context), OnConditionCompleted); }
protected override void OnExecute(NativeActivityContext context) { lock (_forEachExecutionObject) { IDSFDataObject dataObject = context.GetExtension <IDSFDataObject>(); _debugInputs = new List <DebugItem>(); _debugOutputs = new List <DebugItem>(); dataObject.ForEachNestingLevel++; ErrorResultTO allErrors = new ErrorResultTO(); InitializeDebug(dataObject); try { ErrorResultTO errors; ForEachBootstrapTO exePayload = FetchExecutionType(dataObject, dataObject.Environment, out errors, 0); if (errors.HasErrors()) { allErrors.MergeErrors(errors); return; } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.Before, 0); } dataObject.ParentInstanceID = UniqueID; allErrors.MergeErrors(errors); string error; ForEachInnerActivityTO innerA = GetInnerActivity(out error); allErrors.AddError(error); exePayload.InnerActivity = innerA; operationalData = exePayload; // flag it as scoped so we can use a single DataList dataObject.IsDataListScoped = true; dataObject.IsDebugNested = true; if (exePayload.InnerActivity != null && exePayload.IndexIterator.HasMore()) { int idx = exePayload.IndexIterator.FetchNextIndex(); if (exePayload.ForEachType != enForEachType.NumOfExecution) { IterateIOMapping(idx); } else { dataObject.IsDataListScoped = false; } // schedule the func to execute ;) dataObject.ParentInstanceID = UniqueID; context.ScheduleFunc(DataFunc, string.Empty, ActivityCompleted); } } catch (Exception e) { Dev2Logger.Error("DSFForEach", e); allErrors.AddError(e.Message); } finally { // Handle Errors if (allErrors.HasErrors()) { DisplayAndWriteError("DsfForEachActivity", allErrors); foreach (var fetchError in allErrors.FetchErrors()) { dataObject.Environment.AddError(fetchError); } dataObject.ParentInstanceID = _previousParentId; } if (dataObject.IsDebugMode()) { DispatchDebugState(dataObject, StateType.After, 0); } } } }
protected override void Execute(NativeActivityContext context) { context.ScheduleFunc(Condition, OnConditionComplete); }
protected override void Execute(NativeActivityContext context) { //We view the duration before moving to initial state is on transition. StateMachineEventManager localEventManager = this.eventManager.Get(context); localEventManager.OnTransition = true; int index = StateMachineHelper.GetChildStateIndex(rootId, this.InitialState.StateId); context.ScheduleFunc<string, StateMachineEventManager, string>(this.internalStateFuncs[index], this.InitialState.StateId, localEventManager, onStateComplete); }
private void ScheduleGetNextVectors(NativeActivityContext context) { var vars = ComputationContext.GetVariables(context, this); var strategy = vars.Get<BatchingStrategy>(StrategyVarName); if (LastResult != null) { var obs = strategy as OptimizationBatchingStrategy; if (obs != null) { var last = LastResult.Get(context); if (!last.IsEmpty) { obs.SetLastResult(last); } } } var indexSet = new IndexSet(strategy.GetNextIndexes()); context.ScheduleFunc(GetNextVectors, indexSet, OnGetNextVectorsCompleted); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="completedInstance"></param> /// <param name="value"></param> void OnIncrementCompleted(NativeActivityContext context, ActivityInstance completedInstance, TValue value) { current.Set(context, value); context.ScheduleFunc(Condition, current.Get(context), OnConditionCompleted); }
/// <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); }
protected override void Execute(NativeActivityContext context) { context.ScheduleFunc(Algorithm, OnComplete); }
protected override void Execute(NativeActivityContext context) { StateMachineEventManager argument = this.eventManager.Get(context); argument.OnTransition = true; int childStateIndex = StateMachineIdHelper.GetChildStateIndex("0", this.InitialState.StateId); context.ScheduleFunc<StateMachineEventManager, string>(this.internalStateFuncs[childStateIndex], argument, this.onStateComplete, null); }
private void OnStateComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance, string result) { if (StateMachineIdHelper.IsAncestor("0", result)) { int childStateIndex = StateMachineIdHelper.GetChildStateIndex("0", result); context.ScheduleFunc<StateMachineEventManager, string>(this.internalStateFuncs[childStateIndex], this.eventManager.Get(context), this.onStateComplete, null); } }
private void ScheduleGetNextVectors(NativeActivityContext context) { context.ScheduleFunc(GetNextVectors, OnGetNextVectorsCompleted); }
private void ScheduleGetNextVectors(NativeActivityContext context) { var vars = ComputationContext.GetVariables(context, this); var strategy = vars.Get<BatchingStrategy>(StrategyVarName); if (LastResult != null && !strategyHasJustInited.Get(context)) { var obs = strategy as OptimizationBatchingStrategy; if (obs != null) { var last = LastResult.Get(context); if (!last.IsEmpty) { obs.SetLastResult(last); } } } var indexSet = new IndexSet(strategy.GetNextIndexes()); if (IsCached(context)) { // Get From Cache: var cache = vars.Get<SerializableCache>(CacheVarName).Cache; // Create variable: var vectorsFromCache = new LinkedList<NeuralVectors>(); cachedVectors.Set(context, vectorsFromCache); var newIndexSet = new IndexSet(indexSet); foreach (var index in indexSet) { string key = index.ToString(); var cached = cache[key] as NeuralVectors; if (cached != null) { // Cached, add to variable, and remove from indexes: vectorsFromCache.AddLast(cached); newIndexSet.Remove(index); } } indexSet = newIndexSet; } if (indexSet.Count > 0) { // Are there any non-cached item requests? Get it! context.ScheduleFunc(GetNextVectors, indexSet, OnGetNextVectorsCompleted); } else { // All items was in cache, proccess'em! ProcessNextVectors(context, null); } }
private void Begin(NativeActivityContext context) { var vars = ComputationContext.GetVariables(context, this); if (!vars.Exists(IterationsVarName)) { vars.Set(IterationsVarName, 0); } if (!vars.Exists(ItemCountVarName)) { // ItemCount is not yet determined. ScheduleGetItemCount(context); return; } EnsureCache(context); if (!vars.Exists(StrategyVarName)) { context.ScheduleFunc(GetBatchingStrategyFactory, OnGetBatchingStrategyFactoryCompleted); } else { strategyHasJustInited.Set(context, false); ScheduleGetNextVectors(context); } }
/// <summary> /// Respond to the completion callback for the Operation activity. /// </summary> /// <param name="context">The activity context.</param> /// <param name="instance">The current instance of the activity.</param> /// <param name="result">The result returned by the activity at completion.</param> private void OnOperationCompleted(NativeActivityContext context, ActivityInstance instance, string result) { // Check to see if the operation faulted if (this.AzureActivityExceptionCaught.Get(context)) { context.ScheduleActivity(this.Failure); return; } // Store the results of the activity for later context.SetValue(this.PollingEndTime, DateTime.UtcNow.AddSeconds(this.TimeoutSeconds)); context.SetValue(this.OperationId, result); // Start the process of polling for status - kind of like a do/while context.ScheduleFunc( this.PollingBody, this.OperationId.Get(context), this.SubscriptionId.Get(context), this.CertificateThumbprintId.Get(context), this.OnGetStatusCompleted, this.OnOperationFault); }
/// <summary> /// The receive callback. /// </summary> /// <param name="context"> /// The context. /// </param> /// <param name="bookmark"> /// The bookmark. /// </param> /// <param name="value"> /// The value. /// </param> private void ReceiveCallback(NativeActivityContext context, Bookmark bookmark, object value) { context.RemoveAllBookmarks(); this.receiveContext = (IHttpWorkflowReceiveContext)value; this.hostContext = context.GetExtension<IHttpWorkflowHostContext>(); // bind the parameters using the UriTemplate var match = this.hostContext.MatchSingle(this.receiveContext.Request); this.noPersistHandle.Get(context).Enter(context); // TODO: Consider fault handling - do we need to do anything special? context.ScheduleFunc( this.Body, this.receiveContext.Request, match.BoundVariables.AllKeys.ToDictionary(s => s, key => match.BoundVariables[key]), this.OnBodyCompleted); }