Exemplo n.º 1
0
        /// <summary>
        /// 按公司获取员工列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="organizationId">组织主键</param>
        /// <param name="containChildren">含子部门</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByOrganization(BaseUserInfo userInfo, string organizationId, bool containChildren)
        {
            var dt        = new DataTable(BaseStaffEntity.CurrentTableName);
            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                // 用户已经不存在的需要整理干净,防止数据不完整。
                var sql = "UPDATE BaseStaff SET UserId = NULL WHERE (UserId NOT IN (SELECT Id FROM BaseUser))";
                dbHelper.ExecuteNonQuery(sql);
                dbHelper.Close();
                // 这里是读取的服务器连接
                dbHelper.Open(BaseSystemInfo.UserCenterReadDbConnection);
                var manager = new BaseStaffManager(dbHelper, userInfo);
                if (containChildren)
                {
                    dt = manager.GetChildrenStaffs(organizationId);
                }
                else
                {
                    dt = manager.GetDataTableByOrganization(organizationId);
                }
                dt.TableName = BaseStaffEntity.CurrentTableName;
            });
            return(dt);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 按公司获取员工列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="organizeId">组织主键</param>
        /// <param name="containChildren">含子部门</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByOrganize(BaseUserInfo userInfo, string organizeId, bool containChildren)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            DataTable dataTable = new DataTable(BaseStaffEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    // 用户已经不存在的需要整理干净,防止数据不完整。
                    string sqlQuery = "UPDATE BaseStaff SET UserId = NULL WHERE (UserId NOT IN (SELECT Id FROM BaseUser))";
                    dbHelper.ExecuteNonQuery(sqlQuery);
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    if (containChildren)
                    {
                        dataTable = staffManager.GetChildrenStaffs(organizeId);
                    }
                    else
                    {
                        dataTable = staffManager.GetDataTableByOrganize(organizeId);
                    }
                    dataTable.TableName = BaseStaffEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_GetDataTableByOrganize, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return(dataTable);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 按部门获取员工列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="departmentId">部门主键</param>
        /// <param name="containChildren">含子部门</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByDepartment(BaseUserInfo userInfo, string departmentId, bool containChildren)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            DataTable dataTable = new DataTable(BaseStaffEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    if (containChildren)
                    {
                        dataTable = staffManager.GetChildrenStaffs(departmentId);
                    }
                    else
                    {
                        dataTable = staffManager.GetDataTableByDepartment(departmentId);
                    }
                    dataTable.TableName = BaseStaffEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_GetDataTableByDepartment, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return(dataTable);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取下属员工
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="organizationId"></param>
        /// <returns></returns>
        public DataTable GetChildrenStaffs(BaseUserInfo userInfo, string organizationId)
        {
            var dt = new DataTable(BaseStaffEntity.CurrentTableName);

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                // 获得组织机构列表
                var manager         = new BaseStaffManager(dbHelper, userInfo);
                dt                  = manager.GetChildrenStaffs(organizationId);
                dt.DefaultView.Sort = BaseStaffEntity.FieldSortCode;
                dt.TableName        = BaseStaffEntity.CurrentTableName;
            });
            return(dt);
        }
Exemplo n.º 5
0
        public DataTable GetChildrenStaffs(BaseUserInfo userInfo, string organizeId)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            DataTable dataTable = new DataTable(BaseStaffEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    // 获得组织机构列表
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    dataTable = staffManager.GetChildrenStaffs(organizeId);
                    dataTable.DefaultView.Sort = BaseStaffEntity.FieldSortCode;
                    dataTable.TableName        = BaseStaffEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif
            return(dataTable);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 按部门获取员工列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="departmentId">部门主键</param>
        /// <param name="containChildren">含子部门</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByDepartment(BaseUserInfo userInfo, string departmentId, bool containChildren)
        {
            var dt = new DataTable(BaseStaffEntity.CurrentTableName);

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseStaffManager(dbHelper, userInfo);
                if (containChildren)
                {
                    dt = manager.GetChildrenStaffs(departmentId);
                }
                else
                {
                    dt = manager.GetDataTableByDepartment(departmentId);
                }
                dt.TableName = BaseStaffEntity.CurrentTableName;
            });
            return(dt);
        }