예제 #1
0
        public void ResumeWorkflow(NativeActivityContext context, Bookmark bookmark, Object workflowManager)
        {
            // REMOVE THE BOOKMARK SO THAT IT CAN BE USED AGAIN

            context.RemoveBookmark(context.WorkflowInstanceId.ToString());


            // RESET WORKFLOW MANAGER INSTANCE

            WorkflowManager.Set(context, workflowManager);

            WorkflowManager.Get(context).WorkflowStatus = WorkflowStatus.Resumed;


            // RECORD WORKFLOW STEPS

            Workflows.Activities.CommonFunctions.WorkflowStepsAdd(

                WorkflowManager.Get(context).Application,

                1,

                WorkQueueItem.Get(context).Id,

                WorkflowSteps.Get(context),

                "Resume Workflow"

                );

            return;
        }
        protected override void Execute(NativeActivityContext context)
        {
            // RECORD WORKFLOW STEPS

            Workflows.Activities.CommonFunctions.WorkflowStepsAdd(

                WorkflowManager.Get(context).Application,

                1,

                WorkQueueItemId.Get(context),

                WorkflowSteps.Get(context),

                "User Interaction Request: " + Server.CommonFunctions.EnumerationToString(Request.Get(context).UserInteractionType)

                );

            // SAVE WORKFLOW STEPS

            WorkflowManager.Get(context).Application.WorkQueueItemWorkflowStepsSave(WorkQueueItemId.Get(context), WorkflowSteps.Get(context));


            // SET USER INTERACTION REQUEST IN THE WORKFLOW MANAGER

            WorkflowManager.Get(context).UserInteractionRequest = Request.Get(context);


            // CREATE A BOOKMARK SET TO THE WORKFLOW INSTANCE ID TO MAKE IT UNIQUE

            context.CreateBookmark(context.WorkflowInstanceId.ToString(), new BookmarkCallback(this.ReceiveResponse));

            return;
        }
예제 #3
0
        protected override void Execute(CodeActivityContext context)
        {
            // TODO: VALIDATE ENTITY OR THROW EXCEPTION


            Workflows.UserInteractions.Request.RequireFormRequest request = new UserInteractions.Request.RequireFormRequest();

            request.EntityType = Entity.Get(context).EntityType;

            request.EntityObjectId = WorkflowManager.Get(context).Application.EntityObjectIdGet(Entity.Get(context));


            if (Form.Get(context) == null)
            {
                // LOAD FORM BY NAME (NO FORM WAS PASSED FROM PARENT ACTIVITY)

                request.Form = new Core.Forms.Form(WorkflowManager.Get(context).Application, FormName.Get(context));

                if (request.Form == null)
                {
                    CommonFunctions.RaiseActivityException(  // THROW EXCEPTION

                        WorkflowManager.Get(context).Application,

                        1,

                        WorkQueueItemId.Get(context),

                        WorkflowSteps.Get(context),

                        "Unable to load form for " + FormName.Get(context) + "."

                        );
                }

                request.Form.EntityType = request.EntityType;

                request.Form.EntityObjectId = request.EntityObjectId;
            }

            else
            {
                request.Form = Form.Get(context);
            }                                           // USE FORM PASSED IN FROM PARENT ACTIVITY

            request.Form.FormType = Core.Forms.Enumerations.FormType.Instance;


            request.Message = "Form Required: " + request.Form.Name + " (Last Modified: " + request.Form.ModifiedAccountInfo.ActionDate.ToString("MM/dd/yyyy") + ")";

            request.AllowSaveAsDraft = AllowSaveAsDraft.Get(context);

            request.AllowCancel = AllowCancel.Get(context);


            UserInteractionRequest.Set(context, request);

            return;
        }
        public void ReceiveResponse(NativeActivityContext context, Bookmark bookmark, Object workflowManager)
        {
            // REMOVE THE BOOKMARK SO THAT IT CAN BE USED AGAIN

            context.RemoveBookmark(context.WorkflowInstanceId.ToString());


            // RESET WORKFLOW MANAGER INSTANCE

            WorkflowManager.Set(context, workflowManager);

            Response.Set(context, WorkflowManager.Get(context).UserInteractionResponse);


            // RECORD WORKFLOW STEPS

            if (Response.Get(context) != null)
            {
                Workflows.Activities.CommonFunctions.WorkflowStepsAdd(

                    WorkflowManager.Get(context).Application,

                    1,

                    WorkQueueItemId.Get(context),

                    WorkflowSteps.Get(context),

                    "User Interaction Response: " + Server.CommonFunctions.EnumerationToString(Response.Get(context).UserInteractionType)

                    );
            }

            else
            {
                Workflows.Activities.CommonFunctions.WorkflowStepsAdd(

                    WorkflowManager.Get(context).Application,

                    1,

                    WorkQueueItemId.Get(context),

                    WorkflowSteps.Get(context),

                    "User Interaction Response: Unknown Response"

                    );
            }
            return;
        }
예제 #5
0
        protected override void Execute(CodeActivityContext context)
        {
            CommonFunctions.WorkflowStepsAdd(

                Application.Get(context),

                StackDepth.Get(context),

                WorkQueueItemId.Get(context),

                WorkflowSteps.Get(context),

                Status.Get(context),

                Description.Get(context)

                );


            return;
        }
        protected override void Execute(CodeActivityContext context)
        {
            ActivityCompleted.Set(context, false);

            ActivityCanceled.Set(context, false);


            if (UserInteractionResponse.Get(context).UserInteractionType == UserInteractions.Enumerations.UserInteractionType.RequireForm)
            {
                Workflows.UserInteractions.Response.RequireFormResponse response = (UserInteractions.Response.RequireFormResponse)UserInteractionResponse.Get(context);


                if ((response.Form != null) && (!response.SaveAsDraft) && (!response.Cancel))
                {
                    Form.Set(context, response.Form);

                    Form.Get(context).ResetForm(WorkflowManager.Get(context).Application);

                    FormReceived.Set(context, true);

                    ActivityCompleted.Set(context, true);

                    Activities.CommonFunctions.WorkflowStepsAdd(

                        WorkflowManager.Get(context).Application,

                        1,

                        WorkQueueItemId.Get(context),

                        WorkflowSteps.Get(context),

                        Form.Get(context).Name

                        );
                }

                else if (response.SaveAsDraft)
                {
                    Form.Set(context, response.Form);

                    Form.Get(context).ResetForm(WorkflowManager.Get(context).Application);
                }

                else if (response.Cancel)
                {
                    Activities.CommonFunctions.WorkflowStepsAdd(

                        WorkflowManager.Get(context).Application,

                        1,

                        WorkQueueItemId.Get(context),

                        WorkflowSteps.Get(context),

                        "Form Canceled."

                        );


                    ActivityCompleted.Set(context, true);

                    ActivityCanceled.Set(context, true);
                }

                SaveAsDraft.Set(context, response.SaveAsDraft);
            }
        }
예제 #7
0
        protected override void Execute(NativeActivityContext context)
        {
            // RESET APPLICATION REFERENCE ON WORK QUEUE ITEM

            WorkQueueItem.Get(context).Application = WorkflowManager.Get(context).Application;


            // ENSURE THAT THE ITEM IS ASSIGNED TO USER

            WorkQueueItem.Get(context).SelfAssign("Workflow Suspend Work Queue Item", false);


            // ATTEMPT TO SUSPEND THE ITEM

            Success.Set(context, WorkQueueItem.Get(context).Suspend(

                            WorkflowLastStep.Get(context),

                            WorkflowNextStep.Get(context),

                            ConstraintDays.Get(context),

                            MilestoneDays.Get(context),

                            ReleaseItem.Get(context)

                            ));


            if (!Success.Get(context))    // THROW EXCEPTION IF UNABLE TO SUSPEND

            {
                CommonFunctions.RaiseActivityException(WorkflowManager.Get(context).Application,

                                                       1,

                                                       WorkQueueItem.Get(context).Id,

                                                       WorkflowSteps.Get(context),

                                                       WorkflowManager.Get(context).Application.LastException.Message

                                                       );
            }

            // RECORD WORKFLOW STEPS

            Workflows.Activities.CommonFunctions.WorkflowStepsAdd(

                WorkflowManager.Get(context).Application,

                1,

                WorkQueueItem.Get(context).Id,

                WorkflowSteps.Get(context),

                "Suspend for Next Step: " + WorkflowNextStep.Get(context) +

                "  |  Constraint Days: " + ConstraintDays.Get(context).ToString() +

                "  |  Milestone Days: " + MilestoneDays.Get(context).ToString()

                );


            // SAVE WORKFLOW STEPS

            WorkflowManager.Get(context).Application.WorkQueueItemWorkflowStepsSave(WorkQueueItem.Get(context).Id, WorkflowSteps.Get(context));


            // EVALUATE IF WE WANT TO SUSPEND THE WORKFLOW TOO, OR JUST THE WORKFLOW ITEM AND LET THE WORKFLOW CONTINUE

            if (SuspendWorkflow.Get(context))
            {
                // MARK WORKFLOW AS SUSPEND USING WORKFLOW MANAGER

                WorkflowManager.Get(context).WorkflowStatus = WorkflowStatus.Suspended;


                // CREATE A BOOKMARK SET TO THE WORKFLOW INSTANCE ID TO MAKE IT UNIQUE

                context.CreateBookmark(context.WorkflowInstanceId.ToString(), new BookmarkCallback(this.ResumeWorkflow));
            }

            return;
        }
        protected override void Execute(CodeActivityContext context)
        {
            ActivityCompleted.Set(context, false);

            ActivityCanceled.Set(context, false);


            if (UserInteractionResponse.Get(context).UserInteractionType == UserInteractions.Enumerations.UserInteractionType.Prompt)
            {
                Workflows.UserInteractions.Response.PromptUserResponse response = (UserInteractions.Response.PromptUserResponse)UserInteractionResponse.Get(context);


                if (response.ButtonClicked != UserInteractions.Enumerations.UserPromptButtonClicked.None)
                {
                    ButtonClicked.Set(context, response.ButtonClicked);



                    if (response.InputText == null)
                    {
                        response.InputText = String.Empty;
                    }

                    InputText.Set(context, response.InputText);


                    if (response.SelectedValue == null)
                    {
                        response.SelectedValue = String.Empty;
                    }

                    SelectedValue.Set(context, response.SelectedValue);


                    if (response.SelectedText == null)
                    {
                        response.SelectedText = String.Empty;
                    }

                    SelectedText.Set(context, response.SelectedText);


                    Activities.CommonFunctions.WorkflowStepsAdd(

                        WorkflowManager.Get(context).Application,

                        1,

                        WorkQueueItemId.Get(context),

                        WorkflowSteps.Get(context),

                        "Button Clicked: " + ButtonClicked.Get(context).ToString() + "  |  Selected Text = " + SelectedText.Get(context).ToString()

                        );


                    // IF USER DID NOT CANCEL, OR THEY DID CANCEL AND CANCEL ALLOWED, MARK COMPLETED

                    if ((response.ButtonClicked != UserInteractions.Enumerations.UserPromptButtonClicked.Cancel)

                        || ((response.ButtonClicked == UserInteractions.Enumerations.UserPromptButtonClicked.Cancel) && (AllowCancel.Get(context))))
                    {
                        ActivityCompleted.Set(context, true);
                    }
                }
            }
        }
예제 #9
0
        protected override void Execute(CodeActivityContext context)
        {
            if (UserInteractionResponse.Get(context) == null)
            {
                return;
            }                                                              // VALIDATE RESPONSE WAS RECEIVED, OTHERWISE LOOP REQUEST


            ActivityCompleted.Set(context, false);

            ActivityCanceled.Set(context, false);

            if (UserInteractionResponse.Get(context).UserInteractionType == UserInteractions.Enumerations.UserInteractionType.ContactEntity)
            {
                Workflows.UserInteractions.Response.ContactEntityResponse response = (UserInteractions.Response.ContactEntityResponse)UserInteractionResponse.Get(context);


                if ((!response.Cancel) || (!AllowCancel.Get(context)))
                {
                    //if ((response.ContactType != Mercury.Server.Core.Enumerations.EntityContactType.NotSpecified) &&
                    //    (response.ContactOutcome != Mercury.Server.Core.Enumerations.ContactOutcome.NotSpecified)) {

                    if ((response.EntityContact.ContactType != Mercury.Server.Core.Enumerations.EntityContactType.NotSpecified) &&
                        (response.EntityContact.ContactOutcome != Mercury.Server.Core.Enumerations.ContactOutcome.NotSpecified))
                    {
                        #region Contact Received

                        // Core.Entity.EntityContact entityContact = new Mercury.Server.Core.Entity.EntityContact (WorkflowManager.Get (context).Application);

                        Core.Entity.EntityContact entityContact = response.EntityContact;

                        entityContact.Application = WorkflowManager.Get(context).Application;


                        if (!AllowEditContactDateTime.Get(context))
                        {
                            entityContact.ContactDate = DateTime.Now;
                        }

                        //else {

                        //    entityContact.ContactDate = response.EntityContact.ContactDate;

                        //}


                        //entityContact.EntityId = (response.Entity != null) ? response.Entity.Id : 0;

                        //entityContact.RelatedEntityId = (response.RelatedEntity != null) ? response.RelatedEntity.Id : 0;

                        //entityContact.EntityContactInformationId = response.EntityContactInformationId;


                        //entityContact.Direction = response.Direction;

                        //entityContact.ContactType = response.ContactType;


                        //entityContact.ContactOutcome = response.ContactOutcome;

                        //entityContact.Successful = (response.ContactOutcome == Mercury.Server.Core.Enumerations.ContactOutcome.Success);


                        //entityContact.Regarding = response.Regarding;

                        //entityContact.Remarks = response.Remarks;



                        entityContact.ContactedByName = WorkflowManager.Get(context).Application.Session.UserDisplayName;



                        if (AutoSaveContact.Get(context))
                        {
                            ActivityCompleted.Set(context, entityContact.Save());
                        }

                        else
                        {
                            ActivityCompleted.Set(context, true);
                        }

                        EntityContact.Set(context, entityContact);


                        if (ActivityCompleted.Get(context))
                        {
                            ContactAttempts.Set(context, ContactAttempts.Get(context) + 1);

                            ContactSuccess.Set(context, entityContact.Successful);

                            ContactOutcome.Set(context, entityContact.ContactOutcome);

                            Activities.CommonFunctions.WorkflowStepsAdd(

                                WorkflowManager.Get(context).Application,

                                1,

                                WorkQueueItemId.Get(context),

                                WorkflowSteps.Get(context),

                                "Contact Outcome: " + ContactOutcome.Get(context).ToString() + "  |  # of Attempts = " + ContactAttempts.Get(context).ToString()

                                );
                        }

                        else
                        {
                            Activities.CommonFunctions.RaiseActivityException(

                                WorkflowManager.Get(context).Application,

                                1,

                                WorkQueueItemId.Get(context),

                                WorkflowSteps.Get(context),

                                "Unable to save contact information."

                                );
                        }

                        #endregion
                    }
                }

                else
                {
                    // CONTACT CANCELED

                    EntityContact.Set(context, null);

                    ActivityCanceled.Set(context, true);

                    ActivityCompleted.Set(context, true);
                }
            }
        }