protected void WorkQueueItemAssignWindow_ButtonOk_OnClick(Object sender, EventArgs e)
        {
            if (MercuryApplication == null)
            {
                return;
            }


            Boolean success = false;

            String responseScript = "$find(\"" + WorkQueueItemAssignWindow.ClientID + "\").close ();";

            String postScript = String.Empty;


            Int64 workQueueItemId = 0;


            // RE-ASSIGN WORK QUEUE ITEM

            if (Int64.TryParse(WorkQueueItemAssignId.Text, out workQueueItemId))
            {
                Int64 assignedToWorkQueueId = Int64.Parse(WorkQueueItemAssignWorkQueueSelection.SelectedValue);

                Int64 assignedToSecurityAuthorityId = Int64.Parse(WorkQueueItemAssignUserSelection.SelectedValue.Split('|')[0]);

                String assignedToUserAccountId = WorkQueueItemAssignUserSelection.SelectedValue.Split('|')[1];

                String assignedToUserAccountName = WorkQueueItemAssignUserSelection.SelectedValue.Split('|')[2];

                String assignedToUserDisplayName = (WorkQueueItemAssignUserSelection.Text.Split(':').Length >= 2) ? WorkQueueItemAssignUserSelection.Text.Split(':')[1] : String.Empty;


                Client.Core.Work.WorkQueueItem workQueueItem = MercuryApplication.WorkQueueItemGet(workQueueItemId);

                if (assignedToWorkQueueId != workQueueItem.WorkQueueId)
                {
                    success = workQueueItem.MoveToQueue(assignedToWorkQueueId);

                    if (!success)
                    {
                        postScript = ("alert (\"" + MercuryApplication.LastException.Message.Replace("\"", "\\") + "\");");
                    }
                }

                else
                {
                    success = true;
                }

                if (success)
                {
                    success = workQueueItem.AssignTo(assignedToSecurityAuthorityId, assignedToUserAccountId, assignedToUserAccountName, assignedToUserDisplayName, "Work Queue Management - Direct Assignment");
                }
            }

            else
            {
                responseScript += "alert('Unable to parse the Work Queue Item Id.');";
            }


            // REBIND DATE GRID

            WorkQueueItemsGrid.DataSource = null;

            WorkQueueItemsGrid.Rebind();


            // CLIENT-SIDE CLOSE DIALOG WINDOW

            Master.TelerikAjaxManagerControl.ResponseScripts.Add(responseScript + postScript);

            return;
        }
Exemplo n.º 2
0
        private void InitialPageLoadInitialization()
        {
            // SAVE REFERRER SO THAT THE APPLICATION CAN RETURN TO IT AFTER COMPLETING THE WORKFLOW

            if (String.IsNullOrWhiteSpace(ReferrerUrl))    // ONLY RELOAD IF CURRENT SAVE SESSION IS EMPTY REFERRER

            {
                if (Request.UrlReferrer != null)
                {
                    ReferrerUrl = Request.UrlReferrer.ToString();
                }

                else
                {
                    ReferrerUrl = "/Application/Workspace/Workspace.aspx";
                }
            }


            // INITIALIZE WORKFLOW

            String workflowName = (String)Request.QueryString["Workflow"];

            Int64 currentWorkflowId = 0;


            if (!String.IsNullOrWhiteSpace(workflowName))
            {
                CurrentWorkflow = MercuryApplication.WorkflowGet(workflowName, false);
            }

            else
            {
                if (Int64.TryParse((String)Request.QueryString["WorkflowId"], out currentWorkflowId))
                {
                    CurrentWorkflow = MercuryApplication.WorkflowGet(currentWorkflowId, true);

                    if (CurrentWorkflow != null)
                    {
                        workflowName = CurrentWorkflow.Name;
                    }
                }
            }


            if (!String.IsNullOrEmpty((String)Request.QueryString["WorkflowInstanceId"]))
            {
                // RESUME EXISTING WORKFLOW

                WorkflowInstanceId = new Guid((String)Request.QueryString["WorkflowInstanceId"]);

                CurrentWorkflow = MercuryApplication.WorkflowGet(workflowName, false);

                if (CurrentWorkflow == null)
                {
                    CurrentWorkflow = MercuryApplication.WorkflowGet(currentWorkflowId, true);
                }

                if (CurrentWorkflow != null)
                {
                    WorkflowTitleLabel.Text = "Workflow: " + CurrentWorkflow.Name + ((!String.IsNullOrEmpty(CurrentWorkflow.Description)) ? " [" + CurrentWorkflow.Description + "]" : String.Empty);

                    TelerikAjaxManager.ResponseScripts.Add(ResponseScriptWorkflowResume);
                }

                else
                {
                    WorkflowTitleLabel.Text = "Workflow Engine";

                    WorkflowExceptionMessageRow.Style.Clear();

                    WorkflowExceptionMessage.Text = "Workflow Exception: Unable to Load Workflow.";
                }
            }

            else
            {
                Boolean canWork = true;

                Int64 workQueueItemId;

                if (Int64.TryParse((String)Request.QueryString["WorkQueueItemId"], out workQueueItemId))
                {
                    canWork = false;

                    Client.Core.Work.WorkQueueItem workQueueItem = MercuryApplication.WorkQueueItemGet(workQueueItemId);

                    if (workQueueItem != null)
                    {
                        if ((workQueueItem.AssignedToSecurityAuthorityId == MercuryApplication.Session.SecurityAuthorityId)

                            && (workQueueItem.AssignedToUserAccountId == MercuryApplication.Session.UserAccountId))
                        {
                            canWork = true;
                        }

                        else if (workQueueItem.AssignTo(MercuryApplication.Session.SecurityAuthorityId, MercuryApplication.Session.UserAccountId, MercuryApplication.Session.UserAccountName, MercuryApplication.Session.UserDisplayName, "Member Profile - Work History"))
                        {
                            canWork = true;
                        }
                    }

                    if (canWork)
                    {
                        Server.Application.WorkflowStartRequest startRequest = WorkflowStartRequest;

                        startRequest.WorkQueueItemId = workQueueItemId;

                        WorkflowStartRequest = startRequest;
                    }
                }

                if ((canWork) && (CurrentWorkflow != null))
                {
                    WorkflowTitleLabel.Text = "Workflow: " + CurrentWorkflow.Name + ((!String.IsNullOrEmpty(CurrentWorkflow.Description)) ? " [" + CurrentWorkflow.Description + "]" : String.Empty);

                    Page.ClientScript.RegisterStartupScript(this.GetType(), "StartWorkflow", ResponseScriptWorkflowStart);
                }

                else if (!canWork)
                {
                    WorkflowTitleLabel.Text = "Workflow Engine";

                    WorkflowExceptionMessageRow.Style.Clear();

                    WorkflowExceptionMessage.Text = "Permission Denied: Unable to perform work on the selected Work Queue Item. This Item might already be owned. Please try again.";
                }

                else
                {
                    WorkflowTitleLabel.Text = "Workflow Engine";

                    WorkflowExceptionMessageRow.Style.Clear();

                    WorkflowExceptionMessage.Text = "Workflow Exception: " + MercuryApplication.LastException;
                }
            }

            return;
        }