1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| public ETAT_CALCULS ExporterResultatsXML(string fichierResultats, Hashtable donneesJbus, string typeMesure, bool defMesUS, bool defCapteur, ref string erreur)
{
ETAT_CALCULS retour = ETAT_CALCULS.OK;
erreur = "";
string stringParam = "";
long variableBlanche = 0; // Paramètre disponible non exploité
Traces.Tracer(Traces.CALCULS, "ExporterResultatsXML", "*** DEBUT Traitement ***");
// Création du fichier XML Résultats
if (File.Exists(fichierResultats))
File.Delete(fichierResultats);
XmlTextWriter xtw = new XmlTextWriter(fichierResultats, System.Text.Encoding.UTF8);
try
{
xtw.Formatting = Formatting.Indented;
xtw.Indentation = 3;
xtw.WriteStartDocument();
#region Ecriture des données
xtw.WriteStartElement("P2US");
// xtw.WriteStartElement("RESULTATS");
xtw.WriteStartElement("DIVERS");
// Ecriture de la Date (donnée directement extraite du nom du fichier Resultat)
if (retour == ETAT_CALCULS.OK)
{
string dateFormat = "";
if (ExtraireFormatDateHeure(fichierResultats, ref dateFormat, ref erreur))
{
xtw.WriteComment("Date et heure de la mesure");
xtw.WriteStartElement("DATE");
xtw.WriteAttributeString("nbVal", "6");
xtw.WriteString(dateFormat);
xtw.WriteEndElement();
Traces.Tracer(Traces.CALCULS, "ExporterResultatsXML", "-- Export donnée Date OK");
}
else
{
retour = ETAT_CALCULS.ERREUR;
}
}
// Ecriture du Nom de la chaîne
if (retour == ETAT_CALCULS.OK)
{
xtw.WriteComment("Nom de la chaîne");
xtw.WriteStartElement("CHAINE");
xtw.WriteString(Parametrage.LireParametre("CHAINE"));
xtw.WriteEndElement();
Traces.Tracer(Traces.CALCULS, "ExporterResultatsXML", "-- Export donnée Nom de la Chaîne (" + Parametrage.LireParametre("CHAINE") + ") OK");
}
//...
#endregion
// Fermeture du fichier XML Résultats
// xtw.WriteEndElement();
xtw.WriteEndElement();
xtw.Flush();
}
catch (Exception e)
{
erreur = e.Message;
retour = ETAT_CALCULS.ERREUR;
}
finally
{
xtw.Close();
// Indication fin de traitement
if (retour.Equals(ETAT_CALCULS.OK))
{
Traces.Tracer(Traces.CALCULS, "ExporterResultatsXML", "*** FIN Traitement OK ***");
}
}
return retour;
} |
Partager