Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        private void WorkQueueItemSuspendWithAssignment_OnExecuteCode(object sender, EventArgs e)
        {
            Success = false;

            if (WorkflowSteps == null)
            {
                WorkflowSteps = new System.Collections.Generic.List <Mercury.Server.Workflows.WorkflowStep> ();
            }


            //Server.Core.Work.WorkQueueItem workQueueItem = Application.WorkQueueItemGet (WorkQueueItemId);

            //if (workQueueItem == null) { RaiseActivityException ("Unable to retreive Work Queue Item [" + WorkQueueItemId.ToString () + "]."); }


            // SUSPEND

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

            Success = WorkQueueItem.Suspend(WorkflowLastStep, WorkflowNextStep, ConstraintDays, MilestoneDays, ReleaseItem);

            if (!Success)
            {
                RaiseActivityException(Application.LastException.Message);
            }


            // ASSIGNMENT

            Success = WorkQueueItem.AssignTo(AssignedToSecurityAuthorityId, AssignedToUserAccountId, AssignedToUserAccountName, AssignedToUserDisplayName, AssignmentSource, false);

            if (!Success)
            {
                RaiseActivityException(Application.LastException.Message);
            }

            WorkflowStepsAdd("Assigned To: " + AssignedToUserDisplayName);


            WorkflowStepsAdd("Suspend for Next Step: " + WorkflowNextStep + "  |  Constraint Days: " + ConstraintDays.ToString() + "  |  Milestone Days: " + MilestoneDays.ToString());

            Application.WorkQueueItemWorkflowStepsSave(WorkQueueItem.Id, WorkflowSteps);

            // WorkflowSteps = WorkQueueItem.WorkflowStepsGet ();

            return;
        }