Exemplo n.º 1
0
        public BaseUserEntity GetObjectByOpenId(string openId)
        {
            BaseUserEntity userEntity = null;

            // 用户没有找到状态
            this.StatusCode    = Status.UserNotFound.ToString();
            this.StatusMessage = this.GetStateMessage(this.StatusCode);
            // 检查是否有效的合法的参数
            if (!String.IsNullOrEmpty(openId))
            {
                BaseUserLogOnManager userLogOnManager            = new BaseUserLogOnManager();
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BaseUserLogOnEntity.FieldOpenId, openId));
                string id = userLogOnManager.GetId(parameters);
                if (!string.IsNullOrEmpty(id))
                {
                    parameters = new List <KeyValuePair <string, object> >();
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldId, id));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, 0));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1));
                    var dt = this.GetDataTable(parameters);
                    if (dt.Rows.Count == 1)
                    {
                        userEntity = BaseEntity.Create <BaseUserEntity>(dt);
                    }
                }
            }

            return(userEntity);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 发送手机验证码
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="mobile">手机号码</param>
        /// <param name="system">系统</param>
        /// <returns>验证码</returns>
        /// <returns>发送是否正常</returns>
        public bool GetVerificationCode(BaseUserInfo userInfo, string mobile, string system = "中通中天核心系统", string channel = "3")
        {
            // 应用编号
            ApplicationCode = "ZhongTian";
            // 短信发送账户编号
            AccountCode = "ZhongTian";
            // 应用密码
            Password = "******";

            bool result = false;

            if (string.IsNullOrEmpty(system))
            {
                system = "中通中天核心系统";
            }
            // todo 需要增加一天只能收取几次验证码的限制,8个小时内最多只能发送3次验证码
            int sendVerificationCodeCount = GetSendVerificationCodeCount(mobile);

            if (sendVerificationCodeCount < 6)
            {
                // 产生随机验证码、数字的、六位长度
                int code = new Random().Next(100000, 999999);
                // 发送的手机短信
                string message   = "您在" + system + "手机验证码为:" + code.ToString();
                string returnMsg = string.Empty;
                result = SendMobile(userInfo, "Base", "VerificationCode", mobile, message, code.ToString(), true, false, channel, out returnMsg) > 0;
                if (result && userInfo != null)
                {
                    var userLogOnManager = new BaseUserLogOnManager(userInfo);
                    userLogOnManager.SetProperty(userInfo.Id, new KeyValuePair <string, object>(BaseUserLogOnEntity.FieldVerificationCode, code));
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 用户修改签名密码
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="oldPassword">原始密码</param>
        /// <param name="newPassword">新密码</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状消息</param>
        /// <returns>影响行数</returns>
        public int ChangeSignedPassword(BaseUserInfo userInfo, string oldPassword, string newPassword, out string statusCode, out string statusMessage)
        {
            var parameter = ServiceParameter.CreateWithMessage(userInfo
                                                               , MethodBase.GetCurrentMethod()
                                                               , this.serviceName
                                                               , AppMessage.LogOnService_ChangeSignedPassword);
            int    result        = 0;
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;

            ServiceUtil.ProcessUserCenterWriteDb(parameter, (dbHelper) =>
            {
                // 事务开始
                // dbHelper.BeginTransaction();
                var userManager = new BaseUserLogOnManager(dbHelper, userInfo);
                result          = userManager.ChangeSignedPassword(oldPassword, newPassword, out returnCode);
                // 获得状态消息
                returnMessage = userManager.GetStateMessage(returnCode);
                // 事务提交
                // dbHelper.CommitTransaction();
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(result);
        }
        /// <summary>
        /// 缓存预热,强制重新缓存
        /// </summary>
        /// <returns>影响行数</returns>
        public static int CachePreheating()
        {
            int result = 0;

            // 把所有的数据都缓存起来的代码
            BaseUserLogOnManager manager = new BaseUserLogOnManager();
            // 基础用户的登录信息重新缓存起来
            string commandText = "SELECT * FROM baseuserlogon t WHERE t.userpassword IS NOT NULL AND t.openidtimeout IS NOT NULL AND t.enabled = 1 AND t.openidtimeout - sysdate < 0.5";

            using (IDataReader dataReader = manager.ExecuteReader(commandText))
            {
                using (var redisClient = PooledRedisHelper.GetClient())
                {
                    while (dataReader.Read())
                    {
                        BaseUserLogOnEntity entity = BaseEntity.Create <BaseUserLogOnEntity>(dataReader, false);
# if Redis
                        Utilities.SetUserOpenId(redisClient, entity.Id, entity.OpenId);
#else
                        Utilities.SetUserOpenId(entity.Id, entity.OpenId);
# endif
                        result++;
                        System.Console.WriteLine(result.ToString() + " : User : " + entity.Id);
                    }
                    dataReader.Close();
                }
Exemplo n.º 5
0
        /// <summary>
        /// 服务器端检查在线状态
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <returns>离线人数</returns>
        public int ServerCheckOnLine(string taskId)
        {
            int result = 0;

            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(BaseSystemInfo.UserCenterWriteDbConnection);
                    var userLogOnManager = new BaseUserLogOnManager(dbHelper);
                    result = userLogOnManager.CheckOnLine();
                }
                catch (Exception ex)
                {
                    LogUtil.WriteException(ex);
                    throw;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 锁定用户
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <param name="userName">用户名</param>
        /// <returns>是否成功锁定</returns>
        public bool LockUser(string taskId, BaseUserInfo userInfo, string userName)
        {
            bool result = false;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                // BaseLogManager.Instance.Add(result, this.serviceName, AppMessage.LogOnService_LockUser, MethodBase.GetCurrentMethod());
                var userManager = new BaseUserManager(userInfo);
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldUserName, userName));
                parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1));
                parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, 0));
                BaseUserEntity userEntity = BaseEntity.Create <BaseUserEntity>(userManager.GetDataTable(parameters));
                // 判断是否为空的
                if (userEntity != null && !string.IsNullOrEmpty(userEntity.Id))
                {
                    // 被锁定15分钟,不允许15分钟内登录,这时间是按服务器的时间来的。
                    var userLogOnManager = new BaseUserLogOnManager();
                    BaseUserLogOnEntity userLogOnEntity = userLogOnManager.GetObject(userEntity.Id);
                    userLogOnEntity.LockStartDate       = DateTime.Now;
                    userLogOnEntity.LockEndDate         = DateTime.Now.AddMinutes(BaseSystemInfo.PasswordErrorLockCycle);
                    result = userLogOnManager.UpdateObject(userLogOnEntity) > 0;
                }
            });

            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 通过 openId 获取用户信息
        /// </summary>
        /// <param name="openId">唯一键</param>
        /// <returns>用户实体</returns>
        public static BaseUserEntity GetObjectByOpenIdByCache(string openId)
        {
            BaseUserEntity result = null;

            string key    = "OpenId";
            string userId = string.Empty;

            if (!string.IsNullOrWhiteSpace(openId))
            {
                key = key + openId;
# if Redis
                // 2015-12-14 吉日嘎拉 这里可以支持不走缓存的方式
                using (var redisClient = PooledRedisHelper.GetReadOnlyClient())
                {
                    userId = redisClient.Get <string>(key);

                    if (!string.IsNullOrWhiteSpace(userId))
                    {
                        result = GetObjectByCache(redisClient, userId);
                    }

                    if (result == null)
                    {
                        // 若没获取到用户?到数据库里查一次
                        BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
                        userId = userLogOnManager.GetIdByOpenId(openId);
                        if (!string.IsNullOrWhiteSpace(userId))
                        {
                            result = GetObjectByCache(redisClient, userId);
                        }
                    }
                }
#endif
            }
Exemplo n.º 8
0
        /// <summary>
        /// 获取在线用户列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetOnLineState(BaseUserInfo userInfo)
        {
            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var userLogOnManager = new BaseUserLogOnManager(dbHelper, userInfo);
                // 设置为在线状态
                userLogOnManager.OnLine(userInfo.Id);
                if (MessageService.LaseOnLineStateCheck == DateTime.MinValue)
                {
                }
                else
                {
                    // 2008.01.23 JiRiGaLa 修正错误
                    TimeSpan timeSpan = DateTime.Now - MessageService.LaseOnLineStateCheck;
                    if ((timeSpan.Minutes * 60 + timeSpan.Seconds) >= BaseSystemInfo.OnLineCheck)
                    {
                    }
                }
                if (OnLineStateDT == null)
                {
                    // 检查用户在线状态(服务器专用)
                    userLogOnManager.CheckOnLine();
                    // 获取在线状态列表
                    OnLineStateDT                       = userLogOnManager.GetOnLineStateDT();
                    OnLineStateDT.TableName             = BaseUserEntity.TableName;
                    MessageService.LaseOnLineStateCheck = DateTime.Now;
                }
            });

            return(InnerOrganizeDT);
        }
        public static bool CheckIPAddressByCache(string userId, string ipAddress, bool autoAdd = false)
        {
            // 判断用户是否限制ip访问,有的是不限制访问的
            BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
            BaseUserLogOnEntity  userLogOnEntity  = userLogOnManager.GetObject(userId);

            return(CheckIPAddressByCache(userLogOnEntity, ipAddress, autoAdd));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 离职处理
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns>影响行数</returns>
        public int Leave(BaseUserEntity userEntity, BaseUserLogOnEntity userLogOnEntity, string comment)
        {
            int result = 0;

            if (userEntity != null)
            {
                // 更新用户实体
                this.UpdateObject(userEntity);
            }

            // 更新登录信息
            if (userLogOnEntity != null)
            {
                BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager(this.UserInfo);
                userLogOnManager.UpdateObject(userLogOnEntity);
            }

            // 填写评论
            if (!string.IsNullOrWhiteSpace(comment))
            {
                SQLBuilder sqlBuilder = new SQLBuilder(BaseSystemInfo.ServerDbType);
                sqlBuilder.BeginInsert(BaseCommentEntity.TableName);
                sqlBuilder.SetValue(BaseCommentEntity.FieldId, System.Guid.NewGuid().ToString("N"));
                sqlBuilder.SetValue(BaseCommentEntity.FieldCategoryCode, BaseUserEntity.TableName);
                sqlBuilder.SetValue(BaseCommentEntity.FieldObjectId, userEntity.Id);
                sqlBuilder.SetValue(BaseCommentEntity.FieldContents, comment);
                sqlBuilder.SetValue(BaseCommentEntity.FieldWorked, 1);
                sqlBuilder.SetValue(BaseCommentEntity.FieldDepartmentId, userEntity.DepartmentId);
                sqlBuilder.SetValue(BaseCommentEntity.FieldDepartmentName, userEntity.DepartmentName);
                sqlBuilder.SetValue(BaseCommentEntity.FieldCreateUserId, this.UserInfo.Id);
                sqlBuilder.SetValue(BaseCommentEntity.FieldCreateBy, this.UserInfo.RealName);
                sqlBuilder.SetDBNow(BaseCommentEntity.FieldCreateOn);
                sqlBuilder.SetValue(BaseCommentEntity.FieldIPAddress, this.UserInfo.IPAddress);
                sqlBuilder.SetValue(BaseCommentEntity.FieldEnabled, 1);
                sqlBuilder.SetValue(BaseCommentEntity.FieldDeletionStateCode, 0);
                sqlBuilder.EndInsert();
            }

            // 2016-03-17 吉日嘎拉 停止吉信的号码
            if (userEntity != null && !string.IsNullOrEmpty(userEntity.NickName))
            {
                AfterLeaveStopIM(userEntity);
            }

            // 2016-03-17 吉日嘎拉 停止吉信的号码
            if (userEntity != null && !string.IsNullOrEmpty(userEntity.Id))
            {
                BaseUserContactEntity userContactEntity = BaseUserContactManager.GetObjectByCache(userEntity.Id);
                {
                    if (userContactEntity != null && !string.IsNullOrEmpty(userContactEntity.CompanyMail))
                    {
                        ChangeUserMailStatus(userContactEntity.CompanyMail, true);
                    }
                }
            }

            return(result);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 用户现在
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <param name="onLineState">用户在线状态</param>
        public void OnLine(string taskId, BaseUserInfo userInfo, int onLineState = 1)
        {
            var parameter = ServiceInfo.Create(taskId, userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
                userLogOnManager.OnLine(userInfo.Id, onLineState);
            });
        }
Exemplo n.º 12
0
        /// <summary>
        /// 重新设置数据
        /// </summary>
        /// <returns>影响行数</returns>
        public int Reset()
        {
            int result = 0;

            result += this.ResetData();
            BaseUserLogOnManager manager = new BaseUserLogOnManager(this.DbHelper, this.UserInfo);

            result += manager.ResetVisitInfo();
            return(result);
        }
        /// <summary>
        /// 检查用户的登录许可信息
        /// </summary>
        /// <param name="userId">用户主键</param>
        /// <returns>用户登录信息</returns>
        public UserLogOnResult CheckUser(string userId)
        {
            // 这个从缓存获取,效率高,一般不会有经常在修改的事情,缓存的时间很短才可以,否则读取脏数据了
            BaseUserEntity userEntity = this.GetObject(userId);

            // 获取登录状态表
            BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager(this.UserInfo, this.UserLogOnTable);
            BaseUserLogOnEntity  userLogOnEntity  = userLogOnManager.GetObject(userId);

            return(CheckUser(userEntity, userLogOnEntity));
        }
Exemplo n.º 14
0
        /// <summary>
        /// 用户离线(退出)
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        public void SignOut(string taskId, BaseUserInfo userInfo)
        {
            var parameter = ServiceInfo.Create(taskId, userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                // 2015-12-14 吉日嘎拉 用户的登录日志不用重复写日志
                BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
                userLogOnManager.SignOut(userInfo.OpenId);
            });
        }
Exemplo n.º 15
0
        /// <summary>
        /// 重置用户访问情况
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">日志主键</param>
        /// <returns>影响行数</returns>
        public int ResetVisitInfo(BaseUserInfo userInfo, string[] ids)
        {
            int result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDbWithTransaction(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseUserLogOnManager(dbHelper, userInfo);
                // 重置访问情况
                result = manager.ResetVisitInfo(ids);
            });
            return(result);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 获取新的OpenId
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <returns>OpenId</returns>
        public string CreateOpenId(string taskId, BaseUserInfo userInfo)
        {
            string result = string.Empty;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager(userInfo);
                result = userLogOnManager.CreateOpenId();
            });

            return(result);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 判断证码是否正确
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <param name="code">验证码</param>
        /// <returns>正确</returns>
        public bool ValidateVerificationCode(string taskId, BaseUserInfo userInfo, string code)
        {
            bool result = false;

            BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
            string verificationCode = userLogOnManager.GetProperty(userInfo.Id, BaseUserLogOnEntity.FieldVerificationCode);

            if (!string.IsNullOrEmpty(verificationCode))
            {
                result = verificationCode.Equals(code);
            }

            return(result);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 检查在线状态
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="onLineState">用户在线状态</param>
        /// <returns>离线人数</returns>
        public int CheckOnLine(BaseUserInfo userInfo, int onLineState)
        {
            int result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var userLogOnManager = new BaseUserLogOnManager(dbHelper);
                // 设置为在线状态
                userLogOnManager.OnLine(userInfo.Id, onLineState);
                result = userLogOnManager.CheckOnLine();
            });
            return(result);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">实体</param>
        /// <returns>影响行数</returns>
        public int Update(string taskId, BaseUserInfo userInfo, BaseUserLogOnEntity entity)
        {
            int result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                // 调用方法,并且返回运行结果
                BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
                result = userLogOnManager.Update(entity);
            });

            return(result);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 获取当前用户的公钥
        /// </summary>
        /// <param name="userId">用户主键</param>
        /// <returns>公钥</returns>
        public string GetPublicKey(BaseUserInfo userInfo, string userId)
        {
            var parameter = ServiceParameter.CreateWithMessage(userInfo
                                                               , MethodBase.GetCurrentMethod()
                                                               , this.serviceName
                                                               , AppMessage.LogOnService_GetPublicKey);
            string result = string.Empty;

            ServiceUtil.ProcessUserCenterReadDb(parameter, (dbHelper) =>
            {
                var userManager = new BaseUserLogOnManager(dbHelper, userInfo);
                result          = userManager.GetPublicKey(userId);
            });
            return(result);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 验证用户通讯密码
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="communicationPassword">通讯密码</param>
        /// <param name="ipAddress">IP地址</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状消息</param>
        /// <returns>是否正确</returns>
        public bool CommunicationPassword(BaseUserInfo userInfo, string communicationPassword)
        {
            var parameter = ServiceParameter.CreateWithMessage(userInfo
                                                               , MethodBase.GetCurrentMethod()
                                                               , this.serviceName
                                                               , AppMessage.LogOnService_CommunicationPassword);
            bool result = false;

            ServiceUtil.ProcessUserCenterReadDb(parameter, (dbHelper) =>
            {
                var userManager = new BaseUserLogOnManager(dbHelper, userInfo);
                result          = userManager.CommunicationPassword(communicationPassword);
            });
            return(result);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 设置用户主管的审核状态
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <param name="auditStates">审核状态</param>
        /// <returns>影响行数</returns>
        public int SetUserManagerAuditStates(BaseUserInfo userInfo, string[] ids, AuditStatus auditStates)
        {
            int result = 0;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                var userManager = new BaseUserManager(dbHelper, userInfo);
                // 被审核通过
                if (auditStates == AuditStatus.AuditPass)
                {
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldManagerAuditStatus, auditStates.ToString()));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldManagerAuditDate, DateTime.Now));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1));
                    result = userManager.SetProperty(ids, parameters);

                    // 锁定时间需要去掉
                    // 密码错误次数需要修改掉
                    var userLogOnManager = new BaseUserLogOnManager(dbHelper, userInfo);
                    parameters           = new List <KeyValuePair <string, object> >();
                    parameters.Add(new KeyValuePair <string, object>(BaseUserLogOnEntity.FieldLockStartDate, null));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserLogOnEntity.FieldLockEndDate, null));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserLogOnEntity.FieldUserOnLine, 0));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserLogOnEntity.FieldPasswordErrorCount, 0));
                    result = userLogOnManager.SetProperty(ids, parameters);

                    // var staffManager = new BaseStaffManager(dbHelper, result);
                    // string[] staffIds = staffManager.GetIds(BaseStaffEntity.FieldUserId, ids);
                    // staffManager.SetProperty(staffIds, new KeyValuePair<string, object>(BaseStaffEntity.FieldEnabled, 1));
                }
                // 被退回
                if (auditStates == AuditStatus.AuditReject)
                {
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldManagerAuditStatus, auditStates.ToString()));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldManagerAuditDate, DateTime.Now));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 0));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldAuditStatus, auditStates.ToString()));
                    result = userManager.SetProperty(ids, parameters);
                }
            });

            return(result);
        }
Exemplo n.º 23
0
        /// <summary>
        /// 获取消息状态
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="onLineState">用户在线状态</param>
        /// <param name="lastChekDate">最后检查日期</param>
        /// <returns>消息状态数组</returns>
        public string[] MessageChek(BaseUserInfo userInfo, int onLineState, string lastChekDate)
        {
            string[] result = null;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                // 设置为在线状态
                var userLogOnManager = new BaseUserLogOnManager(dbHelper, userInfo);
                userLogOnManager.OnLine(userInfo.Id, onLineState);
                // 读取信息状态
                var messageManager = new BaseMessageManager(userInfo);
                result             = messageManager.MessageChek();
            });

            return(result);
        }
Exemplo n.º 24
0
        /// <summary>
        /// 激活用户
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <param name="openId">唯一识别码</param>
        /// <returns>用户实体</returns>
        public BaseUserInfo AccountActivation(string taskId, BaseUserInfo userInfo, string openId)
        {
            BaseUserInfo result = null;

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var userLogOnManager = new BaseUserLogOnManager(dbHelper, userInfo);
                // 先侦测是否在线
                userLogOnManager.CheckOnLine();
                // 再进行登录
                var userManager = new BaseUserManager(dbHelper, userInfo);
                result          = userManager.AccountActivation(openId);
            });

            return(result);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 按唯一识别码登录
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <param name="openId">唯一识别码</param>
        /// <returns>用户实体</returns>
        public UserLogOnResult LogOnByOpenId(string taskId, BaseUserInfo userInfo, string openId)
        {
            UserLogOnResult result = new UserLogOnResult();

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

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                // 先侦测是否在线
                BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
                userLogOnManager.CheckOnLine();
                // 若是单点登录,那就不能判断ip地址,因为不是直接登录,是间接登录
                var userManager = new BaseUserManager(userInfo);
                result          = userManager.LogOnByOpenId(openId, string.Empty, string.Empty);
            });

            return(result);
        }
Exemplo n.º 26
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public BaseUserLogOnEntity GetObject(string taskId, BaseUserInfo userInfo, string id)
        {
            BaseUserLogOnEntity result = null;

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

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                var userManager = new BaseUserManager(dbHelper, userInfo);
                // 判断是否已经登录的用户?
                if (userManager.UserIsLogOn(userInfo))
                {
                    BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
                    result = userLogOnManager.GetObject(id);
                }
            });

            return(result);
        }
Exemplo n.º 27
0
        /// <summary>
        /// 设置用户通讯密码
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">被设置的员工主键</param>
        /// <param name="password">新密码</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状消息</param>
        /// <returns>影响行数</returns>
        public int SetCommunicationPassword(BaseUserInfo userInfo, string[] userIds, string password, out string statusCode, out string statusMessage)
        {
            var parameter = ServiceParameter.CreateWithLog(userInfo
                                                           , MethodBase.GetCurrentMethod());
            int    result        = 0;
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;

            ServiceUtil.ProcessUserCenterWriteDb(parameter, (dbHelper) =>
            {
                var userManager = new BaseUserLogOnManager(dbHelper, userInfo);
                result          = userManager.BatchSetCommunicationPassword(userIds, password, out returnCode);
                // 获得状态消息
                returnMessage = userManager.GetStateMessage(returnCode);
                BaseLogManager.Instance.Add(userInfo, this.serviceName, AppMessage.LogOnService_SetPassword, MethodBase.GetCurrentMethod());
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(result);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 创建数字证书签名
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="password">密码</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状消息</param>
        /// <returns>私钥</returns>
        public string CreateDigitalSignature(BaseUserInfo userInfo, string password, out string statusCode, out string statusMessage)
        {
            var parameter = ServiceParameter.CreateWithMessage(userInfo
                                                               , MethodBase.GetCurrentMethod()
                                                               , this.serviceName
                                                               , AppMessage.LogOnService_CreateDigitalSignature);
            string result        = string.Empty;
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;

            ServiceUtil.ProcessUserCenterWriteDb(parameter, (dbHelper) =>
            {
                var userManager = new BaseUserLogOnManager(dbHelper, userInfo);
                result          = userManager.CreateDigitalSignature(password, out returnCode);
                // 获得状态消息
                returnMessage = userManager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(result);
        }
Exemplo n.º 29
0
        public static BaseUserEntity GetObjectByOpenIdByCache(string openId)
        {
            BaseUserEntity result = null;

            string userId = string.Empty;

            if (!string.IsNullOrWhiteSpace(openId))
            {
                if (result == null)
                {
                    // 若没获取到用户?到数据库里查一次
                    BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
                    userId = userLogOnManager.GetIdByOpenId(openId);
                    if (!string.IsNullOrWhiteSpace(userId))
                    {
                        result = GetObjectByCache(userId);
                    }
                }
            }

            return(result);
        }
Exemplo n.º 30
0
        /// <summary>
        /// 获得用户列表
        /// </summary>
        /// <param name="taskId">任务标识</param>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetUserDT(string taskId, BaseUserInfo userInfo)
        {
            var result = new DataTable(BaseUserEntity.TableName);

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

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                // 检查用户在线状态(服务器专用)
                BaseUserLogOnManager userLogOnManager = new BaseUserLogOnManager();
                userLogOnManager.CheckOnLine();
                var userManager = new BaseUserManager(dbHelper, userInfo);
                // 获取允许登录列表
                List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1));
                parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, 0));
                result           = userManager.GetDataTable(parameters, BaseUserEntity.FieldSortCode);
                result.TableName = BaseUserEntity.TableName;
            });

            return(result);
        }