示例#1
0
        public ViewModel.UserInfoViewModel Login(string userName, string pwd, string sessionId, string indentifyCode)
        {

            UserInfoViewModel viewModel = new UserInfoViewModel();
            try
            {
                //检查验证码
                if (string.IsNullOrEmpty(indentifyCode))
                {
                    viewModel.Msg = "验证码不能为空";
                    viewModel.IndentifyCode = IndentifyCodeHelper.CreateIndentifyCode(sessionId, 4);
                }
                else if (!IndentifyCodeHelper.CheckIndentifyCode(sessionId, indentifyCode))
                {
                    viewModel.Msg = "验证码不正确";
                    viewModel.IndentifyCode = IndentifyCodeHelper.CreateIndentifyCode(sessionId, 4);
                }
                else
                {
                    viewModel = GetUserInfoViewModel(userName, pwd, sessionId, viewModel);
                }

            }
            catch (Exception ex)
            {
                viewModel.Msg = "发生未处理错误,请联系系统管理员";
                viewModel.IndentifyCode = IndentifyCodeHelper.CreateIndentifyCode(sessionId, 4);
                Logger.Error("[Login]" + ex.Message, ex);
            }

            return viewModel;
        }
 private EMUserGroup GetEMUserGroup(IdentityNoService identityNoServ, string tenantCode, UserInfoViewModel userInfoViewModel)
 {
     EMUserGroup group;
     group = new EMUserGroup()
     {
         IsAdminGroup = true,
         UserGroupID = identityNoServ.GetUserGroupID(),
         UserGroupName = "管理员",
         TenantCode = tenantCode,
     };
     return group;
 }
 private EMUser GetEMUser(IdentityNoService identityNoServ, UserInfoViewModel vm, EMTenant tenant, EMUserGroup group)
 {
     EMUser user;
     user = new EMUser()
     {
         UserCode = identityNoServ.GetUserSerialNo(),
         UserName = vm.UserName,
         UserGroupID = group.UserGroupID,
         Tenant = tenant,
         PassWord = vm.EncryptPwd,
         IsRegisterUser = true,
         Mobile = tenant.PhoneNumber,
         CreateTime = DateTime.Now                 
     };
     return user;
 }
示例#4
0
 private UserInfoViewModel ConvertToViewModel(EMUser user)
 {
     UserInfoViewModel viewModel = new UserInfoViewModel();
     viewModel.UserCode = user.UserCode;
     viewModel.UserName = user.UserName;
     viewModel.TenantCode = user.Tenant.TenantCode;//user.TenantCode;
     viewModel.TenantName = user.Tenant.TenantName;
     //viewModel.Password = user.PassWord;
     viewModel.IsRegisterUser = user.IsRegisterUser;
     return viewModel;
 }
示例#5
0
        public UserInfoViewModel Login(string userName, string pwd, string LastSelectTenantCode)
        {
            UserInfoViewModel viewModel = new UserInfoViewModel();
            try
            {
                EMUser user = _LoginUserDAL.GetLoginUser(userName, pwd);
               
                if (user != null)
                {
                    viewModel = ConvertToViewModel(user);

                    //租户类型
                    EMTenantService tenantService = new EMTenantService();
                    EMTenant tenant = user.Tenant;
                    if (tenant == null)
                    {
                        viewModel.Msg = "error|帐户异常,登录帐户对应的租户类型记录不存在,请与平台方联系";
                        return viewModel;
                    }
                    viewModel.TenantType = (int)tenant.TenantType;
                   // viewModel.OperatorLevel = tenant.OperatorLevel;
                    viewModel.OperatorLevel = string.IsNullOrEmpty(user.UserGroupID.ToString()) ? 0 : tenant.OperatorLevel;//0表示管理员
                    if (!string.IsNullOrEmpty(tenant.LogoUrl))
                    {
                        viewModel.TenantLogoImgURl = tenant.LogoUrl;
                    }

                    if (tenant.TenantType != EnumTenantType.PlatProvider)
                    {
                        EMTenant superTenant = tenantService.Select(tenant.SuperTenantID);
                        if (tenant.TenantType == EnumTenantType.EndCustomer)
                        {
                            viewModel.TenantLogoImgURl = superTenant.LogoUrl;
                        }

                        viewModel.SuperContactNumber = superTenant.PhoneNumber;
                        viewModel.SuperContactName = superTenant.ContactName;
                        viewModel.SuperTenantName = superTenant.TenantName;
                        //是否过期
                        if (tenant.TenantType == EnumTenantType.OperatingMerchant && tenant.ExpireTime.HasValue && DateTime.Now > tenant.ExpireTime.Value)
                        {
                            viewModel.Msg = "error|您的账号已过有效期,请与MOVO客服联系\n\r联系电话:" + superTenant.PhoneNumber;
                            return viewModel;
                        }
                        //是否冻结
                        else if (tenant.IsFreeze)
                        {
                            switch (tenant.TenantType)
                            {
                                case EnumTenantType.EndCustomer:
                                    viewModel.Msg = "error|您的账号已被冻结,请与您的设备服务提供商联系!\n\r联系电话:" + superTenant.PhoneNumber;
                                    break;
                                case EnumTenantType.OperatingMerchant:
                                    viewModel.Msg = "error|您的账号已被冻结,请与MOVO客服联系。\n\r联系电话:" + superTenant.PhoneNumber;
                                    break;
                            }
                            return viewModel;
                        }
                    }

                    switch (viewModel.TenantType)
                    {
                        case 1://平台商
                            EMTenant lastCustomer = null;
                            if (!string.IsNullOrEmpty(LastSelectTenantCode))
                            {
                                lastCustomer = tenantService.Select(LastSelectTenantCode);
                            }
                            if (lastCustomer == null)
                            {
                                lastCustomer = tenantService.SelectLastChildEndCustomer("");
                            }
                            if (lastCustomer != null)
                            {
                                EMUser lastUser = _LoginUserDAL.GetUserByUserCode(lastCustomer.RegisterUserCode);
                                if (lastUser != null)
                                {
                                    viewModel.SelectedUser = new ViewModel.WebModel.SelectedUserViewModel();
                                    viewModel.SelectedUser.UserCode = lastUser.UserCode;
                                    viewModel.SelectedUser.UserName = lastUser.UserName;
                                    viewModel.SelectedUser.TenantCode = lastCustomer.TenantCode;
                                    viewModel.SelectedUser.TenantName = lastCustomer.TenantName;
                                    if (!string.IsNullOrEmpty(lastCustomer.SuperTenantID))
                                    {
                                        EMTenant super = this.GetTenant(lastCustomer.SuperTenantID);
                                        if (super != null)
                                        {
                                            viewModel.SelectedUser.SuperTenantCode = super.TenantCode;
                                            viewModel.SelectedUser.SuperTenantName = super.TenantName;
                                        }
                                    }
                                }
                            }
                            break;
                        case 2://运营商

                            EMTenant lastCustomerForOperating = null;
                            if (!string.IsNullOrEmpty(LastSelectTenantCode))
                            {
                                lastCustomerForOperating = tenantService.Select(LastSelectTenantCode);
                            }
                            if (lastCustomerForOperating == null)
                            {
                                lastCustomerForOperating = tenantService.SelectLastChildEndCustomer(viewModel.TenantCode);
                            }


                             
                            if (lastCustomerForOperating != null)
                            {
                                EMUser lastUser = _LoginUserDAL.GetUserByUserCode(lastCustomerForOperating.RegisterUserCode);
                                if (lastUser != null)
                                {
                                    viewModel.SelectedUser = new ViewModel.WebModel.SelectedUserViewModel();
                                    viewModel.SelectedUser.UserCode = lastUser.UserCode;
                                    viewModel.SelectedUser.UserName = lastUser.UserName;
                                    viewModel.SelectedUser.TenantCode = lastCustomerForOperating.TenantCode;
                                    viewModel.SelectedUser.TenantName = lastCustomerForOperating.TenantName;
                                    viewModel.SelectedUser.SuperTenantCode = viewModel.TenantCode;
                                    viewModel.SelectedUser.SuperTenantName = viewModel.TenantName;
                                }
                            }

                            break;
                        case 3://终端客户
                            viewModel.SelectedUser = new ViewModel.WebModel.SelectedUserViewModel();
                            viewModel.SelectedUser.UserCode = viewModel.UserCode;
                            viewModel.SelectedUser.UserName = viewModel.UserName;
                            viewModel.SelectedUser.TenantCode = viewModel.TenantCode;
                            viewModel.SelectedUser.TenantName = viewModel.TenantName;
                            viewModel.SelectedUser.SuperTenantCode = user.Tenant.SuperTenantID;
                            viewModel.SelectedUser.SuperTenantContactName = user.Tenant.ContactName;
                            viewModel.SelectedUser.SuperTenantName = viewModel.SuperTenantName;
                            break;

                    }
                    if (string.IsNullOrEmpty(viewModel.TenantLogoImgURl))
                    {
                        viewModel.TenantLogoImgURl = UploadImageHelper.TenantImgUrl;
                    }

                    //获取地图类型
                    /*PositioningWCFService mapTypeService = new PositioningWCFService();
                    List<MapTypeViewModel> listMapType = mapTypeService.GetMapType();
                    viewModel.MapTypes = listMapType;*/

                    //令牌环
                    Ticket ticket = new Ticket() { UserCode = user.UserCode, UserName = user.UserName, Password = user.PassWord };
                    string token = EncryptUtil.Encrypt<Ticket>(ticket);
                    viewModel.Token = token;

#if !DEBUG
                        user.LastLoginTime = DateTime.Now;
                        new UserService().UpdLastLoginTime(user);
#endif

                }
                else
                {
                    viewModel.Msg = "error|用户名或密码错误";
                    //viewModel.IndentifyCode = IndentifyCodeHelper.CreateIndentifyCode(sessionId, 4);
                }
            }
            catch (Exception ex)
            {
                viewModel.Msg = "error|发生未处理错误,请联系系统管理员";
                //viewModel.IndentifyCode = IndentifyCodeHelper.CreateIndentifyCode(sessionId, 4);
                Logger.Error("[Login]" + ex.Message, ex);
            }
            return viewModel;
        }
示例#6
0
        /// <summary>
        /// 立即体验 登录
        /// </summary>
        /// <param name="ExperienceUserCode"></param>
        /// <returns></returns>
        public UserInfoViewModel ExperienceLogin(string ExperienceUserCode)
        {
            UserInfoViewModel viewModel = new UserInfoViewModel();
            try
            {
                UserService service = new UserService();
                //EMUser user = service.GetUserFullInfo(ExperienceUserCode);
                EMUser user = _LoginUserDAL.GetUserByUserCode(ExperienceUserCode);
                if (user != null)
                {
                    viewModel = ConvertToViewModel(user);

                    //租户类型
                    IEMTenantService tenantService = new EMTenantService();
                    EMTenant tenant = user.Tenant;
                    if (tenant == null)
                    {
                        viewModel.Msg = "error|体验帐户异常,体验帐户对应的租户类型记录不存在,请与平台方联系";
                        return viewModel;
                    }
                    viewModel.TenantType = (int)tenant.TenantType;
                    viewModel.OperatorLevel = tenant.OperatorLevel;
                    if (!string.IsNullOrEmpty(tenant.LogoUrl))
                    {
                        viewModel.TenantLogoImgURl = tenant.LogoUrl;
                    }

                    if (tenant.TenantType != EnumTenantType.PlatProvider)
                    {
                        EMTenant superTenant = tenantService.Select(tenant.SuperTenantID);
                        if (tenant.TenantType == EnumTenantType.EndCustomer)
                        {
                            viewModel.TenantLogoImgURl = superTenant.LogoUrl;
                        }

                        viewModel.SuperContactNumber = superTenant.PhoneNumber;
                        viewModel.SuperTenantName = superTenant.TenantName;
                        ////是否过期
                        //if (tenant.TenantType == EnumTenantType.OperatingMerchant && tenant.ExpireTime.HasValue && DateTime.Now > tenant.ExpireTime.Value)
                        //{
                        //    viewModel.Msg = "error|体验帐户已过有效期,请与MOVO客服联系\n\r联系电话:" + superTenant.PhoneNumber;
                        //    return viewModel;
                        //}
                        ////是否冻结
                        //else if (tenant.IsFreeze)
                        //{
                        //    switch (tenant.TenantType)
                        //    {
                        //        case EnumTenantType.EndCustomer:
                        //            viewModel.Msg = "error|您的账号已被冻结,请与您的设备服务提供商联系!\n\r联系电话:" + superTenant.PhoneNumber;
                        //            break;
                        //        case EnumTenantType.OperatingMerchant:
                        //            viewModel.Msg = "error|您的账号已被冻结,请与MOVO客服联系。\n\r联系电话:" + superTenant.PhoneNumber;
                        //            break;
                        //    }
                        //    return viewModel;
                        //}
                    }

                    switch (viewModel.TenantType)
                    {
                        case 1://平台商
                            EMTenant firstCustomer = tenantService.SelectLastChildEndCustomer("");
                            if (firstCustomer != null)
                            {
                                EMUser firstUser = service.GetUser(firstCustomer.RegisterUserCode);
                                if (firstUser != null)
                                {
                                    viewModel.SelectedUser = new ViewModel.WebModel.SelectedUserViewModel();
                                    viewModel.SelectedUser.UserCode = firstUser.UserCode;
                                    viewModel.SelectedUser.UserName = firstUser.UserName;
                                    viewModel.SelectedUser.TenantCode = firstCustomer.TenantCode;
                                    viewModel.SelectedUser.TenantName = firstCustomer.TenantName;
                                    if (!string.IsNullOrEmpty(firstCustomer.SuperTenantID))
                                    {
                                        EMTenant super = this.GetTenant(firstCustomer.SuperTenantID);
                                        if (super != null)
                                        {
                                            viewModel.SelectedUser.SuperTenantCode = super.TenantCode;
                                            viewModel.SelectedUser.SuperTenantName = super.TenantName;
                                        }
                                    }
                                }
                            }
                            break;
                        case 2://运营商
                            EMTenant firstChildEndCustomer = tenantService.SelectLastChildEndCustomer(viewModel.TenantCode);
                            if (firstChildEndCustomer != null)
                            {
                                EMUser firstUser = service.GetUser(firstChildEndCustomer.RegisterUserCode);
                                if (firstUser != null)
                                {
                                    viewModel.SelectedUser = new ViewModel.WebModel.SelectedUserViewModel();
                                    viewModel.SelectedUser.UserCode = firstUser.UserCode;
                                    viewModel.SelectedUser.UserName = firstUser.UserName;
                                    viewModel.SelectedUser.TenantCode = firstChildEndCustomer.TenantCode;
                                    viewModel.SelectedUser.TenantName = firstChildEndCustomer.TenantName;
                                    viewModel.SelectedUser.SuperTenantCode = viewModel.TenantCode;
                                    viewModel.SelectedUser.SuperTenantName = viewModel.TenantName;
                                }
                            }

                            break;
                        case 3://终端客户
                            viewModel.SelectedUser = new ViewModel.WebModel.SelectedUserViewModel();
                            viewModel.SelectedUser.UserCode = viewModel.UserCode;
                            viewModel.SelectedUser.UserName = viewModel.UserName;
                            viewModel.SelectedUser.TenantCode = viewModel.TenantCode;
                            viewModel.SelectedUser.TenantName = viewModel.TenantName;
                            viewModel.SelectedUser.SuperTenantCode = user.Tenant.SuperTenantID;
                            viewModel.SelectedUser.SuperTenantName = viewModel.SuperTenantName;
                            break;

                    }
                    if (string.IsNullOrEmpty(viewModel.TenantLogoImgURl))
                    {
                        viewModel.TenantLogoImgURl = UploadImageHelper.TenantImgUrl;
                    }

                    //获取地图类型
                    /*PositioningWCFService mapTypeService = new PositioningWCFService();
                    List<MapTypeViewModel> listMapType = mapTypeService.GetMapType();
                    viewModel.MapTypes = listMapType;*/

                    //令牌环
                    Ticket ticket = new Ticket() { UserCode = user.UserCode, UserName = user.UserName, Password = user.PassWord };
                    string token = EncryptUtil.Encrypt<Ticket>(ticket);
                    viewModel.Token = token;

#if !DEBUG
                        user.LastLoginTime = DateTime.Now;
                        service.Update(user);
#endif

                }
                else
                {
                    viewModel.Msg = "error|体验帐号不存在,请联系系统管理员";
                }
            }
            catch (Exception ex)
            {
                viewModel.Msg = "error|体验帐号登录时,发生未处理错误,请联系系统管理员";
                Logger.Error("[Login]" + ex.Message, ex);
            }
            viewModel.IsExperienceLogin = true;
            return viewModel;
        }
示例#7
0
        private UserInfoViewModel GetUserInfoViewModel(string userName, string pwd, string sessionId, UserInfoViewModel viewModel)
        {
            IUserService service = new UserService();
            EMUser user = service.GetUser(userName, pwd);
            if (user != null)
            {
                viewModel = ConvertToViewModel(user);

                //租户类型
                IEMTenantService tenantService = new EMTenantService();
                EMTenant tenant = tenantService.Select(user.TenantCode);
                viewModel.TenantType = (int)tenant.TenantType;
                viewModel.OperatorLevel = tenant.OperatorLevel;
                if (!string.IsNullOrEmpty(tenant.LogoUrl))
                    viewModel.TenantLogoImgURl = tenant.LogoUrl;
                else
                    viewModel.TenantLogoImgURl = UploadImageHelper.TenantImgUrl;
                if (tenant.TenantType != EnumTenantType.PlatProvider)
                {
                    EMTenant superTenant = tenantService.Select(tenant.SuperTenantID);

                    viewModel.SuperContactNumber = superTenant.PhoneNumber;
                    viewModel.SuperTenantName = superTenant.TenantName;
                    
                    if (tenant.TenantType == EnumTenantType.EndCustomer)
                    {
                            viewModel.TenantLogoImgURl = superTenant.LogoUrl;
                    }
                    if (tenant.TenantType == EnumTenantType.OperatingMerchant && tenant.ExpireTime.HasValue && DateTime.Now > tenant.ExpireTime.Value)
                    {
                        viewModel.Msg = "您的账号已过有效期,请与MOVO客服联系\n\r联系电话:" + superTenant.PhoneNumber;
                        viewModel.IndentifyCode = IndentifyCodeHelper.CreateIndentifyCode(sessionId, 4);
                        return viewModel;
                    }
                    else if (tenant.IsFreeze)
                    {
                        switch (tenant.TenantType)
                        {
                            case EnumTenantType.EndCustomer:
                                viewModel.Msg = "您的账号已被冻结,请与您的设备服务提供商联系!\n\r联系电话:" + superTenant.PhoneNumber;
                                break;
                            case EnumTenantType.OperatingMerchant:
                                viewModel.Msg = "您的账号已被冻结,请与MOVO客服联系。\n\r联系电话:" + superTenant.PhoneNumber;
                                break;
                        }
                        viewModel.IndentifyCode = IndentifyCodeHelper.CreateIndentifyCode(sessionId, 4);
                        return viewModel;
                    }
                }

                //获取地图类型
                PositioningWCFService mapTypeService = new PositioningWCFService();
                List<MapTypeViewModel> listMapType = mapTypeService.GetMapType();
                viewModel.MapTypes = listMapType;

                //令牌环
                Ticket ticket = new Ticket() { UserCode = user.UserCode, UserName = user.UserName, Password = user.PassWord };
                string token = EncryptUtil.Encrypt<Ticket>(ticket);
                viewModel.Token = token;

#if !DEBUG
                        user.LastLoginTime = DateTime.Now;
                        service.Update(user);
#endif

            }
            else
            {
                viewModel.Msg = "用户名或密码错误";
                viewModel.IndentifyCode = IndentifyCodeHelper.CreateIndentifyCode(sessionId, 4);
            }
            return viewModel;
        }
示例#8
0
 public UserInfoViewModel GetUser(string userCode)
 {
     IUserService ser = new UserService();
     EMUser model = ser.GetUser(userCode);
     UserInfoViewModel returnModel = new UserInfoViewModel();
     if (model != null)
         returnModel = ConvertToViewModel(model);
     return returnModel;
 }
示例#9
0
        public UserInfoViewModel AutoLogin(string userCode)
        {
            UserInfoViewModel viewModel = new UserInfoViewModel();
            try
            {
                IUserService service = new UserService();
                EMUser user = service.GetUserFullInfo(userCode);
                if (user != null)
                {
                    viewModel = ConvertToViewModel(user);

                    //租户类型
                    IEMTenantService tenantService = new EMTenantService();
                    EMTenant tenant = tenantService.Select(user.TenantCode);
                    viewModel.TenantType = (int)tenant.TenantType;
                    viewModel.TenantLogoImgURl = tenant.LogoUrl;
                    if (tenant.TenantType != EnumTenantType.PlatProvider)
                    {
                        EMTenant superTenant = tenantService.Select(tenant.SuperTenantID);
                        viewModel.SuperContactNumber = superTenant.PhoneNumber;
                        viewModel.SuperTenantName = superTenant.TenantName;
                        viewModel.TenantLogoImgURl = superTenant.LogoUrl;
                    }

                    //获取地图类型
                    PositioningWCFService mapTypeService = new PositioningWCFService();
                    List<MapTypeViewModel> listMapType = mapTypeService.GetMapType();
                    viewModel.MapTypes = listMapType;

                    //令牌环
                    Ticket ticket = new Ticket() { UserCode = user.UserCode, UserName = user.UserName, Password = user.PassWord };
                    string token = EncryptUtil.Encrypt<Ticket>(ticket);
                    viewModel.Token = token;
                }
                else
                {
                    viewModel.Msg = "未找到记录,UserCode:+" + userCode;
                } return viewModel;
            }
            catch (Exception ex)
            {
                viewModel.Msg = "发生未处理错误,请联系系统管理员";
                Logger.Error(ex.Message);
                return viewModel;
            }
        }