示例#1
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="workReportEntity">实体</param>
        /// <returns>主键</returns>
        private string AddEntity(BaseWorkReportEntity workReportEntity)
        {
            string returnValue = string.Empty;
            BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper);
            string sequence = sequenceManager.GetSequence(BaseWorkReportTable.TableName);

            workReportEntity.SortCode = sequence;

            //获取职员的部门主键和公司主键
            BaseStaffManager staffManager = new BaseStaffManager(DbHelper, UserInfo);
            string           CompanyId    = staffManager.GetProperty(workReportEntity.StaffId, BaseStaffTable.FieldCompanyId);
            string           DepartmentId = staffManager.GetProperty(workReportEntity.StaffId, BaseStaffTable.FieldDepartmentId);

            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginInsert(BaseWorkReportTable.TableName);
            sqlBuilder.SetValue(BaseWorkReportTable.FieldId, sequence);
            sqlBuilder.SetValue(BaseWorkReportTable.FieldCompanyId, CompanyId);
            sqlBuilder.SetValue(BaseWorkReportTable.FieldDepartmentId, DepartmentId);
            this.SetEntity(sqlBuilder, workReportEntity);
            sqlBuilder.SetValue(BaseWorkReportTable.FieldCreateUserId, UserInfo.Id);
            sqlBuilder.SetDBNow(BaseWorkReportTable.FieldCreateOn);
            returnValue = sqlBuilder.EndInsert() > 0 ? sequence : string.Empty;
            return(returnValue);
        }
示例#2
0
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="staffEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状消息</param>
        /// <returns>主键</returns>
        public string AddStaff(BaseUserInfo userInfo, BaseStaffEntity staffEntity, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    // 1.若添加用户成功,添加员工。
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    returnValue = staffManager.Add(staffEntity, out statusCode);
                    statusMessage = staffManager.GetStateMessage(statusCode);
                    // 2.自己不用给自己发提示信息,这个提示信息是为了提高工作效率的
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_AddStaff, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
                BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif
            return returnValue;
        }
示例#3
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;
        }
示例#4
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;
        }
示例#5
0
        /// <summary>
        /// 获取员工列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTable(BaseUserInfo userInfo)
        {
            // 写入调试信息
            #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.GetDataTable(new KeyValuePair<string, object>(BaseStaffEntity.FieldDeletionStateCode, 0), BaseStaffEntity.FieldSortCode);
                    dataTable.TableName = BaseStaffEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_GetDataTable, 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;
        }
示例#6
0
        /// <summary>
        /// 获取内部通讯录
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="organizeId">组织机构主键</param>
        /// <param name="search">查询内容</param>
        /// <param name="pageSize">分页的条数</param>
        /// <param name="pageIndex">当前页数</param>
        /// <returns>数据表</returns>
        public DataTable GetAddressDataTableByPage(BaseUserInfo userInfo, string organizeId, string searchValue, int pageSize, int pageIndex, out int recordCount)
        {
            // 写入调试信息
            #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.GetAddressDataTableByPage(out recordCount, pageSize, pageIndex, organizeId, searchValue);
                    dataTable.TableName = BaseStaffEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_GetAddressPageDT, 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;
        }
示例#7
0
 /// <summary>
 /// 扮演用户
 /// </summary>
 /// <param name="id">用户主键</param>
 /// <returns>用户类</returns>
 public BaseUserInfo Impersonation(string id, out string statusCode)
 {
     BaseUserInfo userInfo = null;
     // 获得登录信息
     DataTable dataTableLogOn = this.GetDataTableById(id);
     BaseUserEntity userEntity = new BaseUserEntity();
     userEntity.GetSingle(dataTableLogOn);
     // 只允许登录一次,需要检查是否自己重新登录了,或者自己扮演自己了
     if (!UserInfo.Id.Equals(id))
     {
         if (BaseSystemInfo.CheckOnLine)
         {
             if (userEntity.UserOnLine > 0)
             {
                 statusCode = StatusCode.ErrorOnLine.ToString();
                 return userInfo;
             }
         }
     }
     userInfo = this.ConvertToUserInfo(userEntity);
     if (userEntity.IsStaff.Equals("1"))
     {
         // 获得员工的信息
         BaseStaffEntity staffEntity = new BaseStaffEntity();
         BaseStaffManager staffManager = new BaseStaffManager(DbHelper, UserInfo);
         DataTable dataTableStaff = staffManager.GetDataTableById(id);
         staffEntity.GetSingle(dataTableStaff);
         userInfo = staffManager.ConvertToUserInfo(staffEntity, userInfo);
     }
     statusCode = StatusCode.OK.ToString();
     // 登录、重新登录、扮演时的在线状态进行更新
     this.ChangeOnLine(id);
     return userInfo;
 }
示例#8
0
        /// <summary>
        /// 移动数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="organizeIds">组织机构主键数组</param>
        /// <param name="organizeId">父结点主键</param>
        /// <returns>影响行数</returns>
        public int MoveTo(BaseUserInfo userInfo, string id, string organizeId)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    returnValue = staffManager.SetProperty(id, new KeyValuePair<string, object>(BaseStaffEntity.FieldDepartmentId, organizeId));
                    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 returnValue;
        }
示例#9
0
        /// <summary>
        /// 员工关联用户
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="staffId">员工主键</param>
        /// <param name="userId">用户主键</param>
        /// <returns>影响行数</returns>
        public int SetStaffUser(BaseUserInfo userInfo, string staffId, string userId)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    if (string.IsNullOrEmpty(userId))
                    {
                        returnValue = staffManager.SetProperty(staffId, new KeyValuePair<string, object>(BaseStaffEntity.FieldUserId, userId));
                    }
                    else
                    {
                        // 一个用户只能帮定到一个帐户上,检查是否已经绑定过这个用户了。
                        string[] staffIds = staffManager.GetIds(new KeyValuePair<string, object>(BaseStaffEntity.FieldUserId, userId), new KeyValuePair<string, object>(BaseStaffEntity.FieldDeletionStateCode, 0));
                        if (staffIds == null || staffIds.Length == 0)
                        {
                            returnValue = staffManager.SetProperty(staffId, new KeyValuePair<string, object>(BaseStaffEntity.FieldUserId, userId));
                            BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                            BaseUserEntity userEntity = userManager.GetEntity(userId);
                            returnValue = staffManager.SetProperty(staffId, new KeyValuePair<string, object>(BaseStaffEntity.FieldUserName, userEntity.UserName));
                        }
                    }
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_SetStaffUser, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            #if (DEBUG)
                BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif
            return returnValue;
        }
示例#10
0
        /// <summary>
        /// 批量打删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(BaseUserInfo userInfo, string[] ids)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    BaseStaffEntity staffEntity = null;
                    for (int i = 0; i < ids.Length; i++)
                    {
                        // 删除相应的用户
                        staffEntity = staffManager.GetEntity(ids[i]);
                        if (staffEntity.UserId != null)
                        {
                            userManager.SetDeleted(staffEntity.UserId);
                        }
                        // 删除职员
                        returnValue = staffManager.SetDeleted(ids[i], true);
                    }
                    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 returnValue;
        }
 public string[] GetUserIds(string organizeId)
 {
     // 要注意不能重复发信息,只能发一次。
     string[] companyUsers = null; // 按公司查找用户
     string[] departmentUsers = null; // 按部门查找用户
     string[] workgroupUsers = null; // 按工作组查找用户
     if (!String.IsNullOrEmpty(organizeId))
     {
         // 这里获得的是用户主键,不是员工主键
         BaseStaffManager staffManager = new BaseStaffManager(DbHelper);
         companyUsers = staffManager.GetIds(new KeyValuePair<string, object>(BaseStaffEntity.FieldCompanyId, organizeId));
         departmentUsers = staffManager.GetIds(new KeyValuePair<string, object>(BaseStaffEntity.FieldDepartmentId, organizeId));
         workgroupUsers = staffManager.GetIds(new KeyValuePair<string, object>(BaseStaffEntity.FieldWorkgroupId, organizeId));
     }
     string[] userIds = StringUtil.Concat(companyUsers, departmentUsers, workgroupUsers);
     return userIds;
 }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="workReportEntity">实体</param>
        /// <returns>主键</returns>
        private string AddEntity(BaseWorkReportEntity workReportEntity)
        {
            string returnValue = string.Empty;
            BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper);
            string sequence = sequenceManager.GetSequence(BaseWorkReportTable.TableName);
            workReportEntity.SortCode = sequence;

            //获取职员的部门主键和公司主键
            BaseStaffManager staffManager = new BaseStaffManager(DbHelper, UserInfo);
            string CompanyId = staffManager.GetProperty(workReportEntity.StaffId, BaseStaffTable.FieldCompanyId);
            string DepartmentId = staffManager.GetProperty(workReportEntity.StaffId, BaseStaffTable.FieldDepartmentId);

            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);
            sqlBuilder.BeginInsert(BaseWorkReportTable.TableName);
            sqlBuilder.SetValue(BaseWorkReportTable.FieldId, sequence);
            sqlBuilder.SetValue(BaseWorkReportTable.FieldCompanyId, CompanyId);
            sqlBuilder.SetValue(BaseWorkReportTable.FieldDepartmentId, DepartmentId);
            this.SetEntity(sqlBuilder, workReportEntity);
            sqlBuilder.SetValue(BaseWorkReportTable.FieldCreateUserId, UserInfo.Id);
            sqlBuilder.SetDBNow(BaseWorkReportTable.FieldCreateOn);
            returnValue = sqlBuilder.EndInsert() > 0 ? sequence : string.Empty;
            return returnValue;
        }
示例#13
0
        /// <summary>
        /// 批量打删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(BaseUserInfo userInfo, string[] ids)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseOrganizeManager organizeManager = new BaseOrganizeManager(dbHelper, userInfo);
                    for (int i = 0; i < ids.Length; i++ )
                    {
                        // 设置部门为删除状态
                        returnValue += organizeManager.SetDeleted(ids[i]);
                        // 相应的用户也需要处理
                        BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                        List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
                        parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldCompanyId, null));
                        parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldCompanyName, null));
                        userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldCompanyId, ids[i]), parameters);
                        parameters = new List<KeyValuePair<string, object>>();
                        parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldSubCompanyId, null));
                        parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldSubCompanyName, null));
                        userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldSubCompanyId, ids[i]), parameters);
                        parameters = new List<KeyValuePair<string, object>>();
                        parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldDepartmentId, null));
                        parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldDepartmentName, null));
                        userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldDepartmentId, ids[i]), parameters);
                        parameters = new List<KeyValuePair<string, object>>();
                        parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldWorkgroupId, null));
                        parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldWorkgroupName, null));
                        userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldWorkgroupId, ids[i]), parameters);
                        // 相应的员工也需要处理
                        BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                        staffManager.SetProperty(new KeyValuePair<string, object>(BaseStaffEntity.FieldCompanyId, ids[i]), new KeyValuePair<string, object>(BaseStaffEntity.FieldCompanyId, null));
                        staffManager.SetProperty(new KeyValuePair<string, object>(BaseStaffEntity.FieldSubCompanyId, ids[i]), new KeyValuePair<string, object>(BaseStaffEntity.FieldSubCompanyId, null));
                        staffManager.SetProperty(new KeyValuePair<string, object>(BaseStaffEntity.FieldDepartmentId, ids[i]), new KeyValuePair<string, object>(BaseStaffEntity.FieldDepartmentId, null));
                        staffManager.SetProperty(new KeyValuePair<string, object>(BaseStaffEntity.FieldWorkgroupId, ids[i]), new KeyValuePair<string, object>(BaseStaffEntity.FieldWorkgroupId, null));
                    }
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.OrganizeService_SetDeleted, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return returnValue;
        }
示例#14
0
 private void ShowUser()
 {
     // 显示用户数据
     this.txtUserName.Text = userEntity.UserName;
     this.txtRealName.Text = userEntity.RealName;
     this.txtCode.Text = userEntity.Code;
     this.txtMobile.Text = userEntity.Mobile;
     this.txtEmail.Text = userEntity.Email;
     if (userEntity.RoleId != null)
     {
         this.cmbRole.SelectedValue = userEntity.RoleId.ToString();
     }
     this.ucCompany.SelectedId = userEntity.CompanyId;
     this.ucSubCompany.SelectedId = userEntity.SubCompanyId;
     this.ucDepartment.SelectedId = userEntity.DepartmentId;
     this.ucWorkgroup.SelectedId = userEntity.WorkgroupId;
     this.chbEnabled.Checked = (userEntity.Enabled == 1);
     this.txtDescription.Text = userEntity.Description;
     // 获取用户对应的员工信息
     if (this.userEntity.Id != null)
     {
         // 加载员工
         BaseStaffManager staffManager = new BaseStaffManager(UserInfo);
         this.staffEntity = new BaseStaffEntity(staffManager.GetDataTable(BaseStaffEntity.FieldUserId, userEntity.Id.ToString()));
     }
 }
示例#15
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public BaseStaffEntity GetEntity(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            BaseStaffEntity staffEntity = null;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    staffEntity = staffManager.GetEntity(id);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_GetEntity, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return staffEntity;
        }
示例#16
0
        public DataTable GetParentChildrenStaffs(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.GetParentChildrenStaffs(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;
        }
示例#17
0
        /// <summary>
        /// 更新员工
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="staffEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状消息</param>
        /// <returns>影响行数</returns>
        public int UpdateStaff(BaseUserInfo userInfo, BaseStaffEntity staffEntity, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            if (!BaseSystemInfo.IsAuthorized(userInfo))
            {
                throw new Exception(AppMessage.MSG0800);
            }

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    // 3.员工的修改
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    returnValue = staffManager.Update(staffEntity, out statusCode);
                    statusMessage = staffManager.GetStateMessage(statusCode);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_UpdateStaff, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
                BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif
            return returnValue;
        }
示例#18
0
        /// <summary>
        /// 重新排序数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>影响行数</returns>
        public int ResetSortCode(BaseUserInfo userInfo)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper);
                    returnValue = staffManager.ResetSortCode();
                    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 returnValue;
        }
示例#19
0
        /// <summary>
        /// 批量更新通讯地址
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="staffEntites">实体</param>
        /// <returns>影响行数</returns>
        public int BatchUpdateAddress(BaseUserInfo userInfo, List<BaseStaffEntity> staffEntites, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    statusCode = string.Empty;
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    for (int i = 0; i < staffEntites.Count; i++)
                    {
                        returnValue += staffManager.UpdateAddress(staffEntites[i], out statusCode);
                    }
                    statusMessage = staffManager.GetStateMessage(statusCode);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_BatchUpdateAddress, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return returnValue;
        }