Esempio n. 1
0
        /// <summary>
        /// 获取成员信息
        /// </summary>
        /// <param name="PatientUserID"></param>
        /// <param name="PatientMemberID"></param>
        /// <returns></returns>
        public ResponseUserMemberDTO GetMemberInfo(string DoctorID, string UserID, string PatientMemberID)
        {
            if (Exists(a => a.DoctorID == DoctorID && a.MemberID == PatientMemberID))
            {
                BLL.User.Implements.UserMemberService service = new User.Implements.UserMemberService();

                var member = service.GetMemberInfo(PatientMemberID);

                if (member == null)
                {
                    //兼容药店端看诊,MemberID非当前用户下的Member
                    BLL.User.Implements.UserService ser = new User.Implements.UserService();
                    var user = ser.GetUserInfoByUserId(UserID);
                    if (user != null && user.UserType == EnumUserType.Drugstore)
                    {
                        return(service.GetMemberInfo(UserID, PatientMemberID));
                    }
                }
                return(member);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="user"></param>
        public ApiResult Login(RequestUserLoginDTO dto)
        {
            //检查账号和密码时长正确
            var user = CheckLogin(dto);

            //账号和密码正确
            if (user != null && !string.IsNullOrEmpty(user.UserID))
            {
                // 如果指定用户角色,则验证用户角色是否正确
                if (dto.UserRole.HasValue)
                {
                    UserService         roleService = new UserService();
                    List <EnumRoleType> roles       = roleService.GetUserRoles(user.UserID);
                    if (!roles.Exists(x => x == dto.UserRole.Value))
                    {
                        return(EnumApiStatus.BizUserLoginAccountOrPwdFail.ToApiResultForApiStatus());
                    }
                }

                //获取服务端票据
                UserLoginServerTicketDTO serverTicket = new UserLoginServerTicketDTO()
                {
                    OpenID = dto.OpenID,
                    UserID = user.UserID,
                };

                if (serverTicket != null)
                {
                    var clientTicket = new ResponseUserTicketReturnDTO()
                    {
                        Identifier = user.Identifier,
                        Mobile     = user.Mobile,
                        UserID     = serverTicket.UserID,
                        UserToken  = string.IsNullOrEmpty(dto.UserToken) ? Guid.NewGuid().ToString("N") : dto.UserToken,
                        UserCNName = user.UserCNName,
                        PhotoUrl   = user.PhotoUrl,
                    };

                    ApiSecurityService.SetUserTicket(serverTicket, clientTicket.UserToken);

                    using (XuHos.EventBus.MQChannel channel = new EventBus.MQChannel())
                    {
                        channel.BeginTransaction();

                        channel.Publish <XuHos.EventBus.Events.UserLoginedEvent>(new EventBus.Events.UserLoginedEvent()
                        {
                            UserID    = clientTicket.UserID,
                            LoginTime = DateTime.Now,
                            UserType  = clientTicket.UserType,
                        });

                        channel.Publish <XuHos.EventBus.Events.UserOperatorLogEvent>(new EventBus.Events.UserOperatorLogEvent()
                        {
                            UserID       = clientTicket.UserID,
                            OperatorTime = DateTime.Now,
                            UserType     = clientTicket.UserType,
                            OperatorType = EnumUserOperationType.Login,
                            OperatorName = "",
                            OrgID        = CurrentOperatorOrgID,
                            Remark       = "",
                            ModuleName   = ""
                        });

                        channel.Commit();
                    }


                    AddUserLoginLog(serverTicket, dto.UserLoginType, dto.Mobile);

                    return(clientTicket.ToApiResultForObject());
                }
                else
                {
                    return(EnumApiStatus.BizError.ToApiResultForApiStatus("LoginTicket Is Null"));
                }
            }
            else
            {
                return(EnumApiStatus.BizUserLoginAccountOrPwdFail.ToApiResultForApiStatus());

                #endregion
            }
        }