コード例 #1
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.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);
        }
コード例 #2
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);
        }