public async void BarCodeScan(object sender, EventArgs e) { try { var scanPage = new ZXingScannerPage(); await Navigation.PushAsync(scanPage); scanPage.OnScanResult += (result) => { Device.BeginInvokeOnMainThread(async() => { var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, ControllerUtil.addJobURL(result.Text), this); clsResponse jsonResponse = JsonConvert.DeserializeObject <clsResponse>(content); if (jsonResponse.IsGood) { GetJobList(); //Ultis.Settings.UpdatedRecord = "Yes"; displayToast("Job added to job list."); scanPage.ResumeAnalysis(); } else { var answer = await DisplayAlert("Error", jsonResponse.Message, "OK", "Cancel"); if (answer.Equals(true)) { scanPage.ResumeAnalysis(); } else { await Navigation.PopAsync(); } } }); }; } catch { await DisplayAlert("Error", "Please try again later", "OK"); } }
//icon in screen and decide what to do by check the call uri async void IconTapped(object sender, EventArgs e) { loading.IsVisible = true; try { if (menuItems.Id == "FuelCost") { await Navigation.PushAsync(new RefuelEntry(menuItems.Name)); } else if (menuItems.Id == "LogBook") { await Navigation.PushAsync(new LogEntry("", menuItems.Name)); } else { var scanPage = new ZXingScannerPage(); await Navigation.PushAsync(scanPage); scanPage.OnScanResult += (result) => { Device.BeginInvokeOnMainThread(async() => { if (menuItems.Id == "JobList" && Ultis.Settings.App == "asolute.Mobile.AILSHaulage") { scanPage.PauseAnalysis(); var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, ControllerUtil.addJobURL(result.Text), this); clsResponse response = JsonConvert.DeserializeObject <clsResponse>(content); if (response.IsGood) { Ultis.Settings.RefreshListView = "Yes"; GetListData(); displayToast("Job added to job list."); } scanPage.ResumeAnalysis(); } else { await Navigation.PopAsync(); searchBar.Text = result.Text; } }); }; } loading.IsVisible = false; } catch (Exception ex) { await DisplayAlert("Error", ex.Message, "OK"); } }
async void ScanBarCode() { try { dataGrid.IsVisible = false; dataGrid.ItemsSource = null; var scanPage = new ZXingScannerPage(); await Navigation.PushAsync(scanPage); scanPage.OnScanResult += (result) => { scanPage.PauseAnalysis(); TallyOut(result.Text); scanPage.ResumeAnalysis(); }; } catch { } }