Beispiel #1
0
        /// <summary>
        /// 增加节点, 返回新增加的标识列
        /// 增加失败返回0
        /// </summary>
        public int Add(MR_PageInfo model)
        {
            string cmdText = @"
            if not exists (select top 1 1 from R_PageInfo where PUrl=@Purl and PName=@PName and ParentID=@ParentID) begin
            insert into R_PageInfo(PName,PUrl,IsUrl,Queue,ParentID,DefShowChild) values (@PName,@PUrl,@IsUrl,@Queue,@ParentID,@DefShowChild);
            select SCOPE_IDENTITY();
            end else begin
            select 0
            end
            ";

            SqlParameter[] parameters = {
                    new SqlParameter("@PName",  model.PName),
                    new SqlParameter("@PUrl",model.PUrl),
                    new SqlParameter("@IsUrl", model.IsUrl),
                    new SqlParameter("@Queue", model.Queue),
                    new SqlParameter("@ParentID", model.ParentID),
                    new SqlParameter("@DefShowChild", model.DefShowChild)};
            object obj = SQLHelpers.TcAdmin().ExecuteScalar(cmdText, parameters);
            if (obj == null) {
                return 0;
            } else {
                return Convert.ToInt32(obj);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 添加节点,返回是否成功,成功时,PID值>0
 /// </summary>
 public bool Add(MR_PageInfo model, out string exStr)
 {
     exStr = string.Empty;
     try {
         model.PID = _dal.Add(model);
         return model.PID > 0;
     } catch (Exception ex) {
         exStr = ex.ToString();
         return false;
     }
 }
Beispiel #3
0
 /// <summary>
 /// 添加一个菜单节点,返回节点ID
 /// </summary>
 /// <param name="text">节点文字</param>
 /// <param name="url">节点链接</param>
 /// <param name="parentId">父节点ID,根目录ID为0</param>
 public bool AddNode(string text, string url, int parentId, int queue)
 {
     if (text == string.Empty)
         return false;
     MR_PageInfo model = new MR_PageInfo();
     model.PName = text;
     model.ParentID = parentId;
     model.Queue = queue;
     if (url.Length > 0) {
         model.PUrl = url;
         model.IsUrl = true;
     } else {
         model.PUrl = string.Empty;
         model.IsUrl = false;
     }
     int result = new DR_PageInfo().Add(model);
     if (result > 0) {
         StaticFunctions.ClearServerCache();
         StaticFunctions.ClearClientPageCache();
         return true;
     }
     return false;
 }
        /// <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>
        /// 添加导入的页面配置-单个,如果存在相同url则,使用更新
        /// </summary>
        /// <param name="pId"></param>
        /// <param name="child"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        private bool DoImportPageCfgOne(int pId, MR_PageInfo child, out string errMsg)
        {
            errMsg = "";
            var isURL = false;

            if (child.PName.IsEmpty()) {
                errMsg = "请输入页面名称";
                return false;
            }
            if (child.PUrl.IsNotEmpty()) {
                isURL = true;
            }
            if (child.PUrl.IsNotEmpty()) {
                var existPage = pageBLL.GetModel(child.PUrl);
                if (existPage != null) {
                    //存在同URL的页面
                    if (existPage.ParentID != pId) {
                        errMsg = "其他位置存在同URL的页面";
                        return false;
                    }
                    //同位置下的,采用更新机制
                    child.PID = existPage.PID;
                }
            }

            child.IsUrl = isURL;

            if (child.HideParentID > 0) {
                child.ParentID = -1;
            } else {
                child.ParentID = pId;
            }

            if (child.PID <= 0) {
                if (!pageBLL.Add(child, out errMsg)) {
                    if (errMsg.IsEmpty()) {
                        errMsg = "添加失败,可能已添加";
                        return false;
                    } else {
                        errMsg = "添加失败,ex:" + errMsg;
                        return false;
                    }
                }
            }
            if (child.ParentID == -1 && child.PID > 0) {
                if (!pageParentBLL.Exists(child.PID, pId)) pageParentBLL.Add(child.PID, pId, out errMsg);
            }

            errMsg = "";
            return true;
        }
 /// <summary>
 /// 判断要改变的父级ID是否在自己的子集里---递归处理方法
 /// </summary>
 /// <param name="oldPID"></param>
 /// <param name="oldPInfo"></param>
 /// <param name="changePID"></param>
 /// <param name="pages"></param>
 /// <returns></returns>
 private bool CheckPIDInChildsByPages(int oldPID, ref MR_PageInfo oldPInfo, int changePID, List<MR_PageInfo> pages, out bool isEnd)
 {
     foreach (var page in pages) {
         if (page.PID == oldPID) {
             //找到自己,那么只从自己的子集找起,结果直接返回最外层
             isEnd = true;
             oldPInfo = page;
             if (page.Childs == null && page.Childs.Count <= 0) {
                 return false;
             }
             return CheckPIDInChildsByPages(oldPID, ref oldPInfo, changePID, page.Childs, out isEnd);
         }
         if (page.PID == changePID) {
             //找到目标,如果自己还没找到算通过,否则
             isEnd = true;
             if (oldPInfo == null) return false;
             else return true;
         }
         //递归,先序遍历,如果里面找到,那么就有,没找到,继续遍历其他的
         if (page.Childs != null && page.Childs.Count <= 0) {
             var re = CheckPIDInChildsByPages(oldPID, ref oldPInfo, changePID, page.Childs, out isEnd);
             //里面说不用找了,直接返回结果
             if (isEnd) return re;
             //里面找到了,直接返回结果
             if (re) { isEnd = true; return true; }
         }
     }
     //如果都没找到,则返回不在里面
     isEnd = false;
     return false;
 }
Beispiel #7
0
 /// <summary>
 /// 更新页面
 /// </summary>
 public bool Update(MR_PageInfo model)
 {
     string cmdtext = "update R_PageInfo set PName=@PName,Queue=@Queue,PUrl=@PUrl,DefShowChild=@DefShowChild,ParentID=@ParentID where PID=@PID ";
     SqlParameter[] parameters = {
             new SqlParameter("@PID", model.PID),
             new SqlParameter("@PName", model.PName),
             new SqlParameter("@Queue" , model.Queue),
             new SqlParameter("@PUrl", model.PUrl),
             new SqlParameter("@DefShowChild", model.DefShowChild),
             new SqlParameter("@ParentID", model.ParentID)};
     return SQLHelpers.TcAdmin().ExecuteNonQuery(cmdtext, parameters) > 0;
 }
Beispiel #8
0
 /// <summary>
 /// 更新页面
 /// </summary>
 public bool Update(MR_PageInfo model)
 {
     return _dal.Update(model);
 }