/// <summary> /// 数据状态检测 /// </summary> void OnTrigger() { using (SystemContextScope.CreateScope()) { using (MySqlDataBaseScope.CreateScope(MySqlDataBase.DefaultDataBase)) { DoDataChanged(); } } }
/// <summary> /// 检查类型绑定 /// </summary> /// <param name="pid"></param> /// <param name="types"></param> public bool BindType(long pid, List <Type> types) { using (SystemContextScope.CreateScope()) { using (MySqlDataBaseScope.CreateScope(Access.DataBase)) { FindAndBindType(pid, types); } } return(true); }
/// <summary> /// 保存完成后的操作 /// </summary> /// <param name="data">数据</param> /// <param name="isAdd">是否为新增</param> /// <returns>如果为否将阻止后续操作</returns> protected override bool OnSaved(PageItemData data, bool isAdd) { using (SystemContextScope.CreateScope()) { using (MySqlDataBaseScope.CreateScope(Access.DataBase)) { Cache(data, Access); } } return(true); }
static void CacheTask(int roleId) { using (SystemContextScope.CreateScope()) { using (MySqlDataBaseScope.CreateScope(MySqlDataBase.DefaultDataBase)) { RoleCache.Cache(roleId); RoleCache cache = new RoleCache(); cache.CachePageAuditUser(); cache.CacheTypeUser(); } } }
static void CacheTask(int pid) { var orb = new UserBusinessLogic(); using (SystemContextScope.CreateScope()) { using (MySqlDataBaseScope.CreateScope(MySqlDataBase.DefaultDataBase)) { orb.SyncUser(orb._posAccess.First(pid)); RoleCache cache = new RoleCache(); cache.CachePageAuditUser(); cache.CacheTypeUser(); } } }
/// <summary> /// 添加所有主管与办事员 /// </summary> public void CreateAll() { using (MySqlDataBaseScope.CreateScope(Access.DataBase)) { var oAccess = new OrganizationDataAccess(); var orgs = oAccess.All(p => p.DataState < DataStateType.Delete); foreach (var org in orgs) { var leader = org.FullName.Last() + "长"; if (!Access.Any(p => p.OrganizationId == org.Id && p.RoleId == 3)) { Access.Insert(new OrganizePositionData { Position = leader, OrganizationId = org.Id, RoleId = 3, Memo = org.FullName + leader }); } else { Access.SetValue(p => p.DataState, DataStateType.None, p => p.OrganizationId == org.Id && p.RoleId == 3 && p.DataState == DataStateType.Delete); } if (!Access.Any(p => p.OrganizationId == org.Id && p.RoleId == 4)) { Access.Insert(new OrganizePositionData { Position = "办事员", OrganizationId = org.Id, RoleId = 4, Memo = org.FullName + "办事员" }); } else { Access.SetValue(p => p.DataState, DataStateType.None, p => p.OrganizationId == org.Id && p.RoleId == 4 && p.DataState == DataStateType.Delete); } } } }
/// <summary> /// 缓存 /// </summary> private void DoCache() { using (SystemContextScope.CreateScope()) { using (MySqlDataBaseScope.CreateScope(Access.DataBase)) { var pAccess = new PositionPersonnelDataAccess(); foreach (var pos in pAccess.All()) { SyncUser(pos); } var users = Access.All(); using (var proxy = new RedisProxy(RedisProxy.DbSystem)) { foreach (var user in users) { Cache(proxy, user); } } } } }
/// <summary> /// 检查标准的增删改查按钮 /// </summary> /// <param name="pid"></param> /// <param name="type">类型</param> public bool CheckNormalButtons(long pid, string type) { using (SystemContextScope.CreateScope()) { using (MySqlDataBaseScope.CreateScope(Access.DataBase)) { DeleteButtonItem(p => p.ExtendValue == "list" || p.ExtendValue == "physical_delete"); if (pid < 0) { var ids = Access.LoadValues(p => p.Id, p => p.ItemType == PageItemType.Page); foreach (var id in ids) { NormalButtons(id); } } else { CheckNormalButtonsInner(pid); } } } return(true); }
/// <summary> /// 载入角色的树形页面权限数据 /// </summary> /// <param name="roleId">角色ID</param> /// <returns>树形页面权限数据</returns> private List <EasyUiTreeNode> LoadRolePowers(int roleId) { using (MySqlDataBaseScope.CreateScope(Access.DataBase)) { var pAccess = new RolePowerDataAccess { DataBase = Access.DataBase }; var powers = pAccess.All(p => p.RoleId == roleId); Dictionary <int, RolePowerData> dictionary; try { dictionary = powers.ToDictionary(p => p.PageItemId); } catch// (Exception e) { dictionary = new Dictionary <int, RolePowerData>(); foreach (var g in powers.GroupBy(p => p.PageItemId)) { dictionary.Add(g.Key, g.First()); foreach (var item in g.Skip(1)) { pAccess.DeletePrimaryKey(item.Id); } } } var tree = RoleCache.LoadPowerTree(); SyncPower(tree, dictionary); return(new List <EasyUiTreeNode> { tree }); } }