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; }
/// <summary> /// 车辆的相关信息 /// </summary> /// <param name="param"></param> /// <returns></returns> public AndroidData<RVehicleInfo> GetVehicleInfo(PSearchVehicleInfo param) { AndroidData<RVehicleInfo> result = new AndroidData<RVehicleInfo>() { Message = "车辆编号不存在!", ResultCode = (int)ResultCodeEnum.Fail }; try { PositioningWCFService service = new PositioningWCFService(); var res = service.GetVehicleDetailInfo(param.VehicleCode, (EnumMapType)param.MapType); if (res != null) { if (res.Lng.HasValue && res.Lat.HasValue) { PES.GPS.MapService.Entity.LatLon _marLatLon = null; try { switch ((EnumMapType)param.MapType) { case EnumMapType.GoogleCN: _marLatLon = gMapSrv.LatLonToMar(new PES.GPS.MapService.Entity.LatLon { Longitude = res.Lng.Value, Latitude = res.Lat.Value }); var googleLocation = gMapSrv.LatLngToAddr(_marLatLon); res.City = googleLocation.City; res.Location = googleLocation.Address; res.RoadName = googleLocation.RoadName; break; case EnumMapType.BaiduMap: _marLatLon = bMapSrv.LatLonToMar(new PES.GPS.MapService.Entity.LatLon { Longitude = res.Lng.Value, Latitude = res.Lat.Value }); var baiduLocation = bMapSrv.LatLngToAddr(_marLatLon); res.City = baiduLocation.City; res.Location = baiduLocation.Address; res.RoadName = baiduLocation.RoadName; break; } } catch (Exception ex) { res.City = string.Empty; res.Location = string.Empty; res.RoadName = string.Empty; Logger.Error("地图服务Http请求解析失败," + ex.Message, ex); } if (_marLatLon != null) { res.Lng = _marLatLon.Longitude; res.Lat = _marLatLon.Latitude; } _marLatLon = null; } RVehicleInfo resultData = new RVehicleInfo() { VehicleCode = res.VehicleCode.ToGuid(), LicenceNumber = res.LicenceNumber, Longitude = res.Lng, Latitude = res.Lat, Location = string.IsNullOrEmpty(res.Location) ? " " : res.Location, City = string.IsNullOrEmpty(res.City) ? " " : res.City, RoadName = string.IsNullOrEmpty(res.RoadName) ? " " : res.RoadName, Acc = res.Acc, Speed = res.Speed, ReportTime = res.ReportTime.HasValue ? res.ReportTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : " " }; result.Message = string.Empty; result.ResultCode = (int)ResultCodeEnum.Success; result.ResultData = resultData; } } catch (Exception ex) { result.Message = ex.Message; result.ResultCode = (int)ResultCodeEnum.Fail; Logger.Error("[GetMobileGuestList]:" + ex.Message, ex); } return result; }
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; } }