protected void Page_Load(object sender, EventArgs e) { (Page as DefaultPage).Body = " onresize=\"ResizeElements('all');\""; AdminPanelUtils.ShowReportAndReportMessages(Page); bool result = CheckDB(); if (result) { string mode = (!string.IsNullOrEmpty(Request.QueryString["mode"]) ? Request.QueryString["mode"] : "domains"); domains_management domainsControl = (domains_management)LoadControl(@"domains.ascx"); if (domainsControl != null) { if (!string.IsNullOrEmpty(Request.QueryString["asc"])) { domainsControl.Asc = (string.Compare(Request.QueryString["asc"], "true", true, CultureInfo.InvariantCulture) == 0) ? true : false; } if (!string.IsNullOrEmpty(Request.QueryString["order"])) { domainsControl.OrderBy = Request.QueryString["order"]; } ContentPlaceHolder.Controls.Add(domainsControl); } try { switch (mode) { case "new": if (AdminPanelUtils.IsSuperAdmin(Page.Session, (Page as DefaultPage).Settings)) { Control ctrl = LoadControl(@"domain-edit.ascx"); if (ctrl != null) { domainsControl.FindControl("PlaceHolderDomain").Controls.Add(ctrl); } } break; case "edit": { if ((!string.IsNullOrEmpty(Request.QueryString["name"])) || (!string.IsNullOrEmpty(Request.QueryString["uid"]))) { Control ctrl = LoadControl(@"domain-edit.ascx"); if (ctrl != null) { domainsControl.FindControl("PlaceHolderDomain").Controls.Add(ctrl); } } } break; case "close_search": { AdminPanelUtils.SaveState("wm_adm_dm_condition", null, Page.Session); Response.Redirect(string.Format(@"default.aspx?mode=domains"), false); } break; } if (Page.IsPostBack) { AdminPanelUtils.SaveState("Page", Request[domainsControl.FindControl("HFPageInfo").UniqueID].ToString(), Page.Session); string action = Request[domainsControl.FindControl("HFAction").UniqueID].ToString(); string value = Request[domainsControl.FindControl("HFValue").UniqueID].ToString(); switch (action) { case "sort": if (value != "") { bool sortOrder = true; AdminPanelUtils.SaveState("wm_adm_dm_order", value, Page.Session); if (Session["wm_adm_dmAsc"] != null) { sortOrder = bool.Parse(Session["wm_adm_dmAsc"].ToString()); } Session["wm_adm_dmAsc"] = !sortOrder; } Response.Redirect(Request.RawUrl, false); break; case "search": AdminPanelUtils.SaveState("wm_adm_dm_condition", value, Page.Session); Response.Redirect(string.Format(@"default.aspx?mode=domains"), false); break; case "delete": if (AdminPanelUtils.IsSuperAdmin(Page.Session, (Page as DefaultPage).Settings)) { try { string[] values = value.Split(','); foreach (string val in values) { SelectedValueStruct sds = AdminPanelUtils.ParseSelectedValue(HttpUtility.UrlDecode(val)); DeleteDomain(sds.Name, sds.Type); if (AdminPanelUtils.LoadState("selectedDomain", Page.Session) != null && AdminPanelUtils.LoadState("selectedDomain", Page.Session).ToString() == val) { AdminPanelUtils.SaveState("selectedDomain", null, Page.Session); } } AdminPanelUtils.SaveState("SessPageReportMessage", WebMail.Constants.mailAdmUpdateAccountSuccess, Page.Session); } catch { AdminPanelUtils.SaveState("SessPageErrorMessage", WebMail.Constants.mailAdmUpdateAccountUnsuccess, Page.Session); } Response.Redirect(string.Format(@"default.aspx?mode=domains"), false); } break; } } } catch (Exception ex) { Log.WriteException(ex); AdminPanelUtils.SetPageErrorMessage(this.Page, (ex.InnerException != null ? ex.InnerException.Message : ex.Message)); } if (AdminPanelUtils.LoadState("Page", Page.Session) != null) { domainsControl.PageNumber = Int32.Parse(AdminPanelUtils.LoadState("Page", Page.Session).ToString()); } } else { AdminPanelUtils.SetPageErrorMessage(this.Page, "<b>Database is not configured</b>. <br />Before creating domains and users, you need to configure database connection first. <br />Please navigate WebMail / Database Settings and configure database connection there."); } }