private void getFromServeur(UInt32 idDocumentCible) { Dictionary<string, object> arg = new Dictionary<string, object>(); arg.Add("@idDocument", idDocumentCible); MySqlDataReader Reader = ConnectorMySql.ExecCommand(@"SET @tableToJoin = (SELECT typeDocument FROM Documents WHERE idDocument = @idDocument); SET @sql = CONCAT('SELECT * FROM Documents AS d JOIN ', @tableToJoin, ' AS t USING (idDocument) WHERE d.idDocument=', @idDocument); PREPARE stmt FROM @sql; EXECUTE stmt;", arg); while (Reader!= null && Reader.Read()) { //Récupération de tous les paramètre concernant le document this.idDocument = GetDBUInt32("idDocument", Reader); this.dateTimeEditionBDD = GetDBDateTime("dateTimeEditionBDD", Reader); this.versionDocumentBDD = GetDBUInt32("versionDocumentBDD", Reader); this.idUtilisateur = GetDBUInt32("idUtilisateur", Reader); this.systeme = GetDBString("systeme", Reader); this.section = GetDBString("section", Reader); this.subdivision = GetDBString("subdivision", Reader); this.typeDocument = GetDBString("typeDocument", Reader); this.typeContenu = GetDBString("typeContenu", Reader); //En fonction de ce qu'on lit dans le reader, on instancie la class correspondant au type de document if (this.typeDocument == "DocNormales") { DocNormales tmpDocument = new DocNormales(idDocument); tmpDocument.categorieDocument = GetDBString("categorieDocument", Reader); tmpDocument.titreDocument = GetDBString("titreDocument", Reader); tmpDocument.dateDocument = GetDBDateTime("dateDocument", Reader); tmpDocument.versionDocument = GetDBString("versionDocument", Reader); tmpDocument.auteurDocument = GetDBString("auteurDocument", Reader); this.document = tmpDocument; } if (this.typeDocument == "TachesJournalieres") { TachesJournalieres tmpDocument = new TachesJournalieres(idDocument); tmpDocument.titreAction = GetDBString("titreAction", Reader); tmpDocument.jourApplication = GetDBString("jourApplication", Reader); tmpDocument.detailAction = GetDBString("detailAction", Reader); tmpDocument.derniereAction = GetDBDateTime("derniereAction", Reader); tmpDocument.versionAction = GetDBString("versionAction", Reader); tmpDocument.dateVersion = GetDBDateTime("dateVersion", Reader); tmpDocument.heureApplication = GetDBTime("heureApplication", Reader); tmpDocument.duree = GetDBTime("duree", Reader); tmpDocument.dateExpiration = GetDBDateTime("dateExpiration", Reader); this.document = tmpDocument; } if (this.typeDocument == "Consignes") { Consignes tmpDocument = new Consignes(idDocument); tmpDocument.objetConsigne = GetDBString("objetConsigne", Reader); tmpDocument.typeConsigne = GetDBString("typeConsigne", Reader); tmpDocument.debut = GetDBDateTime("debut", Reader); tmpDocument.fin = GetDBDateTime("fin", Reader); tmpDocument.referenceConsigne = GetDBString("referenceConsigne", Reader); tmpDocument.annuleEtRemplace = GetDBString("annuleEtRemplace", Reader); tmpDocument.redigePar = GetDBString("redigePar", Reader); tmpDocument.validePar = GetDBString("validePar", Reader); tmpDocument.signePar = GetDBString("signePar", Reader); tmpDocument.intervenant = GetDBString("intervenant", Reader); tmpDocument.responsableOperation = GetDBString("responsableOperation", Reader); tmpDocument.miseEnService = GetDBBoolean("miseEnService", Reader); tmpDocument.refMISO = GetDBString("refMISO", Reader); tmpDocument.epis = GetDBBoolean("epis", Reader); tmpDocument.refEPIS = GetDBString("refEPIS", Reader); tmpDocument.consequenceOperationnelle = GetDBBoolean("consequenceOperationnelle", Reader); tmpDocument.consequenceDocumentation = GetDBBoolean("consequenceDocumentation", Reader); tmpDocument.dateArchivage = GetDBDateTime("dateArchivage", Reader); this.document = tmpDocument; } if (this.typeDocument == "Verifications") { Verifications tmpDocument = new Verifications(idDocument); tmpDocument.titreAction = GetDBString("titreAction", Reader); tmpDocument.vacationCible = GetDBString("vacationCible", Reader); tmpDocument.lieu = GetDBString("lieu", Reader); tmpDocument.detailAction = GetDBString("detailAction", Reader); tmpDocument.derniereVerification = GetDBDateTime("derniereVerification", Reader); this.document = tmpDocument; } } ConnectorMySql.Close(Reader); //Requete SQL pour sélectionner le contenu d'une documentation // Si y'a un contenu hein =) if (this.typeContenu != "WITHOUT_CONTENT") { //cmd.CommandText = @"SELECT * FROM Contenus WHERE idDocument = @idDocument"; Reader = ConnectorMySql.ExecCommand(@"SELECT * FROM Contenus WHERE idDocument = @idDocument", arg); //Reader = cmd.ExecuteReader(); //cmd.Dispose(); while (Reader.Read()) { this.contenu = new Contenus(idDocument); //On stocke l'adresse du fichier sans le prefixe serveur web (ou serveur de fichier) this.contenu.pathToFolder = Properties.Settings.Default.pathToDataLocal + GetDBString("pathToFolder", Reader); //.Replace(Properties.Settings.Default.pathToDataServeurFichier, Properties.Settings.Default.pathToDataLocal) this.contenu.fileName = GetDBString("fileName", Reader); this.contenu.parsingDocument = GetDBString("parsingDocument", Reader); } ConnectorMySql.Close(Reader); } }
private void getFromLocalDB(UInt32 idDocumentCible) { Dictionary<string, object> arg = new Dictionary<string, object>(); arg.Add("@idDocument", (Int64)idDocumentCible); SqlDataReader Reader = ConnectorSqlServer.ExecCommandSql( @"SELECT typeDocument FROM Documents WHERE idDocument = @idDocument", arg); string nomTable = ""; while (Reader.Read()) { nomTable = GetDBString("typeDocument", Reader); } ConnectorSqlServer.Close(Reader); Reader = ConnectorSqlServer.ExecCommandSql( @"SELECT * FROM Documents JOIN " + nomTable + @" ON Documents.idDocument = " + nomTable + @".idDocument WHERE Documents.idDocument = @idDocument", arg); if (Reader == null) return; while (Reader.Read()) { //Récupération de tous les paramètre concernant le document this.idDocument = GetDBBigInt("idDocument", Reader); this.dateTimeEditionBDD = GetDBDateTime("dateTimeEditionBDD", Reader); this.versionDocumentBDD = GetDBInt("versionDocumentBDD", Reader); this.idUtilisateur = GetDBBigInt("idUtilisateur", Reader); this.systeme = GetDBString("systeme", Reader); this.section = GetDBString("section", Reader); this.subdivision = GetDBString("subdivision", Reader); this.typeDocument = GetDBString("typeDocument", Reader); this.typeContenu = GetDBString("typeContenu", Reader); //En fonction de ce qu'on lit dans le reader, on instancie la class correspondant au type de document if (this.typeDocument == "DocNormales") { DocNormales tmpDocument = new DocNormales(idDocument); tmpDocument.categorieDocument = GetDBString("categorieDocument", Reader); tmpDocument.titreDocument = GetDBString("titreDocument", Reader); tmpDocument.dateDocument = GetDBDateTime("dateDocument", Reader); tmpDocument.versionDocument = GetDBString("versionDocument", Reader); tmpDocument.auteurDocument = GetDBString("auteurDocument", Reader); this.document = tmpDocument; } if (this.typeDocument == "TachesJournalieres") { TachesJournalieres tmpDocument = new TachesJournalieres(idDocument); tmpDocument.titreAction = GetDBString("titreAction", Reader); tmpDocument.jourApplication = GetDBString("jourApplication", Reader); tmpDocument.detailAction = GetDBString("detailAction", Reader); tmpDocument.derniereAction = GetDBDateTime("derniereAction", Reader); tmpDocument.versionAction = GetDBString("versionAction", Reader); tmpDocument.dateVersion = GetDBDateTime("dateVersion", Reader); tmpDocument.heureApplication = GetDBTime("heureApplication", Reader); tmpDocument.duree = GetDBTime("duree", Reader); tmpDocument.dateExpiration = GetDBDateTime("dateExpiration", Reader); this.document = tmpDocument; } if (this.typeDocument == "Consignes") { Consignes tmpDocument = new Consignes(idDocument); tmpDocument.objetConsigne = GetDBString("objetConsigne", Reader); tmpDocument.typeConsigne = GetDBString("typeConsigne", Reader); tmpDocument.debut = GetDBDateTime("debut", Reader); tmpDocument.fin = GetDBDateTime("fin", Reader); tmpDocument.referenceConsigne = GetDBString("referenceConsigne", Reader); tmpDocument.annuleEtRemplace = GetDBString("annuleEtRemplace", Reader); tmpDocument.redigePar = GetDBString("redigePar", Reader); tmpDocument.validePar = GetDBString("validePar", Reader); tmpDocument.signePar = GetDBString("signePar", Reader); tmpDocument.intervenant = GetDBString("intervenant", Reader); tmpDocument.responsableOperation = GetDBString("responsableOperation", Reader); tmpDocument.miseEnService = GetDBBoolean("miseEnService", Reader); tmpDocument.refMISO = GetDBString("refMISO", Reader); tmpDocument.epis = GetDBBoolean("epis", Reader); tmpDocument.refEPIS = GetDBString("refEPIS", Reader); tmpDocument.consequenceOperationnelle = GetDBBoolean("consequenceOperationnelle", Reader); tmpDocument.consequenceDocumentation = GetDBBoolean("consequenceDocumentation", Reader); tmpDocument.dateArchivage = GetDBDateTime("dateArchivage", Reader); this.document = tmpDocument; } if (this.typeDocument == "Verifications") { Verifications tmpDocument = new Verifications(idDocument); tmpDocument.titreAction = GetDBString("titreAction", Reader); tmpDocument.vacationCible = GetDBString("vacationCible", Reader); tmpDocument.lieu = GetDBString("lieu", Reader); tmpDocument.detailAction = GetDBString("detailAction", Reader); tmpDocument.derniereVerification = GetDBDateTime("derniereVerification", Reader); this.document = tmpDocument; } } ConnectorSqlServer.Close(Reader); //Récupération de tous les informations concernant le contenu du document //Requete SQL pour sélectionner le contenu d'une documentation // Si y'a un contenu hein =) if (this.typeDocument != "WITHOUT_CONTENT") { Reader = ConnectorSqlServer.ExecCommandSql(@"SELECT * FROM Contenus WHERE idDocument = @idDocument", arg); if (Reader == null) return; while (Reader.Read()) { this.contenu = new Contenus(idDocument); this.contenu.pathToFolder = GetDBString("pathToFolder", Reader); this.contenu.fileName = GetDBString("fileName", Reader); this.contenu.parsingDocument = GetDBString("parsingDocument", Reader); } ConnectorSqlServer.Close(Reader); } }