/// <summary> /// Login by email and password /// </summary> /// <param name="emil">User email</param> /// <param name="password">User password</param> private async Task <int> LoginUserForId(string email, string password) { bool regexCheck = Regex.IsMatch(email, @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$", RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)); if (regexCheck) { wrongInputLbl.Visibility = Visibility.Hidden; //email = Uri.EscapeDataString(email); try { string loginData = await ApiConnection.AppLoginApiAsync(email, password); _currentPatient = JSONConvertor.CreatePatient(loginData); return(_currentPatient != null ? 1 : 0); } catch (HttpRequestException httpE) { return(2); } } wrongInputLbl.Visibility = Visibility.Visible; return(0); }
private async void DownloadCurrentGDB(Exercise exercise, int key, Barrier downloadTrainingBarrier) { Console.WriteLine("S => Exercise id {0}, key = {1}, start at {2}", exercise.ExerciseId, key, DateTime.Now.ToString("hh:MM:ss.fff")); string json = await ApiConnection.GetExerciseGesturesApiAsync(exercise.ExerciseId); JSONConvertor.GettingExerciseGesture(exercise, json); using (DownloadCache dc = new DownloadCache(_currentPatient)) { dc.DownloadGDBfile(exercise); exercise.Downloaded = true; } if (key == FIRST_EXERCISE) //use for the first gdb - that exercise window can be upload (after splash) { finishFirstGDBSemaphore.Release(); } foreach (var item in _currentTraining.Playlist[key]) { if (!item.isDemo && !item.Equals(exercise)) { item.DBPath = exercise.DBPath; item.CopyGesturesFromOrigin(exercise); item.Downloaded = true; } } Console.WriteLine("F => Exercise id {0}, key = {1}, finish at {2}", exercise.ExerciseId, key, DateTime.Now.ToString("hh:MM:ss.fff")); downloadTrainingBarrier.SignalAndWait(); }
private async void CloseExeciseView() { Task clearData = new Task(async() => { CurrentTraining.ClearTrainingData(); string response = await ApiConnection.GetTrainingApiAsync(CurrentTraining.TrainingId); JSONConvertor.GettingPatientTraining2(CurrentTraining, response); }); clearData.Start(); GoBackToTreatmentScreen(CurrentPatient); }
/// <summary> /// Retrive trainings detail from server (such id, all exercises list and etc.) /// </summary> private async void RetriveTrainingDetails() { try { //await _semaphoreSlime.WaitAsync(); if (!isErrorAccure) { Barrier barrier = new Barrier(_currentPatient.PatientTreatment.TrainingList.Count + 1); //downloading all the trainings data in the current treatment foreach (Training training in _currentPatient.PatientTreatment.TrainingList) { Task t = new Task(async() => { string trainingData = await ApiConnection.GetTrainingApiAsync(training.TrainingId); JSONConvertor.GettingPatientTraining2(training, trainingData); barrier.SignalAndWait(); }); t.Start(); } barrier.SignalAndWait(); //downloading current images for treatment screen using (DownloadCache _downloadCache = new DownloadCache(_currentPatient)) { _downloadCache.DownloadAllTreatmentImages(); } } } catch { //throw new Exception(); } finally { _semaphoreSlime.Release(); } }
/// <summary> /// Retrive patient details from server (such as name, age, gender, image and etc.) /// </summary> private async void RetrivePatientDetails() { try { // await _semaphoreSlime.WaitAsync(); if (!isErrorAccure) { string userData = await ApiConnection.GetUserDataApiAsync(_currentPatient.AccountId, ApiConnection.PATIENT_LEVEL); JSONConvertor.GettingPatientData(_currentPatient, userData); } } catch { return; } finally { _semaphoreSlime.Release(); } }
/// <summary> /// Retrive treatment details from server (such id, start date, therapsit id, list of training and etc.) /// </summary> private async void RetriveTreatmentDetails() { try { //await _semaphoreSlime.WaitAsync(); if (!isErrorAccure) { //string treatmentData = await ApiConnection.GetTreatmentApiAsync(_currentPatient.PatientTreatment.TreatmentId); string userTreatmentsData = await ApiConnection.GetTreatmentByUserApiAsync(_currentPatient.AccountId); JSONConvertor.GettingPatientTreatment(_currentPatient, userTreatmentsData); } } catch { //throw new Exception(); } finally { _semaphoreSlime.Release(); } }
/// <summary> /// Retrive therapist detail from server (such id, name, image and etc.) /// </summary> private async void RetriveTherapistDetails() { try { //await _semaphoreSlime.WaitAsync(); if (!isErrorAccure) { string therapistData = await ApiConnection.GetUserDataApiAsync(_currentPatient.PatientTreatment.TreatmentTherapist.AccountId, ApiConnection.THERAPIST_LEVEL); JSONConvertor.GettingTherapistData(_currentPatient.PatientTreatment.TreatmentTherapist, therapistData); _currentPatient.PatientTreatment.TreatmentTherapist.StartDate = _currentPatient.PatientTreatment.StartDate; } } catch { // throw new Exception(); } finally { _semaphoreSlime.Release(); } }