public string AddReceiver(string contactId, string receiverId)
 {
     string returnValue = string.Empty;
     // 需要判断是否存在
     if (this.Exists(new KeyValuePair<string, object>(BaseContactDetailsEntity.FieldContactId,contactId)
         , new KeyValuePair<string, object>(BaseContactDetailsEntity.FieldReceiverId, receiverId)
         , new KeyValuePair<string, object>(BaseContactDetailsEntity.FieldCategory, "User")))
     {
         return string.Empty;
     }
     BaseUserManager userManager = new BaseUserManager(DbHelper, UserInfo);
     BaseUserEntity useEntity = userManager.GetEntity(int.Parse(receiverId));
     BaseContactDetailsEntity contactDetailsEntity = new BaseContactDetailsEntity();
     // 这里一定要给个不可猜测的主键,为了提高安全性
     contactDetailsEntity.Id = BaseBusinessLogic.NewGuid();
     contactDetailsEntity.ContactId = contactId;
     contactDetailsEntity.Category = "User";
     contactDetailsEntity.ReceiverId = useEntity.Id.ToString();
     contactDetailsEntity.ReceiverRealName = useEntity.RealName;
     contactDetailsEntity.IsNew = 0;
     contactDetailsEntity.Enabled = 1;
     contactDetailsEntity.NewComment = 0;
     returnValue = this.Add(contactDetailsEntity);
     // 这里需要重新计算发送给了几个人,几个人已经阅读的功能
     this.SetReadState(contactId);
     return returnValue;
 }
        /// <summary>
        /// 清除角色权限
        /// 
        /// 1.清除角色的用户归属。
        /// 2.清除角色的模块权限。
        /// 3.清除角色的操作权限。
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>数据表</returns>
        public int ClearRolePermission(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #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);
                    returnValue += userManager.ClearUser(id);

                    string tableName = BasePermissionEntity.TableName;
                    if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
                    {
                        tableName = BaseSystemInfo.SystemCode + "Permission";
                    }
                    BaseRolePermissionManager rolePermissionManager = new BaseRolePermissionManager(dbHelper, userInfo, tableName);
                    returnValue += rolePermissionManager.RevokeAll(id);

                    tableName = BasePermissionScopeEntity.TableName;
                    if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
                    {
                        tableName = BaseSystemInfo.SystemCode + "PermissionScope";
                    }
                    BaseRoleScopeManager roleScopeManager = new BaseRoleScopeManager(dbHelper, userInfo, tableName);
                    returnValue += roleScopeManager.RevokeAll(id);

                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.PermissionService_ClearRolePermission, 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;
        }
 /// <summary>
 /// 替换当前步骤中的人员
 /// </summary>
 /// <param name="oldUserId">原来的工号</param>
 /// <param name="newUserId">新的工号</param>
 /// <returns>影响行数</returns>
 public int ReplaceUser(string oldUserId, string newUserId)
 {
     BaseUserManager userManager = new BaseUserManager(this.UserInfo);
     BaseUserEntity newUserEntity = userManager.GetEntity(newUserId);
     SQLBuilder sqlBuilder = new SQLBuilder(this.DbHelper);
     sqlBuilder.BeginUpdate(this.CurrentTableName);
     sqlBuilder.SetValue(BaseWorkFlowStepEntity.FieldAuditUserId, newUserEntity.Id);
     sqlBuilder.SetValue(BaseWorkFlowStepEntity.FieldAuditUserCode, newUserEntity.Code);
     sqlBuilder.SetValue(BaseWorkFlowStepEntity.FieldAuditUserRealName, newUserEntity.RealName);
     sqlBuilder.SetValue(BaseWorkFlowStepEntity.FieldAuditDepartmentId, newUserEntity.DepartmentId);
     sqlBuilder.SetValue(BaseWorkFlowStepEntity.FieldAuditDepartmentName, newUserEntity.DepartmentName);
     sqlBuilder.SetWhere(BaseWorkFlowStepEntity.FieldAuditUserId, oldUserId, "OldUserId");
     return sqlBuilder.EndUpdate();
 }
示例#4
0
        /// <summary>
        /// 用户添加到角色
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="addUserIds">用户主键</param>
        /// <returns>影响行数</returns>
        public int AddUserToRole(BaseUserInfo userInfo, string roleId, string[] addUserIds)
        {
            // 写入调试信息
            #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);
                    string tableName = BaseUserRoleEntity.TableName;
                    if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
                    {
                        tableName = BaseSystemInfo.SystemCode + "UserRole";
                    }
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo, tableName);
                    // 小心异常,检查一下参数的有效性
                    if (addUserIds != null)
                    {
                        returnValue += userManager.AddToRole(addUserIds, roleId);
                    }
                    BaseLogManager.Instance.Add(dbHelper, userInfo, serviceName, AppMessage.RoleService_AddUserToRole, 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 GetAllRolesId()
        {
            string[] roleIds=new BaseUserManager().GetAllRoleIds(this.UserInfo.Id);
            string roleIdsString = null;
            if(roleIds.Length>0)
            {
                foreach (var roleId in roleIds)
                {
                    roleIdsString += roleId + ",";
                }
                if (!string.IsNullOrEmpty(roleIdsString ))
                {
                    // 去掉末尾的","
                    roleIdsString=roleIdsString.TrimEnd(',');
                }

            }
            return roleIdsString;
        }
示例#6
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="dbHelper">数据库连接</param>
        /// <param name="userInfo">用户信息</param>
        /// <param name="userEntity">用户实体</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        public string AddUser(IDbHelper dbHelper, BaseUserInfo userInfo, BaseUserEntity userEntity, out string statusCode, out string statusMessage)
        {
            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
                BaseSystemInfo.IsAuthorized(userInfo);
            #endif

            string returnValue = string.Empty;
            BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
            // 若是系统需要用加密的密码,这里需要加密密码。
            if (BaseSystemInfo.ServerEncryptPassword)
            {
                userEntity.UserPassword = userManager.EncryptUserPassword(userEntity.UserPassword);
                // 安全通讯密码、交易密码也生成好
                userEntity.CommunicationPassword = userManager.EncryptUserPassword(userEntity.CommunicationPassword);
            }
            returnValue = userManager.Add(userEntity, out statusCode);
            statusMessage = userManager.GetStateMessage(statusCode);
            // 自己不用给自己发提示信息,这个提示信息是为了提高工作效率的,还是需要审核通过的,否则垃圾信息太多了
            if (userEntity.Enabled == 0 && statusCode.Equals(StatusCode.OKAdd.ToString()))
            {
                // 不是系统管理员添加
                if (!userInfo.IsAdministrator)
                {
                    // 给超级管理员群组发信息
                    BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                    string[] roleIds = roleManager.GetIds(new KeyValuePair<string, object>(BaseRoleEntity.FieldCode, "Administrators"));
                    string[] userIds = userManager.GetIds(new KeyValuePair<string, object>(BaseUserEntity.FieldCode, "Administrator"));
                    // 发送请求审核的信息
                    BaseMessageEntity messageEntity = new BaseMessageEntity();
                    messageEntity.FunctionCode = MessageFunction.WaitForAudit.ToString();

                    // Pcsky 2012.05.04 显示申请的用户名
                    messageEntity.Contents = userInfo.RealName + "(" + userInfo.IPAddress + ")" + AppMessage.UserService_Application + userEntity.UserName + AppMessage.UserService_Check;
                    //messageEntity.Contents = userInfo.RealName + "(" + userInfo.IPAddress + ")" + AppMessage.UserService_Application + userEntity.RealName + AppMessage.UserService_Check;

                    BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo);
                    messageManager.BatchSend(userIds, null, roleIds, messageEntity, false);
                }
            }
            return returnValue;
        }
示例#7
0
        /// <summary>
        /// 激活帐户
        /// </summary>
        /// <param name="openId">唯一识别码</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>用户实体</returns>
        public BaseUserInfo AccountActivation(string openId, out string statusCode)
        {
            // 1.用户是否存在?
            BaseUserInfo userInfo = null;

            // 用户没有找到状态
            statusCode = StatusCode.UserNotFound.ToString();
            // 检查是否有效的合法的参数
            if (!String.IsNullOrEmpty(openId))
            {
                BaseUserManager userManager = new BaseUserManager(DbHelper);
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldOpenId, openId));
                parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, 0));
                DataTable dataTable = userManager.GetDataTable(parameters);
                if (dataTable.Rows.Count == 1)
                {
                    BaseUserEntity userEntity = new BaseUserEntity(dataTable);
                    // 3.用户是否被锁定?
                    if (userEntity.Enabled == 0)
                    {
                        statusCode = StatusCode.UserLocked.ToString();
                        return(userInfo);
                    }
                    if (userEntity.Enabled == 1)
                    {
                        // 2.用户是否已经被激活?
                        statusCode = StatusCode.UserIsActivate.ToString();
                        return(userInfo);
                    }
                    if (userEntity.Enabled == -1)
                    {
                        // 4.成功激活用户
                        statusCode = StatusCode.OK.ToString();
                        userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldId, userEntity.Id), new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1));
                        return(userInfo);
                    }
                }
            }
            return(userInfo);
        }
示例#8
0
 /// <summary>
 /// 激活帐户
 /// </summary>
 /// <param name="openId">唯一识别码</param>
 /// <param name="statusCode">返回状态码</param>
 /// <returns>用户实体</returns>
 public BaseUserInfo AccountActivation(string openId, out string statusCode)
 {
     // 1.用户是否存在?
     BaseUserInfo userInfo = null;
     // 用户没有找到状态
     statusCode = StatusCode.UserNotFound.ToString();
     // 检查是否有效的合法的参数
     if (!String.IsNullOrEmpty(openId))
     {
         BaseUserManager userManager = new BaseUserManager(DbHelper);
         List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
         parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldOpenId, openId));
         parameters.Add(new KeyValuePair<string, object>(BaseUserEntity.FieldDeletionStateCode, 0));
         DataTable dataTable = userManager.GetDataTable(parameters);
         if (dataTable.Rows.Count == 1)
         {
             BaseUserEntity userEntity = new BaseUserEntity(dataTable);
             // 3.用户是否被锁定?
             if (userEntity.Enabled == 0)
             {
                 statusCode = StatusCode.UserLocked.ToString();
                 return userInfo;
             }
             if (userEntity.Enabled == 1)
             {
                 // 2.用户是否已经被激活?
                 statusCode = StatusCode.UserIsActivate.ToString();
                 return userInfo;
             }
             if (userEntity.Enabled == -1)
             {
                 // 4.成功激活用户
                 statusCode = StatusCode.OK.ToString();
                 userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldId, userEntity.Id), new KeyValuePair<string, object>(BaseUserEntity.FieldEnabled, 1));
                 return userInfo;
             }
         }
     }
     return userInfo;
 }
 public string[] GetUserIds(string[] organizeIds, string[] roleIds)
 {
     // 要注意不能重复发信息,只能发一次。
     string[] companyUsers    = null; // 按公司查找用户
     string[] departmentUsers = null; // 按部门查找用户
     string[] workgroupUsers  = null; // 按工作组查找用户
     if (organizeIds != null)
     {
         // 这里获得的是用户主键,不是员工主键
         companyUsers    = this.GetProperties(BaseUserEntity.FieldCompanyId, organizeIds, BaseUserEntity.FieldId);
         departmentUsers = this.GetProperties(BaseUserEntity.FieldDepartmentId, organizeIds, BaseUserEntity.FieldId);
         workgroupUsers  = this.GetProperties(BaseUserEntity.FieldWorkgroupId, organizeIds, BaseUserEntity.FieldId);
     }
     string[] roleUsers = null;
     if (roleIds != null)
     {
         BaseUserManager userManager = new BaseUserManager(DbHelper);
         roleUsers = userManager.GetUserIds(roleIds);
     }
     string[] userIds = StringUtil.Concat(companyUsers, departmentUsers, workgroupUsers, roleUsers);
     return(userIds);
 }
 /// <summary>
 /// 删除用户的审核步骤
 /// </summary>
 /// <param name="userId">用户主键</param>
 /// <returns>影响行数</returns>
 public int DeleteAuditStepByUser(string userId)
 {
     int returnValue = 0;
     // 1: 若还有当前审核中的记录,不能被删除掉
     BaseWorkFlowCurrentManager manager = new BaseWorkFlowCurrentManager(this.DbHelper, this.UserInfo);
     List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>(3);
     parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowCurrentEntity.FieldAuditUserId, userId));
     parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowCurrentEntity.FieldEnabled, 1));
     parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowCurrentEntity.FieldDeletionStateCode, 0));
     if (!manager.Exists(parameters))
     {
         // 2: 删除用户的审核步骤。
         returnValue = this.SetProperty(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldAuditUserId, userId), new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldDeletionStateCode, 1));
         // 3: 同时把用户设置为无效。
         if (returnValue > 0)
         {
             BaseUserManager userManager = new BaseUserManager(this.UserInfo);
             userManager.SetProperty(new KeyValuePair<string, object>(BaseUserEntity.FieldId, userId), new KeyValuePair<string, object>(BaseUserEntity.FieldEnabled, 0));
         }
     }
     return returnValue;
 }
 /// <summary>
 /// 转发给别人看
 /// </summary>
 /// <param name="contactId">内部联络单主键</param>
 /// <param name="receiverIds">送给</param>
 /// <returns>影响行数</returns>
 public int AddReceivers(string contactId, string[] receiverIds)
 {
     int returnValue = 0;
     BaseUserManager userManager = new BaseUserManager(DbHelper, UserInfo);
     BaseUserEntity useEntity = null;
     for (int i = 0; i < receiverIds.Length; i++)
     {
         if (!this.Exists(new KeyValuePair<string, object>(BaseContactDetailsEntity.FieldContactId, contactId)
             , new KeyValuePair<string, object>(BaseContactDetailsEntity.FieldReceiverId, receiverIds[i])))
         {
             useEntity = userManager.GetEntity(receiverIds[i]);
             // 是有效的用户,而且是未必删除的用户才发邮件
             if (useEntity.Enabled == 1 && useEntity.DeletionStateCode == 0)
             {
                 this.AddReceiver(useEntity, contactId, receiverIds[i]);
                 returnValue++;
             }
         }
     }
     // 这里需要重新计算发送给了几个人,几个人已经阅读的功能
     this.SetReadState(contactId);
     return returnValue;
 }
示例#12
0
        /// <summary>
        /// 单个删除
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>影响行数</returns>
        public int Delete(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #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);
                    returnValue = userManager.Delete(id);
                    // 用户已经被删除的员工的UserId设置为Null,说白了,是需要整理数据
                    userManager.CheckUserStaff();
                    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;
        }
示例#13
0
        /// <summary>
        /// 用户名是否重复
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="parameters">字段名,字段值</param>
        /// <returns>已存在</returns>
        public bool Exists(BaseUserInfo userInfo, List<KeyValuePair<string, object>> parameters)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            bool returnValue = false;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserManager userManager = new BaseUserManager(dbHelper);
                    returnValue = userManager.Exists(parameters);
                }
                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[] GetPermissionIdsByUser(string userId)
        {
            string tableName = BaseUserRoleEntity.TableName;
            if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
            {
                tableName = BaseSystemInfo.SystemCode + "UserRole";
            }

            string sqlQuery =
                            // 用户的操作权限
                               " SELECT " + BasePermissionEntity.FieldPermissionItemId
                             + "   FROM " + this.CurrentTableName
                             + "  WHERE (" + BasePermissionEntity.FieldResourceCategory + " = '" + BaseUserEntity.TableName + "') "
                             + "        AND (" + BasePermissionEntity.FieldEnabled + " = 1) "
                             + "        AND (" + BasePermissionEntity.FieldResourceId + " = '" + userId + "')"

                            + " UNION "

                            // 角色的操作权限
                            + " SELECT " + BasePermissionEntity.FieldPermissionItemId
                            + "   FROM " + this.CurrentTableName
                            + "  WHERE " + "(" + BasePermissionEntity.FieldResourceCategory + " = '" + BaseRoleEntity.TableName + "') "
                            + "        AND (" + BasePermissionEntity.FieldEnabled + " = 1) "
                            + "        AND (" + BasePermissionEntity.FieldResourceId + " IN ( "
                                                + " SELECT " + BaseUserRoleEntity.FieldRoleId
                                                + "   FROM " + tableName
                                                + "  WHERE " + BaseUserRoleEntity.FieldUserId + " = '" + userId + "' "
                                                + "        AND " + BaseUserRoleEntity.FieldEnabled + " = 1"
                                                + "  UNION "
                                                + " SELECT " + BaseUserEntity.FieldRoleId
                                                + "   FROM " + BaseUserEntity.TableName
                                                + "  WHERE " + BaseUserEntity.FieldId + " = '" + userId + "'"
                                                + ")) ";

            DataTable dataTable = DbHelper.Fill(sqlQuery);
            string[] permissionItemIds = BaseBusinessLogic.FieldToArray(dataTable, BasePermissionEntity.FieldPermissionItemId);

            // 按部门获取权限项
            if (BaseSystemInfo.UseOrganizePermission)
            {
                sqlQuery = string.Empty;
                BaseUserEntity userEntity = new BaseUserManager(this.DbHelper).GetEntity(userId);
                sqlQuery = " SELECT "+BasePermissionEntity.FieldPermissionItemId
                           + "   FROM " + this.CurrentTableName
                           + "  WHERE (" + this.CurrentTableName + ".ResourceCategory = '" +
                           BaseOrganizeEntity.TableName + "') "
                           + "        AND (ResourceId = '" + userEntity.CompanyId + "' OR "
                           + "              ResourceId = '" + userEntity.DepartmentId + "' OR "
                           + "              ResourceId = '" + userEntity.SubCompanyId + "' OR"
                           + "              ResourceId = '" + userEntity.WorkgroupId + "') "
                           + "        AND (Enabled = 1) "
                           + "        AND (DeletionStateCode = 0)";
                dataTable = DbHelper.Fill(sqlQuery);
                string[] permissionItemIdsByOrganize = BaseBusinessLogic.FieldToArray(dataTable,
                                                                                BasePermissionEntity.FieldPermissionItemId);
                permissionItemIds = StringUtil.Concat(permissionItemIds, permissionItemIdsByOrganize);
            }
            return permissionItemIds;
        }
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (this.CheckInput())
            {
                BaseUserManager userManager = new BaseUserManager(this.UserInfo);
                DataTable dtUser = userManager.GetDataTable(DbTypes.Access,this.SelectedIds);

                BaseUserEntity userEntity = null;
                foreach (DataRow dataRow in dtUser.Rows)
                {
                    userEntity = new BaseUserEntity(dataRow);
                    userEntity.CompanyId = this.ucCompany.SelectedId;
                    userEntity.CompanyName = this.ucCompany.SelectedFullName;
                    userEntity.SubCompanyId = this.ucSubCompany.SelectedId;
                    userEntity.SubCompanyName = this.ucSubCompany.SelectedFullName;
                    userEntity.DepartmentId = this.ucDepartment.SelectedId;
                    userEntity.DepartmentName = this.ucDepartment.SelectedFullName;
                    userEntity.WorkgroupId = this.ucWorkgroup.SelectedId;
                    userEntity.WorkgroupName = this.ucWorkgroup.SelectedFullName;
                    userManager.Update(userEntity);
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
示例#16
0
        /// <summary>
        /// 获取等审核信息
        /// </summary>
        /// <param name="userId">用户主键</param>
        /// <param name="categoryCode">分类代码</param>      
        /// <param name="searchValue">查询字符串</param>
        /// <param name="showAuditReject">显示退回的</param>
        /// <returns>数据表</returns>
        public DataTable GetWaitForAudit(string userId = null, string categoryCode = null, string categorybillFullName = null, string searchValue = null, bool showAuditReject = true)
        {
            if (string.IsNullOrEmpty(userId))
            {
                userId = this.UserInfo.Id;
            }
            string sqlQuery = " SELECT * "
                            + "   FROM " + BaseWorkFlowCurrentEntity.TableName
                // 未被删除的,有效的数据,还没能审核结束的
                            + "  WHERE (" + BaseWorkFlowCurrentEntity.FieldDeletionStateCode + " = 0) "
                // Enabled 0 表示,审核还没结束
                            + "    AND (" + BaseWorkFlowCurrentEntity.FieldEnabled + " = 0) ";
            if (!showAuditReject)
            {
                sqlQuery += "    AND (" + BaseWorkFlowCurrentEntity.FieldAuditStatus + " != 'AuditReject') ";
            }
            if (!string.IsNullOrEmpty(userId))
            {
                // 待审核的工作流(指向用户的)

                switch (BaseSystemInfo.UserCenterDbType)
                {
                    case DbTypes.Access:
                        sqlQuery += "    AND (" + BaseWorkFlowCurrentEntity.FieldToUserId + "= '" + userId + "' ";
                        break;
                    default:
                        sqlQuery += "    AND (" + BaseWorkFlowCurrentEntity.FieldToUserId + "=" + userId + " ";
                        break;
                }

                //(指向角色的)
                BaseUserManager userManager = new BaseUserManager(this.UserInfo);
                string[] roleIds = userManager.GetAllRoleIds(userId);
                if (roleIds != null && roleIds.Length > 0)
                {
                    sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldToRoleId + " IN (" + StringUtil.ArrayToList(roleIds) + ")";
                }
                //(指向部门的)
                string[] organizeIds = userManager.GetAllOrganizeIds(userId);
                if (organizeIds != null && organizeIds.Length > 0)
                {
                    sqlQuery += " OR (" + BaseWorkFlowCurrentEntity.FieldToUserId + " IS NULL AND + " + BaseWorkFlowCurrentEntity.FieldToDepartmentId + " IN (" + StringUtil.ArrayToList(organizeIds) + "))";
                }
                sqlQuery += " ) ";
            }
            if (!string.IsNullOrEmpty(categoryCode))
            {
                BaseWorkFlowBillTemplateManager templateManager = new BaseWorkFlowBillTemplateManager(this.DbHelper, this.UserInfo);
                DataTable dataTable = templateManager.Search(string.Empty, categoryCode, string.Empty, null, false);
                string categoryCodes = BaseBusinessLogic.FieldToList(dataTable, BaseWorkFlowBillTemplateEntity.FieldCode);
                if (!string.IsNullOrEmpty(categoryCodes))
                {
                    sqlQuery += " AND (BaseWorkFlowCurrent.CategoryCode IN (" + categoryCodes + ")) ";
                }
            }
            if (!string.IsNullOrEmpty(categorybillFullName))
            {
                sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.TableName + "." + BaseWorkFlowCurrentEntity.FieldCategoryFullName + " ='" + categorybillFullName + "') ";
            }

            List<IDbDataParameter> dbParameters = new List<IDbDataParameter>();
            if (!String.IsNullOrEmpty(searchValue))
            {
                searchValue = searchValue.Trim();
                sqlQuery += " AND (" + BaseWorkFlowCurrentEntity.FieldObjectFullName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldObjectFullName);
                sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldAuditUserRealName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldAuditUserRealName);
                sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldAuditIdea + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldAuditIdea);
                sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldAuditStatusName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldAuditStatusName);
                sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldToDepartmentName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldToDepartmentName);
                sqlQuery += " OR " + BaseWorkFlowCurrentEntity.FieldToUserRealName + " LIKE " + DbHelper.GetParameter(BaseWorkFlowCurrentEntity.FieldToUserRealName) + ")";
                if (searchValue.IndexOf("%") < 0)
                {
                    searchValue = "%" + searchValue + "%";
                }
                dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldObjectFullName, searchValue));
                dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldAuditUserRealName, searchValue));
                dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldAuditIdea, searchValue));
                dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldAuditStatusName, searchValue));
                dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldToDepartmentName, searchValue));
                dbParameters.Add(DbHelper.MakeParameter(BaseWorkFlowCurrentEntity.FieldToUserRealName, searchValue));
            }
            // 排序字段
            sqlQuery += " ORDER BY " + BaseWorkFlowCurrentEntity.FieldSendDate;
            return DbHelper.Fill(sqlQuery, dbParameters.ToArray());
        }
        /// <summary>
        /// 是否有相应的权限
        /// </summary>
        /// <param name="userId">用户主键</param>
        /// <param name="permissionItemCode">权限编号</param>
        /// <param name="permissionItemName">权限名称</param>
        /// <returns>是否有权限</returns>
        public bool CheckPermissionByUser(string userId, string permissionItemCode, string permissionItemName = null)
        {
            // 若不存在就需要自动能增加一个操作权限项
            string tableName = BasePermissionItemEntity.TableName;
            if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
            {
                tableName = BaseSystemInfo.SystemCode + "PermissionItem";
            }
            BasePermissionItemManager permissionItemManager = new BasePermissionItemManager(DbHelper, UserInfo, tableName);
            string permissionItemId = permissionItemManager.GetIdByAdd(permissionItemCode, permissionItemName);
            BasePermissionItemEntity permissionItemEntity = permissionItemManager.GetEntity(permissionItemId);

            // 先判断用户类别
            if (UserInfo.IsAdministrator)
            {
                return true;
            }

            // 没有找到相应的权限
            if (String.IsNullOrEmpty(permissionItemId))
            {
                return false;
            }

            // 这里需要判断,是系统权限?
            bool returnValue = false;
            BaseUserManager userManager = new BaseUserManager(this.DbHelper, this.UserInfo);
            if (!string.IsNullOrEmpty(permissionItemEntity.CategoryCode) && permissionItemEntity.CategoryCode.Equals("System"))
            {
                // 用户管理员
                returnValue = userManager.IsInRoleByCode(userId, "UserAdmin");
                if (returnValue)
                {
                    return returnValue;
                }
            }

            // 这里需要判断,是业务权限?
            if (!string.IsNullOrEmpty(permissionItemEntity.CategoryCode) && permissionItemEntity.CategoryCode.Equals("Application"))
            {
                returnValue = userManager.IsInRoleByCode(userId, "Admin");
                if (returnValue)
                {
                    return returnValue;
                }
            }

            // 判断用户权限
            if (this.CheckUserPermission(userId, permissionItemId))
            {
                return true;
            }
            // 判断用户角色权限
            if (this.CheckUserRolePermission(userId, permissionItemId))
            {
                return true;
            }

            // 判断用户组织机构权限,这里有开关是为了提高性能用的,
            // 下面的函数接着还可以提高性能,可以进行一次判断就可以了,其实不用执行4次判断,浪费I/O,浪费性能。
            if (BaseSystemInfo.UseOrganizePermission)
            {
                if (this.CheckUserOrganizePermission(userId, permissionItemId, this.UserInfo.WorkgroupId))
                {
                    return true;
                }
                else if (this.CheckUserOrganizePermission(userId, permissionItemId, this.UserInfo.DepartmentId))
                {
                    return true;
                }
                else if (this.CheckUserOrganizePermission(userId, permissionItemId, this.UserInfo.SubCompanyId))
                {
                    return true;
                }
                else if (this.CheckUserOrganizePermission(userId, permissionItemId, this.UserInfo.CompanyId))
                {
                    return true;
                }
            }

            return false;
        }
示例#18
0
        /// <summary>
        /// 更新用户
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <param name="userEntity">用户实体</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>影响行数</returns>
        public int UpdateUser(BaseUserInfo userInfo, BaseUserEntity userEntity, 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);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    // 调用方法,并且返回运行结果
                    returnValue = userManager.Update(userEntity, out statusCode);
                    statusMessage = userManager.GetStateMessage(statusCode);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.UserService_UpdateUser, 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>
 /// <returns>离线人数</returns>
 public int ServerCheckOnLine()
 {
     int returnValue = 0;
     using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
     {
         try
         {
             dbHelper.Open(UserCenterDbConnection);
             BaseUserManager userManager = new BaseUserManager(dbHelper);
             returnValue = userManager.CheckOnLine();
         }
         catch (Exception ex)
         {
             LogUtil.WriteException(ex);
             throw ex;
         }
         finally
         {
             dbHelper.Close();
         }
     }
     return returnValue;
 }
示例#20
0
        /// <summary>
        /// 获取用户实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public BaseUserEntity GetEntity(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            BaseUserEntity userEntity = null;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    userEntity = userManager.GetEntity(id);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.UserService_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 userEntity;
        }
示例#21
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);
                    // 考虑主键是数值类型的,支持Access
                    returnValue = userManager.SetDeleted(ids, 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;
        }
示例#22
0
        /// <summary>
        /// 设置用户密码
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">被设置的员工主键</param>
        /// <param name="password">新密码</param>
        /// <param name="returnStatusCode">返回状态码</param>
        /// <param name="returnStatusMessage">返回状消息</param>
        /// <returns>影响行数</returns>
        public int SetPassword(BaseUserInfo userInfo, string[] userIds, string password, out string returnStatusCode, out string returnStatusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            returnStatusCode = string.Empty;
            returnStatusMessage = string.Empty;
            int returnValue = 0;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.LogOnService_SetPassword, MethodBase.GetCurrentMethod());
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    returnValue = userManager.BatchSetPassword(userIds, password);
                    returnStatusCode = userManager.ReturnStatusCode;
                    // 获得状态消息
                    returnStatusMessage = userManager.GetStateMessage(returnStatusCode);
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return returnValue;
        }
示例#23
0
        /// <summary>
        /// 激活用户
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="openId">唯一识别码</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状消息</param>
        /// <returns>用户实体</returns>
        public BaseUserInfo AccountActivation(BaseUserInfo userInfo, string openId, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            BaseUserInfo returnUserInfo = null;
            statusCode = string.Empty;
            statusMessage = string.Empty;

            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    // 先侦测是否在线
                    userManager.CheckOnLine();
                    // 再进行登录
                    returnUserInfo = userManager.AccountActivation(openId, out statusCode);
                    statusMessage = userManager.GetStateMessage(statusCode);
                    // 登录时会自动记录进行日志记录,所以不需要进行重复日志记录
                    // 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 returnUserInfo;
        }
 public string[] GetUserIds(string[] organizeIds, string[] roleIds)
 {
     // 要注意不能重复发信息,只能发一次。
     string[] companyUsers = null; // 按公司查找用户
     string[] departmentUsers = null; // 按部门查找用户
     string[] workgroupUsers = null; // 按工作组查找用户
     if (organizeIds != null)
     {
         // 这里获得的是用户主键,不是员工主键
         companyUsers = this.GetProperties(BaseUserEntity.FieldCompanyId, organizeIds, BaseUserEntity.FieldId);
         departmentUsers = this.GetProperties(BaseUserEntity.FieldDepartmentId, organizeIds, BaseUserEntity.FieldId);
         workgroupUsers = this.GetProperties(BaseUserEntity.FieldWorkgroupId, organizeIds, BaseUserEntity.FieldId);
     }
     string[] roleUsers = null;
     if (roleIds != null)
     {
         BaseUserManager userManager = new BaseUserManager(DbHelper);
         roleUsers = userManager.GetUserIds(roleIds);
     }
     string[] userIds = StringUtil.Concat(companyUsers, departmentUsers, workgroupUsers, roleUsers);
     return userIds;
 }
示例#25
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;
        }
示例#26
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;
        }
示例#27
0
        /// <summary>
        /// 查询用户
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="search">查询</param>
        /// <param name="auditStates">有效</param>
        /// <param name="roleIds">用户角色</param>
        /// <returns>数据表</returns>
        public DataTable Search(BaseUserInfo userInfo, string searchValue, string auditStates, string[] roleIds)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            DataTable dataTable = new DataTable(BaseUserEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    dataTable = userManager.Search(searchValue, roleIds, null, auditStates);
                    dataTable.TableName = BaseUserEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.UserService_Search, 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;
        }
示例#28
0
        /// <summary>
        /// 用户是否在某个组织架构里的判断
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <param name="organizeName">部门名称</param>
        /// <returns>存在</returns>
        public bool UserIsInOrganize(BaseUserInfo userInfo, string userId, string organizeName)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            bool returnValue = false;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    returnValue = userManager.IsInOrganize(userId, organizeName);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.UserService_UserInRole, 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;
        }
示例#29
0
        /// <summary>
        /// 设置用户审核状态
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <param name="auditStates">审核状态</param>
        /// <returns>影响行数</returns>
        public int SetUserAuditStates(BaseUserInfo userInfo, string[] ids, AuditStatus auditStates)
        {
            // 写入调试信息
            #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);
                    returnValue = userManager.SetProperty(ids, new KeyValuePair<string, object>(BaseUserEntity.FieldAuditStatus, auditStates.ToString()));
                    // 被审核通过
                    if (auditStates == AuditStatus.AuditPass)
                    {
                        returnValue = userManager.SetProperty(ids, new KeyValuePair<string, object>(BaseUserEntity.FieldEnabled, 1));
                        // returnValue = userManager.SetProperty(ids, BaseUserEntity.FieldAuditStatus, StatusCode.UserIsActivate.ToString());
                    }
                    // 被退回
                    if (auditStates == AuditStatus.AuditReject)
                    {
                        returnValue = userManager.SetProperty(ids, new KeyValuePair<string, object>(BaseUserEntity.FieldEnabled, 0));
                        returnValue = userManager.SetProperty(ids, new KeyValuePair<string, object>(BaseUserEntity.FieldAuditStatus, StatusCode.UserLocked.ToString()));
                    }
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.UserService_SetUserAuditStates, 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;
        }
        /// <summary>
        /// 下个流程发送给谁
        /// </summary>
        /// <param name="id">当前主键</param>
        /// <returns>影响行数</returns>
        private int StepAuditTransmit(string currentId, string workFlowCategory, string sendToId, string auditIdea)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);

            // 1.记录当前的审核时间、审核人信息
            workFlowCurrentEntity.ToDepartmentId = this.UserInfo.DepartmentId;
            workFlowCurrentEntity.ToDepartmentName = this.UserInfo.DepartmentName;
            workFlowCurrentEntity.ToUserId = this.UserInfo.Id;
            workFlowCurrentEntity.ToUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditStatus = AuditStatus.Transmit.ToString();
            workFlowCurrentEntity.AuditStatusName = AuditStatus.Transmit.ToDescription();

            // 2.记录审核日志
            this.AddHistory(workFlowCurrentEntity);

            // 3.上一个审核结束了,新的审核又开始了,更新待审核情况
            workFlowCurrentEntity.AuditUserId = this.UserInfo.Id;
            workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditDate = DateTime.Now;
            workFlowCurrentEntity.AuditIdea = auditIdea;

            // 是否提交给部门审批
            if (workFlowCategory.Equals("ByOrganize"))
            {
                BaseOrganizeManager organizeManager = new BaseOrganizeManager(UserInfo);
                BaseOrganizeEntity organizeEntity = organizeManager.GetEntity(sendToId);
                // 设置审批部门主键
                workFlowCurrentEntity.ToDepartmentId = sendToId;
                // 设置审批部门名称
                workFlowCurrentEntity.ToDepartmentName = organizeEntity.FullName;
            }
            // 是否提交给角色审批
            if (workFlowCategory.Equals("ByRole"))
            {
                BaseRoleManager roleManger = new BaseRoleManager(this.UserInfo);
                BaseRoleEntity roleEntity = roleManger.GetEntity(sendToId);
                // 设置审批角色主键
                workFlowCurrentEntity.ToRoleId = sendToId;
                // 设置审批角色名称
                workFlowCurrentEntity.ToRoleRealName = roleEntity.RealName;
            }
            // 是否提交给用户审批
            if (workFlowCategory.Equals("ByUser"))
            {
                BaseUserManager userManager = new BaseUserManager(UserInfo);
                BaseUserEntity userEntity = userManager.GetEntity(sendToId);
                // 设置审批用户主键
                workFlowCurrentEntity.ToUserId = sendToId;
                // 设置审批用户名称
                workFlowCurrentEntity.ToUserRealName = userEntity.RealName;
                // TODO 用户的部门信息需要处理
                if (!string.IsNullOrEmpty(userEntity.DepartmentId))
                {
                    BaseOrganizeManager organizeManager = new BaseOrganizeManager(UserInfo);
                    BaseOrganizeEntity organizeEntity = organizeManager.GetEntity(userEntity.DepartmentId);
                    workFlowCurrentEntity.ToDepartmentId = userEntity.DepartmentId;
                    workFlowCurrentEntity.ToDepartmentName = organizeEntity.FullName;
                }
            }
            workFlowCurrentEntity.AuditStatus = AuditStatus.WaitForAudit.ToString();
            workFlowCurrentEntity.AuditStatusName = AuditStatus.WaitForAudit.ToDescription();
            // 当前审核人的信息写入当前工作流
            workFlowCurrentEntity.Enabled = 0;
            workFlowCurrentEntity.DeletionStateCode = 0;
            return this.UpdateEntity(workFlowCurrentEntity);
        }
示例#31
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);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    if (containChildren)
                    {
                        dataTable = userManager.GetChildrenUsers(departmentId);
                    }
                    else
                    {
                        dataTable = userManager.GetDataTableByDepartment(departmentId);
                    }
                    dataTable.TableName = BaseUserEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.UserService_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;
        }
示例#32
0
        /// <summary>
        /// 用户现在
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="onLineState">用户在线状态</param>
        public void OnLine(BaseUserInfo userInfo, int onLineState = 1)
        {
            // 写入调试信息
            #if (DEBUG)
                // int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    // BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.LogOnService_OnLine, MethodBase.GetCurrentMethod());
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    userManager.OnLine(userInfo.Id, onLineState);
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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