public App() { InitializeComponent(); //For https connexion System.Net.ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true; //Read config file to load server URL ApplicationConstants.ReadConfigFile(); //Load and send json which were not sended to server Task.Run(() => { try { EvaluationSender.LoadJsons(); EvaluationSender.SendJsonEvalToServer(); } catch (Exception e) { Console.WriteLine(e.ToString()); } }); //Display the first Page of the app (MainPage => LoginPage) MainPage = new NavigationPage(new Onek.MainPage()); }
protected override void OnSleep() { // Handle when your app sleeps //Load and send json which were not sended to server Task.Run(() => { try { EvaluationSender.LoadJsons(); EvaluationSender.SendJsonEvalToServer(); } catch (Exception) { } }); }
/// <summary> /// Save the evaluation and add signature if needed and if asked /// </summary> /// <param name="signature">Boolean, true if the user has clicked on sign button</param> async void SaveEvaluation(Boolean signature) { if (signature && Eval.Criterias.All(c => !c.SelectedLevel.Equals("")) && !Eval.IsSigned) { ComeBackSigning = true; await Navigation.PushAsync(new SigningPage(Eval, CurrentCandidate)); } Eval.LastUpdatedDate = DateTime.Now; String jsonEval = JsonParser.GenerateJsonEval(Eval); JsonParser.WriteJsonInInternalMemory(jsonEval, CurrentCandidate.Id, LoggedUser.Id, CurrentEvent.Id); foreach (Criteria c in Eval.Criterias) { c.IsModified = false; } Eval.IsModified = false; int index = CandidateList.IndexOf(CandidateList.Where(x => x.Id == CurrentCandidate.Id).First()); CandidateList[index] = CurrentCandidate; CurrentCandidate.CheckStatus(); ChangeStatusImage(); if (Eval.Criterias.All(c => !c.SelectedLevel.Equals(""))) { ButtonSigner.IsEnabled = true; } else { ButtonSigner.IsEnabled = false; } await Task.Run(() => { Device.BeginInvokeOnMainThread(() => { ButtonEnregister.IsEnabled = false; }); EvaluationSender.AddEvaluationInQueue(jsonEval); EvaluationSender.SendJsonEvalToServer(); Device.BeginInvokeOnMainThread(() => { ButtonEnregister.IsEnabled = true; }); }); }
/// <summary> /// Called when user clicks on disconnect button, redirect to login page /// </summary> /// <param name="sender"></param> /// <param name="e"></param> async void OnButtonDeconnexionClicked(object sender, EventArgs e) { bool answer = await DisplayAlert("Deconnexion", "Voulez-vous vraiment vous deconnecter ?", "Oui", "Non"); if (answer) { if (CrossConnectivity.Current.IsConnected) { //Load and send json which were not sended to server Task.Run(() => { try { EvaluationSender.LoadJsons(); EvaluationSender.SendJsonEvalToServer(); } catch (Exception) { } }); } await Navigation.PopAsync(); } }