public string CreateLoginUserSubVillageTreeData() { try { StringBuilder str = new StringBuilder(); List <BaseCompany> companys = CompanyServices.QueryCompanyAndSubordinateCompany(GetCurrentUserCompanyId); if (companys.Count == 0) { return(str.ToString()); } BaseCompany topCompany = companys.FirstOrDefault(p => p.CPID == GetCurrentUserCompanyId); List <BaseVillage> villages = VillageServices.QueryVillageByCompanyIds(companys.Select(p => p.CPID).ToList()); villages = villages.Where(p => p.CPID != topCompany.CPID).ToList(); if (topCompany == null) { return(str.ToString()); } str.Append("["); str.Append("{\"id\":\"" + topCompany.CPID + "\","); str.Append("\"iconCls\":\"my-company-icon\","); str.Append("\"attributes\":{\"type\":0},"); str.Append("\"text\":\"" + topCompany.CPName + "\""); CreateSubordinateVillageTreeData(companys, villages, topCompany.CPID, str); str.Append("}"); str.Append("]"); return(str.ToString()); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "构建小区树结构失败"); return(string.Empty); } }
public string GetSysScopeAuthorize() { try { if (string.IsNullOrWhiteSpace(Request.Params["scopeId"])) { return(string.Empty); } string scopeId = Request.Params["scopeId"]; SysScope scope = SysScopeServices.QuerySysScopeByRecordId(scopeId); if (scope == null) { return(string.Empty); } StringBuilder strTree = new StringBuilder(); strTree.Append("[{\"id\":\"" + scope.ASID + "\","); strTree.Append("\"attributes\":{\"type\":0},"); strTree.Append("\"text\":\"" + scope.ASName + "[作用域]\""); List <SysScopeAuthorize> scopeAuthorizes = SysScopeAuthorizeServices.QuerySysScopeAuthorizeByScopeId(scope.ASID) .Where(p => p.ASType == ASType.Village).ToList(); List <BaseCompany> compamys = CompanyServices.QueryCompanyAndSubordinateCompany(GetCurrentUserCompanyId); if (compamys.Count == 0) { return(string.Empty); } var list = VillageServices.QueryVillageByCompanyIds(compamys.Select(p => p.CPID).ToList()); if (list.Count > 0) { strTree.Append(",\"children\":["); } int i = 1; foreach (var item in list) { string villageName = item.VName; BaseCompany company = compamys.FirstOrDefault(p => p.CPID == item.CPID); if (company != null) { villageName = string.Format("{0}【{1}】", item.VName, company.CPName); } strTree.Append("{\"id\":\"" + scope.ASID + "_" + item.VID + "\","); strTree.Append("\"attributes\":{\"type\":1},"); strTree.Append("\"text\":\"" + villageName + "\""); if (scopeAuthorizes != null && scopeAuthorizes.Exists(p => p.TagID == item.VID)) { strTree.Append(",\"checked\":true"); } strTree.Append("}"); if (i != list.Count()) { strTree.Append(","); } i++; } if (list.Count > 0) { strTree.Append("]"); } strTree.Append("}]"); return(strTree.ToString()); } catch (MyException ex) { return(string.Empty); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "作用域授权时获取小区信息失败"); return(string.Empty); } }