/// <summary> /// 获取指定部门下的所有子对象 /// </summary> /// <param name="strOrgValues">要求查询的部门对象(父部门标识,多个之间采用","分隔)</param> /// <param name="soc">查询要求的查询列名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> /// <param name="iLot">要求查询的数据对象类型(机构、组、人员、兼职对象)</param> /// <param name="iLod">是否包含被逻辑删除的成员</param> /// <param name="iDepth">要求查询的层次(最少一层)(0代表全部子对象)</param> /// <param name="strOrgRankCodeName">查询中要求的机构对象级别</param> /// <param name="strUserRankCodeName">查询中要求的人员对象级别</param> /// <param name="strHideType">查询中要求屏蔽的数据(对应于配置文件HideTypes.xml中的配置)</param> /// <param name="strAttrs">查询中要求获取数据对象的属性类型</param> /// <param name="iOrgClass">要求展现机构的类型</param> /// <param name="iOrgType">要求展现机构的属性</param> /// <returns>获取指定部门下的所有子对象的查询结果</returns> public static DataSet GetOrganizationChildren(string strOrgValues, SearchObjectColumn soc, int iLot, int iLod, int iDepth, string strOrgRankCodeName, string strUserRankCodeName, string strHideType, string strAttrs, int iOrgClass, int iOrgType) { strAttrs = OGUCommonDefine.CombinateAttr(strAttrs); SearchOrgChildrenCondition scc = new SearchOrgChildrenCondition(strOrgValues, soc, strAttrs); scc.ListObjDelete = (ListObjectDelete)iLod; scc.ListObjType = (ListObjectType)iLot; scc.Depth = iDepth; scc.OrgRankCN = strOrgRankCodeName; scc.UserRankCN = strUserRankCodeName; scc.HideType = strHideType; scc.OrgClass = iOrgClass; scc.OrgType = iOrgType; return GetOrganizationChildren(scc); }
//public SearchOrgChildrenCondition(string strRootGuids, string strAttrs, DataAccess da) //{ // InitSearchOrgChildrenCondition(strRootGuids, strAttrs, da); //} /// <summary> /// 构造函数(构造数据对象查询条件) /// </summary> /// <param name="strRootValues">指定的机构标识(多个之间采用“,”分隔)</param> /// <param name="soc">查询要求的查询列名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> /// <param name="strAttrs">要求获取的属性</param> public SearchOrgChildrenCondition(string strRootValues, SearchObjectColumn soc, string strAttrs) { using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias)) { string strRootGuids = string.Empty; if (strRootValues.Length > 0 && soc != SearchObjectColumn.SEARCH_GUID) { Database database = DatabaseFactory.Create(context); DataSet ds = OGUReader.GetObjectsDetail("ORGANIZATIONS", strRootValues, soc, string.Empty, SearchObjectColumn.SEARCH_NULL, string.Empty); foreach (DataRow row in ds.Tables[0].Rows) { if (strRootGuids.Length > 0) { strRootGuids += ","; } strRootGuids += row["GUID"].ToString(); } } else { strRootGuids = strRootValues; } InitSearchOrgChildrenCondition(strRootGuids, strAttrs, string.IsNullOrEmpty(strRootValues) ? true : false); } }
/// <summary> /// 获取查询的数据字段名称代号 /// </summary> /// <param name="strValueType">对应查询的数据结果(对应字段名称)</param> /// <returns>数据查询条件类型(对应于字段名称)</returns> public static SearchObjectColumn GetSearchObjectColumn(string strValueType) { SearchObjectColumn soc = SearchObjectColumn.SEARCH_NULL; switch (strValueType) { case "GUID": soc = SearchObjectColumn.SEARCH_GUID; break; case "USER_GUID": soc = SearchObjectColumn.SEARCH_USER_GUID; break; case "ORIGINAL_SORT": soc = SearchObjectColumn.SEARCH_ORIGINAL_SORT; break; case "GLOBAL_SORT": soc = SearchObjectColumn.SEARCH_GLOBAL_SORT; break; case "ALL_PATH_NAME": soc = SearchObjectColumn.SEARCH_ALL_PATH_NAME; break; case "LOGON_NAME": soc = SearchObjectColumn.SEARCH_LOGON_NAME; break; case "PERSON_ID": soc = SearchObjectColumn.SEARCH_PERSON_ID; break; case "IC_CARD": soc = SearchObjectColumn.SEARCH_IC_CARD; break; case "CUSTOMS_CODE": soc = SearchObjectColumn.SEARCH_CUSTOMS_CODE; break; case "SYSDISTINCT1": soc = SearchObjectColumn.SEARCH_SYSDISTINCT1; break; case "SYSDISTINCT2": soc = SearchObjectColumn.SEARCH_SYSDISTINCT2; break; case "SYSOUDISTINCT1": soc = SearchObjectColumn.SEARCH_OUSYSDISTINCT1; break; case "SYSOUDISTINCT2": soc = SearchObjectColumn.SEARCH_OUSYSDISTINCT2; break; //为配合南京海关统一平台切换,新增加字段ID[自增唯一字段] case "ID": case "[ID]": soc = SearchObjectColumn.SEARCH_IDENTITY; break; default: ExceptionHelper.TrueThrow <ApplicationException>(true, "对不起,系统不提供该" + strValueType + "查询数据类型!"); break; } return(soc); }
/// <summary> /// 获取查询的数据字段名称 /// </summary> /// <param name="soc">数据查询条件类型(对应于字段名称)</param> /// <returns>对应查询的数据结果(对应字段名称)</returns> internal static string GetSearchObjectColumn(SearchObjectColumn soc) { string strResult = string.Empty; switch (soc) { case SearchObjectColumn.SEARCH_GUID: strResult = "GUID"; break; case SearchObjectColumn.SEARCH_USER_GUID: strResult = "USER_GUID"; break; case SearchObjectColumn.SEARCH_ORIGINAL_SORT: strResult = "ORIGINAL_SORT"; break; case SearchObjectColumn.SEARCH_GLOBAL_SORT: strResult = "GLOBAL_SORT"; break; case SearchObjectColumn.SEARCH_ALL_PATH_NAME: strResult = "ALL_PATH_NAME"; break; case SearchObjectColumn.SEARCH_LOGON_NAME: strResult = "LOGON_NAME"; break; case SearchObjectColumn.SEARCH_PERSON_ID: strResult = "PERSON_ID"; break; case SearchObjectColumn.SEARCH_IC_CARD: strResult = "IC_CARD"; break; case SearchObjectColumn.SEARCH_CUSTOMS_CODE: strResult = "CUSTOMS_CODE"; break; case SearchObjectColumn.SEARCH_SYSDISTINCT1: strResult = "SYSDISTINCT1"; break; case SearchObjectColumn.SEARCH_SYSDISTINCT2: strResult = "SYSDISTINCT2"; break; case SearchObjectColumn.SEARCH_OUSYSDISTINCT1: strResult = "SYSOUDISTINCT1"; break; case SearchObjectColumn.SEARCH_OUSYSDISTINCT2: strResult = "SYSOUDISTINCT2"; break; //为配合南京海关统一平台切换,新增加字段ID[自增唯一字段] case SearchObjectColumn.SEARCH_IDENTITY: strResult = "ID"; break; case SearchObjectColumn.SEARCH_NULL: default: ExceptionHelper.TrueThrow <ApplicationException>(true, "对不起,系统不提供该" + soc.ToString() + "查询数据类型!"); break; } return(strResult); }
/// <summary> /// /// </summary> private void GetObjectsDetail() { XmlElement root = _XmlRequest.DocumentElement; string strValueType = root.GetAttribute("valueType"); SearchObjectColumn soc = OGUCommonDefine.GetSearchObjectColumn(strValueType); string strValue = root.GetAttribute("oValues"); string strExtAttr = root.GetAttribute("extAttrs"); DataSet ds = OGUReader.GetObjectsDetail(string.Empty, strValue, soc, string.Empty, SearchObjectColumn.SEARCH_NULL, strExtAttr); _XmlResult = InnerCommon.GetXmlDocAttr(ds.Tables[0], "OBJECTCLASS"); #if DEBUG Debug.WriteLine(_XmlResult.OuterXml, "Result"); #endif }
/// <summary> /// 用户修改口令接口 /// </summary> /// <param name="strUserValue">要求被修改口令的用户</param> /// <param name="socu">strUserValue对应的数据类型</param> /// <param name="strOldPwd">用户的旧口令</param> /// <param name="strNewPwd">使用的新口令</param> /// <param name="strConfirmPwd">新口令的确认</param> /// <returns>本次修改是否成功</returns> public bool UpdateUserPwd(string strUserValue, SearchObjectColumn socu, string strOldPwd, string strNewPwd, string strConfirmPwd) { ExceptionHelper.TrueThrow(string.IsNullOrEmpty(strNewPwd.Trim()), "对不起,用户的登录口令不能为空!"); ExceptionHelper.FalseThrow(strNewPwd == strConfirmPwd, "对不起,用户的“新口令”必须与“确认口令”一致!"); using (TransactionScope scope = TransactionScopeFactory.Create()) { using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias)) { Database database = DatabaseFactory.Create(context); string strUserColName = OGUCommonDefine.GetSearchObjectColumn(socu); string strSql = @"SELECT USERS.GUID FROM USERS, OU_USERS WHERE USERS.GUID = OU_USERS.USER_GUID AND " + DatabaseSchema.Instence.GetTableColumns(strUserColName, "USERS") + " = " + TSqlBuilder.Instance.CheckQuotationMark(strUserValue, true) + @"; SELECT TOP 1 GUID FROM PWD_ARITHMETIC WHERE VISIBLE = 1 ORDER BY SORT_ID;" ; DataSet ds = database.ExecuteDataSet(CommandType.Text, strSql); ExceptionHelper.TrueThrow(ds.Tables[0].Rows.Count == 0, "对不起,系统中没有找到您指定的用户!"); ExceptionHelper.TrueThrow(ds.Tables[0].Rows.Count > 1, "对不起,您指定的用户在系统中不唯一!"); ExceptionHelper.TrueThrow(ds.Tables[1].Rows.Count < 1, "对不起,系统中找的不到数据表PWD_ARITHMETIC的数据!"); string secNewPwd = SecurityCalculate.PwdCalculate(ds.Tables[1].Rows[0][0].ToString(), strNewPwd); string secOldPwd = SecurityCalculate.PwdCalculate(ds.Tables[1].Rows[0][0].ToString(), strOldPwd); strSql = "UPDATE USERS SET USER_PWD = " + TSqlBuilder.Instance.CheckQuotationMark(secNewPwd, true) + @" WHERE USERS.GUID = " + TSqlBuilder.Instance.CheckQuotationMark((string)ds.Tables[0].Rows[0]["GUID"], true) + @" AND USERS.USER_PWD = " + TSqlBuilder.Instance.CheckQuotationMark(secOldPwd, true); ExceptionHelper.FalseThrow(database.ExecuteNonQuery(CommandType.Text, strSql) == 1, "对不起,用户的旧口令不正确!"); } scope.Complete(); } return(true); }
/// <summary> /// 用户修改口令接口 /// </summary> /// <param name="strUserValue">要求被修改口令的用户</param> /// <param name="socu">strUserValue对应的数据类型</param> /// <param name="strOldPwd">用户的旧口令</param> /// <param name="strNewPwd">使用的新口令</param> /// <param name="strConfirmPwd">新口令的确认</param> /// <returns>本次修改是否成功</returns> public bool UpdateUserPwd(string strUserValue, SearchObjectColumn socu, string strOldPwd, string strNewPwd, string strConfirmPwd) { ExceptionHelper.TrueThrow(string.IsNullOrEmpty(strNewPwd.Trim()), "对不起,用户的登录口令不能为空!"); ExceptionHelper.FalseThrow(strNewPwd == strConfirmPwd, "对不起,用户的“新口令”必须与“确认口令”一致!"); using (TransactionScope scope = TransactionScopeFactory.Create()) { using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias)) { Database database = DatabaseFactory.Create(context); string strUserColName = OGUCommonDefine.GetSearchObjectColumn(socu); string strSql = @"SELECT USERS.GUID FROM USERS, OU_USERS WHERE USERS.GUID = OU_USERS.USER_GUID AND " + DatabaseSchema.Instence.GetTableColumns(strUserColName, "USERS") + " = " + TSqlBuilder.Instance.CheckQuotationMark(strUserValue, true) + @"; SELECT TOP 1 GUID FROM PWD_ARITHMETIC WHERE VISIBLE = 1 ORDER BY SORT_ID;"; DataSet ds = database.ExecuteDataSet(CommandType.Text, strSql); ExceptionHelper.TrueThrow(ds.Tables[0].Rows.Count == 0, "对不起,系统中没有找到您指定的用户!"); ExceptionHelper.TrueThrow(ds.Tables[0].Rows.Count > 1, "对不起,您指定的用户在系统中不唯一!"); ExceptionHelper.TrueThrow(ds.Tables[1].Rows.Count < 1, "对不起,系统中找的不到数据表PWD_ARITHMETIC的数据!"); string secNewPwd = SecurityCalculate.PwdCalculate(ds.Tables[1].Rows[0][0].ToString(), strNewPwd); string secOldPwd = SecurityCalculate.PwdCalculate(ds.Tables[1].Rows[0][0].ToString(), strOldPwd); strSql = "UPDATE USERS SET USER_PWD = " + TSqlBuilder.Instance.CheckQuotationMark(secNewPwd, true) + @" WHERE USERS.GUID = " + TSqlBuilder.Instance.CheckQuotationMark((string)ds.Tables[0].Rows[0]["GUID"], true) + @" AND USERS.USER_PWD = " + TSqlBuilder.Instance.CheckQuotationMark(secOldPwd, true); ExceptionHelper.FalseThrow(database.ExecuteNonQuery(CommandType.Text, strSql) == 1, "对不起,用户的旧口令不正确!"); } scope.Complete(); } return true; }
/// <summary> /// 形成根据指定条件查询“人员”的SQL语句 /// </summary> /// <param name="strOrgValues">指定的范围机构标识(多个之间采用","分隔)</param> /// <param name="soc">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> /// <param name="strLikeName">“人员”上的名称模糊匹配对象</param> /// <param name="bLike">是否采用模糊匹配</param> /// <param name="strAttr">要求获取的字段属性</param> /// <param name="iListObjType">用于是否查询兼职问题</param> /// <param name="iLod">查询删除的对象策略</param> /// <param name="iDep">要求查询的深度</param> /// <param name="strHideType">要求屏蔽的类型设置</param> /// <param name="rootPath">传入的ORIGINAL_SORT</param> /// <returns>形成根据指定条件查询“人员”的SQL语句</returns> /// //2009-05-06 删除 RANK_DEFINE 约束,调整ORIGINAL_SORT约束 private static string QueryUsersByCondition2(string strOrgValues, SearchObjectColumn soc, string strLikeName, bool bLike, string strAttr, int iListObjType, ListObjectDelete iLod, int iDep, string strHideType, string rootPath) { string strColName = OGUCommonDefine.GetSearchObjectColumn(soc); StringBuilder strB = new StringBuilder(1024); strB.Append(@" SELECT 'USERS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttr, "USERS", "OU_USERS") + @" FROM USERS , OU_USERS WHERE USERS.GUID = OU_USERS.USER_GUID AND ( " + GetSqlSearchParOriginal2("OU_USERS", iDep, rootPath) + " )"); string strListDelete = GetSqlSearchStatus("OU_USERS", iLod); if (strListDelete.Length > 0) strB.Append(" \n AND ( " + strListDelete + " ) "); if ((iListObjType & (int)ListObjectType.SIDELINE) == 0) strB.Append(" \n AND OU_USERS.SIDELINE = 0 "); if (strLikeName != SearchAllTerm) strB.Append(string.Format(@" AND (OU_USERS.SEARCH_NAME like '%{0}%')", strLikeName)); else strB.Append(BuildSearchCondition("OU_USERS.SEARCH_NAME", strLikeName, bLike)); //strB.Append(BuildSearchCondition("OU_USERS.SEARCH_NAME", strLikeName, bLike)); if (strHideType.Length > 0) strB.Append(GetHideTypeFromXmlForLike(strHideType, "OU_USERS")); return strB.ToString(); }
/// <summary> /// 获取指定对象的父机构对象(GROUPS、USERS或者是ORGANIZATIONS的父部门) /// </summary> /// <param name="strObjType">要查询自身的对象(GROUPS、USERS或者ORGANIZATIONS)</param> /// <param name="strObjValues">自身所具有的数据值</param> /// <param name="soc">自身所具有的数据类型(GUID、OBJ_NAME、ORIGINAL_SORT、GLOBAL_SORT等)</param> /// <param name="bOnlyDirectly">是否仅仅获取最接近的机构对象</param> /// <param name="bWithVisiual">是否要求忽略虚拟部门</param> /// <param name="strOrgRankCodeName">要求最低的机构行政级别</param> /// <param name="strAttrs">要求获取的数据字段</param> /// <returns>获取指定对象的父部门对象</returns> public static DataSet GetObjectParentOrgs(string strObjType, string strObjValues, SearchObjectColumn soc, bool bOnlyDirectly, bool bWithVisiual, string strOrgRankCodeName, string strAttrs) { string cacheKey = InnerCacheHelper.BuildCacheKey(strObjType, strObjValues, soc, bOnlyDirectly, bWithVisiual, strOrgRankCodeName, strAttrs); DataSet result; //if (false == GetObjectParentOrgsQueue.Instance.TryGetValue(cacheKey, out result)) //{ // lock (typeof(GetObjectParentOrgsQueue)) // { if (false == GetObjectParentOrgsQueue.Instance.TryGetValue(cacheKey, out result)) { string strColName = OGUCommonDefine.GetSearchObjectColumn(soc); strAttrs = OGUCommonDefine.CombinateAttr(strAttrs); string strSql = string.Empty; string strWhere = string.Empty; string strWhereRankDefine = string.Empty; if (false == bWithVisiual)//计虚拟部门 strWhere = " AND ORGANIZATIONS.ORG_TYPE <> 1 "; if (strOrgRankCodeName.Length > 0) strWhereRankDefine = " AND RANK_DEFINE.SORT_ID <= (SELECT SORT_ID FROM RANK_DEFINE WHERE CODE_NAME = " + TSqlBuilder.Instance.CheckQuotationMark(strOrgRankCodeName.Trim(), true) + ") "; using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias)) { switch (strObjType) { case "ORGANIZATIONS": case "GROUPS": #region ORGANIZATIONS And GROUPS strSql = @" SELECT {0} 'ORGANIZATIONS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttrs, "ORGANIZATIONS", "RANK_DEFINE") + @" FROM ORGANIZATIONS JOIN RANK_DEFINE ON ORGANIZATIONS.RANK_CODE = RANK_DEFINE.CODE_NAME " + strWhereRankDefine + @" WHERE (SELECT ORIGINAL_SORT FROM {1} WHERE {2}) LIKE ORGANIZATIONS.ORIGINAL_SORT + '%' " + strWhere + @" ORDER BY ORGANIZATIONS.ORIGINAL_SORT DESC"; string strOnlyDirectly = string.Empty; if (bOnlyDirectly) strOnlyDirectly = " TOP 2 "; //strOnlyDirectly = " TOP 1 ";//Modify By Yuanyong 20080723如果为1的话就只能返回自身这个对象了 string strOrgSelf = DatabaseSchema.Instence.GetTableColumns(strColName, strObjType) + " IN (" + OGUCommonDefine.AddMulitStrWithQuotationMark(strObjValues) + ") "; strSql = string.Format(strSql, strOnlyDirectly, TSqlBuilder.Instance.CheckQuotationMark(strObjType, false), strOrgSelf); break; #endregion case "USERS": #region USERS strWhere += " AND " + DatabaseSchema.Instence.GetTableColumns(strColName, strObjType, "OU_USERS") + " IN (" + OGUCommonDefine.AddMulitStrWithQuotationMark(strObjValues) + ") "; if (bOnlyDirectly) { strSql = @" SELECT 'ORGANIZATIONS' AS OBJECTCLASS, S.* FROM ( SELECT OU_USERS.GLOBAL_SORT AS USERS_GLOBAL_SORT, MAX(LEN(ORGANIZATIONS.ORIGINAL_SORT)) AS MAX_LEN FROM USERS, OU_USERS, ORGANIZATIONS JOIN RANK_DEFINE ON ORGANIZATIONS.RANK_CODE = RANK_DEFINE.CODE_NAME {2} WHERE USERS.GUID = OU_USERS.USER_GUID AND OU_USERS.ORIGINAL_SORT LIKE ORGANIZATIONS.ORIGINAL_SORT + '%' {0} GROUP BY OU_USERS.GLOBAL_SORT ) G, ( SELECT OU_USERS.GLOBAL_SORT AS USERS_GLOBAL_SORT, {1} FROM USERS, OU_USERS, ORGANIZATIONS JOIN RANK_DEFINE ON ORGANIZATIONS.RANK_CODE = RANK_DEFINE.CODE_NAME {2} WHERE USERS.GUID = OU_USERS.USER_GUID AND OU_USERS.ORIGINAL_SORT LIKE ORGANIZATIONS.ORIGINAL_SORT + '%' {0} ) S WHERE G.USERS_GLOBAL_SORT = S.USERS_GLOBAL_SORT AND G.MAX_LEN = LEN(S.ORIGINAL_SORT) ORDER BY S.USERS_GLOBAL_SORT DESC "; } else { strSql = @" SELECT 'ORGANIZATIONS' AS OBJECTCLASS, {1} FROM USERS, OU_USERS, ORGANIZATIONS JOIN RANK_DEFINE ON ORGANIZATIONS.RANK_CODE = RANK_DEFINE.CODE_NAME {2} WHERE USERS.GUID = OU_USERS.USER_GUID AND OU_USERS.ORIGINAL_SORT LIKE ORGANIZATIONS.ORIGINAL_SORT + '%' {0} ORDER BY OU_USERS.ORIGINAL_SORT, ORGANIZATIONS.ORIGINAL_SORT DESC "; } strSql = string.Format(strSql, strWhere, DatabaseSchema.Instence.GetTableColumns(strAttrs, "ORGANIZATIONS", "RANK_DEFINE", "OU_USERS", "USERS"), strWhereRankDefine); break; #endregion } Database database = DatabaseFactory.Create(CommonResource.AccreditConnAlias); result = database.ExecuteDataSet(CommandType.Text, strSql); } GetObjectParentOrgsQueue.Instance.Add(cacheKey, result, InnerCacheHelper.PrepareDependency()); } // } //} return result; }
/// <summary> /// 获取查询的数据字段名称 /// </summary> /// <param name="soc">数据查询条件类型(对应于字段名称)</param> /// <returns>对应查询的数据结果(对应字段名称)</returns> internal static string GetSearchObjectColumn(SearchObjectColumn soc) { string strResult = string.Empty; switch (soc) { case SearchObjectColumn.SEARCH_GUID: strResult = "GUID"; break; case SearchObjectColumn.SEARCH_USER_GUID: strResult = "USER_GUID"; break; case SearchObjectColumn.SEARCH_ORIGINAL_SORT: strResult = "ORIGINAL_SORT"; break; case SearchObjectColumn.SEARCH_GLOBAL_SORT: strResult = "GLOBAL_SORT"; break; case SearchObjectColumn.SEARCH_ALL_PATH_NAME: strResult = "ALL_PATH_NAME"; break; case SearchObjectColumn.SEARCH_LOGON_NAME: strResult = "LOGON_NAME"; break; case SearchObjectColumn.SEARCH_PERSON_ID: strResult = "PERSON_ID"; break; case SearchObjectColumn.SEARCH_IC_CARD: strResult = "IC_CARD"; break; case SearchObjectColumn.SEARCH_CUSTOMS_CODE: strResult = "CUSTOMS_CODE"; break; case SearchObjectColumn.SEARCH_SYSDISTINCT1: strResult = "SYSDISTINCT1"; break; case SearchObjectColumn.SEARCH_SYSDISTINCT2: strResult = "SYSDISTINCT2"; break; case SearchObjectColumn.SEARCH_OUSYSDISTINCT1: strResult = "SYSOUDISTINCT1"; break; case SearchObjectColumn.SEARCH_OUSYSDISTINCT2: strResult = "SYSOUDISTINCT2"; break; //为配合南京海关统一平台切换,新增加字段ID[自增唯一字段] case SearchObjectColumn.SEARCH_IDENTITY: strResult = "ID"; break; case SearchObjectColumn.SEARCH_NULL: default: ExceptionHelper.TrueThrow<ApplicationException>(true, "对不起,系统不提供该" + soc.ToString() + "查询数据类型!"); break; } return strResult; }
///// <summary> ///// ///// </summary> ///// <param name="strObjType"></param> ///// <param name="strObjValue"></param> ///// <param name="soc"></param> ///// <param name="strParentGuid"></param> ///// <param name="objsDs"></param> ///// <returns></returns> //public static bool IsObjectIsIncludeInObjects(string strObjType, string strObjValue, SearchObjectColumn soc, string strParentGuid, DataSet objsDs) //{ // using (TransactionScope scope = TransactionScopeFactory.Create()) // { // using (DbContext context = DbContext.GetContext(AccreditResource.ConnAlias)) // { // DataAccess da = new DataAccess(OGUCommonDefine.STR_CONN); // using (da.dBContextInfo) // { // da.dBContextInfo.OpenConnection(); // return IsObjectIsIncludeInObjects(strObjType, strObjValue, soc, strParentGuid, objsDs, da); // } // } // scope.Complete(); // } //} /// <summary> /// /// </summary> /// <param name="strObjType"></param> /// <param name="strObjValue"></param> /// <param name="soc"></param> /// <param name="objsDs"></param> /// <param name="da"></param> /// <returns></returns> public static bool IsObjectIsIncludeInObjects(string strObjType, string strObjValue, SearchObjectColumn soc, string strParentGuid, DataSet objsDs) { DataSet oDs = OGUReader.GetObjectsDetail(strObjType, strObjValue, soc, strParentGuid, SearchObjectColumn.SEARCH_GUID); foreach (DataRow oRow in oDs.Tables[0].Rows) { string strObjAllPathName = OGUCommonDefine.DBValueToString(oRow["ALL_PATH_NAME"]); foreach (DataRow sRow in objsDs.Tables[0].Rows) { string[] strArry = OGUCommonDefine.DBValueToString(sRow["DESCRIPTION"]).Split(',', ';', ' '); foreach (string strValue in strArry) { if (strValue.Length <= strObjAllPathName.Length && strValue.Length >= 0 && strObjAllPathName.Substring(0, strValue.Length) == strValue) return true; } } } return false; }
/// <summary> /// 判断一个用户是否存在于指定的多个部门之中 /// </summary> /// <param name="strUserValue">用户的属性数据值</param> /// /// <param name="socu">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strUserParentGuid">指定用户所在的父部门标识(可空)</param> /// <param name="objectXmlDoc">判断对象的属性数据值</param> /// <param name="soco">机构的属性名称 /// (GUID、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="bDirect">是否直接从属(无中间部门)</param> /// <param name="bFitAll">是否要求完全匹配(存在于指定的每一个部门中)</param> /// <returns>判断一个用户是否存在于指定的多个部门之中</returns> public static bool IsUserInObjects(string strUserValue, SearchObjectColumn socu, string strUserParentGuid, XmlDocument objectXmlDoc, SearchObjectColumn soco, bool bDirect, bool bFitAll) { return IsUserInObjects(strUserValue, socu, strUserParentGuid, objectXmlDoc, soco, ListObjectDelete.COMMON, bDirect, bFitAll); }
/// <summary> /// 判断一个用户是否存在于指定的多个部门之中 /// </summary> /// <param name="strUserGuid">用户的属性数据值</param> /// <param name="strUserParentGuid">指定用户所在的父部门标识(可空)</param> /// <param name="objectXmlDoc">判断对象的属性数据值</param> /// <param name="soco">机构的属性名称 /// (GUID、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <returns>判断一个用户是否存在于指定的多个部门之中</returns> public static bool IsUserInObjects(string strUserGuid, string strUserParentGuid, XmlDocument objectXmlDoc, SearchObjectColumn soco) { return IsUserInObjects(strUserGuid, SearchObjectColumn.SEARCH_GUID, strUserParentGuid, objectXmlDoc, soco); }
///// <summary> ///// 对于指定对象在系统中重新排序以后返回 ///// </summary> ///// <param name="xmlDoc">包含所有要求被排序对象</param> ///// <param name="soc">xmlDoc中适用于标识机构人员系统对象的属性类别</param> ///// <param name="bSortByRank">是否要求采用级别排序</param> ///// <param name="strAttrs">附加属性</param> ///// <returns>重新排序结果</returns> //public static DataSet GetObjectsSort(XmlDocument xmlDoc, SearchObjectColumn soc, bool bSortByRank, string strAttrs) //{ // DataAccess da = new DataAccess(OGUCommonDefine.STR_CONN); // using (da.dBContextInfo) // { // da.dBContextInfo.OpenConnection(); // return GetObjectsSort(xmlDoc, soc, bSortByRank, strAttrs, da); // } //} /// <summary> /// 对于指定对象在系统中重新排序以后返回 /// </summary> /// <param name="xmlDoc">包含所有要求被排序对象</param> /// <param name="soc">xmlDoc中适用于标识机构人员系统对象的属性类别</param> /// <param name="strAttrs">附加属性</param> /// <returns>重新排序结果</returns> public static DataSet GetObjectsSort(XmlDocument xmlDoc, SearchObjectColumn soc, string strAttrs) { return GetObjectsSort(xmlDoc, soc, true, strAttrs); }
/// <summary> /// 对于指定对象在系统中重新排序以后返回 /// </summary> /// <param name="xmlDoc">包含所有要求被排序对象</param> /// <param name="soc">xmlDoc中适用于标识机构人员系统对象的属性类别</param> /// <returns>重新排序结果</returns> public static DataSet GetObjectsSort(XmlDocument xmlDoc, SearchObjectColumn soc) { return GetObjectsSort(xmlDoc, soc, string.Empty); }
///// <summary> ///// 获取指定对象的父机构对象(GROUPS、USERS或者是ORGANIZATIONS的父部门(指定层次)) ///// </summary> ///// <param name="strObjType">要查询自身的对象(GROUPS、USERS或者ORGANIZATIONS)</param> ///// <param name="strObjValues">自身所具有的数据值(多个之间采用","分隔)</param> ///// <param name="soc">自身所具有的数据类型(GUID、OBJ_NAME、ORIGINAL_SORT、GLOBAL_SORT等)</param> ///// <param name="iDep">要求获取的深度</param> ///// <param name="strAttrs">要求获取的数据字段</param> ///// <returns>获取指定对象的父部门对象</returns> //public static DataSet GetObjectDepOrgs(string strObjType, string strObjValues, SearchObjectColumn soc, int iDep, string strAttrs) //{ // DataAccess da = new DataAccess(OGUCommonDefine.STR_CONN); // using (da.dBContextInfo) // { // da.dBContextInfo.OpenConnection(); // return GetObjectDepOrgs(strObjType, strObjValues, soc, iDep, strAttrs, da); // } //} /// <summary> /// 获取指定对象的父机构对象(GROUPS、USERS或者是ORGANIZATIONS的父部门(指定层次)) /// </summary> /// <param name="strObjType">要查询自身的对象(GROUPS、USERS或者ORGANIZATIONS)</param> /// <param name="strObjValues">自身所具有的数据值(多个之间采用","分隔)</param> /// <param name="soc">自身所具有的数据类型(GUID、OBJ_NAME、ORIGINAL_SORT、GLOBAL_SORT等)</param> /// <param name="strAttrs">要求获取的数据字段</param> /// <returns>获取指定对象的父部门对象</returns> public static DataSet GetObjectDepOrgs(string strObjType, string strObjValues, SearchObjectColumn soc, string strAttrs) { return GetObjectDepOrgs(strObjType, strObjValues, soc, 1, strAttrs); }
/// <summary> /// 对于指定对象在系统中重新排序以后返回 /// </summary> /// <param name="xmlDoc">包含所有要求被排序对象</param> /// <param name="soc">xmlDoc中适用于标识机构人员系统对象的属性类别</param> /// <param name="bSortByRank">是否要求采用级别排序</param> /// <param name="strAttrs">附加数据属性</param> /// <returns>重新排序结果</returns> public static DataSet GetObjectsSort(XmlDocument xmlDoc, SearchObjectColumn soc, bool bSortByRank, string strAttrs) { string cacheKey = InnerCacheHelper.BuildCacheKey(xmlDoc.DocumentElement.OuterXml, soc, bSortByRank, strAttrs); DataSet result; //if (false == GetObjectsSortQueue.Instance.TryGetValue(cacheKey, out result)) //{ // lock (typeof(GetObjectsSortQueue)) // { if (false == GetObjectsSortQueue.Instance.TryGetValue(cacheKey, out result)) { if (strAttrs.Length == 0) strAttrs = "RANK_CODE"; else { if (strAttrs.IndexOf("RANK_CODE") < 0) strAttrs += ",RANK_CODE"; } strAttrs = OGUCommonDefine.CombinateAttr(strAttrs); string strColumnName = OGUCommonDefine.GetSearchObjectColumn(soc); StringBuilder strB = new StringBuilder(1024); XmlElement root = xmlDoc.DocumentElement; foreach (XmlElement elem in root.ChildNodes) { if (strB.Length > 0) strB.Append(","); strB.Append(TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute(strColumnName), true)); } string strSortByRank = string.Empty; string strRankSortID = string.Empty; if (bSortByRank) { strSortByRank = " RANK_DEFINE.SORT_ID, "; strRankSortID = ", ISNULL (RANK_DEFINE.SORT_ID, 99) AS SORT_ID "; } using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias)) { #region Sql Prepare string strSql = @" SELECT RESULT.* " + strRankSortID + @" FROM ( SELECT 'ORGANIZATIONS' AS OBJECTCLASS," + DatabaseSchema.Instence.GetTableColumns(strAttrs, "ORGANIZATIONS", "RANK_DEFINE") + @" FROM ORGANIZATIONS JOIN RANK_DEFINE ON ORGANIZATIONS.RANK_CODE = RANK_DEFINE.CODE_NAME WHERE " + DatabaseSchema.Instence.GetTableColumns(strColumnName, "ORGANIZATIONS") + @" IN ({0}) UNION SELECT 'GROUPS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttrs, "GROUPS") + @" FROM GROUPS WHERE " + DatabaseSchema.Instence.GetTableColumns(strColumnName, "GROUPS") + @" IN ({0}) UNION SELECT 'USERS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttrs, "OU_USERS", "USERS", "RANK_DEFINE") + @" FROM ORGANIZATIONS, OU_USERS, USERS JOIN RANK_DEFINE ON USERS.RANK_CODE = RANK_DEFINE.CODE_NAME WHERE ORGANIZATIONS.GUID = OU_USERS.PARENT_GUID AND USERS.GUID = OU_USERS.USER_GUID AND " + DatabaseSchema.Instence.GetTableColumns(strColumnName, "OU_USERS", "USERS") + @" IN ({0}) )RESULT JOIN RANK_DEFINE ON RANK_DEFINE.CODE_NAME = RESULT.RANK_CODE ORDER BY " + strSortByRank + " RESULT.GLOBAL_SORT"; strSql = string.Format(strSql, strB.ToString()); #endregion Database database = DatabaseFactory.Create(context); result = database.ExecuteDataSet(CommandType.Text, strSql); } GetObjectsSortQueue.Instance.Add(cacheKey, result, InnerCacheHelper.PrepareDependency()); } // } //} return result; }
/// <summary> /// 获取指定对象的父机构对象(GROUPS、USERS或者是ORGANIZATIONS的父部门(指定层次)) /// </summary> /// <param name="strObjType">要查询自身的对象(GROUPS、USERS或者ORGANIZATIONS)</param> /// <param name="strObjValues">自身所具有的数据值</param> /// <param name="soc">自身所具有的数据类型(GUID、OBJ_NAME、ORIGINAL_SORT、GLOBAL_SORT等)</param> /// <param name="iDep">要求获取的深度</param> /// <param name="strAttrs">要求获取的数据字段</param> /// <returns>获取指定对象的父部门对象</returns> public static DataSet GetObjectDepOrgs(string strObjType, string strObjValues, SearchObjectColumn soc, int iDep, string strAttrs) { string cacheKey = InnerCacheHelper.BuildCacheKey(strObjType, strObjValues, soc, iDep, strAttrs); DataSet result; //if (false == GetObjectDepOrgsQueue.Instance.TryGetValue(cacheKey, out result)) //{ // lock (typeof(GetObjectDepOrgsQueue)) // { if (false == GetObjectDepOrgsQueue.Instance.TryGetValue(cacheKey, out result)) { ExceptionHelper.TrueThrow(iDep <= 0, "参数“iDep”的值必须大于0!"); strAttrs = OGUCommonDefine.CombinateAttr(strAttrs); string strColName = OGUCommonDefine.GetSearchObjectColumn(soc); int iLength = iDep * CommonResource.OriginalSortDefault.Length;// OGUCommonDefine.OGU_ORIGINAL_SORT.Length; string strSql = string.Empty; using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias)) { switch (strObjType) { case "ORGANIZATIONS": case "GROUPS": #region ORGANIZATIONS And GROUPS strSql = @" SELECT 'ORGANIZATIONS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttrs, "ORGANIZATIONS", "RANK_DEFINE") + @" FROM ( SELECT ORIGINAL_SORT FROM " + strObjType + @" WHERE " + strColName + " IN (" + OGUCommonDefine.AddMulitStrWithQuotationMark(strObjValues) + @") ) ROS, ORGANIZATIONS JOIN RANK_DEFINE ON ORGANIZATIONS.RANK_CODE = RANK_DEFINE.CODE_NAME WHERE LEN(ORGANIZATIONS.ORIGINAL_SORT) = " + iLength.ToString() + @" AND ROS.ORIGINAL_SORT LIKE ORGANIZATIONS.ORIGINAL_SORT + '%' ORDER BY RANK_DEFINE.SORT_ID, ORGANIZATIONS.GLOBAL_SORT "; break; #endregion case "USERS": #region USERS strSql = @" SELECT 'ORGANIZATIONS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttrs, "ORGANIZATIONS", "RANK_DEFINE") + @" FROM ( SELECT OU_USERS.ORIGINAL_SORT FROM USERS, OU_USERS WHERE USERS.GUID = OU_USERS.USER_GUID AND " + DatabaseSchema.Instence.GetTableColumns(strColName, "USERS", "OU_USERS") + " IN (" + OGUCommonDefine.AddMulitStrWithQuotationMark(strObjValues) + @") ) ROS, ORGANIZATIONS JOIN RANK_DEFINE ON ORGANIZATIONS.RANK_CODE = RANK_DEFINE.CODE_NAME WHERE LEN(ORGANIZATIONS.ORIGINAL_SORT) = " + iLength.ToString() + @" AND ROS.ORIGINAL_SORT LIKE ORGANIZATIONS.ORIGINAL_SORT + '%' ORDER BY RANK_DEFINE.SORT_ID, ORGANIZATIONS.GLOBAL_SORT"; break; #endregion default: ExceptionHelper.TrueThrow(true, "(" + strObjType + ")未知的对象数据类型!"); break; } Database database = DatabaseFactory.Create(context); result = database.ExecuteDataSet(CommandType.Text, strSql); } GetObjectDepOrgsQueue.Instance.Add(cacheKey, result, InnerCacheHelper.PrepareDependency()); } // } //} return result; }
/// <summary> /// 获取指定对象的父机构对象(GROUPS、USERS或者是ORGANIZATIONS的父部门) /// </summary> /// <param name="strObjType">要查询自身的对象(GROUPS、USERS或者ORGANIZATIONS)</param> /// <param name="strObjValues">自身所具有的数据值(多个之间采用","分隔)</param> /// <param name="soc">自身所具有的数据类型(GUID、OBJ_NAME、ORIGINAL_SORT、GLOBAL_SORT等)</param> /// <param name="strAttrs">要求获取的数据字段</param> /// <returns>获取指定对象的父部门对象</returns> public static DataSet GetObjectParentOrgs(string strObjType, string strObjValues, SearchObjectColumn soc, string strAttrs) { return GetObjectParentOrgs(strObjType, strObjValues, soc, string.Empty, strAttrs); }
/// <summary> /// 获取指定对象的父机构对象(GROUPS、USERS或者是ORGANIZATIONS的父部门) /// </summary> /// <param name="strObjType">要查询自身的对象(GROUPS、USERS或者ORGANIZATIONS)</param> /// <param name="strObjValues">自身所具有的数据值(多个之间采用","分隔)</param> /// <param name="soc">自身所具有的数据类型(GUID、OBJ_NAME、ORIGINAL_SORT、GLOBAL_SORT等)</param> /// <param name="strOrgRankCodeName">要求最低的机构行政级别</param> /// <param name="strAttrs">要求获取的数据字段</param> /// <returns>获取指定对象的父部门对象</returns> public static DataSet GetObjectParentOrgs(string strObjType, string strObjValues, SearchObjectColumn soc, string strOrgRankCodeName, string strAttrs) { return GetObjectParentOrgs(strObjType, strObjValues, soc, false, strOrgRankCodeName, strAttrs); }
///// <summary> ///// 获取指定部门下的所有子对象 ///// </summary> ///// <param name="strOrgValues">要求查询的部门对象(父部门标识,多个之间采用","分隔)</param> ///// <param name="soc">查询要求的查询列名称 ///// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> ///// <param name="iLot">要求查询的数据对象类型(机构、组、人员、兼职对象)</param> ///// <param name="iLod">是否包含被逻辑删除的成员</param> ///// <param name="iDepth">要求查询的层次(最少一层)(0代表全部子对象)</param> ///// <param name="strOrgRankCodeName">查询中要求的机构对象级别</param> ///// <param name="strUserRankCodeName">查询中要求的人员对象级别</param> ///// <param name="strHideType">查询中要求屏蔽的数据(对应于配置文件HideTypes.xml中的配置)</param> ///// <param name="strAttrs">查询中要求获取数据对象的属性类型</param> ///// <param name="iOrgClass">要求展现机构的类型</param> ///// <param name="iOrgType">要求展现机构的属性</param> ///// <param name="da">数据库操作对象</param> ///// <returns>获取指定部门下的所有子对象的查询结果</returns> //public static DataSet GetOrganizationChildren(string strOrgValues, SearchObjectColumn soc, int iLot, int iLod, int iDepth, string strOrgRankCodeName, string strUserRankCodeName, string strHideType, string strAttrs, int iOrgClass, int iOrgType, DataAccess da) //{ // strAttrs = OGUCommonDefine.CombinateAttr(strAttrs); // SearchOrgChildrenCondition scc = new SearchOrgChildrenCondition(strOrgValues, soc, strAttrs, da); // scc.ListObjDelete = (ListObjectDelete)iLod; // scc.ListObjType = (ListObjectType)iLot; // scc.Depth = iDepth; // scc.OrgRankCN = strOrgRankCodeName; // scc.UserRankCN = strUserRankCodeName; // scc.HideType = strHideType; // scc.OrgClass = iOrgClass; // scc.OrgType = iOrgType; // return GetOrganizationChildren(scc, da); //} ///// <summary> ///// 获取指定部门下的所有子对象 ///// </summary> ///// <param name="strOrgValues">要求查询的部门对象(父部门标识,多个之间采用","分隔)</param> ///// <param name="soc">查询要求的查询列名称 ///// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> ///// <param name="iLot">要求查询的数据对象类型(机构、组、人员、兼职对象)</param> ///// <param name="iLod">是否包含被逻辑删除的成员</param> ///// <param name="iDepth">要求查询的层次(最少一层)(0代表全部子对象)</param> ///// <param name="strOrgRankCodeName">查询中要求的机构对象级别</param> ///// <param name="strUserRankCodeName">查询中要求的人员对象级别</param> ///// <param name="strHideType">查询中要求屏蔽的数据(对应于配置文件HideTypes.xml中的配置)</param> ///// <param name="strAttrs">查询中要求获取数据对象的属性类型</param> ///// <param name="da">数据库操作对象</param> ///// <returns>获取指定部门下的所有子对象的查询结果</returns> //public static DataSet GetOrganizationChildren(string strOrgValues, SearchObjectColumn soc, int iLot, int iLod, int iDepth, string strOrgRankCodeName, string strUserRankCodeName, string strHideType, string strAttrs, DataAccess da) //{ // return GetOrganizationChildren(strOrgValues, soc, iLot, iLod, iDepth, strOrgRankCodeName, strUserRankCodeName, strHideType, strAttrs, 0, 0, da); //} ///// <summary> ///// 按照一定的查询条件查询系统中的数据对象 ///// </summary> ///// <param name="scc">系统的查询条件对象</param> ///// <param name="da">数据库操作对象</param> ///// <returns>按照一定的查询条件查询系统中的数据对象</returns> //public static DataSet GetOrganizationChildren(SearchOrgChildrenCondition scc, DataAccess da) //{ // StringBuilder strB = new StringBuilder(1024); // if ((scc.ListObjType & ListObjectType.ORGANIZATIONS) != 0) // { // strB.Append(" ( " + GetOrganizationsSqlByScc(scc, da) + " \n )"); // } // if ((scc.ListObjType & ListObjectType.GROUPS) != 0) // { // if (strB.Length > 0) // strB.Append(" \n UNION \n "); // strB.Append(" ( " + GetGroupsSqlByScc(scc, da) + " \n )"); // } // if ((scc.ListObjType & ListObjectType.USERS) != 0) // { // if (strB.Length > 0) // strB.Append(" \n UNION \n "); // strB.Append(" ( " + GetUsersSqlByScc(scc, da) + " \n )"); // } // string strSql = "SELECT * FROM ( " + strB.ToString() + " ) RESULT ORDER BY GLOBAL_SORT"; // return OGUCommonDefine.ExecuteDataset(strSql, da); //} /// <summary> /// 判断一个用户是否存在于指定的多个部门之中 /// </summary> /// <param name="strUserValue">用户的属性数据值</param> /// <param name="socu">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strUserParentGuid">指定用户所在的父部门标识(可空)</param> /// <param name="objectXmlDoc">判断对象的属性数据值</param> /// <param name="soc">机构的属性名称 /// (GUID、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="lod">是否包含被逻辑删除的成员</param> /// <param name="strHideType">查询中要求屏蔽的数据(对应于配置文件HideTypes.xml中的配置)</param> /// <param name="bDirect">是否直接从属(无中间部门)</param> /// <param name="bFitAll">是否要求完全匹配(存在于指定的每一个部门中)</param> /// <returns>判断一个用户是否存在于指定的多个部门之中</returns> /// <remarks> /// objectXmlDoc的结构如下: /// <code> /// <OBJECTS> /// <ORGANIZATIONS oValue="" rankCode="" /> /// <GROUPS oValue="" rankCode="" /> /// <USERS oValue="" parentGuid="" /> /// </OBJECTS> /// </code> /// </remarks> public static bool IsUserInObjects(string strUserValue, SearchObjectColumn socu, string strUserParentGuid, XmlDocument objectXmlDoc, SearchObjectColumn soc, ListObjectDelete lod, string strHideType, bool bDirect, bool bFitAll) { string cacheKey = Common.InnerCacheHelper.BuildCacheKey(strUserValue, socu, strUserParentGuid, objectXmlDoc, soc, lod, strHideType, bDirect, bFitAll); bool result; //if (false == IsUserInObjectsQueue.Instance.TryGetValue(cacheKey, out result)) //{ // lock (typeof(IsUserInObjectsQueue)) // { if (false == IsUserInObjectsQueue.Instance.TryGetValue(cacheKey, out result)) { string strUserColName = OGUCommonDefine.GetSearchObjectColumn(socu); string strObjColName = OGUCommonDefine.GetSearchObjectColumn(soc); strHideType = OGUCommonDefine.GetHideType(strHideType); string strHideList = GetHideTypeFromXmlForLike(strHideType, "OU_USERS"); string strDirect = "%"; if (bDirect) strDirect = "______"; string strUserLimit = " AND " + DatabaseSchema.Instence.GetTableColumns(strUserColName, "OU_USERS", "USERS") + " = " + TSqlBuilder.Instance.CheckQuotationMark(strUserValue, true); if (strUserParentGuid.Length > 0) strUserLimit += " AND OU_USERS.PARENT_GUID = " + TSqlBuilder.Instance.CheckQuotationMark(strUserParentGuid, true); string strDelUser = GetSqlSearchStatus("OU_USERS", lod); StringBuilder strB = new StringBuilder(1024); #region 内部实现 XmlElement root = objectXmlDoc.DocumentElement; foreach (XmlElement elem in root.ChildNodes) { string strRankLimit = string.Empty; if (elem.GetAttribute("rankCode") != null && elem.GetAttribute("rankCode").Length > 0) strRankLimit = " AND RANK_DEFINE.SORT_ID <= (SELECT SORT_ID FROM RANK_DEFINE WHERE CODE_NAME = " + TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("rankCode"), true) + ") "; switch (elem.LocalName) { case "ORGANIZATIONS": strB.Append(@" SELECT DISTINCT ORGANIZATIONS.GUID, OU_USERS.USER_GUID FROM OU_USERS, ORGANIZATIONS, USERS JOIN RANK_DEFINE ON USERS.RANK_CODE = RANK_DEFINE.CODE_NAME " + strRankLimit + @" WHERE OU_USERS.USER_GUID = USERS.GUID AND OU_USERS.ORIGINAL_SORT LIKE ORGANIZATIONS.ORIGINAL_SORT + " + TSqlBuilder.Instance.CheckQuotationMark(strDirect, true) + @" AND " + DatabaseSchema.Instence.GetTableColumns(strObjColName, "ORGANIZATIONS") + @" = " + TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("oValue"), true) + @" AND (" + strDelUser + @") " + strUserLimit + strHideList + @";"); break; case "GROUPS": strB.Append(@" SELECT DISTINCT GROUPS.GUID, OU_USERS.USER_GUID FROM GROUPS, GROUP_USERS, OU_USERS, USERS JOIN RANK_DEFINE ON USERS.RANK_CODE = RANK_DEFINE.CODE_NAME " + strRankLimit + @" WHERE GROUPS.GUID = GROUP_USERS.GROUP_GUID AND OU_USERS.USER_GUID = GROUP_USERS.USER_GUID AND OU_USERS.PARENT_GUID = GROUP_USERS.USER_PARENT_GUID AND OU_USERS.USER_GUID = USERS.GUID AND " + DatabaseSchema.Instence.GetTableColumns(strObjColName, "GROUPS") + @" = " + TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("oValue"), true) + @" AND (" + strDelUser + @") " + strUserLimit + strHideList + @";"); break; case "USERS": strB.Append(@" SELECT DISTINCT USERS.GUID, OU_USERS.USER_GUID FROM OU_USERS, USERS WHERE OU_USERS.USER_GUID = USERS.GUID AND " + DatabaseSchema.Instence.GetTableColumns(strObjColName, "OU_USERS", "USERS") + " = " + TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("oValue"), true) + @" AND (" + strDelUser + @")" + strUserLimit + strHideList + @";"); break; default: ExceptionHelper.TrueThrow(true, "对不起,系统没有对应处理“" + elem.LocalName + "”的相应程序!"); break; } } #endregion result = CheckIsUserInOrganizations(strB, bFitAll); IsUserInObjectsQueue.Instance.Add(cacheKey, result, InnerCacheHelper.PrepareDependency()); } // } //} return result; }
/// <summary> /// 获取当前制定对象的所在独立部门(隶属海关或者是派驻机构、直属海关、总署、分署、特派办) /// </summary> /// <param name="strObjType">要查询自身的对象(GROUPS、USERS或者ORGANIZATIONS)</param> /// <param name="strObjValue">自身所具有的数据值</param> /// <param name="soc">自身所具有的数据类型(GUID、OBJ_NAME、ORIGINAL_SORT、GLOBAL_SORT等)</param> /// <param name="strAttrs">要求获取的数据字段</param> /// <returns>获取当前制定对象的所在独立部门</returns> public static DataSet GetIndependOrganizationOfUser(string strObjType, string strObjValue, SearchObjectColumn soc, string strAttrs) { string cacheKey = InnerCacheHelper.BuildCacheKey(strObjType, strObjValue, soc, strAttrs); DataSet result; //if (false == GetIndependOrganizationOfUserQueue.Instance.TryGetValue(cacheKey, out result)) //{ // lock (typeof(GetIndependOrganizationOfUserQueue)) // { if (false == GetIndependOrganizationOfUserQueue.Instance.TryGetValue(cacheKey, out result)) { if (strAttrs.IndexOf("ORG_CLASS") < 0) { if (strAttrs.Length > 0) strAttrs += ",ORG_CLASS"; else strAttrs = "ORG_CLASS"; } DataSet resultDS = GetObjectDepOrgs(strObjType, strObjValue, soc, 3, strAttrs); DataTable oTable = resultDS.Tables[0]; if (oTable.Rows.Count > 0) { if (false == (oTable.Rows[0]["ORG_CLASS"] is DBNull)) if (((int)oTable.Rows[0]["ORG_CLASS"] & (32 + 64)) != 0) return resultDS; } result = GetObjectDepOrgs(strObjType, strObjValue, soc, 2, strAttrs); GetIndependOrganizationOfUserQueue.Instance.Add(cacheKey, result, InnerCacheHelper.PrepareDependency()); } // } //} return result; }
///// <summary> ///// 获取指定用户所从属的"人员组"集合 ///// </summary> ///// <param name="strUserValues">指定的用户标识(多个之间采用“,”分隔)</param> ///// <param name="socu">用户的属性名称 ///// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) ///// </param> ///// <param name="strParentValue">指定的用户所在部门(用于区别兼职问题)</param> ///// <param name="soco">机构的属性名称 ///// (GUID、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) ///// </param> ///// <param name="strAttrs">所要求获取的属性信息</param> ///// <param name="iLod">本次查询中要求查询对象的状态信息数据(是否包含逻辑删除对象)</param> ///// <returns>获取指定人员的所有"人员组"集合(注意其中逻辑删除的数据对象)</returns> //public static DataSet GetGroupsOfUsers(string strUserValues, SearchObjectColumn socu, string strParentValue, SearchObjectColumn soco, string strAttrs, int iLod) //{ // DataAccess da = new DataAccess(OGUCommonDefine.STR_CONN); // using (da.dBContextInfo) // { // da.dBContextInfo.OpenConnection(); // return GetGroupsOfUsers(strUserValues, socu, strParentValue, soco, strAttrs, iLod, da); // } //} /// <summary> /// 获取指定用户所从属的"人员组"集合 /// </summary> /// <param name="strUserValues">指定的用户标识(多个之间采用“,”分隔)</param> /// <param name="socu">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strParentValue">指定的用户所在部门(用于区别兼职问题)</param> /// <param name="soco">机构的属性名称 /// (GUID、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strAttrs">所要求获取的属性信息</param> /// <returns>获取指定人员的所有"人员组"集合(注意其中逻辑删除的数据对象)</returns> public static DataSet GetGroupsOfUsers(string strUserValues, SearchObjectColumn socu, string strParentValue, SearchObjectColumn soco, string strAttrs) { return GetGroupsOfUsers(strUserValues, socu, strParentValue, soco, strAttrs, (int)ListObjectDelete.COMMON); }
/// <summary> /// 依据直属海关属性获取该直属海关辖的隶属海关 /// </summary> /// <param name="strParentOrgValue"></param> /// <param name="soc"></param> /// <param name="strAttrs"></param> /// <returns></returns> public static DataSet GetSubjectionCustoms(string strParentOrgValue, SearchObjectColumn soc, string strAttrs) { string cacheKey = InnerCacheHelper.BuildCacheKey(strParentOrgValue, soc, strAttrs); DataSet result; //if (false == GetSubjectionCustomsQueue.Instance.TryGetValue(cacheKey, out result)) //{ // lock (typeof(GetSubjectionCustomsQueue)) // { if (false == GetSubjectionCustomsQueue.Instance.TryGetValue(cacheKey, out result)) { using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias)) { if (soc == SearchObjectColumn.SEARCH_GUID) { //这里在内部进行缓存处理,所以直接返回即可 return GetSubjectionCustoms(strParentOrgValue, strAttrs); //result = GetSubjectionCustoms(strParentOrgValue, strAttrs); } else { strAttrs = OGUCommonDefine.CombinateAttr(strAttrs); string strColName = OGUCommonDefine.GetSearchObjectColumn(soc); Database database = DatabaseFactory.Create(context); string strSql = @" SELECT " + DatabaseSchema.Instence.GetTableColumns(strAttrs, "ORGANIZATIONS") + @" FROM ORGANIZATIONS WHERE LEN(CUSTOMS_CODE) = 4 AND PARENT_GUID IN ( SELECT GUID FROM ORGANIZATIONS WHERE " + TSqlBuilder.Instance.CheckQuotationMark(strColName, false) + " = " + TSqlBuilder.Instance.CheckQuotationMark(strParentOrgValue, true) + @") ORDER BY GLOBAL_SORT"; result = database.ExecuteDataSet(CommandType.Text, strSql); } } GetSubjectionCustomsQueue.Instance.Add(cacheKey, result, InnerCacheHelper.PrepareDependency()); } // } //} return result; }
/// <summary> /// 判断一个用户是否存在于指定的多个部门之中 /// </summary> /// <param name="strUserValue">用户的属性数据值</param> /// <param name="socu">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strUserParentGuid">指定用户所在的父部门标识(可空)</param> /// <param name="objectXmlDoc">判断对象的属性数据值</param> /// <param name="soco">机构的属性名称 /// (GUID、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <returns>判断一个用户是否存在于指定的多个部门之中</returns> public static bool IsUserInObjects(string strUserValue, SearchObjectColumn socu, string strUserParentGuid, XmlDocument objectXmlDoc, SearchObjectColumn soco) { return IsUserInObjects(strUserValue, socu, strUserParentGuid, objectXmlDoc, soco, false); }
/// <summary> /// 获取指定秘书的所有领导人成员 /// </summary> /// <param name="strSecValues">指定秘书的标识(多个之间采用","分隔)</param> /// <param name="soc">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strAttrs">要求在本次查询中获取对象的字段名称</param> /// <param name="iLod">本次查询中要求查询对象的状态信息数据(是否包含逻辑删除对象)</param> /// <returns>获取指定秘书的所有领导人成员</returns> public static DataSet GetLeadersOfSecretaries(string strSecValues, SearchObjectColumn soc, string strAttrs, int iLod) { string cacheKey = InnerCacheHelper.BuildCacheKey(strSecValues, soc, strAttrs, iLod); DataSet result; //if (false == GetLeadersOfSecretariesQueue.Instance.TryGetValue(cacheKey, out result)) //{ // lock (typeof(GetLeadersOfSecretariesQueue)) // { if (false == GetLeadersOfSecretariesQueue.Instance.TryGetValue(cacheKey, out result)) { string strColName = OGUCommonDefine.GetSearchObjectColumn(soc); strAttrs = OGUCommonDefine.CombinateAttr(strAttrs); using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias)) { string strSql = @" SELECT 'USERS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttrs, "USERS", "OU_USERS", "RANK_DEFINE", "SECRETARIES") + @" FROM OU_USERS, SECRETARIES, USERS JOIN RANK_DEFINE ON USERS.RANK_CODE = RANK_DEFINE.CODE_NAME WHERE USERS.GUID = OU_USERS.USER_GUID AND OU_USERS.USER_GUID = SECRETARIES.LEADER_GUID AND OU_USERS.SIDELINE = 0 AND SECRETARIES.SECRETARY_GUID IN ( SELECT USERS.GUID FROM USERS, OU_USERS WHERE USERS.GUID = OU_USERS.USER_GUID AND {0} IN ({1}) ) AND ({2}) ORDER BY SECRETARIES.SECRETARY_GUID, RANK_DEFINE.SORT_ID "; strSql = string.Format(strSql, DatabaseSchema.Instence.GetTableColumns(strColName, "OU_USERS", "USERS"), OGUCommonDefine.AddMulitStrWithQuotationMark(strSecValues), GetSqlSearchStatus("OU_USERS", (ListObjectDelete)iLod)); Database database = DatabaseFactory.Create(context); result = database.ExecuteDataSet(CommandType.Text, strSql); } GetLeadersOfSecretariesQueue.Instance.Add(cacheKey, result, InnerCacheHelper.PrepareDependency()); } // } //} return result; }
/// <summary> /// 判断用户群是否存在于指定的多个部门之中 /// </summary> /// <param name="xmlUserDoc">用户群标识(多个之间采用","分隔)</param> /// <param name="socu">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> /// <param name="xmlObjDoc">机构群(采用XML方式)</param> /// <param name="soc">机构的属性名称 /// (GUID、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> /// <param name="lod">是否包含被逻辑删除的成员</param> /// <param name="strHideType">查询中要求屏蔽的数据(对应于配置文件HideTypes.xml中的配置)</param> /// <param name="bDirect">是否直接从属(无中间部门)</param> /// <remarks> /// <code> /// xmlUserDoc的结构如下(说明oValue必填,与socu配合使用;parentGuid可不填): /// <USERS> /// <USERS oValue="" parentGuid="" /> /// <USERS oValue="" parentGuid="" /> /// </USERS> /// xmlObjDoc的结构如下(说明oValue必填,与soc配合使用;parentGuid可不填;rankCode可不填): /// <OBJECTS> /// <ORGANIZATIONS oValue="" rankCode="" /> /// <GROUPS oValue="" rankCode="" /> /// <USERS oValue="" parentGuid="" /> /// </OBJECTS> /// </code> /// xmlObjDoc的返回结果(字节点方式嵌入返回): /// <OBJECTS> /// <ORGANIZATIONS oValue="" rankCode="" > /// <USERS oValue="" parentGuid=""/> /// <USERS oValue="" parentGuid=""/> /// </ORGANIZATIONS> /// <GROUPS oValue="" rankCode="" > /// <USERS oValue="" parentGuid=""/> /// <USERS oValue="" parentGuid=""/> /// </GROUPS> /// <USERS oValue="" parentGuid="" > /// <USERS oValue="" parentGuid=""/> /// </USERS> /// </OBJECTS> /// </remarks> public static void CheckUserInObjects(XmlDocument xmlUserDoc, SearchObjectColumn socu, XmlDocument xmlObjDoc, SearchObjectColumn soc, ListObjectDelete lod, string strHideType, bool bDirect) { string cacheKey = InnerCacheHelper.BuildCacheKey(xmlUserDoc.DocumentElement.OuterXml, socu, xmlObjDoc.DocumentElement.OuterXml, soc, lod, strHideType, bDirect); XmlDocument result; #if DEBUG Debug.WriteLine(xmlObjDoc.OuterXml, "begin"); #endif //if (false == CheckUserInObjectsQueue.Instance.TryGetValue(cacheKey, out result)) //{ // lock (typeof(CheckUserInObjectsQueue)) // { if (false == CheckUserInObjectsQueue.Instance.TryGetValue(cacheKey, out result)) { string strUserColName = OGUCommonDefine.GetSearchObjectColumn(socu); string strObjColName = OGUCommonDefine.GetSearchObjectColumn(soc); strHideType = OGUCommonDefine.GetHideType(strHideType); string strHideList = GetHideTypeFromXmlForLike(strHideType, "OU_USERS"); string strDelUser = GetSqlSearchStatus("OU_USERS", lod); string strDirect = "%"; if (bDirect) strDirect = "______"; #region Db control using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias)) { string strUserLimit = GetUserLimitInCheckUserInOrganizations(xmlUserDoc, strUserColName); /*****************************************************************************************************************/ string strExtraWhere = @" AND (" + strDelUser + @") AND " + strUserLimit + strHideList; StringBuilder strB = GetSqlSearchForCheckUserInObjects(xmlObjDoc, strUserColName, strObjColName, strDirect, strExtraWhere); if (strB.Length > 0) { Database database = DatabaseFactory.Create(context); DataSet ds = database.ExecuteDataSet(CommandType.Text, strB.ToString()); foreach (DataTable oTable in ds.Tables) { foreach (DataRow row in oTable.Rows) { XmlNode uNode = xmlUserDoc.DocumentElement.SelectSingleNode("USERS[@oValue=\"" + OGUCommonDefine.DBValueToString(row["USER_VALUE"]) + "\"]"); if (uNode != null) { XmlElement oRoot = xmlObjDoc.DocumentElement; string oClass = OGUCommonDefine.DBValueToString(row["OBJECTCLASS"]); string oValue = OGUCommonDefine.DBValueToString(row["OBJ_VALUE"]); foreach (XmlElement oElem in oRoot.SelectNodes(oClass + "[@oValue=\"" + oValue + "\"]")) { if (row["RANK_CODE"] is DBNull) { if (oElem.GetAttribute("rankCode") == string.Empty) { XmlElement uElem = (XmlElement)XmlHelper.AppendNode(oElem, uNode.LocalName); foreach (XmlAttribute xAttr in uNode.Attributes) uElem.SetAttribute(xAttr.LocalName, xAttr.InnerText); } } else { if (oElem.GetAttribute("rankCode") == OGUCommonDefine.DBValueToString(row["RANK_CODE"])) { XmlElement uElem = (XmlElement)XmlHelper.AppendNode(oElem, uNode.LocalName); foreach (XmlAttribute xAttr in uNode.Attributes) uElem.SetAttribute(xAttr.LocalName, xAttr.InnerText); } } } } } } } } #endregion #region Deleted /*****************************************************************************************************************/ /*******下面一段程序并没有错误,但是性能上有差异。以下程序针对每个OBJ对象产生一条SQL查询语句,********************/ /*******在对象多的情况下导致SQL查询语句的庞大,修改参阅GetSqlSearchForCheckUserInObjects**************************/ /*****************************************************************************************************************/ // 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(elem.GetAttribute("rankCode")) + ") "; // else // strRankLimit = string.Empty; // // string strSql = string.Empty; // switch (elem.LocalName) // { // case "ORGANIZATIONS": // strSql = @" // SELECT DISTINCT " + GetTableColumns(strUserColName, da, "USERS", "OU_USERS") + " AS USER_VALUE, " + GetTableColumns(strObjColName, da, "ORGANIZATIONS") + @" AS OBJ_VALUE // FROM ORGANIZATIONS, OU_USERS, USERS JOIN RANK_DEFINE ON USERS.RANK_CODE = RANK_DEFINE.CODE_NAME // WHERE OU_USERS.USER_GUID = USERS.GUID // AND OU_USERS.ORIGINAL_SORT LIKE ORGANIZATIONS.ORIGINAL_SORT + " + TSqlBuilder.Instance.CheckQuotationMark(strDirect) + @" // AND (" + strDelUser + @") // AND " + GetTableColumns(strObjColName, da, "ORGANIZATIONS") + " = " + TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("oValue")) + @" // AND " + strUserLimit + @" // " + strRankLimit + strHideList + @" // ORDER BY OBJ_VALUE"; // break; // case "GROUPS": // strSql = @" // SELECT DISTINCT " + GetTableColumns(strUserColName, da, "USERS", "OU_USERS") + " AS USER_VALUE, " + GetTableColumns(strObjColName, da, "GROUPS") + @" AS OBJ_VALUE // FROM GROUPS, GROUP_USERS, OU_USERS, USERS JOIN RANK_DEFINE ON USERS.RANK_CODE = RANK_DEFINE.CODE_NAME // WHERE GROUPS.GUID = GROUP_USERS.GROUP_GUID // AND GROUP_USERS.USER_GUID = OU_USERS.USER_GUID // AND GROUP_USERS.USER_PARENT_GUID = OU_USERS.PARENT_GUID // AND OU_USERS.USER_GUID = USERS.GUID // AND GROUPS." + strObjColName + " = " + TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("oValue")) + @" // AND ( " + strDelUser + @" ) // AND " + strUserLimit + strHideList + @" // " + strRankLimit + @" // ORDER BY OBJ_VALUE"; // break; // case "USERS": // strSql = @" // SELECT DISTINCT " + GetTableColumns(strUserColName, da, "USERS", "OU_USERS") + " AS USER_VALUE, " + GetTableColumns(strObjColName, da, "USERS", "OU_USERS") + @" AS OBJ_VALUE // FROM OU_USERS, USERS // WHERE OU_USERS.USER_GUID = USERS.GUID // AND " + GetTableColumns(strObjColName, da, "USERS", "OU_USERS") + " = " + TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("oValue")) + @" // AND ( " + strDelUser + @" ) // AND " + strUserLimit + strHideList + @" // ORDER BY OBJ_VALUE "; // break; // default : ExceptionHelper.TrueThrow(true, "对不起,系统没有对应处理“" + elem.LocalName + "”的相应程序!"); // break; // } // // strB.Append(strSql + ";\n"); // } // if (strB.Length > 0) // { // DataSet ds = OGUCommonDefine.ExecuteDataset(strB.ToString(), da); // for (int iTable = 0; iTable < ds.Tables.Count; iTable++) // { // foreach (DataRow row in ds.Tables[iTable].Rows) // { // XmlNode uNode = xmlUserDoc.DocumentElement.SelectSingleNode("USERS[@oValue=\"" + XmlHelper.DBValueToString(row["USER_VALUE"]) + "\"]"); // if (uNode != null) // { // XmlElement oElem = (XmlElement)XmlHelper.AppendNode(xmlObjDoc, xmlObjDoc.DocumentElement.ChildNodes[iTable], uNode.LocalName); // foreach (XmlAttribute xAttr in uNode.Attributes) // oElem.SetAttribute(xAttr.LocalName, xAttr.InnerText); // } // } // } // } /*****************************************************************************************************************/ #endregion result = xmlObjDoc; CheckUserInObjectsQueue.Instance.Add(cacheKey, result, InnerCacheHelper.PrepareDependency()); } // } //} xmlObjDoc = result; #if DEBUG Debug.WriteLine(xmlObjDoc.OuterXml, "result"); #endif }
/// <summary> /// 获取指定用户所从属的"人员组"集合 /// </summary> /// <param name="strUserValues">指定的用户标识(多个之间采用“,”分隔)</param> /// <param name="socu">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strAttrs">所要求获取的属性信息</param> /// <returns>获取指定人员的所有"人员组"集合(注意其中逻辑删除的数据对象)</returns> public static DataSet GetGroupsOfUsers(string strUserValues, SearchObjectColumn socu, string strAttrs) { return GetGroupsOfUsers(strUserValues, socu, string.Empty, SearchObjectColumn.SEARCH_NULL, strAttrs); }
/// <summary> /// /// </summary> /// <param name="strObjType"></param> /// <param name="strObjValue"></param> /// <param name="soc"></param> /// <param name="objsDs"></param> /// <param name="da"></param> /// <returns></returns> private static bool IsObjectIsIncludeInObjects(string strObjType, string strObjValue, SearchObjectColumn soc, DataSet objsDs) { return IsObjectIsIncludeInObjects(strObjType, strObjValue, soc, string.Empty, objsDs); }
/// <summary> /// 形成根据指定条件查询“人员组”的SQL语句 /// </summary> /// <param name="strOrgValues">指定的范围机构标识(多个之间采用","分隔)</param> /// <param name="soc">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> /// <param name="strLikeName">“人员组”上的名称模糊匹配对象</param> /// <param name="bLike">是否采用模糊匹配</param> /// <param name="strAttr">要求获取的字段属性</param> /// <param name="iLod">查询删除的对象策略</param> /// <param name="iDep">要求查询的深度</param> /// <param name="strHideType">要求屏蔽的类型设置</param> /// <param name="rootPath">传入的ORIGINAL_SORT</param> /// <returns>形成根据指定条件查询“人员组”的SQL语句</returns> /// //2009-05-06 删除 RANK_DEFINE 约束,调整ORIGINAL_SORT约束 private static string QueryGroupsByCondition2(string strOrgValues, SearchObjectColumn soc, string strLikeName, bool bLike, string strAttr, ListObjectDelete iLod, int iDep, string strHideType, string rootPath) { string strColName = OGUCommonDefine.GetSearchObjectColumn(soc); StringBuilder strB = new StringBuilder(1024); strB.Append(@" SELECT 'GROUPS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttr, "GROUPS") + @" FROM GROUPS WHERE ( " + GetSqlSearchParOriginal2("GROUPS", iDep, rootPath) + " )"); string strListDelete = GetSqlSearchStatus("GROUPS", iLod); if (strListDelete.Length > 0) strB.Append(" \n AND ( " + strListDelete + " ) "); strB.Append(BuildSearchCondition("GROUPS.SEARCH_NAME", strLikeName, bLike)); if (strHideType.Length > 0) strB.Append(GetHideTypeFromXmlForLike(strHideType, "GROUPS")); return strB.ToString(); }
/// <summary> /// 获取指定用户所从属的"人员组"集合 /// </summary> /// <param name="strUserValues">指定的用户标识(多个之间采用“,”分隔)</param> /// <param name="socu">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strParentValue">指定的用户所在部门(用于区别兼职问题)</param> /// <param name="soco">机构的属性名称 /// (GUID、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strAttrs">所要求获取的属性信息</param> /// <param name="iLod">本次查询中要求查询对象的状态信息数据(是否包含逻辑删除对象)</param> /// <returns>获取指定人员的所有"人员组"集合(注意其中逻辑删除的数据对象)</returns> public static DataSet GetGroupsOfUsers(string strUserValues, SearchObjectColumn socu, string strParentValue, SearchObjectColumn soco, string strAttrs, int iLod) { string cacheKey = InnerCacheHelper.BuildCacheKey(strUserValues, socu, strParentValue, soco, strAttrs, iLod); DataSet result; //if (false == GetGroupsOfUsersQueue.Instance.TryGetValue(cacheKey, out result)) //{ // lock (typeof(GetGroupsOfUsersQueue)) // { if (false == GetGroupsOfUsersQueue.Instance.TryGetValue(cacheKey, out result)) { string strColName = OGUCommonDefine.GetSearchObjectColumn(socu); string strParentColName = OGUCommonDefine.GetSearchObjectColumn(soco); strAttrs = OGUCommonDefine.CombinateAttr(strAttrs); using (DbContext context = DbContext.GetContext(CommonResource.AccreditConnAlias)) { string strSql = @" SELECT 'GROUPS' AS OBJECTCLASS, GROUPS.GUID, " + DatabaseSchema.Instence.GetTableColumns(strAttrs, "GROUPS") + @" FROM GROUPS, GROUP_USERS, OU_USERS, USERS, ORGANIZATIONS WHERE GROUPS.GUID = GROUP_USERS.GROUP_GUID AND ORGANIZATIONS.GUID = OU_USERS.PARENT_GUID AND OU_USERS.USER_GUID = USERS.GUID AND GROUP_USERS.USER_GUID = OU_USERS.USER_GUID AND GROUP_USERS.USER_PARENT_GUID = OU_USERS.PARENT_GUID {0} AND {1} IN ({2}) AND ({3}) ORDER BY OU_USERS.GLOBAL_SORT, GROUPS.GLOBAL_SORT "; string strParent = string.Empty; if (strParentValue.Length != 0) strParent = " AND " + DatabaseSchema.Instence.GetTableColumns(strParentColName, "ORGANIZATIONS") + " IN (" + OGUCommonDefine.AddMulitStrWithQuotationMark(strParentValue) + ") "; strSql = string.Format(strSql, strParent, DatabaseSchema.Instence.GetTableColumns(strColName, "OU_USERS", "USERS"), OGUCommonDefine.AddMulitStrWithQuotationMark(strUserValues), GetSqlSearchStatus("GROUPS", (ListObjectDelete)iLod)); Database database = DatabaseFactory.Create(context); result = database.ExecuteDataSet(CommandType.Text, strSql); } GetGroupsOfUsersQueue.Instance.Add(cacheKey, result, InnerCacheHelper.PrepareDependency()); } // } //} return result; }
/// <summary> /// 形成根据指定条件查询“人员”的SQL语句 /// </summary> /// <param name="strOrgValues">指定的范围机构标识(多个之间采用","分隔)</param> /// <param name="soc">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME)</param> /// <param name="strLikeName">“人员”上的名称模糊匹配对象</param> /// <param name="bLike">是否采用模糊匹配</param> /// <param name="bFirstPerson">查询对象是否是一把手</param> /// <param name="strUserRankCodeName">“人员”要求的级别范围</param> /// <param name="strAttr">要求获取的字段属性</param> /// <param name="iListObjType">用于是否查询兼职问题</param> /// <param name="iDep">要求查询的深度</param> /// <param name="strHideType">要求屏蔽的类型设置</param> /// <param name="rootPath">传入的ORIGINAL_SORT</param> /// <returns>形成根据指定条件查询“人员”的SQL语句</returns> /// //2009-05-11 private static string QueryUsersByCondition(string strOrgValues, SearchObjectColumn soc, string strLikeName, bool bLike, bool bFirstPerson, string strUserRankCodeName, string strAttr, int iListObjType, int iDep, string strHideType, string rootPath) { string strColName = OGUCommonDefine.GetSearchObjectColumn(soc); StringBuilder strB = new StringBuilder(1024); strB.Append(@" SELECT 'USERS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttr, "USERS", "OU_USERS", "RANK_DEFINE") + @" FROM USERS JOIN RANK_DEFINE ON RANK_DEFINE.CODE_NAME = USERS.RANK_CODE {0}, OU_USERS WHERE USERS.GUID = OU_USERS.USER_GUID AND ( " + GetSqlSearchParOriginal2("OU_USERS", iDep, rootPath) + " )"); string strListDelete = GetSqlSearchStatus("OU_USERS", ListObjectDelete.ALL_TYPE); if (strListDelete.Length > 0) strB.Append(" \n AND ( " + strListDelete + " ) "); string strRankLimit = string.Empty; if (strUserRankCodeName.Length > 0) strRankLimit = " AND RANK_CLASS = 2 AND RANK_DEFINE.SORT_ID <= (SELECT SORT_ID FROM RANK_DEFINE WHERE CODE_NAME = " + TSqlBuilder.Instance.CheckQuotationMark(strUserRankCodeName, true) + " ) "; if ((iListObjType & (int)ListObjectType.SIDELINE) == 0) strB.Append(" \n AND OU_USERS.SIDELINE = 0 "); strB.Append(BuildSearchCondition("OU_USERS.SEARCH_NAME", strLikeName, bLike)); if (bFirstPerson)//要求是部门一把手 strB.Append(" AND OU_USERS.INNER_SORT = " + TSqlBuilder.Instance.CheckQuotationMark(CommonResource.OriginalSortDefault, true)); if (strHideType.Length > 0) strB.Append(GetHideTypeFromXmlForLike(strHideType, "OU_USERS")); return string.Format(strB.ToString(), strRankLimit); }
/// <summary> /// 依据直属海关属性获取该直属海关辖的隶属海关 /// </summary> /// <param name="strParentOrgValue"></param> /// <param name="soc"></param> /// <returns></returns> public static DataSet GetSubjectionCustoms(string strParentOrgValue, SearchObjectColumn soc) { return GetSubjectionCustoms(strParentOrgValue, soc, string.Empty); }
///// <summary> ///// 获取指定秘书的所有领导人成员 ///// </summary> ///// <param name="strSecValues">指定秘书的标识(多个之间采用","分隔)</param> ///// <param name="soc">用户的属性名称 ///// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) ///// </param> ///// <param name="strAttrs">要求在本次查询中获取对象的字段名称</param> ///// <param name="iLod">本次查询中要求查询对象的状态信息数据(是否包含逻辑删除对象)</param> ///// <returns>获取指定秘书的所有领导人成员</returns> //public static DataSet GetLeadersOfSecretaries(string strSecValues, SearchObjectColumn soc, string strAttrs, int iLod) //{ // DataAccess da = new DataAccess(OGUCommonDefine.STR_CONN); // using (da.dBContextInfo) // { // da.dBContextInfo.OpenConnection(); // return GetLeadersOfSecretaries(strSecValues, soc, strAttrs, iLod, da); // } //} /// <summary> /// 获取指定秘书的所有领导人成员 /// </summary> /// <param name="strSecValues">指定秘书的标识(多个之间采用","分隔)</param> /// <param name="soc">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strAttrs">要求在本次查询中获取对象的字段名称</param> /// <returns>获取指定秘书的所有领导人成员</returns> public static DataSet GetLeadersOfSecretaries(string strSecValues, SearchObjectColumn soc, string strAttrs) { return GetLeadersOfSecretaries(strSecValues, soc, strAttrs, (int)ListObjectDelete.COMMON); }
private bool IsObjectIsIncludeInObjects(string strObjType, string strObjValue, SearchObjectColumn soc, DataSet objsDs) { DataSet oDs = OGUReader.GetObjectsDetail(strObjType, strObjValue, soc, string.Empty, SearchObjectColumn.SEARCH_NULL); foreach (DataRow oRow in oDs.Tables[0].Rows) { string strObjAllPathName = OGUCommonDefine.DBValueToString(oRow["ALL_PATH_NAME"]); foreach (DataRow sRow in objsDs.Tables[0].Rows) { string[] strArry = OGUCommonDefine.DBValueToString(sRow["DESCRIPTION"]).Split(',', ';', ' '); foreach (string strValue in strArry) { if (strValue.Length <= strObjAllPathName.Length && strValue.Length >= 0 && strObjAllPathName.Substring(0, strValue.Length) == strValue) { return(true); } } } } return(false); }
///// <summary> ///// 获取当前制定对象的所在独立部门(隶属海关或者是派驻机构、直属海关、总署、分署、特派办) ///// </summary> ///// <param name="strUserGuid">自身所具有的数据值(用户)</param> ///// <param name="da">数据库操作对象</param> ///// <returns>获取当前制定对象的所在独立部门</returns> //public static DataSet GetIndependOrganizationOfUser(string strUserGuid) //{ // return GetIndependOrganizationOfUser("USERS", strUserGuid, da); //} ///// <summary> ///// 获取当前制定对象的所在独立部门(隶属海关或者是派驻机构、直属海关、总署、分署、特派办) ///// </summary> ///// <param name="strObjType">要查询自身的对象(GROUPS、USERS或者ORGANIZATIONS)</param> ///// <param name="strObjGuid">自身所具有的数据值</param> ///// <param name="da">数据库操作对象</param> ///// <returns>获取当前制定对象的所在独立部门</returns> //public static DataSet GetIndependOrganizationOfUser(string strObjType, string strObjGuid) //{ // return GetIndependOrganizationOfUser(strObjType, strObjGuid, string.Empty, da); //} ///// <summary> ///// 获取当前制定对象的所在独立部门(隶属海关或者是派驻机构、直属海关、总署、分署、特派办) ///// </summary> ///// <param name="strObjType">要查询自身的对象(GROUPS、USERS或者ORGANIZATIONS)</param> ///// <param name="strObjGuid">自身所具有的数据值</param> ///// <param name="strAttrs">要求获取的数据字段</param> ///// <param name="da">数据库操作对象</param> ///// <returns>获取当前制定对象的所在独立部门</returns> //public static DataSet GetIndependOrganizationOfUser(string strObjType, string strObjGuid, string strAttrs) //{ // return GetIndependOrganizationOfUser(strObjType, strObjGuid, SearchObjectColumn.SEARCH_GUID, strAttrs, da); //} ///// <summary> ///// 获取当前制定对象的所在独立部门(隶属海关或者是派驻机构、直属海关、总署、分署、特派办) ///// </summary> ///// <param name="strObjType">要查询自身的对象(GROUPS、USERS或者ORGANIZATIONS)</param> ///// <param name="strObjValue">自身所具有的数据值</param> ///// <param name="soc">自身所具有的数据类型(GUID、OBJ_NAME、ORIGINAL_SORT、GLOBAL_SORT等)</param> ///// <param name="strAttrs">要求获取的数据字段</param> ///// <param name="da">数据库操作对象</param> ///// <returns>获取当前制定对象的所在独立部门</returns> //public static DataSet GetIndependOrganizationOfUser(string strObjType, // string strObjValue, // SearchObjectColumn soc, // string strAttrs) //{ // if (strAttrs.IndexOf("ORG_CLASS") < 0) // { // if (strAttrs.Length > 0) // strAttrs += ",ORG_CLASS"; // else // strAttrs = "ORG_CLASS"; // } // DataSet resultDS = GetObjectDepOrgs(strObjType, strObjValue, soc, 3, strAttrs, da); // DataTable oTable = resultDS.Tables[0]; // if (oTable.Rows.Count > 0) // { // if (false==(oTable.Rows[0]["ORG_CLASS"] is DBNull)) // if (((int)oTable.Rows[0]["ORG_CLASS"] & (32 + 64)) != 0) // return resultDS; // } // resultDS = GetObjectDepOrgs(strObjType, strObjValue, soc, 2, strAttrs, da); // return resultDS; //} #endregion #region private functions /// <summary> /// 形成根据指定条件查询机构“机构”的SQL语句 /// </summary> /// <param name="strOrgValues">指定的范围机构标识(多个之间采用","分隔)</param> /// <param name="soc">用户的属性名称 /// (GUID、USER_GUID、LOGON_NAME、ORIGINAL_SORT、GLOBAL_SORT、ALL_PATH_NAME) /// </param> /// <param name="strLikeName">机构上的名称模糊匹配对象</param> /// <param name="bLike">是否采用模糊匹配</param> /// <param name="strOrgRankCodeName">机构要求的级别范围</param> /// <param name="strAttr">要求获取的字段属性</param> /// <param name="iDep">要求查询的深度</param> /// <param name="strHideType">要求屏蔽的类型设置</param> /// <param name="rootPath">传入的ORIGINAL_SORT</param> /// <returns>形成根据指定条件查询机构的SQL语句</returns> /// //2009-05-11 private static string QueryOrganizationsByCondition(string strOrgValues, SearchObjectColumn soc, string strLikeName, bool bLike, string strOrgRankCodeName, string strAttr, int iDep, string strHideType, string rootPath) { string strColName = OGUCommonDefine.GetSearchObjectColumn(soc); StringBuilder strB = new StringBuilder(1024); strB.Append(" SELECT 'ORGANIZATIONS' AS OBJECTCLASS, " + DatabaseSchema.Instence.GetTableColumns(strAttr, "ORGANIZATIONS", "RANK_DEFINE") + @" FROM ORGANIZATIONS JOIN RANK_DEFINE ON ORGANIZATIONS.RANK_CODE = RANK_DEFINE.CODE_NAME {0} WHERE ( " + GetSqlSearchParOriginal2("ORGANIZATIONS", iDep, rootPath) + " ) "); string strListDelete = GetSqlSearchStatus("ORGANIZATIONS", ListObjectDelete.ALL_TYPE); if (strListDelete.Length > 0) strB.Append(" \n AND ( " + strListDelete + " ) "); string strRankLimit = string.Empty; if (strOrgRankCodeName.Length > 0) strRankLimit = " AND RANK_CLASS = 1 AND RANK_DEFINE.SORT_ID <= (SELECT SORT_ID FROM RANK_DEFINE WHERE CODE_NAME = " + TSqlBuilder.Instance.CheckQuotationMark(strOrgRankCodeName, true) + " ) "; strB.Append(BuildSearchCondition("ORGANIZATIONS.SEARCH_NAME", strLikeName, bLike)); if (strHideType.Length > 0) strB.Append(GetHideTypeFromXmlForLike(strHideType, "ORGANIZATIONS")); return string.Format(strB.ToString(), strRankLimit); }