/// <summary> /// 查询模块列表 /// </summary> /// <param name="systems">系统ID</param> /// <returns></returns> private object BindList(string systems) { var query = ModuleManage.LoadAll(null); if (!string.IsNullOrEmpty(systems)) { query = query.Where(p => p.FK_BELONGSYSTEM == systems); } else { query = query.Where(p => CurrentUser.System_Id.Any(e => e == p.FK_BELONGSYSTEM)); } //递归排序 var entity = ModuleManage.RecursiveModule(query.ToList()) .Select(p => new { p.ID, MODULENAME = GetModuleName(p.NAME, p.LEVELS), p.ALIAS, p.MODULEPATH, p.SHOWORDER, p.ICON, MODULETYPE = ((Common.Enums.enumModuleType)p.MODULETYPE).ToString(), ISSHOW = p.ISSHOW ? "显示":"隐藏", p.NAME, SYSNAME = p.SYS_SYSTEM.NAME, p.FK_BELONGSYSTEM }); if (!string.IsNullOrEmpty(base.keywords)) { entity = entity.Where(p => p.NAME.Contains(keywords)); } return(Common.JsonHelper.JsonConverter.JsonClass(entity)); }
// GET: Home public ActionResult Index() { //系统模块列表 ViewData["Module"] = ModuleManage.GetModule(CurrentUser.Id, CurrentUser.Permissions, CurrentUser.System_Id); ViewData["Contacts"] = Contacts(); return(View(CurrentUser)); }
/// <summary> /// 构造方法 /// </summary> public ModuleAppService(IRepository <Module, int> moduleRepository, ModuleManage moduleManage ) { _moduleRepository = moduleRepository; _moduleManage = moduleManage; }
public object GetModuleByDetail(string sysid) { return((from p in this.ModuleManage.RecursiveModule(ModuleManage.LoadAll(p => p.FK_BELONGSYSTEM == sysid).ToList()) select new { ID = p.ID, NAME = this.GetModuleName(p.NAME, new decimal?(p.LEVELS)) }).ToList()); }
public ActionResult Index() { //获取系统模块列表(如果用BUI可以写个方法输出Json给BUI) ViewData["Module"] = ModuleManage.GetModule(this.CurrentUser.Id, this.CurrentUser.Permissions, this.CurrentUser.System_Id); //通讯录 ViewData["Contacts"] = Contacts(); return(View(this.CurrentUser)); }
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; } }
public ActionResult Save(SYS_MODULE entity) { bool isEdit = false; var json = new JsonHelper { Status = "n", Msg = "保存成功!" }; 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 = 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; } //模块别名同系统下不能重名 if ( ModuleManage.IsExist( p => p.FK_BELONGSYSTEM == entity.FK_BELONGSYSTEM && p.ALIAS.ToLower() == entity.ALIAS.ToLower() && 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)) { json.Msg = "模块" + entity.NAME + "已存在,不能重复添加"; return(Json(json)); } if (this.ModuleManage.SaveOrUpdate(entity, isEdit)) { json.Status = "y"; } else { json.Msg = "保存失败!"; } //变更下级模块的级别 if (isEdit) { this.ModuleManage.MoreModifyModule(entity.ID, Convert.ToInt32(entity.LEVELS)); } } else { json.Msg = "未找到需要保存的模块!"; } } catch (Exception ex) { json.Msg = "保存模块发生内部错误!"; WriteLog(Common.Enums.enumOperator.None, "保存模块", ex); } return(Json(json)); }
public ActionResult Save(Domain.SYS_MODULE entity) { bool isEdit = false; var json = new JsonHelper { Msg = "保存成功", Status = "n" }; try { if (entity == null) { json.Msg = "未找到需要保存的模块"; return(Json(json)); } //验证 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; } //模块别名同系统下不能重复 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)) { json.Status = "y"; } else { json.Msg = "保存失败"; } //如果模块修改成功,我们变更下级模块的级别 if (isEdit) { ModuleManage.MoreModifyModule(entity.ID, entity.LEVELS); } } else { json.Msg = "模块" + entity.NAME + "已存在,不能重复添加"; } } catch (Exception e) { json.Msg = "保存模块发生内部错误!"; WriteLog(Common.Enums.enumOperator.None, "保存模块:", e); } return(Json(json)); }