public async System.Threading.Tasks.Task DownloadAirportStatus(string url) { try { this.RingVisible = Visibility.Visible; var connectionId = (string)Globals.LogonCore.LogonContext.RegistrationContext.ConnectionData["ApplicationConnectionId"]; // Create an HttpClient instance var client = new SAP.Net.Http.HttpClient( new System.Net.Http.HttpClientHandler() { Credentials = new System.Net.NetworkCredential( Globals.LogonCore.LogonContext.RegistrationContext.BackendUserName, Globals.LogonCore.LogonContext.RegistrationContext.BackendPassword), UseProxy = false }, true); // will be disposed by the store! client.DefaultRequestHeaders.TryAddWithoutValidation("X-SMP-APPCID", connectionId); client.DefaultRequestHeaders.TryAddWithoutValidation("X-SUP-APPCID", connectionId); client.ShouldHandleXcsrfToken = true; // Send a request asynchronously continue when complete HttpResponseMessage response = await client.GetAsync(url); // Check that response was successful or throw exception response.EnsureSuccessStatusCode(); // Read response asynchronously as JsonValue var content = await response.Content.ReadAsStringAsync(); // Parse the content into a JsonObject var jsonContent = JObject.Parse(content); var airlineId = (string)RelatedEntity.Properties["carrid"].Value; var flightNumber = (string)RelatedEntity.Properties["connid"].Value; var flightDate = (DateTime)RelatedEntity.Properties["fldate"].Value; var price = (decimal)RelatedEntity.Properties["PRICE"].Value; var currency = (string)RelatedEntity.Properties["CURRENCY"].Value; var airport = jsonContent["name"].ToString(); jsonContent = jsonContent["weather"].ToObject <JObject>(); var weather = jsonContent["weather"].ToString(); var temp = jsonContent["temp"].ToString(); var wind = jsonContent["wind"].ToString(); SharedContext.JsonContext = new JsonContext(airlineId, flightNumber, flightDate, price, currency, airport, weather, temp, wind); this.RingVisible = Visibility.Collapsed; } catch (Exception ex) { this.RingVisible = Visibility.Collapsed; throw; } }
public SupportabilityUploader(SAP.Net.Http.HttpClient client, bool uploadBtx = true) { if (client == null) { throw new ArgumentNullException("client"); } this.urlPostfix = uploadBtx ? "btx" : "clientlogs"; this.clientRef = client; }
private async void CreateContext() { string message = null; try { var registrationContext = Globals.LogonCore.LogonContext.RegistrationContext; string connectionId = (string)registrationContext.ConnectionData["ApplicationConnectionId"]; string serviceUrl = (string)registrationContext.ConnectionData["ProxyApplicationEndpoint"]; this.DataContext = SharedContext.Context = new ODataContext(serviceUrl); SharedContext.Context.RingVisible = Visibility.Visible; var client = new SAP.Net.Http.HttpClient( new System.Net.Http.HttpClientHandler() { Credentials = new System.Net.NetworkCredential((string)registrationContext.BackendUserName, (string)registrationContext.BackendPassword), UseProxy = false }, true ); // will be disposed by the store! client.DefaultRequestHeaders.TryAddWithoutValidation("X-SMP-APPCID", connectionId); client.DefaultRequestHeaders.TryAddWithoutValidation("X-SUP-APPCID", connectionId); client.ShouldHandleXcsrfToken = true; //client.ShouldHandleSamlRequests = true; //client.SamlFinishEndpoint = new UriBuilder(registrationContext.IsHttps ? "https" : "http", // registrationContext.ServerHost, // registrationContext.ServerPort, "/SAMLAuthLauncher").Uri; //client.SamlFinishEndpointParameter = "finishEndpointParam"; LoggingContext.Context.HttpClient = client; await SharedContext.Context.Store.OpenAsync(client); LoggingContext.Context.Logger.LogInfo("E2ETracing - Retrieving carriers"); await SharedContext.Context.DownloadCollection("CarrierCollection"); SharedContext.Context.IsStoreCreated = true; } catch (Exception ex) { SharedContext.Context.RingVisible = Visibility.Collapsed; message = ex.Message; } if (message != null) { await this.ShowErrorMessageAsync("We could not initialize the store. Details: " + message); } else { LoggingContext.Context.Logger.LogInfo("E2ETracing - Successfully initialized the store"); } }
private async void CreateContext() { string message = null; try { var connectionId = (string)Globals.LogonCore.LogonContext.RegistrationContext.ConnectionData["ApplicationConnectionId"]; var serviceUrl = (string)Globals.LogonCore.LogonContext.RegistrationContext.ConnectionData["ProxyApplicationEndpoint"]; this.DataContext = SharedContext.Context = new ODataContext(serviceUrl); SharedContext.Context.RingVisible = Visibility.Visible; var client = new SAP.Net.Http.HttpClient( new System.Net.Http.HttpClientHandler() { Credentials = new System.Net.NetworkCredential( Globals.LogonCore.LogonContext.RegistrationContext.BackendUserName, Globals.LogonCore.LogonContext.RegistrationContext.BackendPassword), UseProxy = false }, true); // will be disposed by the store! client.DefaultRequestHeaders.TryAddWithoutValidation("X-SMP-APPCID", connectionId); client.DefaultRequestHeaders.TryAddWithoutValidation("X-SUP-APPCID", connectionId); client.ShouldHandleXcsrfToken = true; LoggingContext.Context.HttpClient = client; await SharedContext.Context.Store.OpenAsync(client); LoggingContext.Context.Logger.LogInfo("E2ETracing - Retrieving carriers"); await SharedContext.Context.DownloadCollection("CarrierCollection"); SharedContext.Context.IsStoreCreated = true; } catch (Exception ex) { SharedContext.Context.RingVisible = Visibility.Collapsed; message = ex.Message; } if (message != null) { await new Windows.UI.Popups.MessageDialog("We could not initialize the store. Details: " + message) .ShowAsync(); } }
private async void CreateContext() { string message = null; try { var connectionId = (string)Globals.LogonCore.LogonContext.RegistrationContext.ConnectionData["ApplicationConnectionId"]; var serviceUrl = (string)Globals.LogonCore.LogonContext.RegistrationContext.ConnectionData["ProxyApplicationEndpoint"]; this.DataContext = SharedContext.Context = new ODataContext(serviceUrl); SharedContext.Context.RingVisible = Visibility.Visible; var client = new SAP.Net.Http.HttpClient( new System.Net.Http.HttpClientHandler() { Credentials = new System.Net.NetworkCredential( Globals.LogonCore.LogonContext.RegistrationContext.BackendUserName, Globals.LogonCore.LogonContext.RegistrationContext.BackendPassword), }, true); // will be disposed by the store! client.DefaultRequestHeaders.TryAddWithoutValidation("X-SMP-APPCID", connectionId); client.DefaultRequestHeaders.TryAddWithoutValidation("X-SUP-APPCID", connectionId); client.ShouldHandleXcsrfToken = true; await SharedContext.Context.Store.OpenAsync(client); await SharedContext.Context.DownloadCollection("CarrierCollection"); SharedContext.Context.IsStoreCreated = true; } catch (Exception ex) { SharedContext.Context.RingVisible = Visibility.Collapsed; message = ex.Message; } if (message != null) { await new Windows.UI.Popups.MessageDialog("We could not initialize the store. Details: " + message) .ShowAsync(); } }
public SupportabilityUploader(SAP.Net.Http.HttpClient client, bool uploadBtx = true) { if (client == null) throw new ArgumentNullException("client"); this.urlPostfix = uploadBtx ? "btx" : "clientlogs"; this.clientRef = client; }
public async System.Threading.Tasks.Task DownloadAirportStatus(string url) { try { this.RingVisible = Visibility.Visible; var connectionId = (string)Globals.LogonCore.LogonContext.RegistrationContext.ConnectionData["ApplicationConnectionId"]; // Create an HttpClient instance var client = new SAP.Net.Http.HttpClient( new System.Net.Http.HttpClientHandler() { Credentials = new System.Net.NetworkCredential( Globals.LogonCore.LogonContext.RegistrationContext.BackendUserName, Globals.LogonCore.LogonContext.RegistrationContext.BackendPassword), UseProxy = false }, true); // will be disposed by the store! client.DefaultRequestHeaders.TryAddWithoutValidation("X-SMP-APPCID", connectionId); client.DefaultRequestHeaders.TryAddWithoutValidation("X-SUP-APPCID", connectionId); client.ShouldHandleXcsrfToken = true; // Send a request asynchronously continue when complete HttpResponseMessage response = await client.GetAsync(url); // Check that response was successful or throw exception response.EnsureSuccessStatusCode(); // Read response asynchronously as JsonValue var content = await response.Content.ReadAsStringAsync(); // Parse the content into a JsonObject var jsonContent = JObject.Parse(content); var airlineId = (string)RelatedEntity.Properties["carrid"].Value; var flightNumber = (string)RelatedEntity.Properties["connid"].Value; var flightDate = (DateTime)RelatedEntity.Properties["fldate"].Value; var price = (decimal)RelatedEntity.Properties["PRICE"].Value; var currency = (string)RelatedEntity.Properties["CURRENCY"].Value; var airport = jsonContent["name"].ToString(); jsonContent = jsonContent["weather"].ToObject<JObject>(); var weather = jsonContent["weather"].ToString(); var temp = jsonContent["temp"].ToString(); var wind = jsonContent["wind"].ToString(); SharedContext.JsonContext = new JsonContext(airlineId, flightNumber, flightDate, price, currency, airport, weather, temp, wind); this.RingVisible = Visibility.Collapsed; } catch (Exception ex) { this.RingVisible = Visibility.Collapsed; throw; } }