Beispiel #1
0
        private void GetScopeChildTreeData(List <SysUserScopeMapping> mappings, StringBuilder childTree)
        {
            string          ErrorMessage = string.Empty;
            List <SysScope> scopes       = SysScopeServices.QuerySysScopeByCompanyId(GetCurrentUserCompanyId);

            if (scopes != null && scopes.Count > 0)
            {
                childTree.Append(",\"children\":[");
                int index = 1;
                foreach (var item in scopes)
                {
                    childTree.Append("{\"id\":\"" + item.ASID + "\",");
                    childTree.Append("\"attributes\":{\"type\":1},");
                    if (mappings.FirstOrDefault(p => p.ASID == item.ASID) != null)
                    {
                        childTree.Append("\"checked\":true,");
                    }
                    childTree.Append("\"text\":\"" + item.ASName + "\"");
                    childTree.Append("}");
                    if (index != scopes.Count)
                    {
                        childTree.Append(",");
                    }
                    index++;
                }
                childTree.Append("]");
            }
        }
Beispiel #2
0
 public JsonResult SaveScope(SysScope model)
 {
     try
     {
         string errorMsg = string.Empty;
         if (string.IsNullOrWhiteSpace(model.ASID))
         {
             model.CPID = GetCurrentUserCompanyId;
             model.ASID = GuidGenerator.GetGuid().ToString();
             bool result = SysScopeServices.Add(model);
             if (!result)
             {
                 throw new MyException("添加失败");
             }
         }
         else
         {
             bool result = SysScopeServices.Update(model);
             if (!result)
             {
                 throw new MyException("修改失败");
             }
         }
         return(Json(MyResult.Success()));
     }
     catch (MyException ex)
     {
         return(Json(MyResult.Error(ex.Message)));
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptions(ex, "保存作用域失败");
         return(Json(MyResult.Error("保存失败")));
     }
 }
Beispiel #3
0
 public JsonResult Delete(string recordId)
 {
     try
     {
         bool result = SysScopeServices.DeleteByRecordId(recordId);
         if (!result)
         {
             throw new MyException("删除失败");
         }
         return(Json(MyResult.Success()));
     }
     catch (MyException ex)
     {
         return(Json(MyResult.Error(ex.Message)));
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptions(ex, "删除失败");
         return(Json(MyResult.Error("删除失败")));
     }
 }
Beispiel #4
0
        public string GetScopeTreeData()
        {
            StringBuilder strTree = new StringBuilder();

            try
            {
                strTree.Append("[");
                var roles = SysScopeServices.QuerySysScopeByCompanyId(GetCurrentUserCompanyId);
                int i     = 1;
                foreach (var obj in roles)
                {
                    strTree.Append("{\"id\":\"" + obj.ASID + "\",");
                    strTree.Append("\"attributes\":{\"type\":1,\"isdefault\":\"" + (int)obj.IsDefaultScope + "\"},");
                    if (obj.IsDefaultScope == Common.Entities.YesOrNo.Yes)
                    {
                        strTree.Append("\"text\":\"" + obj.ASName + "[系统默认]" + "\"");
                    }
                    else
                    {
                        strTree.Append("\"text\":\"" + obj.ASName + "\"");
                    }

                    strTree.Append("}");
                    if (i != roles.Count())
                    {
                        strTree.Append(",");
                    }
                    i++;
                }
                strTree.Append("]");
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "作用域管理 构建作用域树失败");
            }
            return(strTree.ToString());
        }
Beispiel #5
0
 private string GetScopeDescription(SysUser users)
 {
     try
     {
         StringBuilder   strInfo = new StringBuilder();
         List <SysScope> scopes  = SysScopeServices.QuerySysScopeByUserId(users.RecordID);
         if (scopes != null && scopes.Count > 0)
         {
             foreach (var item in scopes)
             {
                 strInfo.AppendFormat("{0}<br>", item.ASName);
             }
             if (!string.IsNullOrWhiteSpace(strInfo.ToString()))
             {
                 return(strInfo.ToString().Substring(0, strInfo.Length - 4));
             }
         }
         return(string.Empty);
     }
     catch (Exception ex) {
         ExceptionsServices.AddExceptions(ex, "获取作用域描述失败[用户管理]");
         return(string.Empty);
     }
 }
Beispiel #6
0
        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);
            }
        }