private async void loadPersonsAndCheckEnquiry() { Persons.Clear(); ObservableCollection <Person> persons = await AzureDatabaseService.GetPersonList(PatientId); foreach (Person person in persons) { Persons.Add(person); } //Check the unfinished Stranger Warning Enquiry unfinishedWarningList = await AzureDatabaseService.GetUnfinishedWarningList(PatientId); if (unfinishedWarningList.Count > 0) { WarningImage.Visibility = Visibility.Visible; } }
private async void testInternetConnection() { //Test Internet Connection try { //showProgressDialog("Checking the Internet Connection..."); //progressDialog.Title = "Processing: "; //progressDialog.PrimaryButtonText = "Ok"; statusTextBlock.Text = "Checking the Internet Connection..."; Persons.Clear(); ObservableCollection <Person> persons = await AzureDatabaseService.GetPersonList(PatientId); foreach (Person person in persons) { Persons.Add(person); } //Check the unfinished Stranger Warning Enquiry unfinishedWarningList = await AzureDatabaseService.GetUnfinishedWarningList(PatientId); if (unfinishedWarningList.Count > 0) { WarningImage.Visibility = Visibility.Visible; } } catch (System.Net.Http.HttpRequestException) { internetConnection = false; statusTextBlock.Text = " "; showProgressDialog("Internet Connection Error! Please check your Internet connection."); progressDialog.Title = "Internet Connection Error!"; progressDialog.PrimaryButtonText = "Ok, I know"; progressDialog.IsPrimaryButtonEnabled = true; await progressDialog.ShowAsync(); return; //Test Internet Connection Again //testInternetConnection(); } //Set up the timer to check Stranger Warning Enquiry CheckEnquiryTimer = ThreadPoolTimer.CreatePeriodicTimer(async(source) => { //t++; //for testing //Check the unfinished Stranger Warning Enquiry unfinishedWarningList = await AzureDatabaseService.GetUnfinishedWarningList(PatientId); // Update the UI thread by using the UI core dispatcher. await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { //testTextBlock.Text = t.ToString(); //for testing if (unfinishedWarningList.Count > 0) { WarningImage.Visibility = Visibility.Visible; } }); }, checkEnquiryTimeSpan); internetConnection = true; statusTextBlock.Text = "Internet Connection Success!"; //progressDialog.Content = "Internet Connection Success!"; //progressDialog.IsPrimaryButtonEnabled = true; return; }
/// <summary> /// Test Internet Connection and Load Persons and Faces /// </summary> private async void testInternetConnection() { //Test Internet Connection try { showProgressDialog("Checking the Internet Connection and Loading the data..."); progressDialog.Title = "Processing: "; progressDialog.PrimaryButtonText = "Ok"; //statusTextBlock.Text = "Checking the Internet Connection..."; //Get Person List for this patient Persons.Clear(); ObservableCollection <Person> persons = await AzureDatabaseService.GetPersonList(PatientId); //statusTextBlock.Text = persons.Count + " Persons: "; //Clear Local User Folder StorageFolder userFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(("Users\\"), CreationCollisionOption.OpenIfExists); await userFolder.DeleteAsync(); userFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(("Users\\"), CreationCollisionOption.OpenIfExists); //Perform initialization for facial detection. await FacialSimilarity.TrainDetectionAsync(); //Download each person foreach (Person person in persons) { //Update Info person.DefaultIcon = await AzureBlobService.DisplayImageFile(person.DefaultImageAddress); Persons.Add(person); //Get Face List for each person ObservableCollection <Face> faces = await AzureDatabaseService.GetFaceList(person.Id); foreach (Face face in faces) { face.Image = await AzureBlobService.DisplayImageFile(face.ImageAddress); } Faces.Add(faces); AddNewPersonFromDB(person, faces); //statusTextBlock.Text += faces.Count + " faces "; } } catch (System.Net.Http.HttpRequestException) { internetConnection = false; //statusTextBlock.Text = " "; //showProgressDialog("Internet Connection Error! Please check your Internet connection."); progressDialog.Title = "Internet Connection Error!"; progressDialog.PrimaryButtonText = "Ok, I know"; progressDialog.IsPrimaryButtonEnabled = true; //await progressDialog.ShowAsync(); return; //Test Internet Connection Again //testInternetConnection(); } internetConnection = true; //statusTextBlock.Text = "Internet Connection Success!"; progressDialog.Content = "Success!"; progressDialog.IsPrimaryButtonEnabled = true; return; }