/// <summary> /// 载入完整的组织结构树(包含职位) /// </summary> /// <returns></returns> internal void CreateOrgPosTree(RedisProxy proxy) { var root = CreateRootNode(); var orgs = Access.All(p => p.DataState < DataStateType.Delete); var opAccess = new OrganizePositionDataAccess(); var posts = opAccess.All(p => p.DataState < DataStateType.Delete); CreateOrgPosTree(0, proxy, root, orgs, posts); }
/// <summary> /// 缓存页面的审批用户 /// </summary> private void CacheUser(RedisProxy proxy, string name, List <string> actions) { var posAccess = new OrganizePositionDataAccess(); var ponAccess = new PositionPersonnelDataAccess(); Dictionary <string, List <int> > types = new Dictionary <string, List <int> >(); foreach (var page in _pages.Where(p => p.ItemType == PageItemType.Page)) { if (!_actions.ContainsKey(page.Id)) { continue; } var items = _actions[page.Id].Where(p => actions.Contains(p.ExtendValue)).ToArray(); if (items.Length == 0) { continue; } var item_ids = items.Select(p => p.Id).ToList(); var pwoers = _allPowers.Where(p => item_ids.Contains(p.PageItemId)).ToArray(); if (pwoers.Length == 0) { continue; } var roles = pwoers.Select(p => p.RoleId).Distinct().ToArray(); List <int> personnels; if (types.ContainsKey(page.Config.SystemType)) { personnels = types[page.Config.SystemType]; } else { types.Add(page.Config.SystemType, personnels = new List <int>()); } foreach (var role in roles) { var pons = ponAccess.LoadValues(p => p.UserId, p => p.RoleId == role && p.AuditState == AuditStateType.Pass); personnels.AddRange(pons); var pos = posAccess.LoadValues(p => p.Id, p => p.RoleId == role); foreach (var pid in pos) { pons = ponAccess.LoadValues(p => p.UserId, p => p.OrganizePositionId == pid && p.AuditState == AuditStateType.Pass); personnels.AddRange(pons); } } } foreach (var type in types) { var users = type.Value.Distinct().ToArray(); var keys = $"users:{name}:{type.Key}"; proxy.Set(keys, users); //System.Diagnostics.Trace.WriteLine(users.LinkToString(","), keys); } }
/// <summary> /// 缓存页面的审批用户 /// </summary> /// <param name="proxy"></param> private void CachePageAuditUser(RedisProxy proxy) { foreach (var page in _pages.Where(p => p.ItemType == PageItemType.Page)) { if (!_actions.ContainsKey(page.Id)) { //Trace.WriteLine("错误页面", page.Caption + page.Id); continue; } if (page.Config.AuditPage > 0) { var friend = _pages.FirstOrDefault(p => p.Id == page.Config.AuditPage); if (friend == null) { //Trace.WriteLine($"错误连接({page.Config.AuditPage})", page.Caption + page.Id); } else { proxy.SetValue($"audit:page:link:{page.Id}", page.Config.AuditPage); //Trace.WriteLine($"连接到=>{friend.Caption}", page.Caption + page.Id); } continue; } var items = _actions[page.Id].Where(p => audits.Contains(p.ExtendValue)).ToArray(); if (items.Length == 0) { //Trace.WriteLine("没有审核操作", page.Caption + page.Id); continue; } var item_ids = items.Select(p => p.Id).ToList(); var pwoers = _allPowers.Where(p => item_ids.Contains(p.PageItemId)).ToArray(); if (pwoers.Length == 0) { //Trace.WriteLine("没有审核用户", page.Caption + page.Id); continue; } var roles = pwoers.Select(p => p.RoleId).Distinct().ToArray(); var posAccess = new OrganizePositionDataAccess(); var ponAccess = new PositionPersonnelDataAccess(); Dictionary <int, PositionPersonnelData> personnels = new Dictionary <int, PositionPersonnelData>(); foreach (var role in roles) { var pons = ponAccess.All(p => p.RoleId == role && p.AuditState == AuditStateType.Pass); foreach (var p in pons) { if (personnels.ContainsKey(p.Id)) { continue; } personnels.Add(p.Id, p); } var pos = posAccess.LoadValues(p => p.Id, p => p.RoleId == role); foreach (var pid in pos) { pons = ponAccess.All(p => p.OrganizePositionId == pid && p.AuditState == AuditStateType.Pass); foreach (var p in pons) { if (personnels.ContainsKey(p.Id)) { continue; } personnels.Add(p.Id, p); } } } AuditNode(proxy, page.Id, personnels.Values.ToList()); } }