///// <summary> ///// 获取指定对象中的所有用户对象 ///// </summary> ///// <param name="xmlObjDoc">要求被查询的数据对象</param> ///// <param name="soc">查询要求的查询列名称 ///// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> ///// <param name="strOrgLimitValues">要求对象所在机构的范围内(如果没有将采用系统配置数据,可空)</param> ///// <param name="soco">要求所在机构的范围的查询列名称 ///// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> ///// <param name="lot">要求被查询的数据对象类型(主要是用于辨别是否要求查询兼职人员)</param> ///// <param name="lod">系统中被逻辑删除对象是否查询取出</param> ///// <param name="strHideType">要求隐藏的设置类型</param> ///// <param name="strAttrs">要求获得的数据属性</param> ///// <returns>获取指定对象中的所有用户对象</returns> ///// <remarks> ///// <code> ///// xmlObjDoc的结构: ///// <OBJECTS> ///// <ORGANIZATIONS oValue="" rankCode="" /> ///// <GROUPS oValue="" rankCode="" /> ///// <USERS oValue="" parentGuid="" /> ///// </OBJECTS> ///// </code> ///// </remarks> //public static DataSet GetAllUsersInAllObjects(XmlDocument xmlObjDoc, SearchObjectColumn soc, string strOrgLimitValues, SearchObjectColumn soco, ListObjectType lot, ListObjectDelete lod, string strHideType, string strAttrs) //{ // DataAccess da = new DataAccess(OGUCommonDefine.STR_CONN); // using (da.dBContextInfo) // { // da.dBContextInfo.OpenConnection(); // return GetAllUsersInAllObjects(xmlObjDoc, soc, strOrgLimitValues, soco, lot, lod, strHideType, strAttrs, da); // } //} /// <summary> /// 获取指定对象中的所有用户对象 /// </summary> /// <param name="xmlObjDoc">要求被查询的数据对象</param> /// <param name="soc">查询要求的查询列名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strOrgLimitValues">要求对象所在机构的范围内(如果没有将采用系统配置数据,可空)</param> /// <param name="soco">要求所在机构的范围的查询列名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> /// <param name="lot">要求被查询的数据对象类型(主要是用于辨别是否要求查询兼职人员)</param> /// <param name="lod">系统中被逻辑删除对象是否查询取出</param> /// <param name="strAttrs">要求获得的数据属性</param> /// <returns>获取指定对象中的所有用户对象</returns> /// <remarks> /// <code> /// xmlObjDoc的结构: /// <OBJECTS> /// <ORGANIZATIONS oValue="" rankCode="" /> /// <GROUPS oValue="" rankCode="" /> /// <USERS oValue="" parentGuid="" /> /// </OBJECTS> /// </code> /// </remarks> public static DataSet GetAllUsersInAllObjects(XmlDocument xmlObjDoc, SearchObjectColumn soc, string strOrgLimitValues, SearchObjectColumn soco, ListObjectType lot, ListObjectDelete lod, string strAttrs) { return GetAllUsersInAllObjects(xmlObjDoc, soc, strOrgLimitValues, soco, lot, lod, string.Empty, strAttrs); }
/// <summary> /// 获取指定对象中的所有用户对象 /// </summary> /// <param name="xmlObjDoc">要求被查询的数据对象</param> /// <param name="soc">查询要求的查询列名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> /// <param name="strOrgLimitValues">要求对象所在机构的范围内(如果没有将采用系统配置数据,可空)</param> /// <param name="soco">要求所在机构的范围的查询列名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> /// <param name="lot">要求被查询的数据对象类型(主要是用于辨别是否要求查询兼职人员)</param> /// <param name="lod">系统中被逻辑删除对象是否查询取出</param> /// <param name="strHideType">要求隐藏的设置类型</param> /// <param name="strAttrs">要求获得的数据属性</param> /// <returns>获取指定对象中的所有用户对象</returns> /// <remarks> /// <code> /// xmlObjDoc的结构: /// <OBJECTS> /// <ORGANIZATIONS oValue="" rankCode="" /> /// <GROUPS oValue="" rankCode="" /> /// <USERS oValue="" parentGuid="" /> /// </OBJECTS> /// </code> /// </remarks> public static DataSet GetAllUsersInAllObjects(XmlDocument xmlObjDoc, SearchObjectColumn soc, string strOrgLimitValues, SearchObjectColumn soco, ListObjectType lot, ListObjectDelete lod, string strHideType, string strAttrs) { string cacheKey = InnerCacheHelper.BuildCacheKey(xmlObjDoc.DocumentElement.OuterXml, soc, strOrgLimitValues, soco, lot, lod, strHideType, strAttrs); DataSet result; //if (false == GetAllUsersInAllObjectsQueue.Instance.TryGetValue(cacheKey, out result)) //{ // lock (typeof(GetAllUsersInAllObjectsQueue)) // { if (false == GetAllUsersInAllObjectsQueue.Instance.TryGetValue(cacheKey, out result)) { #region Prepare Db ExceptionHelper.TrueThrow(xmlObjDoc.DocumentElement.ChildNodes.Count <= 0, "对不起,系统没有给定要求查询的数据对象!"); strAttrs = OGUCommonDefine.CombinateAttr(strAttrs); string strObjColName = OGUCommonDefine.GetSearchObjectColumn(soc); string strDelUser = GetSqlSearchStatus("OU_USERS", lod); strHideType = OGUCommonDefine.GetHideType(strHideType); string strHideList = GetHideTypeFromXmlForLike(strHideType, "OU_USERS"); string strListObjectType = string.Empty; if ((lot & ListObjectType.SIDELINE) == 0) strListObjectType = " AND OU_USERS.SIDELINE = 0 "; if (strOrgLimitValues.Length == 0) { strOrgLimitValues = AccreditSection.GetConfig().AccreditSettings.OguRootName;// (new SysConfig()).GetDataFromConfig("OGURootName", string.Empty); ExceptionHelper.TrueThrow<ApplicationException>(string.IsNullOrEmpty(strOrgLimitValues), "对不起,您没有配置好系统默认指定的初始机构!请检查web.config中的configuration\\appSettings\\<add key=\"OGURootName\" value=\"\" />"); soco = SearchObjectColumn.SEARCH_ALL_PATH_NAME; } #endregion StringBuilder strB = new StringBuilder(1024); foreach (XmlElement elem in xmlObjDoc.DocumentElement.ChildNodes) { string strRankLimit = elem.GetAttribute("rankCode"); if (strRankLimit != null && strRankLimit.Length > 0) strRankLimit = " AND RANK_DEFINE.SORT_ID <= (SELECT SORT_ID FROM RANK_DEFINE WHERE CODE_NAME = " + TSqlBuilder.Instance.CheckQuotationMark(strRankLimit, true) + " ) "; else strRankLimit = string.Empty; string strSql = string.Empty; switch (elem.LocalName) { case "ORGANIZATIONS": #region ORGANIZATIONS strSql = @" SELECT 'USERS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttrs, "USERS", "OU_USERS", "RANK_DEFINE") + @" FROM ORGANIZATIONS, OU_USERS, USERS JOIN RANK_DEFINE ON RANK_DEFINE.CODE_NAME = USERS.RANK_CODE " + strRankLimit + @", ( SELECT ORIGINAL_SORT FROM ORGANIZATIONS WHERE " + OGUCommonDefine.GetSearchObjectColumn(soco) + " IN (" + OGUCommonDefine.AddMulitStrWithQuotationMark(strOrgLimitValues) + @" ) ) ORG_LIMIT WHERE USERS.GUID = OU_USERS.USER_GUID AND " + DatabaseSchema.Instence.GetTableColumns(strObjColName, "ORGANIZATIONS") + " = " + TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("oValue"), true) + @" AND OU_USERS.ORIGINAL_SORT LIKE ORGANIZATIONS.ORIGINAL_SORT + '%' AND OU_USERS.ORIGINAL_SORT LIKE ORG_LIMIT.ORIGINAL_SORT + '%' AND (" + strDelUser + @") " + strHideList + strListObjectType; break; #endregion case "GROUPS": #region GROUPS strSql = @" SELECT 'USERS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttrs, "USERS", "OU_USERS", "RANK_DEFINE") + @" FROM GROUPS, GROUP_USERS, OU_USERS, USERS JOIN RANK_DEFINE ON RANK_DEFINE.CODE_NAME = USERS.RANK_CODE " + strRankLimit + @", ( SELECT ORIGINAL_SORT FROM ORGANIZATIONS WHERE " + OGUCommonDefine.GetSearchObjectColumn(soco) + " IN (" + OGUCommonDefine.AddMulitStrWithQuotationMark(strOrgLimitValues) + @" ) ) ORG_LIMIT WHERE GROUPS.GUID = GROUP_USERS.GROUP_GUID AND GROUP_USERS.USER_PARENT_GUID = OU_USERS.PARENT_GUID AND GROUP_USERS.USER_GUID = OU_USERS.USER_GUID AND USERS.GUID = OU_USERS.USER_GUID AND OU_USERS.ORIGINAL_SORT LIKE ORG_LIMIT.ORIGINAL_SORT + '%' AND " + DatabaseSchema.Instence.GetTableColumns(strObjColName, "GROUPS") + " = " + TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("oValue"), true) + @" AND (" + strDelUser + @") " + strHideList + strListObjectType; break; #endregion case "USERS": #region USERS strSql = @" SELECT 'USERS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttrs, "USERS", "OU_USERS", "RANK_DEFINE") + @" FROM OU_USERS, USERS JOIN RANK_DEFINE ON RANK_DEFINE.CODE_NAME = USERS.RANK_CODE " + strRankLimit + @", ( SELECT ORIGINAL_SORT FROM ORGANIZATIONS WHERE " + OGUCommonDefine.GetSearchObjectColumn(soco) + " IN (" + OGUCommonDefine.AddMulitStrWithQuotationMark(strOrgLimitValues) + @" ) ) ORG_LIMIT WHERE OU_USERS.USER_GUID = USERS.GUID AND OU_USERS.ORIGINAL_SORT LIKE ORG_LIMIT.ORIGINAL_SORT + '%' AND " + DatabaseSchema.Instence.GetTableColumns(strObjColName, "OU_USERS", "USERS") + " = " + TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("oValue"), true) + @" AND (" + strDelUser + @") " + strHideList + strListObjectType; break; #endregion default: ExceptionHelper.TrueThrow(true, "对不起,系统没有对应处理“" + elem.LocalName + "”的相应程序!"); break; } if (strB.Length > 0) strB.Append(Environment.NewLine + " UNION " + Environment.NewLine); strB.Append("(" + strSql + ")"); } using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias)) { Database database = DatabaseFactory.Create(context); string sql = "SELECT * FROM (" + strB.ToString() + ") A ORDER BY GLOBAL_SORT"; result = database.ExecuteDataSet(CommandType.Text, sql); } GetAllUsersInAllObjectsQueue.Instance.Add(cacheKey, result, InnerCacheHelper.PrepareDependency()); } // } //} return result; }