Ejemplo n.º 1
0
        public ActionResult Detail(int?id)
        {
            try
            {
                var _entity = new Domain.SYS_MODULE()
                {
                    ISSHOW     = true,
                    MODULEPATH = "javascript:void(0)",
                    MODULETYPE = 1
                };

                //父模块
                string parentId = Request.QueryString["parentId"];
                if (!string.IsNullOrEmpty(parentId))
                {
                    _entity.PARENTID = int.Parse(parentId);
                }
                else
                {
                    _entity.PARENTID = 0;
                }
                //所属系统
                string sys = Request.QueryString["sys"];
                if (!string.IsNullOrEmpty(sys))
                {
                    _entity.FK_BELONGSYSTEM = sys;
                }
                //详情
                if (id != null && id > 0)
                {
                    _entity = ModuleManage.Get(p => p.ID == id);
                }
                //页面类型
                ViewData["ModuleType"] = Enum.GetNames(typeof(enumModuleType));
                //加载用户可操作的系统
                ViewData["Systemlist"] = SystemManage.LoadSystemInfo(CurrentUser.System_Id);

                ViewData["Modules"] = BindList(_entity.FK_BELONGSYSTEM);

                return(View(_entity));
            }
            catch (Exception e)
            {
                WriteLog(enumOperator.Select, "模块管理加载详情", e);
                throw;
            }
        }
Ejemplo n.º 2
0
        public MvcHtmlString GetModuleMenu(Domain.SYS_MODULE module, List <Domain.SYS_MODULE> moduleList)
        {
            System.Text.StringBuilder str = new System.Text.StringBuilder(15000);
            var SecondModule = moduleList.FindAll(p => p.PARENTID == module.ID && p.LEVELS == 1).OrderBy(p => p.SHOWORDER).ToList();

            if (SecondModule != null && SecondModule.Count > 0)
            {
                foreach (var item in SecondModule)
                {
                    str.Append("<li data-id=\"" + module.ALIAS + "\" class=\"FirstModule\" >");
                    str.Append("<a class=\"" + (ChildModuleList(item, moduleList, str, false) ? "" : "J_menuItem") + "\" href=\"" + (string.IsNullOrEmpty(item.MODULEPATH) ? "javascript:void(0)" : item.MODULEPATH) + "\" ><i class=\"" + item.ICON + "\"></i> <span class=\"nav-label\">" + item.NAME + "</span>" + (ChildModuleList(item, moduleList, str, false) ? "<span class=\"fa arrow\"></span>" : "") + "</a>");
                    ChildModuleList(item, moduleList, str, true);
                    str.Append("</li>");
                }
            }

            return(new MvcHtmlString(str.ToString()));
        }
Ejemplo n.º 3
0
        private bool ChildModuleList(Domain.SYS_MODULE module, List <Domain.SYS_MODULE> moduleList, System.Text.StringBuilder str, bool IsAppend)
        {
            var ChildModule = moduleList.FindAll(p => p.PARENTID == module.ID).OrderBy(p => p.SHOWORDER).ToList();

            if (ChildModule != null && ChildModule.Count > 0)
            {
                if (IsAppend)
                {
                    str.Append("<ul class=\"nav nav-second-level\">");
                    foreach (var item in ChildModule)
                    {
                        str.Append("<li>");
                        str.Append("<a class=\"" + (ChildModuleList(item, moduleList, str, false) ? "" : "J_menuItem") + "\" href=\"" + (string.IsNullOrEmpty(item.MODULEPATH) ? "javascript:void(0)" : item.MODULEPATH) + "\" ><i class=\"" + item.ICON + "\"></i> <span class=\"nav-label\">" + item.NAME + "</span>" + (ChildModuleList(item, moduleList, str, false) ? "<span class=\"fa arrow\"></span>" : "") + "</a>");
                        ChildModuleList(item, moduleList, str, true);
                        str.Append("</li>");
                    }
                    str.Append("</ul>");
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public ActionResult Save(Domain.SYS_MODULE entity)
        {
            bool isEdit = false;
            var  json   = new JsonHelper()
            {
                Msg = "保存成功", Status = "n"
            };

            try
            {
                if (entity != null)
                {
                    //验证
                    if (!Regex.IsMatch(entity.ALIAS, @"^[A-Za-z0-9]{1,20}$"))
                    {
                        json.Msg = "模块别名只能以字母数字组成,长度不能超过20个字符";
                        return(Json(json));
                    }
                    //级别加1,一级模块默认0
                    if (entity.PARENTID <= 0)
                    {
                        entity.LEVELS = 0;
                    }
                    else
                    {
                        entity.LEVELS = this.ModuleManage.Get(p => p.ID == entity.PARENTID).LEVELS + 1;
                    }
                    //添加
                    if (entity.ID <= 0)
                    {
                        entity.CREATEDATE = DateTime.Now;
                        entity.CREATEUSER = this.CurrentUser.Name;
                        entity.UPDATEDATE = DateTime.Now;
                        entity.UPDATEUSER = this.CurrentUser.Name;
                    }
                    else //修改
                    {
                        entity.UPDATEDATE = DateTime.Now;
                        entity.UPDATEUSER = this.CurrentUser.Name;
                        isEdit            = true;
                    }
                    //模块图标
                    entity.ICON = Request.Form["ICON"];
                    //模块别名同系统下不能重复
                    if (this.ModuleManage.IsExist(p => p.FK_BELONGSYSTEM == entity.FK_BELONGSYSTEM && p.ALIAS == entity.ALIAS && p.ID != entity.ID))
                    {
                        json.Msg = "同系统下模块别名不能重复";
                        return(Json(json));
                    }
                    //判断同一个父模块下,是否重名
                    if (!this.ModuleManage.IsExist(p => p.PARENTID == entity.PARENTID && p.FK_BELONGSYSTEM == entity.FK_BELONGSYSTEM && p.NAME == entity.NAME && p.ID != entity.ID))
                    {
                        if (this.ModuleManage.SaveOrUpdate(entity, isEdit))
                        {
                            //变更下级模块的级别
                            if (isEdit)
                            {
                                this.ModuleManage.MoreModifyModule(entity.ID, Convert.ToInt32(entity.LEVELS));
                            }
                            json.Status = "y";
                        }
                        else
                        {
                            json.Msg = "保存失败";
                        }
                    }
                    else
                    {
                        json.Msg = "模块" + entity.NAME + "已存在,不能重复添加";
                    }
                }
                else
                {
                    json.Msg = "未找到需要保存的模块";
                }
                if (isEdit)
                {
                    WriteLog(Common.Enums.enumOperator.Edit, "修改模块,结果:" + json.Msg, Common.Enums.enumLog4net.INFO);
                }
                else
                {
                    WriteLog(Common.Enums.enumOperator.Add, "添加模块,结果:" + json.Msg, Common.Enums.enumLog4net.INFO);
                }
            }
            catch (Exception e)
            {
                json.Msg = "保存模块发生内部错误!";
                WriteLog(Common.Enums.enumOperator.None, "保存模块:", e);
            }
            return(Json(json));
        }