Пример #1
0
        private void OnSecondaryRootScheduled(NativeActivityContext context, Bookmark bookmark, object value)
        {
            CompensationExtension compensationExtension = context.GetExtension <CompensationExtension>();

            Fx.Assert(compensationExtension != null, "CompensationExtension must be valid");

            long compensationId = (long)value;

            CompensationTokenData compensationToken = compensationExtension.Get(compensationId);

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

            if (compensationToken.CompensationState == CompensationState.Canceling)
            {
                Fx.Assert(compensationToken.BookmarkTable[CompensationBookmarkName.Canceled] == null, "Bookmark should not be already initialized in the bookmark table.");
                compensationToken.BookmarkTable[CompensationBookmarkName.Canceled] = context.CreateBookmark(new BookmarkCallback(OnCanceledOrCompensated));

                compensationExtension.NotifyMessage(context, compensationToken.CompensationId, CompensationBookmarkName.OnCancellation);
            }
            else if (compensationToken.CompensationState == CompensationState.Compensating)
            {
                Fx.Assert(compensationToken.BookmarkTable[CompensationBookmarkName.Compensated] == null, "Bookmark should not be already initialized in the bookmark table.");
                compensationToken.BookmarkTable[CompensationBookmarkName.Compensated] = context.CreateBookmark(new BookmarkCallback(OnCanceledOrCompensated));

                compensationExtension.NotifyMessage(context, compensationToken.CompensationId, CompensationBookmarkName.OnCompensation);
            }
        }
Пример #2
0
        private void OnConfirmationHandlerComplete(NativeActivityContext context, ActivityInstance completedInstance)
        {
            Fx.Assert(context != null, "context must be valid");
            Fx.Assert(completedInstance != null, "completedInstance must be valid");

            CompensationExtension compensationExtension = context.GetExtension <CompensationExtension>();

            Fx.Assert(compensationExtension != null, "CompensationExtension must be valid");

            CompensationTokenData compensationToken = compensationExtension.Get(this.compensationId.Get(context));

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

            if (completedInstance.State == ActivityInstanceState.Closed)
            {
                Fx.Assert(compensationToken.CompensationState == CompensationState.Confirming, "CompensationParticipant should be in Confirming State");

                this.currentCompensationToken.Set(context, new CompensationToken(compensationToken));
                if (compensationToken.ExecutionTracker.Count > 0)
                {
                    context.ScheduleActivity(DefaultConfirmation, new CompletionCallback(this.OnConfirmationComplete));
                }
                else
                {
                    compensationExtension.NotifyMessage(context, compensationToken.CompensationId, CompensationBookmarkName.Confirmed);
                }
            }
        }
        private void OnConfirmation(NativeActivityContext context, Bookmark bookmark, object value)
        {
            CompensationExtension extension = context.GetExtension <CompensationExtension>();
            long compensationId             = (long)value;
            CompensationTokenData tokenData = extension.Get(compensationId);

            if (TD.CompensationStateIsEnabled())
            {
                TD.CompensationState(tokenData.DisplayName, tokenData.CompensationState.ToString());
            }
            tokenData.RemoveBookmark(context, CompensationBookmarkName.OnCancellation);
            tokenData.RemoveBookmark(context, CompensationBookmarkName.OnCompensation);
            if (this.ConfirmationHandler != null)
            {
                context.ScheduleActivity(this.ConfirmationHandler, new CompletionCallback(this.OnConfirmationHandlerComplete), new FaultCallback(this.OnExceptionFromHandler));
            }
            else
            {
                this.currentCompensationToken.Set(context, new CompensationToken(tokenData));
                if (tokenData.ExecutionTracker.Count > 0)
                {
                    context.ScheduleActivity(this.DefaultConfirmation, new CompletionCallback(this.OnConfirmationComplete));
                }
                else
                {
                    extension.NotifyMessage(context, tokenData.CompensationId, CompensationBookmarkName.Confirmed);
                }
            }
        }
Пример #4
0
        private void InternalOnCompensationComplete(NativeActivityContext context, CompensationExtension compensationExtension, CompensationTokenData compensationToken)
        {
            switch (compensationToken.CompensationState)
            {
            case CompensationState.Canceling:
                compensationExtension.NotifyMessage(context, compensationToken.CompensationId, CompensationBookmarkName.Canceled);
                break;

            case CompensationState.Compensating:
                compensationExtension.NotifyMessage(context, compensationToken.CompensationId, CompensationBookmarkName.Compensated);
                break;

            default:
                Fx.Assert(false, "CompensationState is in unexpected state!");
                break;
            }
        }
        private void OnSecondaryRootScheduled(NativeActivityContext context, Bookmark bookmark, object value)
        {
            CompensationExtension extension = context.GetExtension <CompensationExtension>();
            long compensationId             = (long)value;
            CompensationTokenData data      = extension.Get(compensationId);

            if (data.CompensationState == CompensationState.Canceling)
            {
                data.BookmarkTable[CompensationBookmarkName.Canceled] = context.CreateBookmark(new BookmarkCallback(this.OnCanceledOrCompensated));
                extension.NotifyMessage(context, data.CompensationId, CompensationBookmarkName.OnCancellation);
            }
            else if (data.CompensationState == CompensationState.Compensating)
            {
                data.BookmarkTable[CompensationBookmarkName.Compensated] = context.CreateBookmark(new BookmarkCallback(this.OnCanceledOrCompensated));
                extension.NotifyMessage(context, data.CompensationId, CompensationBookmarkName.OnCompensation);
            }
        }
        protected override void Execute(NativeActivityContext context)
        {
            CompensationExtension extension = context.GetExtension <CompensationExtension>();
            CompensationToken     token     = this.Target.Get(context);
            CompensationTokenData data      = extension.Get(token.CompensationId);

            data.BookmarkTable[CompensationBookmarkName.Compensated] = context.CreateBookmark(new BookmarkCallback(this.OnCompensated));
            data.CompensationState = CompensationState.Compensating;
            extension.NotifyMessage(context, data.CompensationId, CompensationBookmarkName.OnCompensation);
        }
        private void InternalOnCompensationComplete(NativeActivityContext context, CompensationExtension compensationExtension, CompensationTokenData compensationToken)
        {
            switch (compensationToken.CompensationState)
            {
            case CompensationState.Compensating:
                compensationExtension.NotifyMessage(context, compensationToken.CompensationId, CompensationBookmarkName.Compensated);
                break;

            case CompensationState.Compensated:
                break;

            case CompensationState.Canceling:
                compensationExtension.NotifyMessage(context, compensationToken.CompensationId, CompensationBookmarkName.Canceled);
                return;

            default:
                return;
            }
        }
        private void OnConfirmationComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance)
        {
            CompensationExtension extension = context.GetExtension <CompensationExtension>();
            CompensationTokenData data      = extension.Get(this.compensationId.Get(context));

            if (completedInstance.State == ActivityInstanceState.Closed)
            {
                extension.NotifyMessage(context, data.CompensationId, CompensationBookmarkName.Confirmed);
            }
        }
Пример #9
0
        private void OnConfirmationComplete(NativeActivityContext context, ActivityInstance completedInstance)
        {
            Fx.Assert(context != null, "context must be valid");
            Fx.Assert(completedInstance != null, "completedInstance must be valid");

            CompensationExtension compensationExtension = context.GetExtension <CompensationExtension>();

            Fx.Assert(compensationExtension != null, "CompensationExtension must be valid");

            CompensationTokenData compensationToken = compensationExtension.Get(this.compensationId.Get(context));

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

            if (completedInstance.State == ActivityInstanceState.Closed)
            {
                compensationExtension.NotifyMessage(context, compensationToken.CompensationId, CompensationBookmarkName.Confirmed);
            }
        }
        private void OnConfirmationHandlerComplete(NativeActivityContext context, System.Activities.ActivityInstance completedInstance)
        {
            CompensationExtension extension = context.GetExtension <CompensationExtension>();
            CompensationTokenData tokenData = extension.Get(this.compensationId.Get(context));

            if (completedInstance.State == ActivityInstanceState.Closed)
            {
                this.currentCompensationToken.Set(context, new CompensationToken(tokenData));
                if (tokenData.ExecutionTracker.Count > 0)
                {
                    context.ScheduleActivity(this.DefaultConfirmation, new CompletionCallback(this.OnConfirmationComplete));
                }
                else
                {
                    extension.NotifyMessage(context, tokenData.CompensationId, CompensationBookmarkName.Confirmed);
                }
            }
        }
Пример #11
0
        private void OnConfirmation(NativeActivityContext context, Bookmark bookmark, object value)
        {
            CompensationExtension compensationExtension = context.GetExtension <CompensationExtension>();

            Fx.Assert(compensationExtension != null, "CompensationExtension must be valid");

            long compensationId = (long)value;

            Fx.Assert(compensationId != CompensationToken.RootCompensationId, "CompensationId must be passed when resuming the Completed bookmark");

            CompensationTokenData compensationToken = compensationExtension.Get(compensationId);

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

            Fx.Assert(compensationToken.CompensationState == CompensationState.Confirming, "CompensationState should be in Confirming state");

            if (TD.CompensationStateIsEnabled())
            {
                TD.CompensationState(compensationToken.DisplayName, compensationToken.CompensationState.ToString());
            }

            compensationToken.RemoveBookmark(context, CompensationBookmarkName.OnCancellation);
            compensationToken.RemoveBookmark(context, CompensationBookmarkName.OnCompensation);

            if (ConfirmationHandler != null)
            {
                context.ScheduleActivity(ConfirmationHandler, new CompletionCallback(OnConfirmationHandlerComplete), new FaultCallback(OnExceptionFromHandler));
            }
            else
            {
                this.currentCompensationToken.Set(context, new CompensationToken(compensationToken));
                if (compensationToken.ExecutionTracker.Count > 0)
                {
                    context.ScheduleActivity(DefaultConfirmation, new CompletionCallback(this.OnConfirmationComplete));
                }
                else
                {
                    compensationExtension.NotifyMessage(context, compensationToken.CompensationId, CompensationBookmarkName.Confirmed);
                }
            }
        }
Пример #12
0
        protected override void Execute(NativeActivityContext context)
        {
            CompensationExtension compensationExtension = context.GetExtension <CompensationExtension>();

            Fx.Assert(compensationExtension != null, "CompensationExtension must be valid");

            CompensationToken compensationToken = Target.Get(context);

            Fx.Assert(compensationToken != null, "CompensationToken must be valid");

            // The compensationToken should be a valid one at this point. Ensure its validated in Compensate activity.
            CompensationTokenData tokenData = compensationExtension.Get(compensationToken.CompensationId);

            Fx.Assert(tokenData != null, "The compensationToken should be a valid one at this point. Ensure its validated in Compensate activity.");

            Fx.Assert(tokenData.BookmarkTable[CompensationBookmarkName.Compensated] == null, "Bookmark should not be already initialized in the bookmark table.");
            tokenData.BookmarkTable[CompensationBookmarkName.Compensated] = context.CreateBookmark(new BookmarkCallback(OnCompensated));

            tokenData.CompensationState = CompensationState.Compensating;
            compensationExtension.NotifyMessage(context, tokenData.CompensationId, CompensationBookmarkName.OnCompensation);
        }
 void InternalOnCompensationComplete(NativeActivityContext context, CompensationExtension compensationExtension, CompensationTokenData compensationToken)
 {
     switch (compensationToken.CompensationState)
     {
         case CompensationState.Canceling:
             compensationExtension.NotifyMessage(context, compensationToken.CompensationId, CompensationBookmarkName.Canceled);
             break;
         case CompensationState.Compensating:
             compensationExtension.NotifyMessage(context, compensationToken.CompensationId, CompensationBookmarkName.Compensated);
             break;
         default:
             Fx.Assert(false, "CompensationState is in unexpected state!");
             break;
     }
 }