/// <summary> /// 处理AJAX-删除页面节点 /// </summary> private void ProcAjaxDeletePage(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 101; errMsg = ""; ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", }; string exStr = ""; var PID = Request.GetF("PID").GetInt(0, false); var HideParentID = Request.GetF("HideParentID").GetInt(0, false); var DelPage = Request.GetF("DelPage").GetInt(0, false); if (HideParentID > 0) { //是隐藏页面,先删除关联 if (!pageParentBLL.Delete(PID, HideParentID, out exStr)) { if (exStr.IsEmpty()) { code = 100; errMsg = ""; } else { errMsg = "关联删除失败:" + exStr; } return; } else { code = 100; } } if (DelPage == 1) { if (pageBLL.Delete(PID, out exStr)) { code = 100; errMsg = ""; } else { code = 101; errMsg = "删除失败,请先删除该页面的所有非隐藏子页面" + (exStr.IsEmpty() ? "" : "\n异常:" + exStr); } } if (code == 100) { List <MR_PageInfo> allPagesTree; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.PageTreeDrListHTML = BindPageTreeDrList(allPagesTree).RenderControl(); ajaxHTMLData.HidePagesListHTML = BindHidePages().RenderControl(); ajaxHTMLData.ChkNewPagesListHTML = this.LoadControl("~/Role/UserControl/ChkNewPages.ascx").RenderControl(); } }
/// <summary> /// 处理AJAX选择 /// </summary> /// <returns></returns> private bool ProcAjaxSwitch() { //100成功,要刷单个 //200成功,要刷列表 //101失败,不操作 //202失败,刷页面 var action = Request.GetF("Action"); int code = 101; string errMsg = ""; AjaxHTMLData ajaxHTMLData = new AjaxHTMLData(); switch (action) { case "EditPage": ProcAjaxEditPage(out code, out errMsg, out ajaxHTMLData); break; case "AddChildPage": ProcAjaxAddChildPage(out code, out errMsg, out ajaxHTMLData); break; case "DeletePage": ProcAjaxDeletePage(out code, out errMsg, out ajaxHTMLData); break; case "AddHidePageRe": ProcAjaxAddHidePageRe(out code, out errMsg, out ajaxHTMLData); break; case "GetChkNewPages": ProcAjaxGetChkNewPages(out code, out errMsg, out ajaxHTMLData); break; case "ImportPageCfg": ProcAjaxImportPageCfg(out code, out errMsg, out ajaxHTMLData); break; default: return(false); } Response.Write(new { Code = code, ErrMsg = errMsg, PageHTML = ajaxHTMLData.PageTreeListHTML, SelHTML = ajaxHTMLData.PageTreeDrListHTML, HidePageList = ajaxHTMLData.HidePagesListHTML, ChkNewPagesListHTML = ajaxHTMLData.ChkNewPagesListHTML }.GetJSON()); Response.End(); return(true); }
/// <summary> /// 处理AJAX-获取检测新页面的内容 /// </summary> private void ProcAjaxGetChkNewPages(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 200; errMsg = ""; var uCtrl = this.LoadControl("~/Role/UserControl/ChkNewPages.ascx"); ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", ChkNewPagesListHTML = uCtrl.RenderControl(), }; }
/// <summary> /// 处理AJAX-导入页面配置 /// </summary> private void ProcAjaxImportPageCfg(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 200; errMsg = ""; ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", ChkNewPagesListHTML = "", }; var pId = Request.GetF("PID").GetInt(0, false); var cfgJSON = Request.GetF("CfgJSON"); List <MR_PageInfo> childs = null; try { childs = cfgJSON.JSONDeserialize <List <MR_PageInfo> >(); } catch (Exception ex) { code = 101; errMsg = "导入配置解析错误:" + ex.Message; return; } errMsg = DoImportPageCfgList(pId, childs); if (errMsg.IsEmpty()) { code = 200; } else { code = 201; } List <MR_PageInfo> allPagesTree; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.PageTreeDrListHTML = BindPageTreeDrList(allPagesTree).RenderControl(); ajaxHTMLData.HidePagesListHTML = BindHidePages().RenderControl(); ajaxHTMLData.ChkNewPagesListHTML = this.LoadControl("~/Role/UserControl/ChkNewPages.ascx").RenderControl(); }
/// <summary> /// 处理AJAX-隐藏页面关联 /// </summary> private void ProcAjaxAddHidePageRe(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 101; errMsg = ""; ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", }; string exStr = ""; var PID = Request.GetF("PID").GetInt(0, false); var ParentID = Request.GetF("ParentID").GetInt(0, false); if (pageParentBLL.Add(PID, ParentID, out exStr) <= 0) { if (exStr.IsEmpty()) { code = 100; errMsg = "关联失败,可能已添加"; } else { code = 101; errMsg = "关联失败,ex:" + exStr; } } else { code = 100; errMsg = ""; } if (code == 100) { List <MR_PageInfo> allPagesTree; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.HidePagesListHTML = BindHidePages().RenderControl(); } }
/// <summary> /// 处理AJAX选择 /// </summary> /// <returns></returns> private bool ProcAjaxSwitch() { //100成功,要刷单个 //200成功,要刷列表 //101失败,不操作 //202失败,刷页面 var action = Request.GetF("Action"); int code = 101; string errMsg = ""; AjaxHTMLData ajaxHTMLData = new AjaxHTMLData(); switch (action) { case "EditPage": ProcAjaxEditPage(out code, out errMsg, out ajaxHTMLData); break; case "AddChildPage": ProcAjaxAddChildPage(out code, out errMsg, out ajaxHTMLData); break; case "DeletePage": ProcAjaxDeletePage(out code, out errMsg, out ajaxHTMLData); break; case "AddHidePageRe": ProcAjaxAddHidePageRe(out code, out errMsg, out ajaxHTMLData); break; case "GetChkNewPages": ProcAjaxGetChkNewPages(out code, out errMsg, out ajaxHTMLData); break; case "ImportPageCfg": ProcAjaxImportPageCfg(out code, out errMsg, out ajaxHTMLData); break; default: return false; } Response.Write(new { Code = code, ErrMsg = errMsg, PageHTML = ajaxHTMLData.PageTreeListHTML, SelHTML = ajaxHTMLData.PageTreeDrListHTML, HidePageList = ajaxHTMLData.HidePagesListHTML, ChkNewPagesListHTML = ajaxHTMLData.ChkNewPagesListHTML }.GetJSON()); Response.End(); return true; }
/// <summary> /// 处理AJAX-导入页面配置 /// </summary> private void ProcAjaxImportPageCfg(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 200; errMsg = ""; ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", ChkNewPagesListHTML = "", }; var pId = Request.GetF("PID").GetInt(0, false); var cfgJSON = Request.GetF("CfgJSON"); List<MR_PageInfo> childs = null; try { childs = cfgJSON.JSONDeserialize<List<MR_PageInfo>>(); } catch (Exception ex) { code = 101; errMsg = "导入配置解析错误:" + ex.Message; return; } errMsg = DoImportPageCfgList(pId, childs); if (errMsg.IsEmpty()) code = 200; else code = 201; List<MR_PageInfo> allPagesTree; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.PageTreeDrListHTML = BindPageTreeDrList(allPagesTree).RenderControl(); ajaxHTMLData.HidePagesListHTML = BindHidePages().RenderControl(); ajaxHTMLData.ChkNewPagesListHTML = this.LoadControl("~/Role/UserControl/ChkNewPages.ascx").RenderControl(); }
/// <summary> /// 处理AJAX-获取检测新页面的内容 /// </summary> private void ProcAjaxGetChkNewPages(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 200; errMsg = ""; var uCtrl = this.LoadControl("~/Role/UserControl/ChkNewPages.ascx"); ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", ChkNewPagesListHTML = uCtrl.RenderControl(), }; }
/// <summary> /// 处理AJAX-编辑页面 /// </summary> private void ProcAjaxEditPage(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 101; errMsg = ""; ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", }; List<MR_PageInfo> allPagesTree; var editPageInfo = Request.Form.GetModel<MR_PageInfo>(); if (editPageInfo == null || editPageInfo.PID <= 0) { errMsg = "参数不全"; return; } var oldPageInfo = pageBLL.GetModel(editPageInfo.PID); if (oldPageInfo == null) { code = 200; errMsg = "页面已经不存在,请重新操作"; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.PageTreeDrListHTML = BindPageTreeDrList(allPagesTree).RenderControl(); return; } bool isHidePage = false;//是否隐藏页面 //关系变更 if (oldPageInfo.ParentID > -1 && oldPageInfo.ParentID != editPageInfo.ParentID) { if (CheckPIDInChilds(oldPageInfo.PID, editPageInfo.ParentID)) { errMsg = "所属的父级不能是自己或自己的子集"; return; } } if (oldPageInfo.ParentID == -1) { isHidePage = true; } oldPageInfo.PName = editPageInfo.PName; oldPageInfo.PUrl = editPageInfo.PUrl; oldPageInfo.Queue = editPageInfo.Queue; oldPageInfo.DefShowChild = editPageInfo.DefShowChild; if (oldPageInfo.ParentID > -1) oldPageInfo.ParentID = editPageInfo.ParentID; if (oldPageInfo.PUrl.IsNotEmpty()) { if (pageBLL.ExistURL(oldPageInfo.PUrl, oldPageInfo.PID)) { errMsg = "已存在相同URL的页面"; return; } } if (!pageBLL.Update(oldPageInfo)) { errMsg = "更新失败"; return; } code = 200; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.PageTreeDrListHTML = BindPageTreeDrList(allPagesTree).RenderControl(); if (isHidePage) { ajaxHTMLData.HidePagesListHTML = BindHidePages().RenderControl(); } ajaxHTMLData.ChkNewPagesListHTML = this.LoadControl("~/Role/UserControl/ChkNewPages.ascx").RenderControl(); }
/// <summary> /// 处理AJAX-删除页面节点 /// </summary> private void ProcAjaxDeletePage(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 101; errMsg = ""; ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", }; string exStr = ""; var PID = Request.GetF("PID").GetInt(0, false); var HideParentID = Request.GetF("HideParentID").GetInt(0, false); var DelPage = Request.GetF("DelPage").GetInt(0, false); if (HideParentID > 0) { //是隐藏页面,先删除关联 if (!pageParentBLL.Delete(PID, HideParentID, out exStr)) { if (exStr.IsEmpty()) { code = 100; errMsg = ""; } else { errMsg = "关联删除失败:" + exStr; } return; } else { code = 100; } } if (DelPage == 1) { if (pageBLL.Delete(PID, out exStr)) { code = 100; errMsg = ""; } else { code = 101; errMsg = "删除失败,请先删除该页面的所有非隐藏子页面" + (exStr.IsEmpty() ? "" : "\n异常:" + exStr); } } if (code == 100) { List<MR_PageInfo> allPagesTree; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.PageTreeDrListHTML = BindPageTreeDrList(allPagesTree).RenderControl(); ajaxHTMLData.HidePagesListHTML = BindHidePages().RenderControl(); ajaxHTMLData.ChkNewPagesListHTML = this.LoadControl("~/Role/UserControl/ChkNewPages.ascx").RenderControl(); } }
/// <summary> /// 处理AJAX-隐藏页面关联 /// </summary> private void ProcAjaxAddHidePageRe(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 101; errMsg = ""; ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", }; string exStr = ""; var PID = Request.GetF("PID").GetInt(0, false); var ParentID = Request.GetF("ParentID").GetInt(0, false); if (pageParentBLL.Add(PID, ParentID, out exStr) <= 0) { if (exStr.IsEmpty()) { code = 100; errMsg = "关联失败,可能已添加"; } else { code = 101; errMsg = "关联失败,ex:" + exStr; } } else { code = 100; errMsg = ""; } if (code == 100) { List<MR_PageInfo> allPagesTree; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.HidePagesListHTML = BindHidePages().RenderControl(); } }
/// <summary> /// 处理AJAX-添加子节点 /// </summary> private void ProcAjaxAddChildPage(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 101; errMsg = ""; ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", }; string exStr = ""; var parentID = Request.GetF("ParentID").GetInt(0, false); var pageType = Request.GetF("PageType"); var pName = Request.GetF("PName"); var pUrl = Request.GetF("PUrl"); var queue = Request.GetF("Queue").GetInt(0, false); var defShowChild = Request.GetF("DefShowChild").GetBoolean(false); var isURL = false; var isHide = (pageType == "HidePage"); if (pName.IsEmpty()) { code = 201; errMsg = "请输入页面名称"; return; } if (pUrl.IsNotEmpty()) { isURL = true; } if (pUrl.IsNotEmpty()) { if (pageBLL.ExistURL(pUrl, 0)) { code = 201; errMsg = "已存在相同URL的页面"; return; } } var model = new MR_PageInfo { ParentID = parentID, PName = pName, PUrl = pUrl, Queue = queue, DefShowChild = defShowChild, IsUrl = isURL, }; if (isHide) { model.ParentID = -1; } if (pageBLL.Add(model, out exStr)) { code = 200; errMsg = ""; } else { if (exStr.IsEmpty()) { code = 202; errMsg = "添加失败,可能已添加"; return; } else { code = 202; errMsg = "添加失败,ex:" + exStr; return; } } if (code == 200) { if (isHide && model.PID > 0) { pageParentBLL.Add(model.PID, parentID, out exStr); } List<MR_PageInfo> allPagesTree; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.ChkNewPagesListHTML = this.LoadControl("~/Role/UserControl/ChkNewPages.ascx").RenderControl(); switch (pageType) { case "Dir": case "ShowPage": ajaxHTMLData.PageTreeDrListHTML = BindPageTreeDrList(allPagesTree).RenderControl(); break; case "HidePage": ajaxHTMLData.HidePagesListHTML = BindHidePages().RenderControl(); break; } } }
/// <summary> /// 处理AJAX-添加子节点 /// </summary> private void ProcAjaxAddChildPage(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 101; errMsg = ""; ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", }; string exStr = ""; var parentID = Request.GetF("ParentID").GetInt(0, false); var pageType = Request.GetF("PageType"); var pName = Request.GetF("PName"); var pUrl = Request.GetF("PUrl"); var queue = Request.GetF("Queue").GetInt(0, false); var defShowChild = Request.GetF("DefShowChild").GetBoolean(false); var isURL = false; var isHide = (pageType == "HidePage"); if (pName.IsEmpty()) { code = 201; errMsg = "请输入页面名称"; return; } if (pUrl.IsNotEmpty()) { isURL = true; } if (pUrl.IsNotEmpty()) { if (pageBLL.ExistURL(pUrl, 0)) { code = 201; errMsg = "已存在相同URL的页面"; return; } } var model = new MR_PageInfo { ParentID = parentID, PName = pName, PUrl = pUrl, Queue = queue, DefShowChild = defShowChild, IsUrl = isURL, }; if (isHide) { model.ParentID = -1; } if (pageBLL.Add(model, out exStr)) { code = 200; errMsg = ""; } else { if (exStr.IsEmpty()) { code = 202; errMsg = "添加失败,可能已添加"; return; } else { code = 202; errMsg = "添加失败,ex:" + exStr; return; } } if (code == 200) { if (isHide && model.PID > 0) { pageParentBLL.Add(model.PID, parentID, out exStr); } List <MR_PageInfo> allPagesTree; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.ChkNewPagesListHTML = this.LoadControl("~/Role/UserControl/ChkNewPages.ascx").RenderControl(); switch (pageType) { case "Dir": case "ShowPage": ajaxHTMLData.PageTreeDrListHTML = BindPageTreeDrList(allPagesTree).RenderControl(); break; case "HidePage": ajaxHTMLData.HidePagesListHTML = BindHidePages().RenderControl(); break; } } }
/// <summary> /// 处理AJAX-编辑页面 /// </summary> private void ProcAjaxEditPage(out int code, out string errMsg, out AjaxHTMLData ajaxHTMLData) { code = 101; errMsg = ""; ajaxHTMLData = new AjaxHTMLData { PageTreeListHTML = "", PageTreeDrListHTML = "", HidePagesListHTML = "", }; List <MR_PageInfo> allPagesTree; var editPageInfo = Request.Form.GetModel <MR_PageInfo>(); if (editPageInfo == null || editPageInfo.PID <= 0) { errMsg = "参数不全"; return; } var oldPageInfo = pageBLL.GetModel(editPageInfo.PID); if (oldPageInfo == null) { code = 200; errMsg = "页面已经不存在,请重新操作"; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.PageTreeDrListHTML = BindPageTreeDrList(allPagesTree).RenderControl(); return; } bool isHidePage = false;//是否隐藏页面 //关系变更 if (oldPageInfo.ParentID > -1 && oldPageInfo.ParentID != editPageInfo.ParentID) { if (CheckPIDInChilds(oldPageInfo.PID, editPageInfo.ParentID)) { errMsg = "所属的父级不能是自己或自己的子集"; return; } } if (oldPageInfo.ParentID == -1) { isHidePage = true; } oldPageInfo.PName = editPageInfo.PName; oldPageInfo.PUrl = editPageInfo.PUrl; oldPageInfo.Queue = editPageInfo.Queue; oldPageInfo.DefShowChild = editPageInfo.DefShowChild; if (oldPageInfo.ParentID > -1) { oldPageInfo.ParentID = editPageInfo.ParentID; } if (oldPageInfo.PUrl.IsNotEmpty()) { if (pageBLL.ExistURL(oldPageInfo.PUrl, oldPageInfo.PID)) { errMsg = "已存在相同URL的页面"; return; } } if (!pageBLL.Update(oldPageInfo)) { errMsg = "更新失败"; return; } code = 200; ajaxHTMLData.PageTreeListHTML = BindPageTree(out allPagesTree).RenderControl(); ajaxHTMLData.PageTreeDrListHTML = BindPageTreeDrList(allPagesTree).RenderControl(); if (isHidePage) { ajaxHTMLData.HidePagesListHTML = BindHidePages().RenderControl(); } ajaxHTMLData.ChkNewPagesListHTML = this.LoadControl("~/Role/UserControl/ChkNewPages.ascx").RenderControl(); }