예제 #1
0
        private void OnBranchComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance)
        {
            PickState pickState = this.pickStateVariable.Get(context);
            ReadOnlyCollection <System.Activities.ActivityInstance> children = context.GetChildren();

            switch (completedInstance.State)
            {
            case ActivityInstanceState.Closed:
                pickState.HasBranchCompletedSuccessfully = true;
                break;

            case ActivityInstanceState.Canceled:
            case ActivityInstanceState.Faulted:
                if ((context.IsCancellationRequested && (children.Count == 0)) && !pickState.HasBranchCompletedSuccessfully)
                {
                    context.MarkCanceled();
                    context.RemoveAllBookmarks();
                }
                break;
            }
            if ((children.Count == 1) && (pickState.ExecuteActionBookmark != null))
            {
                this.ResumeExecutionActionBookmark(pickState, context);
            }
        }
예제 #2
0
파일: Pick.cs 프로젝트: wfridy/corewf
        private void OnBranchComplete(NativeActivityContext context, ActivityInstance completedInstance)
        {
            PickState pickState = this.pickStateVariable.Get(context);
            ReadOnlyCollection <ActivityInstance> executingChildren = context.GetChildren();

            switch (completedInstance.State)
            {
            case ActivityInstanceState.Closed:
                pickState.HasBranchCompletedSuccessfully = true;
                break;

            case ActivityInstanceState.Canceled:
            case ActivityInstanceState.Faulted:
                if (context.IsCancellationRequested)
                {
                    if (executingChildren.Count == 0 && !pickState.HasBranchCompletedSuccessfully)
                    {
                        // All of the branches are complete and we haven't had a single
                        // one complete successfully and we've been asked to cancel.
                        context.MarkCanceled();
                        context.RemoveAllBookmarks();
                    }
                }
                break;
            }

            //the last branch should always resume action bookmark if it's still there
            if (executingChildren.Count == 1 && pickState.ExecuteActionBookmark != null)
            {
                ResumeExecutionActionBookmark(pickState, context);
            }
        }
 public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
 {
     context.RemoveAllBookmarks();
     NextState.Set(context, nextState);
     NextWorkFlow.Set(context, nextWorkFlow);
     Record.Set(context, recordData);
 }
예제 #4
0
        void OnFinish(NativeActivityContext context, Bookmark bookmark, object o)
        {
            var twilio = context.GetExtension <ITwilioContext>();
            var r      = (NameValueCollection)o;
            var result = r["QueueResult"];
            var sid    = r["QueueSid"];
            var time   = r["QueueTime"];

            // set result values
            if (result != null)
            {
                Result.Set(context, ParseResult(result));
            }
            if (sid != null)
            {
                Sid.Set(context, sid);
            }
            if (time != null)
            {
                Time.Set(context, TimeSpan.FromSeconds(int.Parse(time)));
            }

            // cancel all outstanding activities
            context.RemoveAllBookmarks();
            context.CancelChildren();
        }
예제 #5
0
        protected override void Cancel(NativeActivityContext context)
        {
            var subscriptionHandle = this.SubscriptionHandle.Get(context);

            subscriptionHandle.ReleaseSubscription(context.GetExtension <Hosting.FolderWatcherExtension>());
            context.RemoveAllBookmarks();
            context.MarkCanceled();
        }
 private void OnBodyComplete(NativeActivityContext context, ActivityInstance completedinstance)
 {
     if (_bodyError.Get(context) == null)
     {
         context.GetExtension <CriticalSectionQueueExtension>()
         .Exit(_resumeBookmark.Get(context), QueueName.Get(context));
     }
     context.RemoveAllBookmarks();
 }
예제 #7
0
        /// <summary>
        /// Invoked when digits are available.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bookmark"></param>
        /// <param name="o"></param>
        void OnFinish(NativeActivityContext context, Bookmark bookmark, object o)
        {
            var r      = (NameValueCollection)o;
            var digits = r["Digits"] ?? "";

            Result.Set(context, digits);
            Digits.Set(context, digits);

            // cancel all children
            context.RemoveAllBookmarks();
            context.CancelChildren();
        }
예제 #8
0
        /// <summary>
        /// Invoked when digits are available.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bookmark"></param>
        /// <param name="o"></param>
        void OnAction(NativeActivityContext context, Bookmark bookmark, object o)
        {
            var r        = (NameValueCollection)o;
            var sid      = r["RecordingSid"];
            var url      = r["RecordingUrl"];
            var duration = r["RecordingDuration"];
            var digits   = r["Digits"];

            Sid.Set(context, sid);
            Url.Set(context, url != null ? new Uri(url, UriKind.RelativeOrAbsolute) : null);
            Duration.Set(context, duration != null ? TimeSpan.FromSeconds(int.Parse(duration)) : TimeSpan.Zero);
            Digits.Set(context, digits);
            Result.Set(context, Url.Get(context));

            // cancel all children
            context.RemoveAllBookmarks();
            context.CancelChildren();
        }
        /// <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);
        }
        protected override void Cancel(NativeActivityContext context)
        {
            context.ScheduleActivity(_w1);
            OutcomeState outcome = this.OutcomeOnCancellation.Get(context);

            switch (outcome)
            {
            case OutcomeState.Canceled:
                base.Cancel(context);
                break;

            case OutcomeState.Completed:
                context.RemoveAllBookmarks();
                break;

            case OutcomeState.Faulted:
                throw new TestCaseException("Exception is intentionally thrown during cancellation");
            }
        }
예제 #11
0
파일: Dial.cs 프로젝트: sukitha/twilio-net
        /// <summary>
        /// Invoked when digits are available.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="bookmark"></param>
        /// <param name="o"></param>
        void OnFinish(NativeActivityContext context, Bookmark bookmark, object o)
        {
            var r            = (NameValueCollection)o;
            var status       = r["DialCallStatus"];
            var sid          = r["DialCallSid"];
            var duration     = r["DialCallDuration"];
            var recordingUrl = r["RecordingUrl"];

            // set output arguments
            Result.Set(context, status != null ? ParseCallStatus(status) : DialCallStatus.Unknown);
            Status.Set(context, status != null ? ParseCallStatus(status) : DialCallStatus.Unknown);
            Sid.Set(context, sid);
            Duration.Set(context, duration != null ? TimeSpan.FromSeconds(int.Parse(duration)) : TimeSpan.Zero);
            RecordingUrl.Set(context, recordingUrl != null ? new Uri(recordingUrl) : null);

            // cancel all children
            context.RemoveAllBookmarks();
            context.CancelChildren();
        }
        private void onCompleted(NativeActivityContext context, ActivityInstance completedinstance)
        {
            ICancellableWorkItemWithChildren target = CancellableWorkItem.Get(context);

            if (completedinstance.State == ActivityInstanceState.Canceled ||
                completedinstance.State == ActivityInstanceState.Faulted)
            {
                string message = _childFault.Get(context) != null
                                     ? Resources.CancelledDueToAssociatedTaskFailure
                                     : Resources.CancelledUponUserRequest;

                MarkTasksAsCancelled(target, context, message);

                if (completedinstance.State == ActivityInstanceState.Faulted)
                {
                    PostTrackingRecord(context, target, WorkItemStatus.Faulted, Resources.FailedDueToChildTaskFailure);
                }
            }
            else
            {
                PostTrackingRecord(context, target, WorkItemStatus.Closed);
            }

            context.RemoveAllBookmarks();
            if ((completedinstance.State == ActivityInstanceState.Canceled) ||
                (completedinstance.State == ActivityInstanceState.Faulted))
            {
                _suppressCancel.Set(context, true);
                if (Cancelation != null)
                {
                    context.ScheduleActivity(Cancelation, OnCompensationActivityCompleted);
                }
                else
                {
                    OnCompensationActivityCompleted(context, completedinstance);
                }
            }
        }
        private void OnBranchComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance)
        {
            PickState pickState = this.pickStateVariable.Get(context);
            ReadOnlyCollection<System.Activities.ActivityInstance> children = context.GetChildren();
            switch (completedInstance.State)
            {
                case ActivityInstanceState.Closed:
                    pickState.HasBranchCompletedSuccessfully = true;
                    break;

                case ActivityInstanceState.Canceled:
                case ActivityInstanceState.Faulted:
                    if ((context.IsCancellationRequested && (children.Count == 0)) && !pickState.HasBranchCompletedSuccessfully)
                    {
                        context.MarkCanceled();
                        context.RemoveAllBookmarks();
                    }
                    break;
            }
            if ((children.Count == 1) && (pickState.ExecuteActionBookmark != null))
            {
                this.ResumeExecutionActionBookmark(pickState, context);
            }
        }
예제 #14
0
 void RemoveBookmarks(NativeActivityContext context)
 {
     context.RemoveAllBookmarks();
     RemoveActiveBookmark(context);
 }
예제 #15
0
 public void OnResumeBookmark(NativeActivityContext context, Bookmark bookmark, object obj)
 {
     NextWorkFlow.Set(context, nextWorkFlow);
     context.RemoveAllBookmarks();
 }
예제 #16
0
        void OnBranchComplete(NativeActivityContext context, ActivityInstance completedInstance)
        {
            PickState pickState = this.pickStateVariable.Get(context);
            ReadOnlyCollection<ActivityInstance> executingChildren = context.GetChildren();

            switch (completedInstance.State)
            {
                case ActivityInstanceState.Closed:
                    pickState.HasBranchCompletedSuccessfully = true;
                    break;
                case ActivityInstanceState.Canceled:
                case ActivityInstanceState.Faulted:
                    if (context.IsCancellationRequested)
                    {
                        if (executingChildren.Count == 0 && !pickState.HasBranchCompletedSuccessfully)
                        {
                            // All of the branches are complete and we haven't had a single
                            // one complete successfully and we've been asked to cancel.
                            context.MarkCanceled();
                            context.RemoveAllBookmarks();
                        }
                    }                    
                    break;
            }

            //the last branch should always resume action bookmark if it's still there
            if (executingChildren.Count == 1 && pickState.ExecuteActionBookmark != null)
            {
                ResumeExecutionActionBookmark(pickState, context);
            }
        }
예제 #17
0
 private void RemoveBookmarks(NativeActivityContext context)
 {
     context.RemoveAllBookmarks();
     this.RemoveActiveBookmark(context);
 }
 protected override void Cancel(NativeActivityContext context)
 {
     var subscriptionHandle = this.SubscriptionHandle.Get(context);
     subscriptionHandle.ReleaseSubscription(context.GetExtension<Hosting.FolderWatcherExtension>());
     context.RemoveAllBookmarks();
     context.MarkCanceled();
 }
예제 #19
0
 private void OnProgressActivityCompleted(NativeActivityContext context, ActivityInstance completedinstance)
 {
     context.RemoveAllBookmarks();
 }
예제 #20
0
        /// <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);
        }