Exemplo n.º 1
0
        /// <summary>
        /// Récupération des datas
        /// </summary>
        /// <returns>The instances.</returns>
        /// <param name="idEvent">Identifier event.</param>
        /// <param name="idPrestation">Identifier prestation.</param>
        /// <param name="idParticipant">Identifier participant.</param>
        public async Task <List <Evenement> > GetInstances(int?idEvent = null, int?idPrestation = null, int?idParticipant = null)
        {
            List <Evenement> instances = null;

            // Appelle le Web Service
            //evenements = GetEvents(token);
            WebServiceData <Evenement> webServiceData = new WebServiceData <Evenement>(
                this.Token,
                Global.WS_GET_EVENTS
                );

            if (!webServiceData.IsHorsConnexion)
            {
                instances = await webServiceData.GetData((jsonObject) =>
                {
                    return(new Evenement(jsonObject));
                }, null);
            }
            else
            {
                instances = webServiceData.RetrieveAllFromCache();
            }

            return(instances);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Récupère les data ; si isForcedSQL = true, on tape dans la table et pas sur les WS
        /// </summary>
        /// <returns>The instances.</returns>
        /// <param name="idEvent">Identifier event.</param>
        /// <param name="idPrestation">Identifier prestation.</param>
        /// <param name="idParticipant">Identifier participant.</param>
        /// <param name="isForcedSQL">Is forced sql.</param>
        private async Task <List <Participant> > getInstances(int?idEvent       = null,
                                                              int?idPrestation  = null,
                                                              int?idParticipant = null,
                                                              bool?isForcedSQL  = false)
        {
            List <Participant> instances = null;

            // Appelle le Web Service
            string url = "";

            if (idPrestation.HasValue)
            {
                url = Global.WS_GET_PARTICIPANTS + "?id=" + idPrestation.Value + "&idManif=" + idEvent +
                      "&Prestation=true";
            }
            else
            {
                url = Global.WS_GET_PARTICIPANTS + "?id=" + idEvent;
            }

            WebServiceData <Participant> wsData = new WebServiceData <Participant>(
                this.Token,
                url,
                "GET",
                idEvent,
                idPrestation
                );

            if (!wsData.IsHorsConnexion && (!isForcedSQL.HasValue || isForcedSQL.Value == false))
            {
                instances = await wsData.GetData((jsonObject) =>
                {
                    return(new Participant(jsonObject, idEvent.Value, idPrestation));
                },
                                                 null,
                                                 true,
                                                 Global.NB_ITEMS_PER_BLOCK);
            }
            else
            {
                // Récupère le cache et filtre
                instances = wsData.RetrieveAllFromCache().Where(X => X.IdManif == idEvent).ToList();
                if (idPrestation.HasValue)
                {
                    instances = instances.Where(X => X.IdPrestation == idPrestation.Value).ToList();
                }
                else
                {
                    instances = instances.Where(X => X.IdPrestation == null).ToList();
                }
            }

            return(instances);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Récupération de l'instance et des inscriptions
        /// </summary>
        /// <returns>The instances.</returns>
        /// <param name="idEvent">Identifier event.</param>
        /// <param name="idPrestation">Identifier prestation.</param>
        /// <param name="idParticipant">Identifier participant.</param>
        public async Task <List <Participant> > GetInstances(int?idEvent = null, int?idPrestation = null, int?idParticipant = null)
        {
            List <Participant> instances = null;

            // Appelle le Web Service
            string url = "";

            if (idPrestation.HasValue)
            {
                url = Global.WS_GET_PARTICIPANT_DETAILS + "?id=" + idParticipant + "&Prestation=true";
            }
            else
            {
                url = Global.WS_GET_PARTICIPANT_DETAILS + "?id=" + idParticipant;
            }

            WebServiceData <Participant> wsData = new WebServiceData <Participant>(
                this.Token,
                url,
                "GET",
                idEvent,
                idPrestation,
                idParticipant
                );

            if (!wsData.IsHorsConnexion)
            {
                // Attention : pour cet appel, on fournit IsInCache = false
                // Cela signfie qu'on ne veut pas faire un delete du participant en base SQL - ni un insert.
                // En effet, dans ce cas il y aurait un DELETE sur TOUS les participants de la prestation
                instances = await wsData.GetData((jsonObject) =>
                {
                    return(new Participant(jsonObject, idEvent.Value, idPrestation));
                }, null, false);
            }
            else
            {
                // On récupère la ligne dans la liste
                instances = wsData.RetrieveAllFromCache().Where(X => X.Id == idParticipant.Value).ToList();
            }

            // Présence sur l'accueil :
            // ------------------------
            // On récupère la liste des présences du participant :
            // methods/MobileApp/GetParticipantPresence
            if (idPrestation.HasValue)
            {
                url = Global.WS_GET_PARTICIPANT_PRESENCE + "?id=" + idParticipant.Value + "&Prestation=true";
            }
            else
            {
                url = Global.WS_GET_PARTICIPANT_PRESENCE + "?id=" + idParticipant.Value;
            }
            WebServiceData <PresenceParticipant> wsData2 = new WebServiceData <PresenceParticipant>(
                this.Token,
                url,
                "GET",
                idEvent,
                idPrestation,
                idParticipant
                );

            List <PresenceParticipant> presences = null;

            // On récupère la liste des dates de validation pour le people passé en paramètre pour l'accueil principal !!
            if (!wsData2.IsHorsConnexion)
            {
                presences = await wsData2.GetData((jsonobject) =>
                {
                    return(new PresenceParticipant(jsonobject));
                }, null);
            }
            else
            {
                presences = wsData2.RetrieveAllFromCache().Where(X => X.IdParticipant == idParticipant.Value).ToList();
            }



            // Présences aux autres prestations
            // --------------------------------
            if (idPrestation.HasValue)
            {
                url = Global.WS_GET_PARTICIPANT_INSCRIPTIONS + "?id=" + idParticipant.Value + "&Prestation=true";
            }
            else
            {
                url = Global.WS_GET_PARTICIPANT_INSCRIPTIONS + "?id=" + idParticipant.Value;
            }
            WebServiceData <InscriptionParticipant> wsData3 = new WebServiceData <InscriptionParticipant>(
                this.Token,
                url,
                "GET",
                idEvent,
                idPrestation,
                idParticipant
                );
            List <InscriptionParticipant> inscriptions = null;

            if (!wsData3.IsHorsConnexion)
            {
                inscriptions = await wsData3.GetData((jsonobject) =>
                {
                    return(new InscriptionParticipant(jsonobject));
                }, null);
            }
            else
            {
                // On trie sur le idParticipant
                inscriptions = wsData3.RetrieveAllFromCache().Where(X => X.IdParticipant == idParticipant.Value).ToList();
            }


            // On crée les cellules de présences
            generateInscriptionCells(presences, inscriptions);


            return(instances);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the instances.
        /// </summary>
        /// <returns>The instances.</returns>
        /// <param name="idEvent">Identifier event.</param>
        /// <param name="idPrestation">Identifier prestation.</param>
        /// <param name="idParticipant">Identifier participant.</param>
        public async Task <List <Prestation> > GetInstances(int?idEvent = null, int?idPrestation = null, int?idParticipant = null)
        {
            List <Prestation> instances = null;

            // Les WSData
            WebServiceData <CountParticipants> wsDataCP = new WebServiceData <CountParticipants>(
                this.Token,
                Global.WS_COUNT_PARTICIPANTS + "?id=" + idEvent,
                "GET",
                idEvent

                );
            WebServiceData <Prestation> wsDataP = new WebServiceData <Prestation>(
                this.Token,
                Global.WS_GET_PRESTATIONS + idEvent.ToString(),
                "GET",
                idEvent
                );

            // Si le cache est non valide : on cherche les datas, on peuple
            if (!wsDataP.IsHorsConnexion)
            {
                // Récupération de l'accueil
                List <CountParticipants> partsAccueil = await
                                                        wsDataCP.GetData(null, (jsonObject) =>
                {
                    return(new CountParticipants(jsonObject));
                },
                                                                         false);


                // On récup l'élément
                int NbTotalAccueil    = 0;
                int NbPresentsAccueil = 0;
                if (partsAccueil.Count == 2)
                {
                    NbTotalAccueil    = partsAccueil[0].NbItems;
                    NbPresentsAccueil = partsAccueil[1].NbItems;
                }


                // Prestation accueil
                instances = new List <Prestation>();
                var prestaAccueil = new Prestation()
                {
                    Id              = 0,
                    IdManif         = idEvent.Value,
                    NbPresents      = NbPresentsAccueil,
                    NbRemaining     = 0,
                    NbTotal         = NbTotalAccueil,
                    Title           = "Accueil sur site",
                    NbInscritsLabel = NbTotalAccueil.ToString() + " invités"
                };
                instances.Add(prestaAccueil);


                // Récupération des prestations
                instances.AddRange(await wsDataP.GetData((jsonObject) =>
                {
                    return(new Prestation(jsonObject));
                }, null));

                // Pour chaque prestation, on va récupérer le nb de participants
                // Sauf accueil
                for (int i = 1; i < instances.Count; i++)
                {
                    Prestation prestation = instances[i];
                    wsDataCP.ActionUrl = Global.WS_COUNT_PARTICIPANTS + "?id=" + prestation.Id +
                                         "&idManif=" + idEvent + "&Prestation=true";

                    // Récup du CountParticipants pour chaque prestation
                    List <CountParticipants> parts = await wsDataCP.GetData(null, (jsonObject) =>
                    {
                        return(new CountParticipants(jsonObject));
                    },
                                                                            false);

                    // On récup l'élément
                    if (parts.Count == 2)
                    {
                        prestation.NbPresents = parts[1].NbItems;
                    }
                }

                // On ajoute la prestation Accueil au cache
                // APRES le getData qui fait une purge
                wsDataP.InsertData(prestaAccueil);


                // On met à jour les prestations avec le nb d'inscrits
                wsDataP.UpdateData(instances);
            }
            else
            {
                // On récupère les datas du cache
                instances = wsDataP.RetrieveAllFromCache();
                if (idEvent.HasValue)
                {
                    instances = instances.Where(Xamarin => Xamarin.IdManif == idEvent.Value).ToList();
                }
            }

            return(instances);
        }