public ActionResult GetPlistCatalogAccounts(GetPlistCatalogAccounts input) { if (!ModelState.IsValid) { return(ModelState.ToJsonResult()); } input.IncludeDescendants = input.IncludeDescendants ?? false; List <DicReader> data; if (string.IsNullOrEmpty(input.CatalogCode)) { if (!AcSession.IsDeveloper()) { throw new ValidationException("对不起,您没有查看全部管理员的权限"); } else { data = GetRequiredService <IPrivilegeQuery>().GetPlistCatalogAccountTrs(input.Key.SafeTrim(), input.CatalogCode, input.IncludeDescendants.Value, input); } } else { data = GetRequiredService <IPrivilegeQuery>().GetPlistCatalogAccountTrs(input.Key.SafeTrim(), input.CatalogCode, input.IncludeDescendants.Value, input); } Debug.Assert(input.Total != null, "requestData.total != null"); return(this.JsonResult(new MiniGrid <Dictionary <string, object> > { total = input.Total.Value, data = data })); }
public ActionResult GetAccountInfo() { if (AcSession.Identity.IsAuthenticated) { var account = AcSession.Account; return(this.JsonResult(new { isLogined = AcSession.Identity.IsAuthenticated, loginName = AcSession.IsDeveloper() ? string.Format("{0}(开发人员)", account.LoginName) : account.LoginName, wallpaper = string.Empty, backColor = string.Empty, menus = AcSession.AccountPrivilege.AuthorizedMenus.Cast <IMenu>().ToList().Select(m => new { id = m.Id, text = m.Name, pid = m.ParentId, url = m.Url, img = m.Icon }), roles = AcSession.AccountPrivilege.Roles, groups = AcSession.AccountPrivilege.Groups })); } else { return(this.JsonResult(new ResponseData { success = false, msg = "对不起,您没有登录" }.Error())); } }
public ActionResult Refresh() { var result = new ResponseData { success = true }; if (!AcSession.IsDeveloper()) { result.success = false; result.msg = "对不起,您不是开发人员,不能执行本功能"; } else { GetRequiredService <IFunctionListImport>().Import(AcDomain, AcSession, AcDomain.Config.SelfAppSystemCode); } return(this.JsonResult(result)); }
public ActionResult GetPlistAccounts(GetPlistAccounts input) { if (!ModelState.IsValid) { return(ModelState.ToJsonResult()); } foreach (var filter in input.Filters) { PropertyState property; if (!AcDomain.EntityTypeSet.TryGetProperty(base.EntityType, filter.field, out property)) { throw new ValidationException("意外的Account实体类型属性" + filter.field); } } input.IncludeDescendants = input.IncludeDescendants ?? false; List <DicReader> userAccountTrs = null; // 如果组织机构为空则需要检测是否是开发人员,因为只有开发人员才可以看到全部用户。目录为空表示查询全部目录。 if (string.IsNullOrEmpty(input.CatalogCode)) { if (!AcSession.IsDeveloper()) { throw new ValidationException("对不起,您没有查看全部账户的权限"); } else { userAccountTrs = GetRequiredService <IAccountQuery>().GetPlistAccountTrs(input.Filters, input.CatalogCode , input.IncludeDescendants.Value, input); } } else { userAccountTrs = GetRequiredService <IAccountQuery>().GetPlistAccountTrs(input.Filters, input.CatalogCode , input.IncludeDescendants.Value, input); } Debug.Assert(input.Total != null, "requestModel.total != null"); var data = new MiniGrid <Dictionary <string, object> > { total = input.Total.Value, data = userAccountTrs }; return(this.JsonResult(data)); }
public ActionResult GetNodesByParentId(Guid?parentId) { if (parentId == Guid.Empty) { parentId = null; } if (!parentId.HasValue) { if (AcSession.IsDeveloper()) { var nodeList = new List <CatalogMiniNode>(); nodeList.AddRange(AcDomain.CatalogSet.Where(a => a != CatalogState.VirtualRoot && a.ParentCode == null).OrderBy(a => a.SortCode + a.CategoryCode.GetHashCode()).Select(a => new CatalogMiniNode { CategoryCode = a.CategoryCode, Code = a.Code, expanded = false, Id = a.Id.ToString(), isLeaf = !AcDomain.CatalogSet.Any(o => a.Code.Equals(o.ParentCode, StringComparison.OrdinalIgnoreCase)), Name = a.Name, ParentCode = a.ParentCode, ParentId = a.Parent.Id.ToString(), SortCode = a.SortCode.ToString() })); return(this.JsonResult(nodeList)); } else { var orgs = AcSession.AccountPrivilege.Catalogs; if (orgs != null && orgs.Count > 0) { return(this.JsonResult(orgs.Select(org => new CatalogMiniNode { Code = org.Code ?? string.Empty, Id = org.Id.ToString(), Name = org.Name, isLeaf = AcDomain.CatalogSet.All(o => !org.Code.Equals(o.ParentCode, StringComparison.OrdinalIgnoreCase)) }))); } return(this.JsonResult(new List <CatalogMiniNode>())); } } else { var pid = parentId.Value; CatalogState parentCatalog; if (!AcDomain.CatalogSet.TryGetCatalog(pid, out parentCatalog)) { throw new ValidationException("意外的目录标识" + pid); } var nodeList = new List <CatalogMiniNode>(); nodeList.AddRange(AcDomain.CatalogSet.Where(a => parentCatalog.Code.Equals(a.ParentCode, StringComparison.OrdinalIgnoreCase)).OrderBy(a => a.SortCode + a.CategoryCode.GetHashCode()).Select(a => new CatalogMiniNode { CategoryCode = a.CategoryCode, Code = a.Code, expanded = false, Id = a.Id.ToString(), isLeaf = !AcDomain.CatalogSet.Any(o => a.Code.Equals(o.ParentCode, StringComparison.OrdinalIgnoreCase)), Name = a.Name, ParentCode = a.ParentCode, ParentId = a.Parent.Id.ToString(), SortCode = a.SortCode.ToString() })); nodeList.AddRange(AcDomain.FunctionSet.Where(a => a.ResourceTypeId == pid).OrderBy(a => a.SortCode).Select(a => new CatalogMiniNode { CategoryCode = "operation", Code = a.Code, expanded = false, Id = a.Id.ToString(), isLeaf = true, Name = string.Format("<span style='color:red;'>{0}</span>", a.Description), ParentCode = parentCatalog.Code, ParentId = pid.ToString(), SortCode = a.SortCode.ToString() })); return(this.JsonResult(nodeList)); } }