Пример #1
0
        /// <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;
        }