/// <summary> /// 获取内部组织机构 /// </summary> /// <param name="userInfo">用户</param> /// <returns>数据表</returns> public DataTable GetInnerOrganizeDT(BaseUserInfo userInfo) { var parameter = ServiceParameter.CreateWithLog(userInfo , MethodBase.GetCurrentMethod()); ServiceUtil.ProcessUserCenterWriteDbWithLock(parameter, locker, (dbHelper, getOnLine) => { var manager = new BaseOrganizeManager(dbHelper, userInfo); if (MessageService.LaseInnerOrganizeCheck == DateTime.MinValue) { getOnLine = true; } else { // 2008.01.23 JiRiGaLa 修正错误 TimeSpan timeSpan = DateTime.Now - MessageService.LaseInnerOrganizeCheck; if ((timeSpan.Minutes * 60 + timeSpan.Seconds) >= BaseSystemInfo.OnLineCheck * 10) { getOnLine = true; } } if (OnLineStateDT == null || getOnLine) { string commandText = string.Empty; if (BaseSystemInfo.OrganizeDynamicLoading) { commandText = " SELECT * " + " FROM " + BaseOrganizeEntity.TableName + " WHERE " + BaseOrganizeEntity.FieldDeletionStateCode + " = 0 " + " AND " + BaseOrganizeEntity.FieldIsInnerOrganize + " = 1 " + " AND " + BaseOrganizeEntity.FieldEnabled + " = 1 " + " AND (" + BaseOrganizeEntity.FieldParentId + " IS NULL " + " OR " + BaseOrganizeEntity.FieldParentId + " IN (SELECT " + BaseOrganizeEntity.FieldId + " FROM " + BaseOrganizeEntity.TableName + " WHERE " + BaseOrganizeEntity.FieldDeletionStateCode + " = 0 AND " + BaseOrganizeEntity.FieldIsInnerOrganize + " = 1 AND " + BaseOrganizeEntity.FieldEnabled + " = 1 AND " + BaseOrganizeEntity.FieldParentId + " IS NULL)) " + " ORDER BY " + BaseOrganizeEntity.FieldSortCode; } else { commandText = " SELECT * " + " FROM " + BaseOrganizeEntity.TableName + " WHERE " + BaseOrganizeEntity.FieldDeletionStateCode + " = 0 " + " AND " + BaseOrganizeEntity.FieldIsInnerOrganize + " = 1 " + " AND " + BaseOrganizeEntity.FieldEnabled + " = 1 " + " ORDER BY " + BaseOrganizeEntity.FieldSortCode; } InnerOrganizeDT = manager.Fill(commandText); InnerOrganizeDT.TableName = BaseOrganizeEntity.TableName; MessageService.LaseInnerOrganizeCheck = DateTime.Now; } // BaseLogManager.Instance.Add(userInfo, this.serviceName, MethodBase.GetCurrentMethod()); return(getOnLine); }); return(InnerOrganizeDT); }
/// <summary> /// 获取用户的管理网点 /// </summary> /// <param name="result">数据权限主键</param> /// <returns>管理网点数组</returns> public string[] GetUserCompanyIds(string userId, string permissionId) { string[] result = null; // 用户有权限的省?获取省的网点? // 用户有权限的市?市的网点? // 用户有权限的县?县的网点? // 用户有权限的街道?街道的网点? List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, BaseUserEntity.TableName)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, userId)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionId, permissionId)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldDeletionStateCode, 0)); string tableName = this.UserInfo.SystemCode + "PermissionScope"; BasePermissionScopeManager permissionScopeManager = new BasePermissionScopeManager(this.DbHelper, this.UserInfo, tableName); string[] areaIds = permissionScopeManager.GetProperties(parameters, BasePermissionScopeEntity.FieldTargetId); // 按区域分割省、市、县、街道 string[] province = null; string[] city = null; string[] district = null; string[] street = null; SplitArea(areaIds, out province, out city, out district, out street); string[] areaCompanyIds = null; if (areaIds != null && areaIds.Length > 0) { string commandText = " SELECT " + BaseOrganizeEntity.FieldId + " FROM " + BaseOrganizeEntity.TableName + " WHERE " + BaseOrganizeEntity.FieldEnabled + " = 1 " + " AND " + BaseOrganizeEntity.FieldDeletionStateCode + " = 0 " + " AND ("; if (province != null && province.Length > 0) { commandText += BaseOrganizeEntity.FieldProvinceId + " IN (" + BaseBusinessLogic.ObjectsToList(province, "'") + ")"; } if (city != null && city.Length > 0) { if (province != null && province.Length > 0) { commandText += " OR "; } commandText += BaseOrganizeEntity.FieldCityId + " IN (" + BaseBusinessLogic.ObjectsToList(city, "'") + ")"; } if (district != null && district.Length > 0) { if ((province != null && province.Length > 0) || (city != null && city.Length > 0)) { commandText += " OR "; } commandText += BaseOrganizeEntity.FieldDistrictId + " IN (" + BaseBusinessLogic.ObjectsToList(district, "'") + ")"; } if (street != null && street.Length > 0) { if ((province != null && province.Length > 0) || (city != null && city.Length > 0) || (district != null && district.Length > 0)) { commandText += " OR "; } commandText += BaseOrganizeEntity.FieldStreetId + " IN (" + BaseBusinessLogic.ObjectsToList(areaIds, "'") + ")"; } commandText += ")"; BaseOrganizeManager organizeManager = new BaseOrganizeManager(); DataTable dt = organizeManager.Fill(commandText); areaCompanyIds = BaseBusinessLogic.FieldToArray(dt, BaseOrganizeEntity.FieldId); } // 用户直接有权限的网点 parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceCategory, BaseUserEntity.TableName)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldResourceId, userId)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldPermissionId, permissionId)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldTargetCategory, BaseOrganizeEntity.TableName)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BasePermissionScopeEntity.FieldDeletionStateCode, 0)); string[] companyIds = permissionScopeManager.GetProperties(parameters, BasePermissionScopeEntity.FieldTargetId); result = StringUtil.Concat(companyIds, areaCompanyIds); return(result); }
/// <summary> /// 获取内部组织机构 /// </summary> /// <param name="userInfo">用户</param> /// <returns>数据表</returns> public DataTable GetInnerOrganizeDT(BaseUserInfo userInfo) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif // 是否需要获取用户状态 bool getOnLine = false; lock (locker) { using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseOrganizeManager organizeManager = new BaseOrganizeManager(dbHelper, userInfo); if (MessageService.LaseInnerOrganizeCheck == DateTime.MinValue) { getOnLine = true; } else { // 2008.01.23 JiRiGaLa 修正错误 TimeSpan timeSpan = DateTime.Now - MessageService.LaseInnerOrganizeCheck; if ((timeSpan.Minutes * 60 + timeSpan.Seconds) >= BaseSystemInfo.OnLineCheck * 100) { getOnLine = true; } } if (OnLineStateDT == null || getOnLine) { string commandText = " SELECT * " + " FROM " + BaseOrganizeEntity.TableName + " WHERE " + BaseOrganizeEntity.FieldDeletionStateCode + " = 0 " + " AND " + BaseOrganizeEntity.FieldIsInnerOrganize + " = 1 " + " AND " + BaseOrganizeEntity.FieldEnabled + " = 1 " + " ORDER BY " + BaseOrganizeEntity.FieldSortCode; InnerOrganizeDT = organizeManager.Fill(commandText); InnerOrganizeDT.TableName = BaseOrganizeEntity.TableName; MessageService.LaseInnerOrganizeCheck = DateTime.Now; } // BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } } // 写入调试信息 #if (DEBUG) if (getOnLine) { BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); } #endif return(InnerOrganizeDT); }