/// <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); }
//private INetTools netTools; public WebServiceData(string token, string actionUrl, string method = "GET", int?IdManif = null, int?IdPrestation = null, int?IdParticipant = null, string postString = null ) { this.Token = token; this.Method = method; this.PostString = postString; this.ActionUrl = actionUrl; this.IdManif = IdManif; this.IdPrestation = IdPrestation; this.IdParticipant = IdParticipant; // On récupère le IsHorsConnexion IsHorsConnexion = Global.GetSettingsBool(TypeSettings.IsHorsConnexion); LastHorsConnexionDate = Global.GetSettingsDate(TypeSettings.LastHorsConnexionDate); // L'objet SQL sqlData = new SQLData <T>(); }
/// <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); }
/// <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); } }
/// <summary> /// Constructeur /// </summary> /// <param name="token">Token.</param> /// <param name="isSilentException">Si false : les Exceptions à l'envoi ne sont pas levées ; si tru, elles le sont.</param> public ValidatePresenceService(string token, bool?isSilentExceptions = false) { sqlData = new SQLData <ValidatePresence>(); this.Token = token; if (isSilentExceptions.HasValue) { this.isSilentExceptions = isSilentExceptions.Value; } else { this.isSilentExceptions = false; } // On crée la table au besoin sqlData.CreateTable(); }