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);
                    }
                }
            }
        }
        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);
            }
        }
Example #3
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);
                }
            }
        }