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


            Int64 forWorkQueueId = 0;


            if ((!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.WorkQueueReview))

                && (!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.WorkQueueManage)))

            {
                Response.Redirect("/PermissionDenied.aspx", true); return;
            }


            if (!Page.IsPostBack)
            {
                #region Initial Page Load

                if (Request.QueryString["WorkQueueId"] != null)
                {
                    forWorkQueueId = Int64.Parse(Request.QueryString["WorkQueueId"]);
                }

                if (forWorkQueueId != 0)
                {
                    workQueue = MercuryApplication.WorkQueueGet(forWorkQueueId, false);

                    if (workQueue == null)
                    {
                        workQueue = new Mercury.Client.Core.Work.WorkQueue(MercuryApplication);
                    }

                    Page.Title = "Work Queue - " + workQueue.Name;
                }

                else
                {
                    workQueue = new Mercury.Client.Core.Work.WorkQueue(MercuryApplication);
                }

                InitializeAll();

                Session[SessionCachePrefix + "WorkQueue"] = workQueue;

                Session[SessionCachePrefix + "WorkQueueUnmodified"] = workQueue.Copy();

                #endregion
            } // Initial Page Load

            else   // Postback

            {
                workQueue = (Mercury.Client.Core.Work.WorkQueue)Session[SessionCachePrefix + "WorkQueue"];
            }

            ApplySecurity();

            if (!String.IsNullOrEmpty(workQueue.Name))
            {
                Page.Title = "Work Queue - " + workQueue.Name;
            }
            else
            {
                Page.Title = "New Work Queue";
            }

            return;
        }
        protected Boolean ApplyChanges()
        {
            Boolean success = false;

            Boolean isModified = false;

            Boolean isValid = false;

            Dictionary <String, String> validationResponse;


            if (MercuryApplication == null)
            {
                return(false);
            }


            Mercury.Client.Core.Work.WorkQueue workQueueUnmodified = (Mercury.Client.Core.Work.WorkQueue)Session[SessionCachePrefix + "WorkQueueUnmodified"];


            workQueue.Name = WorkQueueName.Text;

            workQueue.Description = WorkQueueDescription.Text;

            workQueue.Enabled = WorkQueueEnabled.Checked;

            workQueue.Visible = WorkQueueVisible.Checked;

            workQueue.WorkflowId = (WorkQueueWorkflow.SelectedItem != null) ? Convert.ToInt64(WorkQueueWorkflow.SelectedValue) : 0;


            workQueue.GetWorkViewId = (GetWorkViewSelection.SelectedItem != null) ? Convert.ToInt64(GetWorkViewSelection.SelectedValue) : 0;

            workQueue.GetWorkUseGrouping = GetWorkUseGrouping.Checked;


            workQueue.ScheduleValue = Convert.ToInt32(WorkQueueScheduleValue.Text);

            workQueue.ScheduleQualifier = (Mercury.Server.Application.DateQualifier)Convert.ToInt32(WorkQueueScheduleQualifier.SelectedValue);

            workQueue.ThresholdValue = Convert.ToInt32(WorkQueueThresholdValue.Text);

            workQueue.ThresholdQualifier = (Mercury.Server.Application.DateQualifier)Convert.ToInt32(WorkQueueThresholdQualifier.SelectedValue);


            workQueue.InitialConstraintValue = Convert.ToInt32(WorkQueueInitialConstraintValue.Text);

            workQueue.InitialConstraintQualifier = (Mercury.Server.Application.DateQualifier)Convert.ToInt32(WorkQueueInitialConstraintQualifier.SelectedValue);

            workQueue.InitialMilestoneValue = Convert.ToInt32(WorkQueueInitialMilestoneValue.Text);

            workQueue.InitialMilestoneQualifier = (Mercury.Server.Application.DateQualifier)Convert.ToInt32(WorkQueueInitialMilestoneQualifier.SelectedValue);


            if (workQueueUnmodified.Id == 0)
            {
                isModified = true;
            }

            if (!isModified)
            {
                isModified = !workQueue.IsEqual(workQueueUnmodified);
            }


            validationResponse = workQueue.Validate();

            isValid = (validationResponse.Count == 0);


            if ((isModified) && (isValid))
            {
                if (!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.WorkQueueManage))
                {
                    SaveResponseLabel.Text = "Permission Denied.";

                    return(false);
                }

                success = MercuryApplication.WorkQueueSave(workQueue);

                if (success)
                {
                    workQueue = MercuryApplication.WorkQueueGet(workQueue.Id, false);

                    Session[SessionCachePrefix + "WorkQueue"] = workQueue;

                    Session[SessionCachePrefix + "WorkQueueUnmodified"] = workQueue.Copy();

                    SaveResponseLabel.Text = "Save Successful.";

                    InitializeAll();
                }

                else
                {
                    SaveResponseLabel.Text = "Unable to Save.";

                    if (MercuryApplication.LastException != null)
                    {
                        SaveResponseLabel.Text = SaveResponseLabel.Text + " [" + MercuryApplication.LastException.Message + "]";
                    }

                    success = false;
                }
            }

            else if (!isModified)
            {
                SaveResponseLabel.Text = "No Changes Detected."; success = true;
            }

            else if (!isValid)
            {
                foreach (String validationKey in validationResponse.Keys)
                {
                    SaveResponseLabel.Text = "Invalid [" + validationKey + "]: " + validationResponse[validationKey];

                    break;
                }

                success = false;
            }

            return(success);
        }
Example #3
0
        protected Boolean ApplyChanges()
        {
            Boolean success = false;

            Boolean isModified = false;

            Boolean isValid = false;

            Dictionary <String, String> validationResponse;


            if (MercuryApplication == null)
            {
                return(false);
            }


            Mercury.Client.Core.Work.WorkQueue workQueueUnmodified = (Mercury.Client.Core.Work.WorkQueue)Session[SessionCachePrefix + "WorkQueueUnmodified"];


            workQueue.GetWorkViewId = (GetWorkViewSelection.SelectedItem != null) ? Convert.ToInt64(GetWorkViewSelection.SelectedValue) : 0;

            workQueue.GetWorkUseGrouping = GetWorkUseGrouping.Checked;


            // USER VIEWS ARE UPDATED IN THEIR OWN EVENT CYCLE


            if (!isModified)
            {
                isModified = !workQueue.IsEqual(workQueueUnmodified);
            }

            validationResponse = workQueue.Validate();

            isValid = (validationResponse.Count == 0);


            if ((isModified) && (isValid))
            {
                success = MercuryApplication.WorkQueueSaveGetWork(workQueue);

                if (success)
                {
                    workQueue = MercuryApplication.WorkQueueGet(workQueue.Id, false);

                    Session[SessionCachePrefix + "WorkQueue"] = workQueue;

                    Session[SessionCachePrefix + "WorkQueueUnmodified"] = workQueue.Copy();

                    SaveResponseLabel.Text = "Save Successful.";

                    InitializeAll();
                }

                else
                {
                    SaveResponseLabel.Text = "Unable to Save.";

                    if (MercuryApplication.LastException != null)
                    {
                        SaveResponseLabel.Text = SaveResponseLabel.Text + " [" + MercuryApplication.LastException.Message + "]";
                    }

                    success = false;
                }
            }

            else if (!isModified)
            {
                SaveResponseLabel.Text = "No Changes Detected."; success = true;
            }

            else if (!isValid)
            {
                foreach (String validationKey in validationResponse.Keys)
                {
                    SaveResponseLabel.Text = "Invalid [" + validationKey + "]: " + validationResponse[validationKey];

                    break;
                }

                success = false;
            }

            return(success);
        }