protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetCacheability(HttpCacheability.NoCache); try { //当前职员。 string staffId = Request.QueryString["id"]; Staff staff = CommonSrv.LoadObjectById(typeof(Staff), staffId) as Staff; //权限。 SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights"); //生成树节点。 IList topModuleTypes = ModuleTypeSrv.GetAllTopModuleType(); foreach (ModuleType mt in topModuleTypes) { Microsoft.Web.UI.WebControls.TreeNode node = new Microsoft.Web.UI.WebControls.TreeNode(); tvRights.Nodes.Add(node); node.Type = "moduletype"; node.Text = mt.Name; AddSubNodes(node, mt, staff, sct); node.Expanded = true; } } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script type=\"text/javascript\">error=true;</script>"); log.Error(null, ex); } }
/// <summary> /// 新增系统代码。 /// </summary> /// <param name="dto">待新增系统代码的信息。</param> /// <returns>新系统代码的Id。(-2:Tag重复。)</returns> public static string InsertSysCode(SysCodeDTO dto) { SysCode existingSc = GetSysCodeByTag(dto.Tag); if (existingSc != null) { return("-2"); } Db.SessionFactory.EvictQueries("SysCode"); SysCode sc = new SysCode(); sc.Id = IdGen.GetNextId(typeof(SysCode)); sc.Tag = dto.Tag; sc.Name = dto.Name; sc.Remark = dto.Remark; sc.OrderId = dto.OrderId; SysCodeType sct = Db.Session.Load(typeof(SysCodeType), dto.SysCodeTypeId) as SysCodeType; sct.AddSysCode(sc); Db.TransInsert(sc); return(sc.Id); }
public ActionResult EditModule(string Id) { Module mt = CommonSrv.LoadObjectById(typeof(Module), Id) as Module; ModuleDTO mdto = new ModuleDTO(); mdto.Id = mt.Id; mdto.ModuleTypeId = mt.ModuleType.Id; mdto.ModuleUrl = mt.ModuleUrl; mdto.Name = mt.Name; mdto.OrderId = mt.OrderId; mdto.Remark = mt.Remark; mdto.Tag = mt.Tag; //获取 syscode - rights SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights"); if (sct != null) { foreach (SysCode sc in sct.SysCodes) { if (mt.ModuleRights.ContainsKey(sc.Tag)) { mdto.ModuleRights.Add(sc.Name + "|" + sc.Tag + "|" + sc.Id + "|√"); } else { mdto.ModuleRights.Add(sc.Name + "|" + sc.Tag + "|" + sc.Id); } } } return(View("ModuleInfo", mdto)); }
protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetCacheability(HttpCacheability.NoCache); try { if (Request.QueryString["mode"] == "new") { divTitleMess.InnerText = "新增系统代码分类"; } else if (Request.QueryString["mode"] == "edit") { divTitleMess.InnerText = "编辑系统代码分类"; string id = Request.QueryString["id"]; if (id != null) { SysCodeType sct = CommonSrv.LoadObjectById(typeof(SysCodeType), id) as SysCodeType; txtSysCodeTypeTag.Value = sct.Tag; txtSysCodeTypeName.Value = sct.Name; txtSysCodeTypeOrderId.Value = sct.OrderId.ToString(); txtaSysCodeTypeRemark.Value = sct.Remark; } } } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script type=\"text/javascript\">error=true;</script>"); log.Error(null, ex); } }
/// <summary> /// 删除系统代码分类。 /// </summary> /// <param name="id">要删除的系统代码分类的主键值。</param> public static void DeleteSysCodeType(string id) { Db.SessionFactory.EvictQueries("SysCodeType"); SysCodeType sct = Db.Session.Load(typeof(SysCodeType), id) as SysCodeType; Db.TransDelete(sct); }
//返回模块分类 模块 序列化List IList GetModulePermissionList(IList ilModuleType, SysCodeType sct, Role role) { IList l = new List <NodeType>(); foreach (ModuleType sub in ilModuleType) { NodeType ntype = new NodeType(); ntype.id = sub.Id; ntype.text = sub.Name; ntype.ntype = "moduletype"; ntype.state = "closed"; if (sub.SubModuleTypes.Count > 0) { ntype.children = GetModulePermissionList(sub.SubModuleTypes, sct, role); } if (sub.Modules.Count > 0) { ntype.children = ntype.children ?? new List <NodeType>(); //IList l_module = new List<NodeType>(); foreach (Module m in sub.Modules) { NodeType nsubtype = new NodeType(); nsubtype.id = m.Id; nsubtype.text = m.Name; nsubtype.ntype = "module"; IList l_module_rights = new List <NodeType>(); //增加肯定权限。 foreach (SysCode sc in sct.SysCodes) { if (m.ModuleRights.ContainsKey(sc.Tag)) { NodeType rightsType = new NodeType(); ModuleRight mr = m.ModuleRights[sc.Tag] as ModuleRight; rightsType.id = mr.Id; rightsType.ntype = "grant"; rightsType.text = sc.Name; rightsType.Checked = role.ModuleRightsGrant.Contains(mr); l_module_rights.Add(rightsType); } } if (l_module_rights.Count > 0) { nsubtype.children = l_module_rights; ntype.children.Add(nsubtype); } } //ntype.children = l_module; } l.Add(ntype); } return(l); }
/// <summary> /// 编辑syscodetype /// </summary> /// <param name="Id"></param> /// <returns></returns> public ActionResult SysCodeTypeEdit(string Id) { SysCodeType sct = CommonSrv.LoadObjectById(typeof(SysCodeType), Id) as SysCodeType; SysCodeTypeDTO sysCodeTypeDTO = new SysCodeTypeDTO(); sysCodeTypeDTO.Id = sct.Id; sysCodeTypeDTO.Name = sct.Name; sysCodeTypeDTO.OrderId = sct.OrderId; sysCodeTypeDTO.Remark = sct.Remark; sysCodeTypeDTO.Tag = sct.Tag; return(View("SysCodeTypeInfo", sysCodeTypeDTO)); }
/// <summary> /// 获取权限代码Type json /// </summary> /// <param name="Id"></param> /// <returns></returns> public JsonResult GetSysCodeTypeInfoJson(string Id) { SysCodeType sct = CommonSrv.LoadObjectById(typeof(SysCodeType), Id) as SysCodeType; SysCodeTypeDTO sysCodeTypeDTO = new SysCodeTypeDTO(); sysCodeTypeDTO.Id = sct.Id; sysCodeTypeDTO.Name = sct.Name; sysCodeTypeDTO.OrderId = sct.OrderId; sysCodeTypeDTO.Remark = sct.Remark; sysCodeTypeDTO.Tag = sct.Tag; return(Json(sysCodeTypeDTO, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 修改一条数据 /// </summary> /// <returns></returns> public async Task <ApiResult <string> > ModifyAsync(SysCodeType parm) { var res = new ApiResult <string> { statusCode = 200, data = SysCodeTypeDb.Update(m => new SysCodeType() { Name = parm.Name, EditTime = DateTime.Now }, m => m.Guid == parm.Guid) ? "1" : "0" }; return(await Task.Run(() => res)); }
/// <summary> /// 添加一条数据 /// </summary> /// <param name="parm"></param> /// <returns></returns> public async Task <ApiResult <string> > AddAsync(SysCodeType parm) { parm.Guid = Guid.NewGuid().ToString(); parm.AddTime = DateTime.Now; parm.EditTime = DateTime.Now; var res = new ApiResult <string> { statusCode = 200, data = SysCodeTypeDb.Insert(parm) ?"1":"0" }; return(await Task.Run(() => res)); }
private void InitModuleRights() { SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights"); if (sct != null) { StringBuilder sb = new StringBuilder(); foreach (SysCode sc in sct.SysCodes) { sb.Append("<div><span id='" + sc.Tag + "' class='redSpanCheck'></span>" + sc.Name + "</div>"); } divRights.InnerHtml = sb.ToString(); } }
/// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <ApiResult <string> > Modify(SysCodeType model) { var result = new ApiResult <string>(); try { await _thisRepository.UpdateAsync(model); } catch (Exception ex) { result.StatusCode = (int)HttpStatusCode.InternalServerError; result.Message = ex.Message; } return(result); }
public ActionResult CreateModule(string Id) { ModuleDTO dto = new ModuleDTO(); dto.ModuleTypeId = Id; //获取 syscode - rights SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights"); if (sct != null) { foreach (SysCode sc in sct.SysCodes) { dto.ModuleRights.Add(sc.Name + "|" + sc.Tag + "|" + sc.Id); } } return(View("ModuleInfo", dto)); }
public JsonResult ModuleInfo(string Id) { JsonResult jresult = new JsonResult(); jresult.JsonRequestBehavior = JsonRequestBehavior.AllowGet; try { Module mt = CommonSrv.LoadObjectById(typeof(Module), Id) as Module; ModuleDTO mdto = new ModuleDTO(); mdto.Id = mt.Id; mdto.ModuleTypeId = mt.ModuleType.Id; mdto.ModuleUrl = mt.ModuleUrl; mdto.Name = mt.Name; mdto.OrderId = mt.OrderId; mdto.Remark = mt.Remark; mdto.Tag = mt.Tag; mdto.Disabled = mt.Disabled == 1 ? true : false; //获取 syscode - rights SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights"); if (sct != null) { foreach (SysCode sc in sct.SysCodes) { if (mt.ModuleRights.ContainsKey(sc.Tag)) { mdto.ModuleRights.Add(sc.Name + "|√"); } else { mdto.ModuleRights.Add(sc.Name); } } } jresult.Data = mdto; } catch { //TODO js 异常判断 jresult.Data = "[{result:-1}]"; } return(jresult); }
/// <summary> /// 添加一条数据 /// </summary> /// <param name="parm"></param> /// <returns></returns> public async Task <ApiResult <string> > AddAsync(SysCodeTypeDto parm) { var model = new SysCodeType() { Guid = Guid.NewGuid().ToString(), Name = parm.name, ParentGuid = parm.parent, Layer = !string.IsNullOrEmpty(parm.parent)?1:0, Sort = parm.sort, AddTime = DateTime.Now, EditTime = DateTime.Now }; var res = new ApiResult <string> { statusCode = 200, data = SysCodeTypeDb.Insert(model)?"1":"0" }; return(await Task.Run(() => res)); }
/// <summary> /// 更新系统代码分类。 /// </summary> /// <param name="dto">待更新系统代码分类的信息。</param> /// <param name="Id">系统代码分类的Id。</param> /// <returns>成功标示。(1:成功;-2:Tag重复。)</returns> public static string UpdateSysCodeType(SysCodeTypeDTO dto) { SysCodeType existingSct = GetSysCodeTypeByTag(dto.Tag); if (existingSct != null && existingSct.Id != dto.Id) { return("-2"); } Db.SessionFactory.EvictQueries("SysCodeType"); SysCodeType sct = Db.Session.Load(typeof(SysCodeType), dto.Id) as SysCodeType; sct.Tag = dto.Tag; sct.Name = dto.Name; sct.Remark = dto.Remark; sct.OrderId = dto.OrderId; Db.TransUpdate(sct); return("1"); }
/// <summary> /// 新增系统代码分类。 /// </summary> /// <param name="dto">待新增系统代码分类的信息。</param> /// <returns>新系统代码分类的Id。(-2:Tag重复。)</returns> public static string InsertSysCodeType(SysCodeTypeDTO dto) { SysCodeType existingSct = GetSysCodeTypeByTag(dto.Tag); if (existingSct != null) { return("-2"); } Db.SessionFactory.EvictQueries("SysCodeType"); SysCodeType sct = new SysCodeType(); sct.Id = IdGen.GetNextId(typeof(SysCodeType)); sct.Tag = dto.Tag; sct.Name = dto.Name; sct.Remark = dto.Remark; sct.OrderId = dto.OrderId; Db.TransInsert(sct); return(sct.Id); }
public ActionResult PermissionsTree(string Id) { Staff role = CommonSrv.LoadObjectById(typeof(Staff), Id) as Staff; //权限。 SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights"); NodeType ntype = new NodeType(); ntype.id = "0"; ntype.text = "模块分类"; ntype.ntype = "root"; IList ilModuleType = ModuleTypeSrv.GetAllTopModuleType(); var ilNodeType = GetModulePermissionList(ilModuleType, sct, role); ntype.children = ilNodeType; var rNodeType = new List <NodeType>(); rNodeType.Add(ntype); string jsonResult = JsonConvert.SerializeObject(rNodeType, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); return(Content(jsonResult, "application/json")); }
public async Task <IActionResult> AddCodeType([FromBody] SysCodeType parm) { return(Ok(await _sysCodeTypeService.AddAsync(parm))); }
public async Task <ApiResult <string> > EditCode(SysCodeType parm) { return(await _sysCodeTypeService.ModifyAsync(parm)); }
public async Task <ApiResult <string> > AddCodeType(SysCodeType parm) { return(await _sysCodeTypeService.AddAsync(parm)); }
protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetCacheability(HttpCacheability.NoCache); try { //模块权限。 SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights"); StringBuilder sb = new StringBuilder(); if (Request.QueryString["mode"] == "new") { divTitleMess.InnerText = "新增模块"; if (sct != null) { for (int i = 0; i < sct.SysCodes.Count; i++) { SysCode sc = sct.SysCodes[i] as SysCode; sb.Append("<div><input type=checkbox id='" + sc.Tag + "' />" + sc.Name + "</div>"); } divRights.InnerHtml = sb.ToString(); } } else if (Request.QueryString["mode"] == "edit") { divTitleMess.InnerText = "编辑模块"; string id = Request.QueryString["id"]; if (id != null) { Module m = CommonSrv.LoadObjectById(typeof(Module), id) as Module; txtModuleTag.Value = m.Tag; txtModuleName.Value = m.Name; txtModuleOrderId.Value = m.OrderId.ToString(); txtaModuleRemark.Value = m.Remark; txtModuleModuleUrl.Value = m.ModuleUrl; cbModuleDisabled.Checked = (m.Disabled == 1); if (sct != null) { for (int i = 0; i < sct.SysCodes.Count; i++) { SysCode sc = sct.SysCodes[i] as SysCode; if (m.ModuleRights.Contains(sc.Tag)) { sb.Append("<div><input type=checkbox checked id='" + sc.Tag + "' />" + sc.Name + "</div>"); } else { sb.Append("<div><input type=checkbox id='" + sc.Tag + "' />" + sc.Name + "</div>"); } } divRights.InnerHtml = sb.ToString(); } } } } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script type=\"text/javascript\">error=true;</script>"); log.Error(null, ex); } }
public async Task <ApiResult <string> > Modify([FromBody] SysCodeType model) => await _sysCodeTypeService.Modify(model);
public async Task <ApiResult <string> > Update([FromBody] SysCodeType model) { return(await _sysCodeTypeService.ModifyAsync(model)); }
public async Task <ApiResult <string> > Add([FromBody] SysCodeType model) { return(await _sysCodeTypeService.AddAsync(model)); }
private void AddSubNodes(Microsoft.Web.UI.WebControls.TreeNode currentNode, ModuleType currentModuleType, Staff staff, SysCodeType sct) { //增加子模块分类 foreach (ModuleType mt in currentModuleType.SubModuleTypes) { Microsoft.Web.UI.WebControls.TreeNode node = new Microsoft.Web.UI.WebControls.TreeNode(); currentNode.Nodes.Add(node); node.Type = "moduletype"; node.Text = mt.Name; AddSubNodes(node, mt, staff, sct); node.Expanded = true; } //增加模块 foreach (Module m in currentModuleType.Modules) { Microsoft.Web.UI.WebControls.TreeNode node = new Microsoft.Web.UI.WebControls.TreeNode(); currentNode.Nodes.Add(node); node.Type = "module"; node.Text = m.Name; //增加肯定权限。 foreach (SysCode sc in sct.SysCodes) { if (m.ModuleRights.Contains(sc.Tag)) { ModuleRight mr = m.ModuleRights[sc.Tag] as ModuleRight; Microsoft.Web.UI.WebControls.TreeNode rightsNode = new Microsoft.Web.UI.WebControls.TreeNode(); node.Nodes.Add(rightsNode); rightsNode.Type = "grant"; rightsNode.Text = sc.Name; rightsNode.PKId = mr.Id; rightsNode.CheckBox = true; rightsNode.Checked = staff.ModuleRightsGrant.Contains(mr); } } //增加否定权限。 foreach (SysCode sc in sct.SysCodes) { if (m.ModuleRights.Contains(sc.Tag)) { ModuleRight mr = m.ModuleRights[sc.Tag] as ModuleRight; Microsoft.Web.UI.WebControls.TreeNode rightsNode = new Microsoft.Web.UI.WebControls.TreeNode(); node.Nodes.Add(rightsNode); rightsNode.Type = "deny"; rightsNode.Text = sc.Name; rightsNode.PKId = mr.Id; rightsNode.CheckBox = true; rightsNode.Checked = staff.ModuleRightsDeny.Contains(mr); } } } }
public async Task <IActionResult> EditCode([FromBody] SysCodeType parm) { return(Ok(await _sysCodeTypeService.ModifyAsync(parm))); }
private void FillSelects() { //国家。 SysCodeType sctCountry = SysCodeTypeSrv.GetSysCodeTypeByTag("countrys"); selectStaffCountry.Items.Add(new ListItem("", "-1")); foreach (SysCode sc in sctCountry.SysCodes) { selectStaffCountry.Items.Add(new ListItem(sc.Name, sc.Tag)); } //民族。 SysCodeType sctNation = SysCodeTypeSrv.GetSysCodeTypeByTag("nations"); selectStaffNation.Items.Add(new ListItem("", "-1")); foreach (SysCode sc in sctNation.SysCodes) { selectStaffNation.Items.Add(new ListItem(sc.Name, sc.Tag)); } //职位。 SysCodeType sctPosition = SysCodeTypeSrv.GetSysCodeTypeByTag("positions"); selectStaffPosition.Items.Add(new ListItem("", "-1")); foreach (SysCode sc in sctPosition.SysCodes) { selectStaffPosition.Items.Add(new ListItem(sc.Name, sc.Tag)); } //职称。 SysCodeType sctTitle = SysCodeTypeSrv.GetSysCodeTypeByTag("titles"); selectStaffTitle.Items.Add(new ListItem("", "-1")); foreach (SysCode sc in sctTitle.SysCodes) { selectStaffTitle.Items.Add(new ListItem(sc.Name, sc.Tag)); } //政治面貌。 SysCodeType sctPolitical = SysCodeTypeSrv.GetSysCodeTypeByTag("politicals"); selectStaffPolitical.Items.Add(new ListItem("", "-1")); foreach (SysCode sc in sctPolitical.SysCodes) { selectStaffPolitical.Items.Add(new ListItem(sc.Name, sc.Tag)); } //最高学历。 SysCodeType sctDegree = SysCodeTypeSrv.GetSysCodeTypeByTag("degrees"); selectStaffDegree.Items.Add(new ListItem("", "-1")); foreach (SysCode sc in sctDegree.SysCodes) { selectStaffDegree.Items.Add(new ListItem(sc.Name, sc.Tag)); } //性别。 selectStaffSex.Items.Add(new ListItem("", "-1")); selectStaffSex.Items.Add(new ListItem("男", "0")); selectStaffSex.Items.Add(new ListItem("女", "1")); //婚否。 selectStaffMarried.Items.Add(new ListItem("", "-1")); selectStaffMarried.Items.Add(new ListItem("未婚", "0")); selectStaffMarried.Items.Add(new ListItem("已婚", "1")); }