public async Task <UIDInfo> GetInfo(string userName, string token, string uuid) { if (uuid == "") { return new UIDInfo() { UID = uuid, FrameNumber = null } } ; Models.AWS.UIDInfoResponse response = await awsHttpClient.GetInfoAsync(new UIDInfoRequest() { Username = userName, Token = token, UID = uuid }); if (response == null || response?.UIDInfo == null) { return new UIDInfo() { UID = uuid, FrameNumber = null } } ; return(response.UIDInfo); }
public async Task <UIDInfo> GetInfo(string userName, string token, string uuid) { if (uuid == "") { return new UIDInfo() { UID = uuid, FrameNumber = null } } ; if (client.DefaultRequestHeaders.Contains("code")) { client.DefaultRequestHeaders.Remove("code"); } client.DefaultRequestHeaders.Add("code", Constants.AzureApiKey_GetInfo); try { string postBody = JsonConvert.SerializeObject(new UIDInfoRequest() { Username = userName, Token = token, UID = uuid }); HttpResponseMessage response = await client.PostAsync(Constants.AzureEndPoint_GetInfo, new StringContent(postBody, Encoding.UTF8, "application/json")); // AnalyticsService.TrackEvent("Response: " + response.StatusCode.ToString()); if (response.IsSuccessStatusCode) { string str = await response.Content.ReadAsStringAsync(); //AnalyticsService.TrackEvent(str); var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; Models.AWS.UIDInfoResponse infoResponse = JsonConvert.DeserializeObject <Models.AWS.UIDInfoResponse>(str, settings); if (infoResponse == null || infoResponse?.UIDInfo == null) { return new UIDInfo() { UID = uuid, FrameNumber = null } } ; return(infoResponse.UIDInfo); } else { string str = await response.Content.ReadAsStringAsync(); AnalyticsService.TrackEvent(str); } } catch (HttpRequestException hre) { AnalyticsService.TrackError(hre); } catch (TaskCanceledException hca) { AnalyticsService.TrackError(hca); AnalyticsService.TrackEvent("Request canceled"); } catch (Exception ex) { AnalyticsService.TrackError(ex); } finally { /*if (httpClient != null) * { * httpClient.Dispose(); * httpClient = null; * }*/ } return(new UIDInfo() { UID = uuid, FrameNumber = null }); }