Ejemplo n.º 1
0
        /// <summary>
        /// Vérifie si une inscription existe déjà (pour validation hors connexion)
        /// </summary>
        /// <returns><c>true</c>, if participant already recorded was ised, <c>false</c> otherwise.</returns>
        /// <param name="validate">Validate.</param>
        public bool IsInscriptionAlreadyRecorded(ValidatePresence validate)
        {
            bool isFound = false;

            // Si il y a une prestation : on regarde dans Inscription
            // Sinon, on sort, car on peut enregistrer plusieurs participants (si un event dure plusieurs jours, par exemple)
            if (validate == null)
            {
                return(false);
            }

            // En fonction de l'Id prestation, on choisit la table
            if (validate.IdPrestation.HasValue)
            {
                // Objet Inscription
                var sqldata = new SQLData <InscriptionParticipant>();

                // On cherche l'inscription si elle existe...
                var inscription = sqldata.RetrieveAll().Where(x => x.IdParticipant == validate.IdParticipant && x.IdPrestation == validate.IdPrestation.Value).FirstOrDefault();

                if (inscription != null)
                {
                    isFound = true;
                }
            }
            else
            {
                // Pas de prestation : on n'aurait pas du appeler cette fonction
                throw new Exception("Un Participant à une manif sans prestation peut être enregistré plusieurs fois !!");
            }

            return(isFound);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Renvoie toutes les données venant du cache
        /// </summary>
        /// <returns>The from cache.</returns>
        public List <T> RetrieveAllFromCache()
        {
            if (sqlData != null)
            {
                return(sqlData.RetrieveAll());
            }

            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Rafraichit les cellules de présence en lisant dans la base (par exemple, quand on valide une présence)
        /// </summary>
        public void RefreshCells(int idParticipant)
        {
            // Récupère les données de la base
            var sqldata1 = new SQLData <PresenceParticipant>();
            var sqldata2 = new SQLData <InscriptionParticipant>();

            // Présences
            var presences = sqldata1.RetrieveAll().Where(X => X.IdParticipant == idParticipant).ToList();
            // Inscriptions
            var inscriptions = sqldata2.RetrieveAll().Where(X => X.IdParticipant == idParticipant).ToList();

            generateInscriptionCells(presences, inscriptions);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Marque la présence d'un participant UNIQUEMENT en base (l'envoi en WS est fait ailleurs avec Send)
        /// </summary>
        /// <param name="validate">Identifier participant et prestation.</param>
        public void ValidateSQLOnly(ValidatePresence validate)
        {
            if (validate == null)
            {
                return;
            }

            // En fonction de l'Id prestation, on choisit la table
            if (validate.IdPrestation.HasValue)
            {
                // Objet Inscription
                var sqldata = new SQLData <InscriptionParticipant>();

                // On cherche l'inscription si elle existe...
                var inscription = sqldata.RetrieveAll().Where(x => x.IdParticipant == validate.IdParticipant && x.IdPrestation == validate.IdPrestation.Value).FirstOrDefault();

                if (inscription != null)
                {
                    // On update
                    inscription.DatePresence = DateTime.Now;

                    sqldata.UpdateData(inscription);
                }
                else
                {
                    // On insère
                    var newInscription = new InscriptionParticipant()
                    {
                        IdParticipant = validate.IdParticipant,
                        IdPrestation  = validate.IdPrestation,
                        IdStatusA39   = 3,
                        DatePresence  = DateTime.Now
                    };
                    sqldata.InsertData(newInscription);
                }
            }
            else
            {
                // Objet Presence
                var sqldata = new SQLData <PresenceParticipant>();

                // On crée la présence
                var newPresence = new PresenceParticipant()
                {
                    IdParticipant = validate.IdParticipant,
                    StatusPartA09 = 3,
                    DatePresence  = DateTime.Now
                };
                sqldata.InsertData(newPresence);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Envoie tous les ValidatePresence en attente
        /// </summary>
        public async Task <bool> SendAll()
        {
            bool isOk = true;

            // Sauf si Hors connexion
            if (Global.GetSettingsBool(TypeSettings.IsHorsConnexion))
            {
                // On sort
                return(false);
            }

            // Boucle sur toutes les lignes pour les appels de Web Service
            List <ValidatePresence> validatePresences = sqlData.RetrieveAll();

            if (validatePresences.Count() == 0)
            {
                return(false);
            }

            foreach (ValidatePresence instance in validatePresences)
            {
                // On checke si il y a une erreur type 40x
                try
                {
                    await Send(instance);
                }
                catch (WebException ex)
                {
                    HttpWebResponse objresponse = ex.Response as HttpWebResponse;
                    if (objresponse.StatusCode == HttpStatusCode.Unauthorized ||
                        objresponse.StatusCode == HttpStatusCode.Forbidden ||
                        objresponse.StatusCode == HttpStatusCode.NotFound)
                    {
                        // Déjà enregistré : OK mais on mettra un message pour l'indiquer
                        isOk = false;
                    }
                }
            }

            return(isOk);
        }