private void UpdateRoleModule(SysRoleModel model) { CPAccessService.Instance.Delete(o => o.Type == "CP.MODULE" && o.RoleID == item.ID); for (int i = -1; i < VSW.Lib.Web.Application.CPModules.Count; i++) { string moduleCode = "SysAdministrator"; if (i > -1) { moduleCode = VSW.Lib.Web.Application.CPModules[i].Code; } int _Access = 0; if (model.ArrApprove != null && Array.IndexOf(model.ArrApprove, moduleCode) > -1) { _Access |= 16; } if (model.ArrDelete != null && Array.IndexOf(model.ArrDelete, moduleCode) > -1) { _Access |= 8; } if (model.ArrEdit != null && Array.IndexOf(model.ArrEdit, moduleCode) > -1) { _Access |= 4; } if (model.ArrAdd != null && Array.IndexOf(model.ArrAdd, moduleCode) > -1) { _Access |= 2; } if (model.ArrView != null && Array.IndexOf(model.ArrView, moduleCode) > -1) { _Access |= 1; } if (_Access > 0) { if ((_Access & 1) != 1) { _Access |= 1; } CPAccessEntity _AccessEntity = new CPAccessEntity(); _AccessEntity.RefCode = moduleCode; _AccessEntity.RoleID = item.ID; _AccessEntity.Value = _Access; _AccessEntity.Type = "CP.MODULE"; CPAccessService.Instance.Save(_AccessEntity); } } }
private void UpdateRoleModule(SysRoleModel model) { CPAccessService.Instance.Delete(o => o.Type == "CP.MODULE" && o.RoleID == _item.ID); for (var i = -1; i < Web.Application.CPModules.Count; i++) { var moduleCode = "SysAdministrator"; if (i > -1) { moduleCode = Web.Application.CPModules[i].Code; } var access = 0; if (model.ArrApprove != null && model.ArrApprove.Exists(o => o.Equals(moduleCode))) { access |= 16; } if (model.ArrDelete != null && model.ArrDelete.Exists(o => o.Equals(moduleCode))) { access |= 8; } if (model.ArrEdit != null && model.ArrEdit.Exists(o => o.Equals(moduleCode))) { access |= 4; } if (model.ArrAdd != null && model.ArrAdd.Exists(o => o.Equals(moduleCode))) { access |= 2; } if (model.ArrView != null && model.ArrView.Exists(o => o.Equals(moduleCode))) { access |= 1; } //if (access <= 0) continue; //if ((access & 1) != 1) // access |= 1; var accessEntity = new CPAccessEntity { RefCode = moduleCode, RoleID = _item.ID, Value = access, Type = "CP.MODULE" }; CPAccessService.Instance.Save(accessEntity); } }
private void UpdateRoleModule(SysRoleModel model) { CPAccessService.Instance.Delete(o => o.Type == "CP.MODULE" && o.RoleID == entity.ID); for (int i = 0; i < listCPModule.Count; i++) { int _Access = 0; if (model.ArrApprove1 != null && Array.IndexOf(model.ArrApprove1, listCPModule[i].ID) > -1) { _Access |= 32; } if (model.ArrApprove != null && Array.IndexOf(model.ArrApprove, listCPModule[i].ID) > -1) { _Access |= 16; } if (model.ArrDelete != null && Array.IndexOf(model.ArrDelete, listCPModule[i].ID) > -1) { _Access |= 8; } if (model.ArrEdit != null && Array.IndexOf(model.ArrEdit, listCPModule[i].ID) > -1) { _Access |= 4; } if (model.ArrAdd != null && Array.IndexOf(model.ArrAdd, listCPModule[i].ID) > -1) { _Access |= 2; } if (model.ArrView != null && Array.IndexOf(model.ArrView, listCPModule[i].ID) > -1) { _Access |= 1; } if (_Access > 0) { if ((_Access & 1) != 1) { _Access |= 1; } CPAccessEntity _AccessEntity = new CPAccessEntity(); _AccessEntity.RefID = listCPModule[i].ID; _AccessEntity.RoleID = entity.ID; _AccessEntity.Value = _Access; _AccessEntity.Type = "CP.MODULE"; CPAccessService.Instance.Save(_AccessEntity); } } }
public async Task <ActionResult> Create(DefaultModel model, string ArrID) { if (model.ID > 0 && !string.IsNullOrEmpty(ArrID)) { var arr = model.ArrID.Split(',').ToList(); int count = arr.Count; for (int i = 0; i < count; i++) { var iview = arr[i].Split('|'); string cname = iview[0]; string aname = iview[1]; bool isTrue = iview[2] == "true"; var oldItem = _service.GetItem(model.ID, cname, aname); if (oldItem != null) { oldItem.Activity = isTrue; await _service.SaveAsync(oldItem); } else { CPAccessEntity item = new CPAccessEntity() { CModule = cname, CMethod = aname, Activity = isTrue, RoleID = model.ID }; await _service.SaveAsync(item); } } ViewBag.Data = _service.GetItemByRoleID(model.ID); } ViewBag.Control = _menu.GetAdminMenu; ViewBag.Model = model; return(View()); }
private void UpdateRoleModule(SysRoleModel model) { CPAccessService.Instance.Delete(o => o.Type == "CP.MODULE" && o.RoleID == entity.ID); for (int i = 0; i < listCPModule.Count; i++) { int _Access = 0; if (model.ArrApprove != null && Array.IndexOf(model.ArrApprove, listCPModule[i].ID) > -1) _Access |= 16; if (model.ArrDelete != null && Array.IndexOf(model.ArrDelete, listCPModule[i].ID) > -1) _Access |= 8; if (model.ArrEdit != null && Array.IndexOf(model.ArrEdit, listCPModule[i].ID) > -1) _Access |= 4; if (model.ArrAdd != null && Array.IndexOf(model.ArrAdd, listCPModule[i].ID) > -1) _Access |= 2; if (model.ArrView != null && Array.IndexOf(model.ArrView, listCPModule[i].ID) > -1) _Access |= 1; if (_Access > 0) { if ((_Access & 1) != 1) _Access |= 1; CPAccessEntity _AccessEntity = new CPAccessEntity(); _AccessEntity.RefID = listCPModule[i].ID; _AccessEntity.RoleID = entity.ID; _AccessEntity.Value = _Access; _AccessEntity.Type = "CP.MODULE"; CPAccessService.Instance.Save(_AccessEntity); } } }