Example #1
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;
        }
 /// <summary>
 /// 发送即时通讯提醒
 /// </summary>
 /// <param name="id">主键</param>
 /// <param name="auditStatus">审核状态</param>
 /// <param name="auditIdea">审核意见</param>
 /// <param name="userId">发送给用户主键</param>
 /// <param name="roleId">发送给角色主键</param>
 /// <returns>影响行数</returns>
 public int SendRemindMessage(string id, AuditStatus auditStatus, string auditIdea, string[] userIds, string[] organizeIds, string[] roleIds)
 {
     int returnValue = 0;
     // 发送请求审核的信息
     BaseMessageEntity messageEntity = new BaseMessageEntity();
     messageEntity.Id = BaseBusinessLogic.NewGuid();
     // 这里是回调的类,用反射要回调的
     messageEntity.FunctionCode = this.GetType().ToString();
     messageEntity.ObjectId = id;
     // 这里是网页上的显示地址
     // messageEntity.Title = this.GetUrl(id);
     // messageEntity.Content = BaseBusinessLogic.GetAuditStatus(auditStatus) + ":" + this.GetEntity(id).Title + " 请查收"
     //    + Environment.NewLine
     //    + this.GetUrl(id)
     //    + auditIdea;
     messageEntity.IsNew = 1;
     messageEntity.ReadCount = 0;
     messageEntity.Enabled = 1;
     messageEntity.DeletionStateCode = 0;
     BaseMessageManager messageManager = new BaseMessageManager(this.UserInfo);
     returnValue = messageManager.BatchSend(userIds, organizeIds, roleIds, messageEntity, false);
     return returnValue;
 }
Example #3
0
        /// <summary>
        /// 广播消息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="message">消息内容</param>
        /// <returns>主键</returns>
        public int Broadcast(BaseUserInfo userInfo, string message)
        {
            // 写入调试信息
            #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[] receiverIds = null;
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    receiverIds = userManager.GetIds(new KeyValuePair<string, object>(BaseUserEntity.FieldEnabled, 1), new KeyValuePair<string, object>(BaseUserEntity.FieldDeletionStateCode, 0));
                    BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo);
                    BaseMessageEntity messageEntity = new BaseMessageEntity();
                    messageEntity.Id = BaseBusinessLogic.NewGuid();
                    messageEntity.FunctionCode = MessageFunction.Remind.ToString();
                    messageEntity.Contents = message;
                    messageEntity.IsNew = 1;
                    messageEntity.ReadCount = 0;
                    messageEntity.Enabled = 1;
                    messageEntity.DeletionStateCode = 0;
                    returnValue = messageManager.BatchSend(receiverIds, string.Empty, string.Empty, messageEntity, false);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.MessageService_BatchSend, 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;
        }
Example #4
0
        /// <summary>
        /// 批量发送站内信息
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="receiverIds">接受者主键数组</param>
        /// <param name="organizeIds">组织机构主键数组</param>
        /// <param name="roleIds">角色主键数组</param>
        /// <param name="messageEntity">消息内容</param>
        /// <returns>影响行数</returns>
        public int BatchSend(BaseUserInfo userInfo, string[] receiverIds, string[] organizeIds, string[] roleIds, BaseMessageEntity messageEntity)
        {
            // 写入调试信息
            #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);
                    BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo);
                    returnValue = messageManager.BatchSend(receiverIds, organizeIds, roleIds, messageEntity, true);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.MessageService_BatchSend, 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="workFlowCurrentEntity">当前审核流实体信息</param>
        /// <param name="auditStatus">审核状态</param>
        /// <param name="auditIdea">审核意见</param>
        /// <param name="userIds">发送给用户主键</param>
        /// <param name="roleIds">发送给角色主键</param>
        /// <returns>影响行数</returns>
        public virtual int SendRemindMessage(BaseWorkFlowCurrentEntity workFlowCurrentEntity, AuditStatus auditStatus, string[] userIds, string organizeId, string roleId)
        {
            // string currentId, string objectId, string objectFullName
            int returnValue = 0;
            // 不用给自己发消息了,消息多了也烦恼
            userIds = StringUtil.Remove(userIds, this.UserInfo.Id);
            // BaseUserEntity userEntity = userManager.GetEntity(userId);
            // 发送请求审核的信息
            BaseMessageEntity messageEntity = new BaseMessageEntity();
            messageEntity.Id = BaseBusinessLogic.NewGuid();
            // 这里是回调的类,用反射要回调的
            messageEntity.FunctionCode = MessageFunction.Remind.ToString();
            // messageEntity.FunctionCode = this.GetType().ToString();
            messageEntity.ObjectId = workFlowCurrentEntity.ObjectId;
            // 这里是网页上的显示地址
            // messageEntity.Title = this.GetUrl(id);
            string auditIdea = string.Empty;
            if (!string.IsNullOrEmpty(workFlowCurrentEntity.AuditIdea))
            {
                auditIdea = " 批示: " + workFlowCurrentEntity.AuditIdea;
            }
            // messageEntity.Contents = userEntity.DepartmentName + " " + userEntity.RealName
            messageEntity.Contents
                = workFlowCurrentEntity.CreateBy + " 发出审批申请: " + "<a title='点击这里,直接查看单据' target='_blank' href='" + this.GetUrl(workFlowCurrentEntity.Id) + "'>" + workFlowCurrentEntity.ObjectFullName + "</a> "
                + Environment.NewLine
                + this.UserInfo.RealName + " " + BaseBusinessLogic.GetAuditStatus(auditStatus) + " "
                + Environment.NewLine
                + auditIdea;

            messageEntity.Contents = "有单据" + BaseBusinessLogic.GetAuditStatus(auditStatus);
            messageEntity.IsNew = 1;
            messageEntity.ReadCount = 0;
            messageEntity.Enabled = 1;
            messageEntity.DeletionStateCode = 0;
            BaseMessageManager messageManager = new BaseMessageManager(this.UserInfo);
            returnValue = messageManager.BatchSend(userIds, organizeId, roleId, messageEntity, false);
            return returnValue;
        }