private async void XamlSwitch_Toggled(object sender, ToggledEventArgs e) { try { var swtich = sender as Switch; var inprogress = Application.Current.Properties.ContainsKey("inProgess") ? Application.Current.Properties["inProgess"] as string : ""; var HAWB = Application.Current.Properties.ContainsKey("ShipHawb") ? Application.Current.Properties["ShipHawb"] as string : ""; var MoveType = Application.Current.Properties.ContainsKey("ShipMtype") ? Application.Current.Properties["ShipMtype"] as string : ""; var ServiceDate = Application.Current.Properties.ContainsKey("ShipDate") ? Application.Current.Properties["ShipDate"] as string : ""; var username = ""; var CompanyId = ""; var InviteCode = ""; var Url = ""; var RefNo = ""; var DGargo = swtich.IsToggled ? "Y" : "N"; var resp = Application.Current.Properties.ContainsKey("LoadResponse") ? Application.Current.Properties["LoadResponse"] as string : ""; SD_RootObject response = JsonConvert.DeserializeObject <SD_RootObject>(resp); string RDGargo = ""; foreach (var a in response.Details) { RDGargo = a.DCargo; RefNo = a.RefNo; } if (DGargo.ToLower() == RDGargo.ToLower()) { return; } if (inprogress.ToLower() != "y") { if (swtich.IsToggled) { swtich.IsToggled = false; } else { swtich.IsToggled = true; } await DisplayAlert("", "This shipment is not In-progress, cannot save any updates.", "OK"); return; } var customer = from s in App.SqlLiteCon().Table <Customer>() select s; foreach (var c in customer) { username = c.UserId; InviteCode = c.XCode; CompanyId = c.CompanyID; Url = c.TransactURL; break; } var UCresp = App.SOAP_Request.UpdateDCargo(RefNo, HAWB, DGargo, username.Trim(), CompanyId, InviteCode, Url); Cargo_RootObject Btnshipresponse = JsonConvert.DeserializeObject <Cargo_RootObject>(UCresp); if (Btnshipresponse.Details[0].Message.ToLower().Contains("ok")) { // await DisplayAlert("", "Notes Updated.", "OK"); var updresp = App.SOAP_Request.LoadDetails(HAWB, username.Trim(), MoveType, InviteCode, CompanyId, Url); Application.Current.Properties["LoadResponse"] = updresp; } else { // await DisplayAlert("", "Notes could not be Updated.", "OK"); if (swtich.IsToggled) { swtich.IsToggled = false; } else { swtich.IsToggled = true; } } } catch (Exception ex) { await DisplayAlert("", ex.Message, "OK"); } }
public async void loadimg() { try { var inprogress = Application.Current.Properties.ContainsKey("inProgess") ? Application.Current.Properties["inProgess"] as string : ""; if (inprogress.ToLower() != "y") { await DisplayAlert("", "This shipment is not In-progress, cannot save any updates.", "OK"); return; } await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await DisplayAlert("No Camera", ":( No camera available.", "OK"); return; } var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { Directory = "uploadImage", SaveToAlbum = false, CompressionQuality = 75, CustomPhotoSize = 50, PhotoSize = PhotoSize.MaxWidthHeight, SaveMetaData = false, MaxWidthHeight = 2000, DefaultCamera = CameraDevice.Rear }); if (file == null) { return; } string imgBase64String = GetBase64StringForImage(file.Path); try { string OriginalFilePath = file.Path; file.Dispose(); if (File.Exists(OriginalFilePath)) { System.IO.File.Delete(OriginalFilePath); } } catch (Exception ex) { await DisplayAlert("", ex.Message, "OK"); } var HAWB = Application.Current.Properties.ContainsKey("ShipHawb") ? Application.Current.Properties["ShipHawb"] as string : ""; var MoveType = Application.Current.Properties.ContainsKey("ShipMtype") ? Application.Current.Properties["ShipMtype"] as string : ""; var ServiceDate = Application.Current.Properties.ContainsKey("ShipDate") ? Application.Current.Properties["ShipDate"] as string : ""; var customer = from s in App.SqlLiteCon().Table <Customer>() select s; var username = ""; var CompanyId = ""; var InviteCode = ""; var Url = ""; var DGargo = ""; var RefNo = ""; foreach (var c in customer) { username = c.UserId; InviteCode = c.XCode; CompanyId = c.CompanyID; Url = c.TransactURL; break; } var resp = Application.Current.Properties.ContainsKey("LoadResponse") ? Application.Current.Properties["LoadResponse"] as string : ""; SD_RootObject response = JsonConvert.DeserializeObject <SD_RootObject>(resp); foreach (var a in response.Details) { DGargo = a.DCargo; RefNo = a.RefNo; } var UCIresp = App.SOAP_Request.Uploadimgs(RefNo, HAWB, imgBase64String, username.Trim(), CompanyId, InviteCode, Url); Cargo_RootObject Btnshipresponse = JsonConvert.DeserializeObject <Cargo_RootObject>(UCIresp); if (Btnshipresponse.Details[0].Message.ToLower().Contains("ok")) { if (Btnshipresponse.Details[0].Count != "0") { //lbltkpicno.Text = "Total Files Uploaded (" + Btnshipresponse.Details[0].Count + ")"; await Navigation.PushAsync(new ShipmentDetails(HAWB, MoveType, ServiceDate)); } } } catch (Exception ex) { await DisplayAlert("", ex.Message, "OK"); } }
private async void Btnsave_Clicked(object sender, EventArgs e) { try { var note = notes.Text.Trim(); var HAWB = Application.Current.Properties.ContainsKey("carHAWB") ? Application.Current.Properties["carHAWB"] as string : ""; var MoveType = Application.Current.Properties.ContainsKey("carMoveType") ? Application.Current.Properties["carMoveType"] as string : ""; var ServiceDate = Application.Current.Properties.ContainsKey("carManifestNo") ? Application.Current.Properties["carManifestNo"] as string : ""; var inprogress = Application.Current.Properties.ContainsKey("inProgess") ? Application.Current.Properties["inProgess"] as string : ""; var customer = from s in App.SqlLiteCon().Table <Customer>() select s; var username = ""; var CompanyId = ""; var InviteCode = ""; var Url = ""; var DGargo = ""; var RefNo = ""; foreach (var c in customer) { username = c.UserId; InviteCode = c.XCode; CompanyId = c.CompanyID; Url = c.TransactURL; break; } var resp = Application.Current.Properties.ContainsKey("LoadResponse") ? Application.Current.Properties["LoadResponse"] as string : ""; SD_RootObject response = JsonConvert.DeserializeObject <SD_RootObject>(resp); foreach (var a in response.Details) { DGargo = a.DCargo; RefNo = a.RefNo; } if (inprogress.ToLower() != "y") { await DisplayAlert("", "This shipment is not In-progress, cannot save any updates.", "OK"); return; } if (!String.IsNullOrEmpty(note)) { var UCresp = App.SOAP_Request.UpdateDCargoNotes(RefNo, HAWB, note, username.Trim(), CompanyId, InviteCode, Url); Cargo_RootObject Btnshipresponse = JsonConvert.DeserializeObject <Cargo_RootObject>(UCresp); if (Btnshipresponse.Details[0].Message.ToLower().Contains("ok")) { await DisplayAlert("", "Notes Updated.", "OK"); } else { await DisplayAlert("", "Notes could not be Updated.", "OK"); } } List <string> ISL = new List <string>(); if (Application.Current.Properties.ContainsKey("ImageStramList")) { ISL = Application.Current.Properties["ImageStramList"] as List <string>; } string imgcount = ISL.Count.ToString(); foreach (var val in ISL) { var UCIresp = App.SOAP_Request.Uploadimgs(RefNo, HAWB, val, username.Trim(), CompanyId, InviteCode, Url); Cargo_RootObject Btnshipresp = JsonConvert.DeserializeObject <Cargo_RootObject>(UCIresp); if (Btnshipresp.Details[0].Message.ToLower().Contains("ok")) { if (Btnshipresp.Details[0].Count != "0") { lbltkpicno.Text = "Total Files Uploaded (" + Btnshipresp.Details[0].Count + ")"; } } } Application.Current.Properties.Remove("ImageStramList"); } catch (Exception ex) { await DisplayAlert("", ex.Message, "OK"); } }