protected override async void OnAppearing()
        {
            base.OnAppearing();

            // Suppression des anciens composnats
            DataLayout.Children.Clear();
            DataLayout.Children.Add(this.ListView);


            // Récupération des prestations pour l'événement
            if (prestations == null || prestations.Count == 0)
            {
                prestationsData = new ListPrestationsData(Token);

                // Récupération des instances et ge stion des erreurs réseau
                try
                {
                    prestations = await prestationsData.GetInstances(this.idEvent);
                }
                catch (Exception e)
                {
                    // Le message d'erreur
                    UserDialogs.HideSpinner();
                    await UserDialogs.ShowAlert("Erreur", e.Message);

                    return;
                }
            }

            // filtrage éventuel
            await FilterData();

            // Fin téléchargement
            UserDialogs.HideSpinner();
        }
        private async Task DownloadLists()
        {
            if (this.idEvent == -1)
                return;

            UserDialogs.ShowSpinner();
            var downloadData = new ImportBase();
            await downloadData.DownloadData(this.Token, this.idEvent);
            UserDialogs.HideSpinner();

            // Le message
            await this.UserDialogs.ShowAlert("OK", "Les listes ont été correctement téléchargées.");

        }
예제 #3
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            // Le bouton en bas
            // ------------------
            BtnValidate.Clicked += async(sender, e) =>
            {
                // Validation de la présence
                await BtnValidateClicked(sender, e);
            };

            // Affichage des données
            await displayData();

            UserDialogs.HideSpinner();
        }
예제 #4
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            // Suppression des anciens composnats
            DataLayout.Children.Clear();
            DataLayout.Children.Add(this.ListView);


            // Affichage de la liste des participants
            // --------------------------------------

            // Récupération des participants
            if (participants == null || participants.Count == 0)
            {
                peopleData = new ListPeopleData(Token);

                // Récupération des instances et ge stion des erreurs réseau
                try
                {
                    participants = await peopleData.GetInstances(this.idEvent, this.idPrestation);
                }
                catch (Exception e)
                {
                    // Le message d'erreur
                    UserDialogs.HideSpinner();
                    await UserDialogs.ShowAlert("Erreur", e.Message);

                    return;
                }
            }
            else
            {
                // On revient sur la page : il faut rafraichir depuis la base de données
                participants = await peopleData.RefreshFromSQL(this.idEvent, this.idPrestation);
            }

            // filtrage éventuel
            await FilterData();

            // Fin téléchargement
            UserDialogs.HideSpinner();
        }
예제 #5
0
        private async Task displayData()
        {
            // Récupération des participants
            detailPeopleData = new DetailPeopleData(Token);
            List <Participant> participants;

            // Récupération des instances et ge stion des erreurs réseau
            try
            {
                participants = await detailPeopleData.GetInstances(this.idEvent, this.idPrestation, this.idParticipant);
            }
            catch (Exception e)
            {
                // Le message d'erreur
                UserDialogs.HideSpinner();
                await UserDialogs.ShowAlert("Erreur", e.Message);

                return;
            }

            // On affiche le participant
            Participant participant = participants[0];

            FullName.Text  = participant.FirstName + " " + participant.LastName;
            Categorie.Text = participant.Category;
            Societe.Text   = participant.Company;
            Email.Text     = participant.Email;
            Telephone.Text = participant.Telephone;

            // On ajoute la liste des participations
            // La listeview a des lignes de hauteur différentes
            listView.HasUnevenRows = true;


            listView.ItemsSource  = detailPeopleData.InscriptionsCells;
            listView.ItemTemplate = new DataTemplate(typeof(InscriptionCell));
        }
예제 #6
0
        /// <summary>
        /// Vérification du login / password
        /// </summary>
        /// <returns>The login.</returns>
        /// <param name="login">Login.</param>
        /// <param name="password">Password.</param>
        /// <param name="code">Code.</param>
        public async Task <bool> Login(string login, string password, string slot)
        {
            // Creates HTTP web request
            string     url     = Global.GetUrlBase(slot) + Global.WS_LOGIN;
            WebRequest request = WebRequest.Create(new Uri(url)) as WebRequest;

            request.ContentType = "application/json";
            request.Method      = "POST";

            string postString = string.Format("{{\"login\":\"{0}\",\"password\":\"{1}\"}}", login, password);
            //request.ContentLength = postString.Length;

            // Sends the request
            bool isLogged = false;

            try
            {
                StreamWriter requestWriter = new StreamWriter(await request.GetRequestStreamAsync());
                requestWriter.Write(postString);
                requestWriter.Flush();
                //requestWriter.Close();


                using (WebResponse response = await request.GetResponseAsync())
                {
                    // Si on est passé sans exception : on a le droit de se logger


                    // Le stream
                    using (Stream stream = response.GetResponseStream())
                    {
                        // Build the JSON doc
                        JsonValue jsonDoc = await Task.Run(() => JsonObject.Load(stream));

                        isLogged = true;

                        // Le résultat renvoyé est le Token, on le stocke ainsi que la date
                        string result = jsonDoc.ToString();
                        this.token = result;
                        Global.SetSettings(TypeSettings.Token, result);
                        Global.SetSettings(TypeSettings.TokenDate, new DateTime().ToString());

                        // On stocke aussi le URlBase demandé
                        Global.SetSettings(TypeSettings.DBChosen, slot);

                        // On stocke aussi le login OK et le mot de passe ok pour pré remplir
                        Global.SetSettings(TypeSettings.LoginSaved, login);
                        Global.SetSettings(TypeSettings.PasswordSaved, password);
                    }
                }
            }
            catch (WebException ex)
            {
                sd.HideSpinner();

                HttpWebResponse objresponse = ex.Response as HttpWebResponse;
                if (objresponse != null && objresponse.StatusCode == HttpStatusCode.Unauthorized)
                {
                    // 401
                    ErrorMsg.Text = "Login / Password non autorisé";
                }
                else
                {
                    // Générique
                    if (objresponse != null)
                    {
                        ErrorMsg.Text = objresponse.StatusDescription;
                    }
                    else
                    {
                        ErrorMsg.Text = "Problème de connexion / réseau inaccessible.";
                    }
                }
                await this.DisplayAlert("Erreur", ErrorMsg.Text, "OK");
            }
            catch (Exception ex)
            {
                sd.HideSpinner();


                await this.DisplayAlert("Erreur", "Une erreur est survenue : " + ex.Message, "OK");
            }

            return(isLogged);
        }
예제 #7
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();
        }