public SessionDeviceInfoResolver( AuthDbContext authDbContext, DeviceDetectionManager deviceDetectionManager) { _authDbContext = authDbContext; _deviceDetectionManager = deviceDetectionManager; }
private DeviceInformation GetDeviceInformation() { this._isDeviceLookupDone = true; if (!DeviceDetectionManager.IsEnabled || !DeviceDetectionManager.IsReady || string.IsNullOrEmpty(Tracker.Current.Interaction.UserAgent)) { return(new DeviceInformation()); } return(DeviceDetectionManager.GetDeviceInformation(Tracker.Current.Interaction.UserAgent)); }
public Device GetCurrent() { if (this.current != null) { return(this.current); } if (!DeviceDetectionManager.IsEnabled || !DeviceDetectionManager.IsReady || string.IsNullOrEmpty(Tracker.Current.Interaction.UserAgent)) { return(null); } return(this.current = this.CreateDevice(DeviceDetectionManager.GetDeviceInformation(Tracker.Current.Interaction.UserAgent))); }
public HttpResponseMessage WhoAmI() { HttpResponseMessage response; try { var userIpAddress = GeoIpService.GetUserIpAddress(); WhoIsInformation whoami = LookupManager.GetInformationByIp(userIpAddress.ToString()); var userAgent = Request.Headers.UserAgent.ToString(); var di = DeviceDetectionManager.GetDeviceInformation(userAgent); response = Request.CreateResponse(HttpStatusCode.OK, new { Ip = userIpAddress.ToString(), whoami.Country, whoami.City, whoami.Region, whoami.PostalCode, Latitude = whoami.Latitude ?? 0, Longitude = whoami.Longitude ?? 0, Device = new { di.DeviceIsSmartphone, di.DeviceModelName, di.Browser, DeviceType = Enum.GetName(typeof(DeviceType), di.DeviceType), di.DeviceVendor } }); return(response); } catch (Exception ex) { Log.Error($"HomeController.WhoAmI(): Error while getting user's GeoIP and Device Detection information.", ex, this); response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Oops, it looks like something went wrong. Please try again."); return(response); } }