private async void LoadActivityData(DateTime From, DateTime To) { System.Diagnostics.Debug.WriteLine("From : " + string.Format("{0:yy-MM-dd}", From) + " To : " + string.Format("{0:yy-MM-dd}", To)); if (CrossConnectivity.Current.IsConnected) { try { activityIndicator.IsVisible = true; activityIndicator.IsRunning = true; System.Diagnostics.Debug.WriteLine("MyActivity API Call Start Time : " + DateTime.Now + " Milisecond : " + DateTime.Now.Millisecond); APIServices.ApiServices apiServices = new APIServices.ApiServices(); List <ActivityModel> lstActivityModel = await apiServices.GetActivityModelData(dpTo.Date, dpFrom.Date, CrossSettings.Current.GetValueOrDefault <string>("Token", "")); System.Diagnostics.Debug.WriteLine("MyActivity API Call Over Time : " + DateTime.Now + " Milisecond : " + DateTime.Now.Millisecond); AddActivityData(lstActivityModel); } catch (Exception pException) { await DisplayAlert("Searching Failed!", pException.Message, "Ok"); System.Diagnostics.Debug.WriteLine("Search Page : Exception : " + pException.Message); } finally { activityIndicator.IsVisible = false; activityIndicator.IsRunning = false; GC.Collect(); } } else { lblErrorMsg.Text = "Internet connection not available."; lblErrorMsg.IsVisible = true; } }
private async void LoadActivityData() { try { activityIndicator.IsVisible = true; activityIndicator.IsRunning = true; System.Diagnostics.Debug.WriteLine("MyReports DB Call Start Time : " + DateTime.Now + " Milisecond : " + DateTime.Now.Millisecond); APIServices.ApiServices apiServices = new APIServices.ApiServices(); List <InspectorsModel> inspectorsModel = await apiServices.GetInspectors(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); System.Diagnostics.Debug.WriteLine("MyReports DB Call Over Time : " + DateTime.Now + " Milisecond : " + DateTime.Now.Millisecond); UpdateInpectors(inspectorsModel); } catch (Exception pException) { await DisplayAlert("Searching Failed!", pException.Message, "Ok"); System.Diagnostics.Debug.WriteLine("Search Page : Exception : " + pException.Message); } finally { activityIndicator.IsVisible = false; activityIndicator.IsRunning = false; GC.Collect(); } }
private async void LoginWidthCard(NfcFormsTag message) { String CardCert = ByteArrayToString(message.Id); if (!String.IsNullOrEmpty(CardCert)) { if (CrossConnectivity.Current.IsConnected) { try { lblCard.Text = ""; AddProgressBar(); APIServices.ApiServices apiServices = new APIServices.ApiServices(); LoginResult result = await apiServices.LoginCardAsync(CardCert); if (result != null) { if (result.AuthStatus) { CrossSettings.Current.AddOrUpdateValue <bool>("IsLoggedIn", true); CrossSettings.Current.AddOrUpdateValue <string>("Token", result.Token); var navigation = new NavigationPage(new Dashboard()); navigation.BarBackgroundColor = Color.FromHex(App.Black); navigation.BarTextColor = Color.White; App.Current.MainPage = navigation; lblCard.Text = ""; } else { await DisplayAlert("Login Failed!", result.Message, "Ok"); lblCard.Text = CardCert; } } } catch (Exception pException) { await DisplayAlert("Login Failed!", pException.Message, "Ok"); System.Diagnostics.Debug.WriteLine("Exception : " + pException.Message); } finally { RemoveProgressBar(); } } else { await DisplayAlert("Login", "Internet Connection Not Available.", "Ok"); } } else { await DisplayAlert("Login Failed!", "Username and Password can not be empty", "Ok"); } }
void ScanPage_OnScanResult(ZXing.Result result) { scanPage.IsScanning = false; // Pop the page and show the result Device.BeginInvokeOnMainThread(async() => { await Navigation.PopAsync(); System.Diagnostics.Debug.WriteLine("Barcode Value : " + result.Text); //await Navigation.PushAsync(new DetailPage(result.Text)); if (CrossConnectivity.Current.IsConnected) { try { String block_number = result.Text; txtSearch.Text = block_number; activityIndicator.IsVisible = true; activityIndicator.IsRunning = true; btnBarcode.IsEnabled = false; System.Diagnostics.Debug.WriteLine("Search Page API Call Start Time : " + DateTime.Now + " Milisecond : " + DateTime.Now.Millisecond); APIServices.ApiServices apiServices = new APIServices.ApiServices(); List <TicketBlockModel> ticketsModel = await apiServices.AddTicketBlocksAsync(block_number, CrossSettings.Current.GetValueOrDefault <string>("Token", "")); System.Diagnostics.Debug.WriteLine("Search Page API Call Over Time : " + DateTime.Now + " Milisecond : " + DateTime.Now.Millisecond); CheckResult(block_number, ticketsModel); AddDataInList(ticketsModel); } catch (Exception pException) { await DisplayAlert("Searching Failed by Barcode!", pException.Message, "Ok"); System.Diagnostics.Debug.WriteLine("Search Page : Exception : " + pException.Message); } finally { activityIndicator.IsVisible = false; activityIndicator.IsRunning = false; btnBarcode.IsEnabled = true; GC.Collect(); } } else { lblErrorMsg.Text = "Internet connection not available."; lblErrorMsg.IsVisible = true; lblErrorMsg.TextColor = Color.Red; } }); }
void ScanPage_OnScanResult(ZXing.Result result) { scanPage.IsScanning = false; // Pop the page and show the result Device.BeginInvokeOnMainThread(async() => { await Navigation.PopAsync(); System.Diagnostics.Debug.WriteLine("Barcode Value : " + result.Text); String code = result.Text; //"21908" //await Navigation.PushAsync(new DetailPage(result.Text)); if (CrossConnectivity.Current.IsConnected) { try { activityIndicator.IsVisible = true; activityIndicator.IsRunning = true; btnSearch.IsEnabled = false; btnBarcode.IsEnabled = false; APIServices.ApiServices apiServices = new APIServices.ApiServices(); List <UsersModel> usersModel = await apiServices.GetTicketsByBarcodeAsync2(code, CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AddDataInList(usersModel); } catch (Exception pException) { await DisplayAlert("Searching Failed by Barcode!", pException.Message, "Ok"); System.Diagnostics.Debug.WriteLine("Search Page : Exception : " + pException.Message); } finally { //activityIndicator.IsVisible = false; activityIndicator.IsRunning = false; btnBarcode.IsEnabled = true; btnSearch.IsEnabled = true; GC.Collect(); } } else { lblErrorMsg.Text = "Internet connection not available."; lblErrorMsg.IsVisible = true; } }); }
private async void BtnSearch_Clicked(object sender, EventArgs e) { if (CrossConnectivity.Current.IsConnected) { try { activityIndicator.IsVisible = true; activityIndicator.IsRunning = true; btnSearch.IsEnabled = false; btnBarcode.IsEnabled = false; System.Diagnostics.Debug.WriteLine("Search Page API Call Start Time : " + DateTime.Now + " Milisecond : " + DateTime.Now.Millisecond); APIServices.ApiServices apiServices = new APIServices.ApiServices(); List <UsersModel> usersModel = await apiServices.SearchAsync(txtSearch.Text, CrossSettings.Current.GetValueOrDefault <string>("Token", "")); System.Diagnostics.Debug.WriteLine("Search Page API Call Over Time : " + DateTime.Now + " Milisecond : " + DateTime.Now.Millisecond); activityIndicator.IsVisible = false; AddDataInList(usersModel); } catch (Exception pException) { await DisplayAlert("Searching Failed!", pException.Message, "Ok"); System.Diagnostics.Debug.WriteLine("Search Page : Exception : " + pException.Message); } finally { //activityIndicator.IsVisible = false; activityIndicator.IsRunning = false; btnBarcode.IsEnabled = true; btnSearch.IsEnabled = true; GC.Collect(); } } else { lblErrorMsg.Text = "Internet connection not available."; lblErrorMsg.IsVisible = true; } }
private async void SyncData() { try { activityIndicator.IsVisible = true; activityIndicator.IsRunning = true; System.Diagnostics.Debug.WriteLine("Sync DB Call Start Time : " + DateTime.Now + " Milisecond : " + DateTime.Now.Millisecond); APIServices.ApiServices apiServices = new APIServices.ApiServices(); AppendLog(string.Empty, false); APIServices.ApiServices.ApiReadWay apiReadWay = APIServices.ApiServices.ApiReadWay.NormalJSon; if (Device.RuntimePlatform == Device.iOS) { apiReadWay = APIServices.ApiServices.ApiReadWay.HugeJson; } List <StopTimesModel> stopTimes = await apiServices.GetStopTimes(CrossSettings.Current.GetValueOrDefault <string>("Token", ""), apiReadWay); AppendLog("Orari: " + stopTimes.Count.ToString()); UpdateStopTimes(stopTimes); stopTimes = null; GC.Collect(); List <TripsModel> trips = await apiServices.GetTrips(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AppendLog("Corse: " + trips.Count.ToString()); UpdateTrips(trips); trips = null; GC.Collect(); List <StopsModel> stops = await apiServices.GetStops(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AppendLog("Fermate: " + stops.Count.ToString()); UpdateStops(stops); stops = null; GC.Collect(); List <CalendarDatesModel> calendarDates = await apiServices.GetCalendarDates(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AppendLog("Calendario: " + calendarDates.Count.ToString()); UpdateCalendarDates(calendarDates); calendarDates = null; GC.Collect(); List <AreasModel> areas = await apiServices.GetAreas(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AppendLog("Aree: " + areas.Count.ToString()); UpdateAreas(areas); List <LinesModel> lines = await apiServices.GetLines(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AppendLog("Linee: " + lines.Count.ToString()); UpdateLines(lines); List <GeoCountriesModel> countries = await apiServices.GetGeoCountries(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AppendLog("Nazioni: " + countries.Count.ToString()); UpdateCountries(countries); List <GeoProvinceITModel> provinces = await apiServices.GetGeoProvinceIT(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AppendLog("Province: " + provinces.Count.ToString()); UpdateProvinces(provinces); List <GeoComuniITModel> cities = await apiServices.GetGeoComuniIT(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AppendLog("Città : " + cities.Count.ToString()); UpdateCities(cities); List <TipoDocumentoModel> documents = await apiServices.GetTipoDocumento(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AppendLog("Tipi Documenti: " + documents.Count.ToString()); UpdateDocumentTypes(documents); List <TipoTitoloEvasoModel> ticketViolations = await apiServices.GetTipoTitoloEvaso(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AppendLog("Tipi Violazioni: " + ticketViolations.Count.ToString()); UpdateTicketViolations(ticketViolations); List <MotiviSanzioniModel> violations = await apiServices.GetMotiviSanzioni(CrossSettings.Current.GetValueOrDefault <string>("Token", "")); AppendLog("Violazioni: " + violations.Count.ToString()); UpdateViolations(violations); System.Diagnostics.Debug.WriteLine("Sync DB Call Over Time : " + DateTime.Now + " Milisecond : " + DateTime.Now.Millisecond); } catch (Exception pException) { await DisplayAlert("Sincronizzazione fallita!", pException.Message, "Ok"); AppendLog(pException.Message, false); System.Diagnostics.Debug.WriteLine("SyncData : Exception : " + pException.Message); } finally { activityIndicator.IsVisible = false; activityIndicator.IsRunning = false; GC.Collect(); } }