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.WorkQueueView workQueueViewUnmodified = (Mercury.Client.Core.Work.WorkQueueView)Session[SessionCachePrefix + "WorkQueueViewUnmodified"]; workQueueView.Name = WorkQueueViewName.Text; workQueueView.Description = WorkQueueViewDescription.Text; workQueueView.Enabled = WorkQueueViewEnabled.Checked; workQueueView.Visible = WorkQueueViewVisible.Checked; if (workQueueViewUnmodified.Id == 0) { isModified = true; } if (!isModified) { isModified = !workQueueView.IsEqual(workQueueViewUnmodified); } validationResponse = workQueueView.Validate(); isValid = (validationResponse.Count == 0); if ((isModified) && (isValid)) { if (!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.WorkQueueViewManage)) { SaveResponseLabel.Text = "Permission Denied."; return(false); } success = MercuryApplication.WorkQueueViewSave(workQueueView); if (success) { workQueueView = MercuryApplication.WorkQueueViewGet(workQueueView.Id, false); Session[SessionCachePrefix + "WorkQueueView"] = workQueueView; Session[SessionCachePrefix + "WorkQueueViewUnmodified"] = workQueueView.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); }
protected void Page_Load(object sender, EventArgs e) { if (MercuryApplication == null) { return; } Int64 forWorkQueueViewId = 0; if ((!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.WorkQueueViewReview)) && (!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.WorkQueueViewManage))) { Response.Redirect("/PermissionDenied.aspx", true); return; } if (!Page.IsPostBack) { #region Initial Page Load if (Request.QueryString["WorkQueueViewId"] != null) { forWorkQueueViewId = Int64.Parse(Request.QueryString["WorkQueueViewId"]); } if (forWorkQueueViewId != 0) { workQueueView = MercuryApplication.WorkQueueViewGet(forWorkQueueViewId, false); if (workQueueView == null) { workQueueView = new Mercury.Client.Core.Work.WorkQueueView(MercuryApplication); } Page.Title = "Work Queue View - " + workQueueView.Name; } else { workQueueView = new Mercury.Client.Core.Work.WorkQueueView(MercuryApplication); } InitializeAll(); Session[SessionCachePrefix + "WorkQueueView"] = workQueueView; Session[SessionCachePrefix + "WorkQueueViewUnmodified"] = workQueueView.Copy(); #endregion } // Initial Page Load else // Postback { workQueueView = (Mercury.Client.Core.Work.WorkQueueView)Session[SessionCachePrefix + "WorkQueueView"]; } ApplySecurity(); if (!String.IsNullOrEmpty(workQueueView.Name)) { Page.Title = "Work Queue View - " + workQueueView.Name; } else { Page.Title = "New Work Queue View"; } return; }