public void SetEmailAddress(string email, CompletionCallback callback) { MutationQuery query = new MutationQuery(); DefaultQueries.checkout.EmailUpdate(query, CurrentCheckout.id(), email); Client.Mutation(query, (Mutation response, ShopifyError error) => { if (error != null) { callback(error); } else { if (UpdateState(response.checkoutEmailUpdateV2().checkout(), response.checkoutEmailUpdateV2().userErrors())) { if (CurrentCheckout.ready()) { callback(null); } else { PollCheckoutAndUpdate(PollCheckoutReady, callback); } } else { HandleUserError(callback); } } }); }
public override bool callFunction(int fnc, BinaryReader message, CompletionCallback callback = null) { bool ret = base.callFunction(fnc, message, callback); JesterLogger.log("ActionGameSpace.callFunction, ret: " + ret + ", fnc: " + fnc); if (ret) { return(true); } switch (fnc) { case ActionGameProtocol.SNAPSHOT: JesterLogger.log("ActionGameProtocol.Snapshot"); onSnapshot(message); return(true); case ActionGameProtocol.ACTION: JesterLogger.log("ActionGameProtocol.Action"); onAction(message); return(true); case ActionGameProtocol.MOVE: JesterLogger.log("ActionGameProtocol.Move"); onMove(message); return(true); } return(false); }
private void InternalExecute(NativeActivityContext context, ActivityInstance completedInstance) { CompensationExtension compensationExtension = context.GetExtension <CompensationExtension>(); if (compensationExtension == null) { throw Microsoft.CoreWf.Internals.FxTrace.Exception.AsError(new InvalidOperationException(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 (_onChildCompensated == null) { _onChildCompensated = new CompletionCallback(InternalExecute); } _toCompensateToken.Set(context, new CompensationToken(tokenData.ExecutionTracker.Get())); Fx.Assert(Body != null, "Body must be valid"); context.ScheduleActivity(Body, _onChildCompensated); } }
public InternalState(State state) { this.state = state; this.DisplayName = state.DisplayName; this.onEntryComplete = new CompletionCallback(OnEntryComplete); this.onTriggerComplete = new CompletionCallback(OnTriggerComplete); this.onConditionComplete = new CompletionCallback <bool>(OnConditionComplete); this.onExitComplete = new CompletionCallback(OnExitComplete); this.onChildStateComplete = new CompletionCallback <string>(OnChildStateComplete); this.completeStateCallback = new BookmarkCallback(CompleteState); this.evaluateConditionCallback = new BookmarkCallback(StartEvaluateCondition); this.currentRunningTriggers = new Variable <int>(); this.hasRunningChildState = new Variable <bool>(); this.isExiting = new Variable <bool>(); this.evaluateConditionBookmark = new Variable <Bookmark>(); this.completeStateBookmark = new Variable <Bookmark>(); this.internalStates = new Collection <InternalState>(); this.internalTransitions = new Collection <InternalTransition>(); this.internalStateFuncs = new Collection <ActivityFunc <string, StateMachineEventManager, string> >(); this.triggerInternalTransitionMapping = new Dictionary <Activity, InternalTransition>(); }
private bool ExecuteSingleNode(NativeActivityContext context, FlowNode node, out FlowNode nextNode) { FlowStep step = node as FlowStep; if (step != null) { if (this.onStepCompleted == null) { this.onStepCompleted = new CompletionCallback(this.OnStepCompleted); } return(step.Execute(context, this.onStepCompleted, out nextNode)); } nextNode = null; FlowDecision decision = node as FlowDecision; if (decision != null) { if (this.onDecisionCompleted == null) { this.onDecisionCompleted = new CompletionCallback <bool>(this.OnDecisionCompleted); } return(decision.Execute(context, this.onDecisionCompleted)); } IFlowSwitch switch2 = node as IFlowSwitch; return(switch2.Execute(context, this)); }
private void CreateRemoteCheckoutFromLocalState(CompletionCallback callback) { MutationQuery query = new MutationQuery(); List <CheckoutLineItemInput> newLineItemInput = CartLineItems.ConvertToCheckoutLineItemInput(LineItems.All()); DefaultQueries.checkout.Create(query, newLineItemInput); Client.Mutation(query, (Mutation response, ShopifyError error) => { if (error != null) { callback(error); return; } if (UpdateState(response.checkoutCreate().checkout(), response.checkoutCreate().userErrors())) { if (CurrentCheckout.ready()) { callback(null); } else { PollCheckoutAndUpdate(PollCheckoutReady, callback); } } else { HandleUserError(callback); } }); }
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); }
void OnResolveCompletion(PPError result) { if (result != PPError.Ok) { PostMessage("Resolve failed."); return; } var addr = PPBHostResolver.GetNetAddress(resolver_, 0); PostMessage($"Resolved: {(Var)PPBNetAddress.DescribeAsString(addr, PPBool.True)}"); var callback = new CompletionCallback(OnConnectCompletion); if (IsUDP) { PostMessage("Binding ..."); remote_host_ = new PPResource(addr); var ipv4_addr = new PPNetAddressIPv4(0); PPBUDPSocket.Bind(udp_socket_, addr, callback); } else { PostMessage("Connecting ..."); PPBTCPSocket.Connect(tcp_socket_, addr, callback); } }
public Task WriteCloseFragmentAsync(WebSocketCloseStatus closeStatus, string statusDescription) { TaskCompletionSource <object> tcs = new TaskCompletionSource <object>(); // Callback will always be called (since it is responsible for cleanup), even if completed synchronously CompletionCallback callback = (hrError, cbIO, fUtf8Encoded, fFinalFragment, fClose) => { try { ThrowExceptionForHR(hrError); tcs.TrySetResult(null); // regular completion } catch (Exception ex) { tcs.TrySetException(ex); // exceptional completion } }; IntPtr completionContext = GCUtil.RootObject(callback); // Call the underlying implementation; SendConnectionClose should never throw an exception bool completionExpected; int hr = _context.SendConnectionClose( fAsync: true, uStatusCode: (ushort)closeStatus, szReason: statusDescription, // don't need to pin string: CLR marshaler handles managed to unmanaged conversion, and IIS makes local copy for duration of async operation pfnCompletion: _asyncThunkAddress, pvCompletionContext: completionContext, pfCompletionExpected: out completionExpected); if (!completionExpected) { // Completed synchronously or error; the thunk and callback together handle cleanup AsyncCallbackThunk(hr, completionContext, cbIO: 0, fUtf8Encoded: true, fFinalFragment: true, fClose: false); } return(tcs.Task); }
// This thunk dispatches to the appropriate instance continuation when an asynchronous event completes private static void AsyncCallbackThunk(int hrError, IntPtr pvCompletionContext, int cbIO, bool fUtf8Encoded, bool fFinalFragment, bool fClose) { // Calling UnrootObject also makes the callback and everything it references eligible for garbage collection CompletionCallback callback = (CompletionCallback)GCUtil.UnrootObject(pvCompletionContext); callback(hrError, cbIO, fUtf8Encoded, fFinalFragment, fClose); }
/// <summary> /// It's constructor. /// </summary> public StateMachine() { this.internalStates = new Collection<InternalState>(); this.internalStateFuncs = new Collection<ActivityFunc<string, StateMachineEventManager, string>>(); this.eventManager = new Variable<StateMachineEventManager> { Name = "EventManager", Default = new LambdaValue<StateMachineEventManager>(ctx => new StateMachineEventManager()) }; this.onStateComplete = new CompletionCallback<string>(OnStateComplete); }
private bool ExecuteSingleNode(NativeActivityContext context, FlowNode node, out FlowNode nextNode) { Fx.Assert(node != null, "caller should validate"); if (node is FlowStep step) { if (this.onStepCompleted == null) { this.onStepCompleted = new CompletionCallback(this.OnStepCompleted); } return(step.Execute(context, this.onStepCompleted, out nextNode)); } nextNode = null; if (node is FlowDecision decision) { if (this.onDecisionCompleted == null) { this.onDecisionCompleted = new CompletionCallback <bool>(this.OnDecisionCompleted); } return(decision.Execute(context, this.onDecisionCompleted)); } var switchNode = node as IFlowSwitch; Fx.Assert(switchNode != null, "unrecognized FlowNode"); return(switchNode.Execute(context, this)); }
private unsafe void Execute() { while (completed == false) { uint bytesRead; uint completionKey; NativeOverlapped *native; bool result = CompletionInterop.GetQueuedCompletionStatus( port, out bytesRead, out completionKey, &native, 1000); if (native != null) { Overlapped overlapped = Overlapped.Unpack(native); CompletionCallback callback = overlapped.AsyncResult as CompletionCallback; if (result) { callback?.Complete((int)bytesRead); } else { callback?.Fail(native); } Overlapped.Free(native); } } }
protected internal override void Invoke(NativeActivityContext context, System.Activities.ActivityInstance completedInstance) { base.EnsureCallback(completionCallbackType, completionCallbackParameters); CompletionCallback callback = (CompletionCallback)base.Callback; callback(context, completedInstance); }
public void SetShippingLine(string shippingRateHandle, CompletionCallback callback) { MutationQuery query = new MutationQuery(); DefaultQueries.checkout.ShippingLineUpdate(query, CurrentCheckout.id(), shippingRateHandle); Client.Mutation(query, (Mutation response, ShopifyError error) => { if (error != null) { callback(error); return; } if (UpdateState(response.checkoutShippingLineUpdate().checkout(), response.checkoutShippingLineUpdate().userErrors())) { if (CurrentCheckout.ready()) { callback(null); } else { PollCheckoutAndUpdate(PollCheckoutReady, callback); } } else { HandleUserError(callback); } }); }
protected internal override void Invoke(NativeActivityContext context, System.Activities.ActivityInstance completedInstance) { base.EnsureCallback(FuncCompletionCallbackWrapper <T> .callbackType, FuncCompletionCallbackWrapper <T> .callbackParameterTypes, FuncCompletionCallbackWrapper <T> .callbackParameterTypes[2]); CompletionCallback <T> callback = (CompletionCallback <T>)base.Callback; callback(context, completedInstance, this.resultValue); }
public PendingRequest(CreationCallback creationCallback, CompletionCallback completionCallback, long maxAgeMillis) { this.creationCallback = creationCallback; this.completionCallback = completionCallback; this.maxAgeMillis = maxAgeMillis; }
private void InternalExecute(NativeActivityContext executionContext, ActivityInstance completedInstance) { int completedInstanceIndex = _lastIndexHint.Get(executionContext); if (completedInstanceIndex >= this.Activities.Count || this.Activities[completedInstanceIndex] != completedInstance.Activity) { completedInstanceIndex = this.Activities.IndexOf(completedInstance.Activity); } int nextChildIndex = completedInstanceIndex + 1; if (nextChildIndex == this.Activities.Count) { OnSequenceComplete(executionContext); return; } if (_onChildComplete == null) { _onChildComplete = new CompletionCallback(InternalExecute); } Activity nextChild = this.Activities[nextChildIndex]; executionContext.ScheduleActivity(nextChild, _onChildComplete); _lastIndexHint.Set(executionContext, nextChildIndex); }
/// <summary> /// Convert the given message to json and publish it. /// </summary> private bool publishMessage(string topic, object msg, CompletionCallback cb) { if ((client != null) && (client.IsConnected)) { try { lock (completionCallbacks) { var payload = JsonConvert.SerializeObject(msg, Formatting.None); var msgID = client.Publish(topicPrefix + topic, Encoding.UTF8.GetBytes(payload), MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE, true); if (cb != null) { completionCallbacks[msgID] = cb; } return(true); } } catch (Exception ex) { Log.Error("MQTT publish failed: " + ex); return(false); } } else { return(false); } }
private unsafe void Execute() { CompletionInterop.OverlappedEntry[] entries = new CompletionInterop.OverlappedEntry[1024]; while (completed == false) { uint processed; bool result = CompletionInterop.GetQueuedCompletionStatusEx( port, entries, entries.Length, out processed, 1000, 0); if (result) { for (int i = 0; i < processed; i++) { CompletionInterop.OverlappedEntry entry = entries[i]; Overlapped overlapped = Overlapped.Unpack(entry.lpOverlapped); CompletionCallback callback = overlapped.AsyncResult as CompletionCallback; callback?.Complete(entry.lpOverlapped, (int)entry.dwNumberOfBytesTransferred); Overlapped.Free(entry.lpOverlapped); } } } }
protected override void Execute(NativeActivityContext context) { IEnumerable values = this.Values.Get(context); if (values == null) { throw new InvalidOperationException("ParallelForEach requires a non-null Values argument."); } IEnumerator valueEnumerator = values.GetEnumerator(); CompletionCallback onBodyComplete = new CompletionCallback(OnBodyComplete); while (valueEnumerator.MoveNext()) { if (this.Body != null) { context.ScheduleAction(this.Body, valueEnumerator.Current, onBodyComplete); } } IDisposable disposable = valueEnumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } }
void InternalExecute(NativeActivityContext context, ActivityInstance completedInstance) { CompensationExtension compensationExtension = context.GetExtension<CompensationExtension>(); if (compensationExtension == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.ConfirmWithoutCompensableActivity(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.onChildConfirmed == null) { this.onChildConfirmed = new CompletionCallback(InternalExecute); } this.toConfirmToken.Set(context, new CompensationToken(tokenData.ExecutionTracker.Get())); Fx.Assert(Body != null, "Body must be valid"); context.ScheduleActivity(Body, this.onChildConfirmed); } }
protected internal override void Invoke(NativeActivityContext context, ActivityInstance completedInstance) { EnsureCallback(completionCallbackType, completionCallbackParameters); CompletionCallback completionCallback = (CompletionCallback)this.Callback; completionCallback(context, completedInstance); }
public static CompletionBookmark CreateCompletionBookmark <TResult>(CompletionCallback <TResult> onCompleted, System.Activities.ActivityInstance owningInstance) { if (onCompleted != null) { return(new CompletionBookmark(new FuncCompletionCallbackWrapper <TResult>(onCompleted, owningInstance))); } return(null); }
void ScheduleBody(NativeActivityContext context) { if (this.onBodyComplete == null) { this.onBodyComplete = new CompletionCallback(OnBodyComplete); } context.ScheduleActivity(this.Body, this.onBodyComplete); }
public MySequence() { _children = new Collection <Activity>(); _variables = new Collection <Variable>(); _currentindex = new Variable <int>(); _completed = new CompletionCallback(Child_complete); }
private CompletionCallback <T> GetSwitchCompletedCallback(Flowchart parent) { if (_onSwitchCompleted == null) { _onSwitchCompleted = new CompletionCallback <T>(parent.OnSwitchCompleted <T>); } return(_onSwitchCompleted); }
public LFNativeActivity() { this.Children = new Collection <Activity>(); this.Variables = new Collection <Variable>(); this.CurrentIndex = new Variable <int>(); this.Completed = new CompletionCallback(this.Activity_Completed); }
protected override void Execute(NativeActivityContext context) { CompletionCallback <bool> onChildComplete = new CompletionCallback <bool>(OnChildComplete); context.ScheduleActivity(FirstChild, onChildComplete); context.ScheduleActivity(SecondChild, onChildComplete); Result.Set(context, false); }
private void ScheduleCondition(NativeActivityContext context) { if (this.onConditionComplete == null) { this.onConditionComplete = new CompletionCallback <bool>(this.OnConditionComplete); } context.ScheduleActivity <bool>(this.Condition, this.onConditionComplete, null); }
public InternalReceiveMessage() { this.CorrelatesWith = new InArgument<CorrelationHandle>(context => (CorrelationHandle)null); this.receiveMessageInstance = new Variable<VolatileReceiveMessageInstance>(); this.waitForReply = new WaitForReply { Instance = this.receiveMessageInstance }; this.onClientReceiveMessageComplete = new CompletionCallback(ClientScheduleOnReceiveMessageCallback); this.extensionReceiveBookmark = new Variable<Bookmark>(); }
/// <summary> /// It's constructor. /// </summary> public StateMachine() { _internalStates = new Collection <InternalState>(); _internalStateFuncs = new Collection <ActivityFunc <StateMachineEventManager, string> >(); _eventManager = new Variable <StateMachineEventManager> { Name = "EventManager", Default = new StateMachineEventManagerFactory() }; _onStateComplete = new CompletionCallback <string>(this.OnStateComplete); }
private void HandleUserError(CompletionCallback callback) { ShopifyError error = new ShopifyError( ShopifyError.ErrorType.UserError, "There were issues with some of the fields sent. See `cart.UserErrors`" ); callback(error); }
public StateMachine() { Variable<StateMachineEventManager> variable = new Variable<StateMachineEventManager> { Name = "EventManager", Default = new LambdaValue<StateMachineEventManager>(ctx => new StateMachineEventManager()) }; this.eventManager = variable; this.onStateComplete = new CompletionCallback<string>(this.OnStateComplete); }
protected override void Execute(NativeActivityContext context) { if ((this.branches != null) && (this.Branches.Count != 0)) { CompletionCallback onCompleted = new CompletionCallback(this.OnBranchComplete); for (int i = this.Branches.Count - 1; i >= 0; i--) { context.ScheduleActivity(this.Branches[i], onCompleted); } } }
protected override void Execute(NativeActivityContext context) { if (this.branchBodies.Count != 0) { PickState state = new PickState(); this.pickStateVariable.Set(context, state); state.TriggerCompletionBookmark = context.CreateBookmark(new BookmarkCallback(this.OnTriggerComplete)); context.Properties.Add("System.Activities.Statements.Pick.PickState", state); CompletionCallback onCompleted = new CompletionCallback(this.OnBranchComplete); for (int i = this.branchBodies.Count - 1; i >= 0; i--) { context.ScheduleActivity(this.branchBodies[i], onCompleted); } } }
internal bool Execute(NativeActivityContext context, CompletionCallback onCompleted, out FlowNode nextNode) { if ((this.Next == null) && TD.FlowchartNextNullIsEnabled()) { TD.FlowchartNextNull(base.Owner.DisplayName); } if (this.Action == null) { nextNode = this.Next; return true; } context.ScheduleActivity(this.Action, onCompleted); nextNode = null; return false; }
public WaveformTimeline(Panel container, string fileName, CompletionCallback callback = null) { Container = container; FileName = fileName; OnCompletion = callback; CurrentPosition = new Rectangle { Height = container.Height, Width = 4, Fill = Brushes.Black, Opacity = 0.9, Margin = new System.Windows.Thickness(LeftOffset, TopOffset, 0, 0) }; // Add the tracking bar to the container Container.Children.Add(CurrentPosition); }
private void OnConditionComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance, bool result) { if (result) { if (this.Body != null) { if (this.onBodyComplete == null) { this.onBodyComplete = new CompletionCallback(this.OnBodyComplete); } context.ScheduleActivity(this.Body, this.onBodyComplete); } else { this.ScheduleCondition(context); } } }
private void InternalExecute(NativeActivityContext context, System.Activities.ActivityInstance completedInstance) { CompensationExtension extension = context.GetExtension<CompensationExtension>(); if (extension == null) { throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.ConfirmWithoutCompensableActivity(base.DisplayName))); } CompensationToken token = this.Target.Get(context); CompensationTokenData data = (token == null) ? null : extension.Get(token.CompensationId); if (data.ExecutionTracker.Count > 0) { if (this.onChildConfirmed == null) { this.onChildConfirmed = new CompletionCallback(this.InternalExecute); } this.toConfirmToken.Set(context, new CompensationToken(data.ExecutionTracker.Get())); context.ScheduleActivity(this.Body, this.onChildConfirmed); } }
private void OnBranchComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance) { if ((this.CompletionCondition != null) && !this.hasCompleted.Get(context)) { if ((completedInstance.State != ActivityInstanceState.Closed) && context.IsCancellationRequested) { context.MarkCanceled(); this.hasCompleted.Set(context, true); } else { if (this.onConditionComplete == null) { this.onConditionComplete = new CompletionCallback<bool>(this.OnConditionComplete); } context.ScheduleActivity<bool>(this.CompletionCondition, this.onConditionComplete, null); } } }
protected override void UpdateInstance(NativeActivityUpdateContext updateContext) { PickState pickState = updateContext.GetValue(this.pickStateVariable); Fx.Assert(pickState != null, "Pick's Execute must have run by now."); if (updateContext.IsCancellationRequested || pickState.TriggerCompletionBookmark == null) { // do not schedule newly added Branches once a Trigger has successfully completed. return; } CompletionCallback onBranchCompleteCallback = new CompletionCallback(OnBranchComplete); foreach (PickBranchBody body in this.branchBodies) { if (updateContext.IsNewlyAdded(body)) { updateContext.ScheduleActivity(body, onBranchCompleteCallback, null); } } }
/// <summary> /// Get an abortable thread from the pool. Wait until Run() is called on the returned IThreadControl. /// </summary> /// <param name="work">actual work to be executed by this thread</param> /// <param name="arg">application arg</param> /// <param name="done">called when the work is finished</param> /// <returns>control object for the abortable thread</returns> public IThreadControl GetThread(WaitCallback work, object arg, CompletionCallback done) { ThreadControl ctl; lock (_Sync) { if (_Free.Count > 0) { ctl = _Free.Pop(); ctl.Proc = work; ctl.Arg = arg; } else if (_Busy.Count < _Capacity) { ctl = new ThreadControl(_Prefix, this) { Proc = work, Arg = arg }; ctl.Start(); } else return null; _Busy.Add(ctl); } ctl.OnCompletion = done; return ctl; }
private void InternalExecute(NativeActivityContext context, ActivityInstance instance) { if (_onChildComplete == null) { _onChildComplete = InternalExecute; } Log.Info("in CallTestScreenActivity internalexecute"); var steps = GetSteps(context); Host.SetCommand(steps); var rElement = Host.GetResult(); Log.Info("CallTestScreen Receive result from Host:\n"+rElement); foreach (var stepElement in rElement.Descendants()) { stepElement.SetAttributeValue(Constants.PARENT_ID, ResultId); var ret = stepElement.GetAttributeValue(Constants.RESULT); if (!string.IsNullOrEmpty(ret)) { stepElement.SetAttributeValue("Original", ret); stepElement.SetAttributeValue("Final", ret); RunningResult = ret.Equals(Constants.SUCCESS) && RunningResult; } else RunningResult = false; if (!RunningResult) { if (ErrorLevel == OnError.AlwaysReturnTrue) RunningResult = true; if (ErrorLevel == OnError.Terminate) { Log.Fatal("Workflow terminated according OnError.Terminate"); context.Abort(); } if (ErrorLevel == OnError.Continue) { //do nothing, just continue } if (ErrorLevel == OnError.JustShowWarning) { Log.Warn("Warning:\n" + DisplayName + " Error happened, but we ignore it"); RunningResult = true; } if (ErrorLevel == OnError.StopCurrentScript) { //we cannot stop it here, just pass the result to higher level, until it reach the testscript level, then testscript will stop itself Log.Error("Error:\n" + DisplayName + " Error happened, stop current script."); } } //handle the get value here var action = stepElement.GetAttributeValue("Action"); if (action.Equals("GetValue")) { var data = stepElement.GetAttributeValue("Data"); if (!string.IsNullOrEmpty(data)) { var pos = data.IndexOf("=>", StringComparison.Ordinal); try { //var attr = data.Substring(0, pos); var variable = data.Substring(pos + 2); if (!string.IsNullOrEmpty(variable)) { var value = stepElement.GetAttributeValue(variable); if (!string.IsNullOrEmpty(value)) { } } } catch (Exception ex) { Log.Error(ExceptionHelper.FormatStackTrace("GetValue Failed:", ex)); } } } //result.SetAttributeValue(Constants.UI_OBJECT, UIObject); stepElement.SetAttributeValue(Constants._TYPE, "Result"); DBFactory.GetData().Save(stepElement); } SetFinalResult(); }
void OnBodyComplete(NativeActivityContext context, ActivityInstance completedInstance) { // for the completion condition, we handle cancelation ourselves if (this.CompletionCondition != null && !this.hasCompleted.Get(context)) { if (completedInstance.State != ActivityInstanceState.Closed && context.IsCancellationRequested) { // If we hadn't completed before getting canceled // or one of our iteration of body cancels then we'll consider // ourself canceled. context.MarkCanceled(); this.hasCompleted.Set(context, true); } else { if (this.onConditionComplete == null) { this.onConditionComplete = new CompletionCallback<bool>(OnConditionComplete); } context.ScheduleActivity(CompletionCondition, this.onConditionComplete); } } }
internal abstract void ScheduleAction(NativeActivityContext context, Exception exception, CompletionCallback completionCallback, FaultCallback faultCallback);
void ClientScheduleOnReceivedMessage(NativeActivityContext executionContext, ReceiveMessageInstanceData instance) { Fx.Assert(instance.CorrelationRequestContext != null, "Client side receive must have CorrelationRequestContext"); // client side: retrieve the reply from the request context if (instance.CorrelationRequestContext.TryGetReply()) { // Reply has already come back because one of the following happened: // (1) Receive reply completed synchronously // (2) Async receive reply completed very quickly and channel callback already happened by now ClientScheduleOnReceiveMessageCore(executionContext, instance); FinalizeScheduleOnReceivedMessage(executionContext, instance); } else { // Async path: wait for reply to come back VolatileReceiveMessageInstance volatileInstance = new VolatileReceiveMessageInstance { Instance = instance }; this.receiveMessageInstance.Set(executionContext, volatileInstance); if (onClientReceiveMessageComplete == null) { onClientReceiveMessageComplete = new CompletionCallback(ClientScheduleOnReceiveMessageCallback); } executionContext.ScheduleActivity(this.waitForReply, onClientReceiveMessageComplete); } }
protected override void Execute(NativeActivityContext context) { if (this.branchBodies.Count == 0) { return; } PickState pickState = new PickState(); this.pickStateVariable.Set(context, pickState); pickState.TriggerCompletionBookmark = context.CreateBookmark(new BookmarkCallback(OnTriggerComplete)); context.Properties.Add(pickStateProperty, pickState); CompletionCallback onBranchCompleteCallback = new CompletionCallback(OnBranchComplete); //schedule every branch to only run trigger for (int i = this.branchBodies.Count - 1; i >= 0; i--) { context.ScheduleActivity(this.branchBodies[i], onBranchCompleteCallback); } }
protected override void UpdateInstance(NativeActivityUpdateContext updateContext) { if (updateContext.IsCancellationRequested || this.branches == null) { return; } if (this.CompletionCondition != null && updateContext.GetValue(this.hasCompleted)) { // when CompletionCondition exists, schedule newly added branches only if "hasCompleted" variable evaluates to false return; } CompletionCallback onBranchComplete = new CompletionCallback(OnBranchComplete); foreach (Activity branch in this.branches) { if (updateContext.IsNewlyAdded(branch)) { updateContext.ScheduleActivity(branch, onBranchComplete); } } }
public ActivityCompletionCallbackWrapper(CompletionCallback callback, ActivityInstance owningInstance) : base(callback, owningInstance) { }
internal bool Execute(NativeActivityContext context, CompletionCallback<bool> onConditionCompleted) { context.ScheduleActivity(Condition, onConditionCompleted); return false; }
private void InternalExecute(NativeActivityContext context, ActivityInstance instance) { //grab the index of the current Activity var currentActivityIndex = _currentIndex.Get(context); if (currentActivityIndex > 0) { var lastChild = children[currentActivityIndex - 1]; //Get result here, it is sync or async???? RunningResult = RunningResult && ((IPassData)lastChild).GetResult(); if (!RunningResult) { if (ErrorLevel == OnError.AlwaysReturnTrue) RunningResult = true; if (ErrorLevel == OnError.Terminate) { Log.Fatal("Workflow terminated according OnError.Terminate"); context.Abort(); } if (ErrorLevel == OnError.Continue) { //do nothing, just continue } if (ErrorLevel == OnError.JustShowWarning) { Log.Warn("Warning:\n" + lastChild.DisplayName + " Error happened, but we ignore it"); RunningResult = true; } if (ErrorLevel == OnError.StopCurrentScript) { Log.Error("Error:\n" + lastChild.DisplayName + " Error happened, stop current script."); return; } } //set variables value ((AutomationActivity)nextChild).Name to _runningResult AddVariable(lastChild.DisplayName.Replace(" ", "_").Replace(":","_"), RunningResult.ToString()); SetVariableValueByContext(context, lastChild.DisplayName.Replace(" ", "_").Replace(":", "_"), RunningResult.ToString()); } if (currentActivityIndex == children.Count) { //if the currentActivityIndex is equal to the count of MySequence's Activities //MySequence is complete SetFinalResult(); return; } if (_onChildComplete == null) { //on completion of the current child, have the runtime call back on this method _onChildComplete = InternalExecute; } //grab the next Activity in MySequence.Activities and schedule it var nextChild = children[currentActivityIndex]; ((IPassData) nextChild).PassData(InstanceId, UserData); var child = nextChild as AutomationActivity; if (child != null) { child.SetHost(Host); child.SetParentResultId(ResultId); } context.ScheduleActivity(nextChild, _onChildComplete); ////Get result here, it is sync or async???? not important, this is a template, should not calculate the result //_runningResult = _runningResult && ((IPassData)nextChild).GetResult(); //if (!_runningResult) //{ // if (ErrorLevel == OnError.AlwaysReturnTrue) // _runningResult = true; // //if (ErrorLevel == OnError.Terminate) // //{ // // //terminate the instance (send a status to instance) // //} // if (ErrorLevel == OnError.Continue) // { // //do nothing, just continue // } // if (ErrorLevel == OnError.JustShowWarning) // { // //do nothing, log warning // Log.Warn("Warning:\n" + DisplayName + " Error happened, but we ignore it"); // _runningResult = true; // } // if (ErrorLevel == OnError.StopCurrentScript) // { // //log error, then return // } //} //increment the currentIndex _currentIndex.Set(context, ++currentActivityIndex); }
public Sequence() : base() { this.lastIndexHint = new Variable<int>(); this.onChildComplete = new CompletionCallback(InternalExecute); }
private void ScheduleCondition(NativeActivityContext context) { if (this.onConditionComplete == null) { this.onConditionComplete = new CompletionCallback<bool>(this.OnConditionComplete); } context.ScheduleActivity<bool>(this.Condition, this.onConditionComplete, null); }
public Sequence() { this.onChildComplete = new CompletionCallback(this.InternalExecute); }
void OnBranchComplete(NativeActivityContext context, ActivityInstance completedInstance) { if (this.CompletionCondition != null && !this.hasCompleted.Get(context)) { // If we haven't completed, we've been requested to cancel, and we've had a child // end in a non-Closed state then we should cancel ourselves. if (completedInstance.State != ActivityInstanceState.Closed && context.IsCancellationRequested) { context.MarkCanceled(); this.hasCompleted.Set(context, true); return; } if (this.onConditionComplete == null) { this.onConditionComplete = new CompletionCallback<bool>(OnConditionComplete); } context.ScheduleActivity(this.CompletionCondition, this.onConditionComplete); } }
// Methods public Checkpoint() { this.onChildComplete = new CompletionCallback(this.InternalExecute); }
void ScheduleCondition(NativeActivityContext context) { Fx.Assert(this.Condition != null, "validated in OnOpen"); if (this.onConditionComplete == null) { this.onConditionComplete = new CompletionCallback<bool>(OnConditionComplete); } context.ScheduleActivity(this.Condition, this.onConditionComplete); }