Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="dbHelper">数据库连接</param>
        /// <param name="userInfo">用户信息</param>
        /// <param name="entity">用户实体</param>
        /// <param name="userLogonEntity">用户登录实体</param>
        /// <param name="userContactEntity">用户联系方式</param>
        /// <param name="status">状态</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        public string CreateUser(IDbHelper dbHelper, BaseUserInfo userInfo, BaseUserEntity entity, BaseUserLogonEntity userLogonEntity, BaseUserContactEntity userContactEntity, out Status status, out string statusMessage)
        {
            var result = string.Empty;

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

            var userManager = new BaseUserManager(dbHelper, userInfo);
            result        = userManager.AddUser(entity, userLogonEntity);
            status        = userManager.Status;
            statusMessage = userManager.GetStateMessage();

            // 20140219 JiRiGaLa 添加成功的用户才增加联系方式
            if (!string.IsNullOrEmpty(result) && status == Status.OkAdd && userContactEntity != null)
            {
                // 添加联系方式
                userContactEntity.UserId = int.Parse(result);
                var userContactManager = new BaseUserContactManager(dbHelper, userInfo);
                userContactEntity.CompanyId = entity.CompanyId;
                userContactManager.Add(userContactEntity);
            }

            // 自己不用给自己发提示信息,这个提示信息是为了提高工作效率的,还是需要审核通过的,否则垃圾信息太多了
            if (entity.Enabled == 0 && status == Status.OkAdd)
            {
                // 不是系统管理员添加
                if (!BaseUserManager.IsAdministrator(userInfo.Id))
                {
                    // 给超级管理员群组发信息
                    var roleManager = new BaseRoleManager(dbHelper, userInfo);
                    var roleIds     = roleManager.GetIds(new KeyValuePair <string, object>(BaseRoleEntity.FieldCode, "Administrators"));
                    var userIds     = userManager.GetIds(new KeyValuePair <string, object>(BaseUserEntity.FieldCode, "Administrator"));
                    // 发送请求审核的信息
                    //var messageEntity = new BaseMessageEntity
                    //{
                    //    FunctionCode = MessageFunction.WaitForAudit.ToString(),

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

                    //var messageManager = new BaseMessageManager(dbHelper, userInfo);
                    //messageManager.BatchSend(userIds, null, roleIds, messageEntity, false);
                }
            }

            return(result);
        }
Exemplo n.º 3
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);
        }