Esempio n. 1
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)
        {
            var result = 0;

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

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseStaffManager(dbHelper, userInfo);
                if (ValidateUtil.IsInt(userId))
                {
                    result = manager.SetProperty(staffId, new KeyValuePair <string, object>(BaseStaffEntity.FieldUserId, userId));
                }
                else
                {
                    // 一个用户只能帮定到一个帐户上,检查是否已经绑定过这个用户了。
                    var staffIds = manager.GetIds(new KeyValuePair <string, object>(BaseStaffEntity.FieldUserId, userId), new KeyValuePair <string, object>(BaseStaffEntity.FieldDeleted, 0));
                    if (staffIds == null || staffIds.Length == 0)
                    {
                        result          = manager.SetProperty(staffId, new KeyValuePair <string, object>(BaseStaffEntity.FieldUserId, userId));
                        var userManager = new BaseUserManager(dbHelper, userInfo);
                        var userEntity  = userManager.GetEntity(userId);
                        result          = manager.SetProperty(staffId, new KeyValuePair <string, object>(BaseStaffEntity.FieldUserName, userEntity.UserName));
                    }
                }
            });
            return(result);
        }
        /// <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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        /// <summary>
        /// 批量设置删除
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(BaseUserInfo userInfo, string[] ids)
        {
            var result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var userManager             = new BaseUserManager(dbHelper, userInfo);
                var staffManager            = new BaseStaffManager(dbHelper, userInfo);
                BaseStaffEntity staffEntity = null;
                for (var i = 0; i < ids.Length; i++)
                {
                    // 删除相应的用户
                    staffEntity = staffManager.GetEntity(ids[i]);
                    if (staffEntity != null && staffEntity.UserId > 0)
                    {
                        userManager.SetDeleted(staffEntity.UserId);
                    }
                    // 删除职员
                    result = staffManager.SetDeleted(ids[i], true, true);
                }
            });
            return(result);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        /// <summary>
        /// 删除员工关联的用户
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="staffId">员工主键</param>
        /// <returns>影响行数</returns>
        public int DeleteUser(BaseUserInfo userInfo, string staffId)
        {
            var result = 0;

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

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseStaffManager(dbHelper, userInfo);
                result      = manager.DeleteUser(staffId);
            });
            return(result);
        }
Esempio n. 9
0
        /// <summary>
        /// 重新排序数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>影响行数</returns>
        public int ResetSortCode(BaseUserInfo userInfo)
        {
            var result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseStaffManager(dbHelper);
                result      = manager.ResetSortCode();
            });
            return(result);
        }
Esempio n. 10
0
        /// <summary>
        /// 获取主键
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="name">查询的参数</param>
        /// <param name="value">参数值</param>
        /// <returns>影响行数</returns>
        public string GetId(BaseUserInfo userInfo, string name, object value)
        {
            var result = string.Empty;

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

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseStaffManager(dbHelper);
                result      = manager.GetId(new KeyValuePair <string, object>(name, value));
            });
            return(result);
        }
Esempio n. 11
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public BaseStaffEntity GetEntity(BaseUserInfo userInfo, string id)
        {
            BaseStaffEntity entity = null;

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

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseStaffManager(dbHelper, userInfo);
                entity      = manager.GetEntity(id);
            });
            return(entity);
        }
Esempio n. 12
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);
        }
        /// <summary>
        /// 批量设置删除
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(BaseUserInfo userInfo, string[] ids)
        {
            var result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseOrganizationManager(dbHelper, userInfo);
                for (var i = 0; i < ids.Length; i++)
                {
                    // 设置部门为删除状态
                    result += manager.SetDeleted(ids[i]);
                    // 相应的用户也需要处理
                    var userManager = new BaseUserManager(dbHelper, userInfo);
                    var parameters  = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyId, null),
                        new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyId, ids[i]), parameters);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(BaseUserEntity.FieldSubCompanyId, null),
                        new KeyValuePair <string, object>(BaseUserEntity.FieldSubCompanyName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldSubCompanyId, ids[i]), parameters);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentId, null),
                        new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentId, ids[i]), parameters);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupId, null),
                        new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupId, ids[i]), parameters);
                    // 相应的员工也需要处理
                    var 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));
                }
                //var folderManager = new BaseFolderManager(dbHelper, userInfo);
                //folderManager.SetDeleted(ids);
            });
            return(result);
        }
Esempio n. 14
0
        /// <summary>
        /// 获得员工列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="organizationId">组织主键</param>
        /// <param name="searchKey">查询</param>
        /// <returns>数据表</returns>
        public DataTable Search(BaseUserInfo userInfo, string organizationId, string searchKey)
        {
            var dt = new DataTable(BaseStaffEntity.CurrentTableName);

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager  = new BaseStaffManager(dbHelper, userInfo);
                dt           = manager.Search(organizationId, searchKey, false);
                dt.TableName = BaseStaffEntity.CurrentTableName;
            });
            return(dt);
        }
Esempio n. 15
0
        /// <summary>
        /// 获取员工列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">组织主键</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByIds(BaseUserInfo userInfo, string[] ids)
        {
            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.GetDataTable(BaseStaffEntity.FieldId, ids, BaseStaffEntity.FieldSortCode);
                dt.TableName = BaseStaffEntity.CurrentTableName;
            });
            return(dt);
        }
Esempio n. 16
0
        /// <summary>
        /// 获取员工列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTable(BaseUserInfo userInfo)
        {
            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.GetDataTable(new KeyValuePair <string, object>(BaseStaffEntity.FieldDeleted, 0), BaseStaffEntity.FieldSortCode);
                dt.TableName = BaseStaffEntity.CurrentTableName;
            });
            return(dt);
        }
Esempio n. 17
0
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int BatchDelete(BaseUserInfo userInfo, string[] ids)
        {
            var result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseStaffManager(dbHelper, userInfo);
                result      = manager.BatchDelete(ids);
            });

            return(result);
        }
Esempio n. 18
0
        /// <summary>
        /// 同步数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="all">同步所有数据</param>
        /// <returns>影响行数</returns>
        public int Synchronous(BaseUserInfo userInfo, bool all = false)
        {
            var result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var staffManager = new BaseStaffManager(dbHelper, userInfo);
                // result = staffManager.Synchronous(all);
            });

            return(result);
        }
Esempio n. 19
0
        /// <summary>
        /// 获取内部通讯录
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="organizeId">组织机构主键</param>
        /// <param name="search">查询内容</param>
        /// <returns>数据表</returns>
        public DataTable GetAddressDataTable(BaseUserInfo userInfo, string organizeId, string searchValue)
        {
            var dt = new DataTable(BaseStaffEntity.TableName);

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

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var manager  = new BaseStaffManager(dbHelper, userInfo);
                dt           = manager.GetAddressDataTable(organizeId, searchValue);
                dt.TableName = BaseStaffEntity.TableName;
            });
            return(dt);
        }
Esempio n. 20
0
        /// <summary>
        /// 批量保存员工
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="dt">数据表</param>
        /// <returns>影响行数</returns>
        public int BatchSave(BaseUserInfo userInfo, DataTable dt)
        {
            var result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseStaffManager(dbHelper, userInfo);
                result      = manager.BatchSave(dt);
                // ReturnDataTable = Staff.GetDataTableByOrganization(organizationId);
            });
            return(result);
        }
Esempio n. 21
0
        /// <summary>
        /// 移动数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">组织机构主键数组</param>
        /// <param name="organizationId">父结点主键</param>
        /// <returns>影响行数</returns>
        public int MoveTo(BaseUserInfo userInfo, string id, string organizationId)
        {
            var result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseStaffManager(dbHelper, userInfo);
                result      = manager.SetProperty(id, new KeyValuePair <string, object>(BaseStaffEntity.FieldDepartmentId, organizationId));
            });

            return(result);
        }
Esempio n. 22
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);
        }
Esempio n. 23
0
        /// <summary>
        /// 获取父级下属员工
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="organizationId"></param>
        /// <returns></returns>
        public DataTable GetParentChildrenStaffs(BaseUserInfo userInfo, string organizationId)
        {
            var dt = new DataTable(BaseStaffEntity.CurrentTableName);

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                // 获得组织机构列表
                var manager         = new BaseStaffManager(dbHelper, userInfo);
                dt                  = manager.GetParentChildrenStaffs(organizationId);
                dt.DefaultView.Sort = BaseStaffEntity.FieldSortCode;
                dt.TableName        = BaseStaffEntity.CurrentTableName;
            });
            return(dt);
        }
Esempio n. 24
0
        /// <summary>
        /// 批量移动数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">组织机构主键数组</param>
        /// <param name="organizeId">父结点主键</param>
        /// <returns>影响行数</returns>
        public int BatchMoveTo(BaseUserInfo userInfo, string[] ids, string organizeId)
        {
            int result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseStaffManager(dbHelper, userInfo);
                for (int i = 0; i < ids.Length; i++)
                {
                    result += manager.SetProperty(ids[i], new KeyValuePair <string, object>(BaseStaffEntity.FieldDepartmentId, organizeId));
                }
            });
            return(result);
        }
Esempio n. 25
0
        /// <summary>
        /// 部门变动
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">员工主键</param>
        /// <param name="companyId">单位主键</param>
        /// <param name="departmentId">部门主键</param>
        /// <returns>影响行数</returns>
        public int ChangeDepartment(BaseUserInfo userInfo, string id, string companyId, string departmentId)
        {
            int result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseStaffManager(dbHelper, userInfo);
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BaseStaffEntity.FieldCompanyId, companyId));
                parameters.Add(new KeyValuePair <string, object>(BaseStaffEntity.FieldDepartmentId, departmentId));
                result = manager.SetProperty(new KeyValuePair <string, object>(BaseStaffEntity.FieldId, id), parameters);
            });

            return(result);
        }
 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);
 }
Esempio n. 27
0
        public static BaseStaffEntity GetObjectByCodeByCache(string code)
        {
            BaseStaffEntity result = null;

            System.Web.Caching.Cache cache = HttpRuntime.Cache;
            string cacheObject             = "StaffByCode" + code;

            if (cache != null && cache[cacheObject] == null)
            {
                BaseStaffManager staffManager = new BaseStaffManager();
                result = staffManager.GetObjectByCode(code);
                cache.Add(cacheObject, result, null, DateTime.Now.AddMinutes(10), TimeSpan.Zero, CacheItemPriority.Normal, null);
                System.Console.WriteLine(System.DateTime.Now.ToString(BaseSystemInfo.DateTimeFormat) + " cache Staff");
            }
            result = cache[cacheObject] as BaseStaffEntity;
            return(result);
        }
Esempio n. 28
0
        /// <summary>
        /// 批量打删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(BaseUserInfo userInfo, string[] ids)
        {
            var parameter = ServiceParameter.CreateWithMessage(userInfo
                                                               , MethodBase.GetCurrentMethod()
                                                               , this.serviceName
                                                               , AppMessage.OrganizeService_SetDeleted);
            int result = 0;

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseAreaManager(dbHelper, userInfo);
                for (int i = 0; i < ids.Length; i++)
                {
                    // 设置部门为删除状态
                    result += manager.SetDeleted(ids[i]);
                    // 相应的用户也需要处理
                    var 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);
                    // 相应的员工也需要处理
                    var 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));
                }
                var folderManager = new BaseFolderManager(dbHelper, userInfo);
                folderManager.SetDeleted(ids);
            });
            return(result);
        }
Esempio n. 29
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);
        }
Esempio n. 30
0
        /// <summary>
        /// 查询用户
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="permissionCode">权限编码</param>
        /// <param name="companyId"></param>
        /// <param name="condition">查询</param>
        /// <param name="auditStates">有效</param>
        /// <param name="enabled"></param>
        /// <param name="recordCount"></param>
        /// <param name="pageNo"></param>
        /// <param name="pageSize"></param>
        /// <param name="sort"></param>
        /// <returns>数据表</returns>
        public DataTable SearchByPage(BaseUserInfo userInfo, string permissionCode, string companyId, string condition, string auditStates, bool?enabled, out int recordCount, int pageNo = 1, int pageSize = 100, string sort = null)
        {
            recordCount = 0;
            var myRecordCount = 0;
            var result        = new DataTable();

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var staffManager = new BaseStaffManager(dbHelper, userInfo);
                // result = staffManager.GetDataTable(100, BaseStaffEntity.FieldSortCode);
                result           = staffManager.SearchByPage(permissionCode, condition, enabled, auditStates, companyId, null, out myRecordCount, pageNo, pageSize, sort);
                result.TableName = BaseStaffEntity.CurrentTableName;
            });
            recordCount = myRecordCount;
            return(result);
        }