Ejemplo n.º 1
0
        private async Task BtnLogin_Clicked(object source, EventArgs e)
        {
            sd.ShowSpinner();

            // On sort du hors connexion
            Global.SetSettings(TypeSettings.IsHorsConnexion, false);
            //Global.SetSettings(TypeSettings.LastHorsConnexionDate, null);

            // Tentative de login
            bool isOk = await Login(TxtLogin.Text, TxtPassword.Text, TxtSlot.Text);

            // Si Ok : on passe à la liste
            if (isOk)
            {
                // Puisqu'on a du réseau, on en profite pour envoyer les invitations créées en local
                if (!string.IsNullOrEmpty(this.token))
                {
                    var validateService = new ValidatePresenceService(this.token, true);
                    if (await validateService.SendAll())
                    {
                        // Pour l'instant, on ne fait rien du retour...
                        await this.DisplayAlert("Information", "Les modifications faites en Hors Connexion viennent d'être exportées.", "OK");
                    }
                }

                // La navigation
                var listEventsPage = new ListEventsPage();

                await Navigation.PushAsync(listEventsPage);

                //Application.Current.MainPage = new NavigationPage(listEventsPage);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// TODO
        /// </summary>
        /// <param name="paramA09">Parameter a09.</param>
        private async Task SendPresenceAck(string paramA09) //, int? idPrestation)
        {
            int idParticipant;

            if (!int.TryParse(paramA09, out idParticipant))
            {
                //await this.ShowAlert("Attention", "Problème de lecture du QR Code.");
                await this.DisplayAlert("Attention", "Problème de lecture du QR Code.", "Cancel");

                return;
            }

            // On appelle le WS pour signifier la présence
            // On passe par validateService
            // On prépare la validation de la présence
            var validateService = new ValidatePresenceService(this.Token);

            // On ajoute la ligne à valider
            var validate = validateService.AddNewPresence(idParticipant, this.idPrestation, true);

            // On déclenche l'envoi au WS (si besoin)
            if (validate != null)
            {
                // On envoie uniquement en cas de connexion
                if (!Global.GetSettingsBool(TypeSettings.IsHorsConnexion))
                {
                    //await validateService.SendAll();
                    // Attention : si participant déjà enregistré : erreur 403
                    try
                    {
                        await validateService.Send(validate);

                        await this.DisplayAlert("OK", "Le billet est validé.", "OK");
                    }
                    catch (WebException ex)
                    {
                        HttpWebResponse objresponse = ex.Response as HttpWebResponse;
                        if (objresponse.StatusCode == HttpStatusCode.Forbidden)
                        {
                            // 403 : le participant a déjà été enregistré aujourd'hui
                            // Message d'erreur
                            await this.DisplayAlert("Attention", "Le billet a déjà été enregistré, le numéro du billet a déjà été scanné auparavant.", "OK");

                            return;
                        }
                        else if (objresponse.StatusCode == HttpStatusCode.NotFound)
                        {
                            // 404 : billet non valide
                            await this.DisplayAlert("Attention", "Le billet n'est pas valide.", "Cancel");

                            return;
                        }
                        else if (objresponse.StatusCode == HttpStatusCode.Unauthorized)
                        {
                            // 401 : impossible d'identifier le numéro du billet
                            await this.DisplayAlert("Attention", "Impossible d'identifier le numéro du billet, veuillez vérifier les informations de celui ci.", "Cancel");

                            return;
                        }
                    }
                    catch (Exception e) {
                        // Erreur
                        await this.DisplayAlert("Attention", e.Message, "Cancel");

                        return;
                    }
                }
                else
                {
                    // Hors connexion : on vérifie juste si l'utilisateur n'est pas déjà présent dans la table SQL

                    // Attention : si pas de prestation : on a le droit d'enregistrer plusieurs fois la présence
                    // Si il y a une prestation, en revanche, on doit vérifier qu'il n'est pas déjà inscrit

                    if (validate.IdPrestation.HasValue &&
                        validateService.IsInscriptionAlreadyRecorded(validate))
                    {
                        // Déjà trouvé : message d'erreur
                        await this.DisplayAlert("Attention", "Le participant a déjà été enregistré.", "OK");

                        return;
                    }
                }
            }
            else
            {
                // Pb à l'insertion des données ??
            }


            return;
        }
Ejemplo n.º 3
0
        private async Task BtnValidateClicked(object sender, EventArgs e)
        {
            // On prépare la validation de la présence
            var validateService = new ValidatePresenceService(this.Token);

            // On ajoute la ligne à valider
            var validate = validateService.AddNewPresence(this.idParticipant, this.idPrestation);

            // On déclenche l'envoi au WS (si besoin)
            if (validate != null)
            {
                // On envoie uniquement en cas de connexion
                if (!Global.GetSettingsBool(TypeSettings.IsHorsConnexion))
                {
                    //await validateService.SendAll();
                    // Attention : si participant déjà enregistré : erreur 403
                    try
                    {
                        await validateService.Send(validate);
                    }
                    catch (WebException ex)
                    {
                        HttpWebResponse objresponse = ex.Response as HttpWebResponse;
                        if (objresponse.StatusCode == HttpStatusCode.Forbidden)
                        {
                            // 403 : le participant a déjà été enregistré aujourd'hui
                            // Message d'erreur
                            await this.DisplayAlert("Attention", "Le participant a déjà été enregistré aujourd'hui.", "OK");

                            return;
                        }
                        else if (objresponse.StatusCode == HttpStatusCode.Unauthorized)
                        {
                            // 401 : Votre session a expiré
                            await this.DisplayAlert("Attention", "Votre session a expiré, veuillez vous identifier à nouveau.", "Cancel");

                            return;
                        }
                        else if (objresponse.StatusCode == HttpStatusCode.NotFound)
                        {
                            // 404 : PArticipant pas sur la liste d'invités
                            await this.DisplayAlert("Attention", "Veuillez vérifier que le participant fait partie de la liste d'invités.", "Cancel");

                            return;
                        }
                        else
                        {
                            await this.DisplayAlert("Attention", "Erreur lors de la validation d'un invité en ligne.", "Cancel");

                            return;
                        }
                    }
                    catch (Exception ex2)
                    {
                        await this.DisplayAlert("Attention", "Erreur lors de la validation d'un invité en ligne : " + ex2.Message, "Cancel");

                        return;
                    }
                }
                else
                {
                    // Hors connexion : on vérifie juste si l'utilisateur n'est pas déjà présent dans la table SQL

                    // Attention : si pas de prestation : on a le droit d'enregistrer plusieurs fois la présence
                    // Si il y a une prestation, en revanche, on doit vérifier qu'il n'est pas déjà inscrit

                    if (validate.IdPrestation.HasValue &&
                        validateService.IsInscriptionAlreadyRecorded(validate))
                    {
                        // Déjà trouvé : message d'erreur
                        await this.DisplayAlert("Attention", "Le participant a déjà été enregistré.", "Cancel");


                        return;
                    }
                }

                // On marque dans la base la présence dans la table qui va bien (pour voir graphiquement que la présence a été enregistrée)
                validateService.ValidateSQLOnly(validate);
            } // else Afficher un lessage d'erreur ?

            // On réaffiche la liste des présences

            /*detailPeopleData.RefreshCells(this.idParticipant);
             * listView.ItemsSource = detailPeopleData.InscriptionsCells;
             * listView.ItemTemplate = new DataTemplate(typeof(InscriptionCell));*/

            // OK
            await this.DisplayAlert("OK", "Le participant a été correctement enregistré.", "OK");

            UserDialogs.ShowSpinner();
            // Affichage des données
            await displayData();

            UserDialogs.HideSpinner();
        }