async void sendSPC(object sender, EventArgs e) { //assume valid input. input is invalid if missing or not a real time bool invalid = false; string t = spcEntry.Text.ToString(); int hour = 60; int min = 60; string hourStr = t.Substring(0, 2); string minStr = t.Substring(t.Length - 2); //try to fetch input, if error flag as invalid try { hour = Int32.Parse(hourStr); min = Int32.Parse(minStr); } catch { invalid = true; } //handle invalid input if (invalid || hour > 23 || min > 59) { Device.BeginInvokeOnMainThread(async() => { await DisplayAlert("Invalid Time", "Please enter a valid time.", "OK"); }); } //else update database else { var url = "https://jax-apps.com/api.php"; var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("spcPOST", "yes"), new KeyValuePair <string, string>("hour", hour.ToString()), new KeyValuePair <string, string>("min", min.ToString()), new KeyValuePair <string, string>("pm", pm_number), new KeyValuePair <string, string>("slot", currentSPC_slot) }); var myHttpClient = new HttpClient(); // get outgoing packet size outgoArraySize = (await formContent.ReadAsByteArrayAsync()).Length; //start stopwatch stopwatch.Restart(); HttpResponseMessage response = new HttpResponseMessage(); try { response = await myHttpClient.PostAsync(url, formContent); } catch (System.Exception ex) { retryCount++; if (retryCount < 11) { sendSPC(sender, e); } else { Device.BeginInvokeOnMainThread(async() => { await DisplayAlert("Connection Error", ex.GetType().ToString(), "OK"); }); return; } } //get elapsed time and display diagnostic data stopwatch.Stop(); retryCount = 0; if (response.Content == null) { Device.BeginInvokeOnMainThread(async() => { await DisplayAlert("Server Error", "Unable to reach server", "OK"); }); return; } //get incoming packet size incoArraySize = (await response.Content.ReadAsByteArrayAsync()).Length; time = stopwatch.ElapsedMilliseconds; string diag = string.Format("Outgoing Packet Length:{1}{0}Incoming Packet Length:{2}{0}Time (ms):{3}", Environment.NewLine, outgoArraySize, incoArraySize, time); await DisplayAlert("Send SPC", diag, "OK"); //change timeslot spcSlots[Int32.Parse(currentSPC_slot) - 1].Text = spcEntry.Text.ToString(); //post to recent activities string msg = System.String.Format("Updated SPC#{0} to {1}:{2}", currentSPC_slot, hourStr, minStr); postACT(DateTime.Now.ToString("HH"), DateTime.Now.ToString("mm"), DateTime.Now.ToString("ss"), msg, false); //close the popup popupBG.IsVisible = false; spcBox.IsVisible = false; } //refresh screen /*Navigation.InsertPageBefore(new PMViewPage(name, c), this); * await Navigation.PopAsync();*/ }
// Activities list data retrieved from php backend private static async void generateList(Color color) { Activities = new List <Activity>(); var uri = new Uri("https://jax-apps.com/api.php"); HttpClient myClient = MsgPage.client; var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("actGET", "blah"), new KeyValuePair <string, string>("pm", pm_number) }); // get outgoing packet size outgoArraySize = (await formContent.ReadAsByteArrayAsync()).Length; //start stopwatch stopwatch.Restart(); HttpResponseMessage result = new HttpResponseMessage(); try { result = await myClient.PostAsync(uri, formContent); } catch (System.Exception e) { retryCount++; if (retryCount < 11) { generateList(color); } else { Device.BeginInvokeOnMainThread(async() => { await App.Current.MainPage.DisplayAlert("Connection Error", e.GetType().ToString(), "OK"); }); return; } } //get elapsed time and display diagnostic data stopwatch.Stop(); if (result.Content == null) { Device.BeginInvokeOnMainThread(async() => { await App.Current.MainPage.DisplayAlert("Server Error", "Unable to reach server", "OK"); }); return; } //get incoming packet size incoArraySize = (await result.Content.ReadAsByteArrayAsync()).Length; time = stopwatch.ElapsedMilliseconds; string diag = string.Format("Outgoing Packet Length:{1}{0}Incoming Packet Length:{2}{0}Time (ms):{3}", Environment.NewLine, outgoArraySize, incoArraySize, time); await App.Current.MainPage.DisplayAlert("Generate Act List", diag, "OK"); var content = await result.Content.ReadAsStringAsync(); JArray a = JArray.Parse(content); foreach (JObject O in a.Children <JObject>()) { List <string> actdata = new List <string>(); foreach (JProperty P in O.Properties()) { actdata.Add((string)P.Value); } string dt = DateTime.Parse(actdata[3]).ToString("dd MMM yyyy"); string t = DateTime.Parse(actdata[3]).ToString("HH:mm"); Activities.Add(new Activity { activity_id = Int32.Parse(actdata[0]), pm_no = Int32.Parse(actdata[1]), content = actdata[2], activity_time = actdata[3], author = actdata[4], Date = dt, Time = t, color_text = color.ToHex() }); } ActivitiesListView.ItemsSource = Activities; }
async void checkOffSPC(object sender, EventArgs e) { if (!initMode && !inChkRecoveryState) { CheckBox c = (CheckBox)sender; int pos = findCHK(c); //checks if SPC slot is next in line and is not being unchecked //if not next in line, turn it back off if (c.IsChecked && pos != currentSPCOpen) { inChkRecoveryState = true; c.IsChecked = false; await DisplayAlert("Invalid Check", "You can only pull the very next sample.", "OK"); } //if being turned off and is not the current slots predecessor, turn back on else if (!c.IsChecked && pos != (currentSPCOpen - 1)) { inChkRecoveryState = true; c.IsChecked = true; await DisplayAlert("Invalid Check", "You can only undo the very last sample.", "OK"); } //else continue with operation else { if (spcSlots[pos].Text.ToString() == "--:--") { inChkRecoveryState = true; c.IsChecked = !c.IsChecked; await DisplayAlert("SPC", "This Sample# has no time!", "OK"); } else { string isChecked = "1"; string message = "Pulling Sample#" + (pos + 1) + "?"; string action = "Pulled"; if (c.IsChecked == false) { message = "Undo Sample#" + (pos + 1) + "?"; action = "Undid"; } var answer = await DisplayAlert("SPC", message, "Yes", "No"); if (answer) { if (c.IsChecked == false) { isChecked = "0"; currentSPCOpen--; } else { currentSPCOpen++; } var url = "https://jax-apps.com/api.php"; var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("spcCHK", "yes"), new KeyValuePair <string, string>("pm", pm_number), new KeyValuePair <string, string>("slot", (pos + 1).ToString()), new KeyValuePair <string, string>("isChecked", isChecked) }); var myHttpClient = new HttpClient(); // get outgoing packet size outgoArraySize = (await formContent.ReadAsByteArrayAsync()).Length; //start stopwatch stopwatch.Restart(); HttpResponseMessage response = new HttpResponseMessage(); try { response = await myHttpClient.PostAsync(url, formContent); } catch (System.Exception ex) { retryCount++; if (retryCount < 11) { checkOffSPC(sender, e); } else { Device.BeginInvokeOnMainThread(async() => { await DisplayAlert("Connection Error", ex.GetType().ToString(), "OK"); }); return; } } //get elapsed time and display diagnostic data stopwatch.Stop(); retryCount = 0; if (response.Content == null) { Device.BeginInvokeOnMainThread(async() => { await DisplayAlert("Server Error", "Unable to reach server", "OK"); }); return; } //get incoming packet size incoArraySize = (await response.Content.ReadAsByteArrayAsync()).Length; time = stopwatch.ElapsedMilliseconds; string diag = string.Format("Outgoing Packet Length:{1}{0}Incoming Packet Length:{2}{0}Time (ms):{3}", Environment.NewLine, outgoArraySize, incoArraySize, time); await DisplayAlert("Check Off SPC", diag, "OK"); //post to recent activities string msg = System.String.Format("{0} SPC#{1} ", action, (pos + 1).ToString()); postACT(DateTime.Now.ToString("HH"), DateTime.Now.ToString("mm"), DateTime.Now.ToString("ss"), msg, false); } else { inChkRecoveryState = true; c.IsChecked = !c.IsChecked; await DisplayAlert("SPC", "Changes Reverted.", "OK"); } } } inChkRecoveryState = false; } }
//QR DATA IS MODIFIED INTO DICTIONARY AND SENT TO BACKEND USING HTTPCLIENT //QR DATA format batchno|bagno|expdate public async void sendData(string[] data) { var url = "https://jax-apps.com/api.php"; var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("rm", pm_num), new KeyValuePair <string, string>("material", RMType), new KeyValuePair <string, string>("batchno", data[0]), new KeyValuePair <string, string>("bagno", data[1]), new KeyValuePair <string, string>("expdate", data[2]) }); var myHttpClient = MsgPage.client; // get outgoing packet size outgoArraySize = (await formContent.ReadAsByteArrayAsync()).Length; //start stopwatch stopwatch.Restart(); HttpResponseMessage response = new HttpResponseMessage(); try { response = await myHttpClient.PostAsync(url, formContent); } catch (Exception e) { retryCount++; if (retryCount < 11) { sendData(data); } else { Device.BeginInvokeOnMainThread(async() => { await DisplayAlert("Connection Error", e.GetType().ToString(), "OK"); }); return; } } //get elapsed time and display diagnostic data stopwatch.Stop(); retryCount = 0; if (response.Content == null) { Device.BeginInvokeOnMainThread(async() => { await DisplayAlert("Server Error", "Unable to reach server", "OK"); }); return; } //get incoming packet size incoArraySize = (await response.Content.ReadAsByteArrayAsync()).Length; time = stopwatch.ElapsedMilliseconds; string diag = string.Format("Outgoing Packet Length:{1}{0}Incoming Packet Length:{2}{0}Time (ms):{3}", Environment.NewLine, outgoArraySize, incoArraySize, time); var content = await response.Content.ReadAsStringAsync(); //post changes to activity log if (content == "Success!") { string container = "Bag"; if (RMType == "FT32") { container = "Tank"; } string msg = System.String.Format("Changed {0}: {1} {2}#{3} ", RMType, data[0], container, data[1]); PMViewPage.postACT(DateTime.Now.ToString("HH"), DateTime.Now.ToString("mm"), DateTime.Now.ToString("ss"), msg, true); } else { } Device.BeginInvokeOnMainThread(async() => { await App.Current.MainPage.DisplayAlert("Scanned result", content + Environment.NewLine + diag, "OK"); }); }
//COLOR SPC CHECKBOXES ***NOTE***: ALSO ADD CODE TO UPDATE TIMES/CHECK STATUS FROM BACKEND private async void Init_spc(Color color) { var cookieManager = CookieManager.Instance; cookieManager.RemoveAllCookie(); SPCTimes = new List <SPCTime>(); var uri = new Uri("https://jax-apps.com/api.php"); HttpClient myClient = MsgPage.client; var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("spcGET", "blah"), new KeyValuePair <string, string>("pm", pm_number) }); var myHttpClient = new HttpClient(); // get outgoing packet size outgoArraySize = (await formContent.ReadAsByteArrayAsync()).Length; //start stopwatch stopwatch.Restart(); HttpResponseMessage result = new HttpResponseMessage(); try { result = await myHttpClient.PostAsync(uri, formContent); } catch (System.Exception ex) { retryCount++; if (retryCount < 11) { Init_spc(color); } else { Device.BeginInvokeOnMainThread(async() => { await DisplayAlert("Connection Error", ex.GetType().ToString(), "OK"); }); return; } } var content = await result.Content.ReadAsStringAsync(); //get elapsed time and display diagnostic data stopwatch.Stop(); retryCount = 0; if (result.Content == null) { Device.BeginInvokeOnMainThread(async() => { await DisplayAlert("Server Error", "Unable to reach server", "OK"); }); return; } //get incoming packet size incoArraySize = (await result.Content.ReadAsByteArrayAsync()).Length; time = stopwatch.ElapsedMilliseconds; string diag = string.Format("Outgoing Packet Length:{1}{0}Incoming Packet Length:{2}{0}Time (ms):{3}", Environment.NewLine, outgoArraySize, incoArraySize, time); await DisplayAlert("Get SPC", diag, "OK"); JArray a = JArray.Parse(content); foreach (JObject O in a.Children <JObject>()) { List <string> spcdata = new List <string>(); foreach (JProperty P in O.Properties()) { if ((string)P.Value == null) { spcdata.Add("--:--"); } else { spcdata.Add((string)P.Value); } } string timeStr = spcdata[2]; if (timeStr != "--:--") { timeStr = spcdata[2].Substring(12, 5); } bool isP = false; if (spcdata[3] == "1") { isP = true; } SPCTimes.Add(new SPCTime { pm_no = Int32.Parse(spcdata[0]), spc_no = Int32.Parse(spcdata[1]), time = timeStr, isPulled = isP }); } pullTime1.Text = SPCTimes[0].time; spcSlots.Add(pullTime1); pullTime2.Text = SPCTimes[1].time; spcSlots.Add(pullTime2); pullTime3.Text = SPCTimes[2].time; spcSlots.Add(pullTime3); pullTime4.Text = SPCTimes[3].time; spcSlots.Add(pullTime4); pullTime5.Text = SPCTimes[4].time; spcSlots.Add(pullTime5); pullTime6.Text = SPCTimes[5].time; spcSlots.Add(pullTime6); //Check Off Boxes if database says they are checked if (SPCTimes[0].isPulled == true) { spc1_check.IsChecked = true; currentSPCOpen++; } checkBoxes.Add(spc1_check); if (SPCTimes[1].isPulled == true) { spc2_check.IsChecked = true; currentSPCOpen++; } checkBoxes.Add(spc2_check); if (SPCTimes[2].isPulled == true) { spc3_check.IsChecked = true; currentSPCOpen++; } checkBoxes.Add(spc3_check); if (SPCTimes[3].isPulled == true) { spc4_check.IsChecked = true; currentSPCOpen++; } checkBoxes.Add(spc4_check); if (SPCTimes[4].isPulled == true) { spc5_check.IsChecked = true; currentSPCOpen++; } checkBoxes.Add(spc5_check); if (SPCTimes[5].isPulled == true) { spc6_check.IsChecked = true; currentSPCOpen++; } checkBoxes.Add(spc6_check); foreach (CheckBox c in checkBoxes) { c.Color = color; } initMode = false; }
private async Task Login(CancellationToken cancellationToken) { if ((DateTimeOffset.UtcNow - _lastLogin).TotalMinutes < 1) { return; } var options = GetOptions(); var username = options.Addic7edUsername; var password = DecryptPassword(options.Addic7edPasswordHash); if (string.IsNullOrWhiteSpace(username)) { _logger.Debug("No Username"); return; } if (string.IsNullOrWhiteSpace(password)) { _logger.Debug("No Password"); return; } var contentData = new Dictionary <string, string> { { "username", username }, { "password", password }, { "Submit", "Log in" } }; var formUrlEncodedContent = new FormUrlEncodedContent(contentData); var requestContentBytes = await formUrlEncodedContent.ReadAsByteArrayAsync().ConfigureAwait(false); using (var res = await _httpClient.Post(new HttpRequestOptions { Url = _baseUrl + "/dologin.php", RequestContentType = "application/x-www-form-urlencoded", RequestContentBytes = requestContentBytes, CancellationToken = cancellationToken, Referer = _baseUrl }).ConfigureAwait(false)) { if (res.StatusCode == HttpStatusCode.OK) { using (var reader = new StreamReader(res.Content)) { var content = await reader.ReadToEndAsync().ConfigureAwait(false); if (content.Contains("User <b></b> doesn't exist")) { _logger.Debug("User doesn't exist"); return; } if (content.Contains("Wrong password")) { _logger.Debug("Wrong password"); return; } _logger.Debug($"{username} Logged in"); } } } _lastLogin = DateTimeOffset.UtcNow; }
public static async Task DownloadSong(string name, Label ProgressBar) { if (name != null & name != "") { // var values = new Dictionary <string, string> { { "submit", "submit" }, { "cmdownloadname", name } }; var content = new FormUrlEncodedContent(values); try { Dictionary <string, string> siteinfo = ReturnSiteInfo(); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(siteinfo["Main"] + "RBX-C/phpget.php"); request.Method = "POST"; request.Timeout = 1000; request.UserAgent = "Mozilla/5.0 (Linux; U; Android 4.0.4; pt-br; MZ608 Build/7.7.1-141-7-FLEM-UMTS-LA) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30"; byte[] contents = await content.ReadAsByteArrayAsync(); request.ContentLength = contents.Length; request.ContentType = "application/x-www-form-urlencoded"; Stream dataStream = request.GetRequestStream(); dataStream.Write(contents, 0, contents.Length); dataStream.Close(); WebResponse response = await request.GetResponseAsync(); Stream data = response.GetResponseStream(); string DIR = "music"; int total = new int(); //var datatotal = SizeSuffix(GetStreamLength(data)); FormProperties.DownloadStatus("Set", "Start"); var ctype = response.Headers.Get("Content-Type"); var ext = ".unknown"; if (ctype == "audio/mpeg") { ext = ".mp3"; } else if (ctype == "audio/ogg") { ext = ".ogg"; } using (FileStream DestinationStream = File.Create(DIR + "\\" + values["cmdownloadname"] + ext)) { FormProperties.DownloadStatus("Set", "InProgress"); byte[] buffer = new byte[16 * 2048]; int read; while ((read = data.Read(buffer, 0, buffer.Length)) > 0) { string totalstring = SizeSuffix(total); total = total + read; ProgressBar.Text = totalstring; await DestinationStream.WriteAsync(buffer, 0, read); ProgressBar.Text = "Completed"; } DestinationStream.Close(); FormProperties.DownloadStatus("Set", "Completed"); return; } } catch { Console.Write("Failure."); FormProperties.DownloadStatus("Set", "Failure"); } // } }
public async Task MakeAccessTokenRequest(string requestUrl) { try { HttpWebRequest request = WebRequest.Create("https://login.live.com/oauth20_token.srf") as HttpWebRequest; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; List <KeyValuePair <string, string> > postData = new List <KeyValuePair <string, string> >(); postData.Add(new KeyValuePair <string, string>("client_id", CommonConstants.ClientId)); //Public clients can't send a client secret because redirect to https://login.live.com/oauth20_desktop.srf //postData.Add(new KeyValuePair<string, string>("client_secret", CommonConstants.ClientSecret)); postData.Add(new KeyValuePair <string, string>("code", Settings.GetSetting(CommonConstants.AuthCodeKey))); postData.Add(new KeyValuePair <string, string>("redirect_uri", "https://login.live.com/oauth20_desktop.srf")); postData.Add(new KeyValuePair <string, string>("grant_type", "authorization_code")); var content = new FormUrlEncodedContent(postData); var contentBytes = await content.ReadAsByteArrayAsync(); var requestStream = await request.GetRequestStreamAsync().ConfigureAwait(false); await requestStream.WriteAsync(contentBytes, 0, contentBytes.Length); string responseTxt = String.Empty; using (HttpWebResponse response = await request.GetResponseAsync().ConfigureAwait(false) as HttpWebResponse) { if (response.StatusCode == HttpStatusCode.OK) { using (var reader = new StreamReader(response.GetResponseStream())) { responseTxt = reader.ReadToEnd(); var tokenData = JsonConvert.DeserializeObject <Dictionary <string, string> >(responseTxt); if (tokenData.ContainsKey(CommonConstants.AccessTokenKey)) { Settings.SetSetting(CommonConstants.AccessTokenKey, tokenData[CommonConstants.AccessTokenKey]); LogOnViewModel.StoredToken = tokenData[CommonConstants.AccessTokenKey]; // refresh token Settings.SetSetting(CommonConstants.RefreshTokenKey, tokenData[CommonConstants.RefreshTokenKey]); Settings.SetSetting(CommonConstants.TokenKey, string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0},{1}", LogOnViewModel.StoredToken, DateTime.Now)); } if (tokenData.ContainsKey(CommonConstants.CurrentUserIdKey)) { Settings.SetSetting(CommonConstants.CurrentUserIdKey, tokenData[CommonConstants.CurrentUserIdKey]); } } } } } catch (WebException ex) { MyProfileViewModel.Instance.ErrorMessage = ex.Message; } catch (HttpRequestException ex) { MyProfileViewModel.Instance.ErrorMessage = ex.Message; } catch (Exception ex) { MyProfileViewModel.Instance.ErrorMessage = ex.Message; } }
public async static void initMessages() { try { var cachePath = System.IO.Path.GetTempPath(); // If exist, delete the cache directory and everything in it recursivly if (System.IO.Directory.Exists(cachePath)) { System.IO.Directory.Delete(cachePath, true); } // If not exist, restore just the directory that was deleted if (!System.IO.Directory.Exists(cachePath)) { System.IO.Directory.CreateDirectory(cachePath); } } catch (Exception) { } List <Message> messages = new List <Message>(); var uri = new Uri("https://jax-apps.com/msgapi.php"); HttpClient myClient = MsgPage.client; var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("getMsg", "blah"), new KeyValuePair <string, string>("r", LoginViewModel.user.getUsername()) }); // get outgoing packet size outgoArraySize = (await formContent.ReadAsByteArrayAsync()).Length; //start stopwatch stopwatch.Restart(); HttpResponseMessage result = new HttpResponseMessage(); try { result = await myClient.PostAsync(uri, formContent); } catch (Exception e) { retryCount++; if (retryCount < 11) { initMessages(); } else { Device.BeginInvokeOnMainThread(async() => { await App.Current.MainPage.DisplayAlert("Connection Error", e.GetType().ToString(), "OK"); }); return; } } //get elapsed time and display diagnostic data stopwatch.Stop(); if (result.Content == null) { Device.BeginInvokeOnMainThread(async() => { await App.Current.MainPage.DisplayAlert("Server Error", "Unable to reach server", "OK"); }); return; } //get incoming packet size incoArraySize = (await result.Content.ReadAsByteArrayAsync()).Length; time = stopwatch.ElapsedMilliseconds; string diag = string.Format("Outgoing Packet Length:{1}{0}Incoming Packet Length:{2}{0}Time (ms):{3}", Environment.NewLine, outgoArraySize, incoArraySize, time); await App.Current.MainPage.DisplayAlert("Get Messages", diag, "OK"); var content = await result.Content.ReadAsStringAsync(); retryCount = 0; JArray a = JArray.Parse(content); foreach (JObject O in a.Children <JObject>()) { List <string> msgdata = new List <string>(); foreach (JProperty P in O.Properties()) { msgdata.Add((string)P.Value); } int id = Int32.Parse(msgdata[0]); string dt = DateTime.Parse(msgdata[6]).ToString("dd MMM yyyy"); string t = DateTime.Parse(msgdata[6]).ToString("HH:mm"); messages.Add(new Message { id = id, username = msgdata[3], fullname = msgdata[4], photo_url = "https://jax-apps.com/images/" + msgdata[2], content = msgdata[5], date = dt, time = t }); } messageList.ItemsSource = messages; messageBank = messages; }
private async static void initContactBank() { contactBank = new List <Contact>(); var uri = new Uri("https://jax-apps.com/msgapi.php"); var formContent = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("getUsers", "blah") }); // get outgoing packet size outgoArraySize = (await formContent.ReadAsByteArrayAsync()).Length; //start stopwatch stopwatch.Restart(); HttpResponseMessage result = new HttpResponseMessage(); try { result = await client.PostAsync(uri, formContent); } catch (Exception e) { retryCount++; if (retryCount < 11) { initContactBank(); } else { Device.BeginInvokeOnMainThread(async() => { await App.Current.MainPage.DisplayAlert("Connection Error", e.GetType().ToString(), "OK"); }); return; } } //get elapsed time and display diagnostic data stopwatch.Stop(); if (result.Content == null) { Device.BeginInvokeOnMainThread(async() => { await App.Current.MainPage.DisplayAlert("Server Error", "Unable to reach server", "OK"); }); return; } //get incoming packet size incoArraySize = (await result.Content.ReadAsByteArrayAsync()).Length; retryCount = 0; time = stopwatch.ElapsedMilliseconds; string diag = string.Format("Outgoing Packet Length:{1}{0}Incoming Packet Length:{2}{0}Time (ms):{3}", Environment.NewLine, outgoArraySize, incoArraySize, time); await App.Current.MainPage.DisplayAlert("Get Contacts", diag, "OK"); var content = await result.Content.ReadAsStringAsync(); JArray a = JArray.Parse(content); foreach (JObject O in a.Children <JObject>()) { List <string> contactdata = new List <string>(); foreach (JProperty P in O.Properties()) { contactdata.Add((string)P.Value); } int id = Int32.Parse(contactdata[0]); if (id == LoginViewModel.user.manager) { settingsPage.initManager(contactdata[2] + " " + contactdata[3]); } contactBank.Add(new Contact { contactId = id, username = contactdata[1], firstname = contactdata[2], lastname = contactdata[3], isContactGroup = contactdata[5] == "1", imageStr = "https://jax-apps.com/images/" + contactdata[4] }); } }