public List <CCWhs> GetCC(AuthCompany param) { try { List <SingleField> lstCC = new List <SingleField>(); UserAuthParam uParam = new UserAuthParam(); string strSql = string.Empty; uParam.userGuid = param.userGuid; uParam.action = param.action; uParam.fieldName = "costcenter"; uParam.recursion = false; lstCC = (new AccountFactory()).GetAuthList(uParam); string strCostCenterCode = string.Join("','", lstCC.Select(r => r.code).Distinct().ToArray()); strCostCenterCode = "('" + strCostCenterCode + "')"; return(null); } catch (Exception ex) { throw ex; } }
public Response GetAuthList(string token, [FromBody] UserAuthParam param) { Response response = new Response(); if (string.IsNullOrEmpty(token) || !token.Equals(_token)) { response.code = "404"; response.message = "Invild token"; } else { var data = AccountHelper.GetAuthList(param); if (data == null) { response.code = "500"; response.message = "No Data"; } else { response.code = "200"; response.content = data; } } return(response); }
/// <summary> /// 取得权限列表 /// </summary> /// <param name="param"></param> /// <returns></returns> public static List <SingleField> GetAuthList(UserAuthParam param) { try { if (param == null) { throw new Exception("LoginUser is null"); } List <SingleField> lstResult = factory.GetAuthList(param); if (lstResult == null || lstResult.Count == 0) { throw new Exception("DAL.SOAccount.AccountFactory.GetAuthList()==null"); } return(lstResult); } catch (Exception ex) { LogHelper.WriteLog(new Log() { message = ex.Message }, "GetAuthList"); return(null); } }
/// <summary> /// 取得权限列表 /// </summary> /// <param name="param"></param> /// <returns></returns> public List <SingleField> GetAuthList(UserAuthParam param) { // 取得Guid集合 string strMenuGuid = Aden.Util.AdenCommon.MastData.formatActionToMenuGuid(param.action); // costCenter list List <SingleField> lstCC = new List <SingleField>(); // company list List <SingleField> lstCP = new List <SingleField>(); // company Guid条件拼接 string strCompanyGuid = string.Empty; // company Code条件拼接 string strCompanyCode = string.Empty; string strSqlCC = " SELECT RTRIM(CODE) AS CODE " + " FROM TBLUSERMENUDATA " + " WHERE USERGUID = '{0}' " + " AND STATUS = '1' " + " AND TYPE = 'costcenter' " + " AND MENUGUID IN {1} "; string strSqlCP = " SELECT RTRIM(GUID) AS GUID " + " FROM TBLUSERMENUDATA " + " WHERE USERGUID = '{0}' " + " AND STATUS = '1' " + " AND TYPE = 'company' " + " AND MENUGUID IN {1} "; if ("costcenter".Equals(param.fieldName.ToLower())) { lstCC = SqlServerHelper.GetEntityList <SingleField>(SqlServerHelper.salesorderConn(), string.Format(strSqlCC, param.userGuid, strMenuGuid)); } if (param.recursion) { // 递归取得所有子公司 AuthCompany auth = new AuthCompany(); auth.action = param.action; auth.userGuid = param.userGuid; List <Model.SOMastData.Company> lstCompany = (new CompanyFactory()).GetCompanyInAuth(auth); SingleField sf = new SingleField(); foreach (Model.SOMastData.Company company in lstCompany) { sf = new SingleField(); sf.guid = company.companyGuid; lstCP.Add(sf); } } else { lstCP = SqlServerHelper.GetEntityList <SingleField>(SqlServerHelper.salesorderConn(), string.Format(strSqlCP, param.userGuid, strMenuGuid)); } if (lstCP != null && lstCP.Any()) { strCompanyGuid = string.Join("','", lstCP.Select(r => r.guid).Distinct().ToArray()); strCompanyGuid = "('" + strCompanyGuid + "')"; // 取得CompanyGuid对应的companyCode string strSqlCompany = " SELECT GUID " + " , COMPANY AS CODE " + " , NAME_ZH AS NAME1 " + " , NAME_EN AS NAME2 " + " FROM COMPANY " + " WHERE GUID IN {0} " + " AND STATUS = '1' "; lstCP = SqlServerHelper.GetEntityList <SingleField>(SqlServerHelper.salesorderConn(), string.Format(strSqlCompany, strCompanyGuid)); lstCP = lstCP.OrderBy(r => r.code).ToList(); } if ("company".Equals(param.fieldName.ToLower())) { return(lstCP); } /***将公司List转换成CCList***/ if (lstCP != null && lstCP.Any()) { List <SingleField> lstTemp = new List <SingleField>(); strCompanyCode = string.Join("','", lstCP.Select(r => r.code).Distinct().ToArray()); strCompanyCode = "('" + strCompanyCode + "')"; string strSqlCostCenter = " SELECT COSTCENTERCODE AS CODE" + " FROM CCMast " + " WHERE STATUS = '1' " + " AND DBNAME IN {0} "; lstTemp = SqlServerHelper.GetEntityList <SingleField>(SqlServerHelper.salesorderConn(), string.Format(strSqlCostCenter, strCompanyCode)); lstCC = lstCC.Concat(lstTemp).ToList(); lstCC = lstCC.OrderBy(r => r.code).ToList(); /***根据Code去重复***/ lstCC = lstCC.Where((x, i) => lstCC.FindIndex(z => z.code == x.code) == i).ToList(); } return(lstCC); }