Exemplo n.º 1
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;
        }
Exemplo n.º 2
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;
            }
        }