/* * Function: manualButton_Clicked() * -------------------- * inputs: object sender, EventArgs args * * onClick for manual * Sends to manual display page */ private async void manualButton_Clicked(object sender, EventArgs e) { if (CrossConnectivity.Current.IsConnected) { // check for invalid link if (obj[0].LINK == null) { // display alert if true await DisplayAlert("Invalid Input", "Please select valid Motor Controller/Fault Code pair", "OK"); } else { // else, format link, make sure is valid URL var man = obj[0].LINK; if (man == "acError.html" || CheckURLValid(man)) { string code = await getCode(); if (code == get_code_local()) { try { if (CrossConnectivity.Current.IsConnected) { HttpClient Client = new HttpClient(); //URL for the content or JSON data. string myURL = "https://faultcodes.curtisinstruments.com/ac_man.php"; //Gettting the content from the web string linkCONTENT = await Client.GetStringAsync(myURL); var manLink = JsonConvert.DeserializeObject <List <acManLink> >(linkCONTENT); acManLink found = new acManLink(); for (int i = 0; i < manLink.Count(); i++) { if (manLink[i].NAME == obj[0].NAME) { found = manLink[i]; } } if (found.NON_DUAL_DRIVE == "N:A" || found.DUAL_DRIVE == "N:A") { if (found.NON_DUAL_DRIVE == "N:A") { string url = "https://faultcodes.curtisinstruments.com/media/ac_man/" + found.DUAL_DRIVE; await Navigation.PushAsync(new Manual(url, found.NAME)); } else { string url = "https://faultcodes.curtisinstruments.com/media/ac_man/" + found.NON_DUAL_DRIVE; await Navigation.PushAsync(new Manual(url, found.NAME)); } } else { string action = await DisplayActionSheet("Which Manual?", "Cancel", null, "Standard", "Dual Drive"); if (action == "Dual Drive") { string url = "https://faultcodes.curtisinstruments.com/media/ac_man/" + found.DUAL_DRIVE; await Navigation.PushAsync(new Manual(url, found.NAME)); } else if (action == "Standard") { string url = "https://faultcodes.curtisinstruments.com/media/ac_man/" + found.NON_DUAL_DRIVE; await Navigation.PushAsync(new Manual(url, found.NAME)); } } } else { await DisplayAlert("No Content", "Please connect to internet", "OK"); } } catch (Exception ex) { // print error to console Console.Write(ex); } } else { // if URL not valid, display error await DisplayAlert("Manual Not Available", "Please connect your OEM", "OK"); } } else { // if valid, send to manual page await Navigation.PushAsync(new Manual(man, obj[0].NAME)); } } } else { await DisplayAlert("No Content", "Please connect to internet", "OK"); } }
/* * Function: manualButton_Clicked() * -------------------- * inputs: object sender, EventArgs args * * onClick for manual * Sends to manual display page */ private async void manualButton_Clicked(object sender, EventArgs e) { if (CrossConnectivity.Current.IsConnected) { // get motor controller as string string motCon = mcPicker?.SelectedItem.ToString(); // check for empty content if (content != "") { // faultsToDisplayManual list of type Faults List <Faults> faultsToDisplayManual = new List <Faults>(); // Iterate through JSON data for (int i = 0; i < Items.Count(); i++) { // if Name matches motor controller // only need to find one for that name, manual is the same for all if (Items[i].NAME == motCon) { // add to list faultsToDisplayManual.Add(Items[i]); // break break; } } // if list == null if (faultsToDisplayManual == null) { // display alert await DisplayAlert("Invalid Input", "Please select valid Motor Controller", "OK"); } else { // if list is not null, enters loop // string man set to link string man = faultsToDisplayManual[0].LINK; // check for valid URL if (man == "acError.html" || CheckURLValid(man)) { string code = await getCode(); if (code == get_code_local()) { try { if (CrossConnectivity.Current.IsConnected) { HttpClient Client = new HttpClient(); //URL for the content or JSON data. string myURL = "https://faultcodes.curtisinstruments.com/ac_man.php"; //Gettting the content from the web string linkCONTENT = await Client.GetStringAsync(myURL); var manLink = JsonConvert.DeserializeObject <List <acManLink> >(linkCONTENT); acManLink found = new acManLink(); for (int i = 0; i < manLink.Count(); i++) { if (manLink[i].NAME == motCon) { found = manLink[i]; } } if (found.NON_DUAL_DRIVE == "N:A" || found.DUAL_DRIVE == "N:A") { if (found.NON_DUAL_DRIVE == "N:A") { string url = "https://faultcodes.curtisinstruments.com/media/ac_man/" + found.DUAL_DRIVE; await Navigation.PushAsync(new Manual(url, found.NAME)); } else { string url = "https://faultcodes.curtisinstruments.com/media/ac_man/" + found.NON_DUAL_DRIVE; await Navigation.PushAsync(new Manual(url, found.NAME)); } } else { string action = await DisplayActionSheet("Which Manual?", "Cancel", null, "Standard", "Dual Drive"); if (action == "Dual Drive") { string url = "https://faultcodes.curtisinstruments.com/media/ac_man/" + found.DUAL_DRIVE; await Navigation.PushAsync(new Manual(url, found.NAME)); } else if (action == "Standard") { string url = "https://faultcodes.curtisinstruments.com/media/ac_man/" + found.NON_DUAL_DRIVE; await Navigation.PushAsync(new Manual(url, found.NAME)); } } } //await DisplayAlert("Manual Will Be Displayed", "You are approved", "OK"); } catch (Exception ex) { // print error to console Console.Write(ex); } } else { // if URL not valid, display error await DisplayAlert("Manual Not Available", "Please connect your OEM", "OK"); } } else { // if valid, send to manual page await Navigation.PushAsync(new Manual(man, faultsToDisplayManual[0].NAME)); } } } else { // if content is empty, prompt user to connect to internet await DisplayAlert("No Content", "Please connect to internet", "OK"); } } else { await DisplayAlert("No Content", "Please connect to internet", "OK"); } }