/* * accordVersementConfig contient une configuration d'accord de versement * qui définit toutes les informations relatives au versement (profil, producteur, ...) * */ public abstract void prepareInformationsWithConfigFile(SimpleConfig config, String baseURI, String accordVersement, String dataSha1);
DataControlConfig configLoader(String configName) { SimpleConfig config = new SimpleConfig(); String erreur = config.loadFile("./job.config"); if (erreur != String.Empty) // on tient compte du fait qu'en environnement de développement, l'exe est dans bin/Release erreur = config.loadFile("../../job.config"); if (erreur != String.Empty) { System.Console.WriteLine(erreur); Assert.Fail(erreur); } return config.getDatacontrolConfig(configName); }
static int Main(string[] args) { StreamWriter streamWriter = null; String jobName; if (args.Length < 1) { System.Console.WriteLine("Syntaxe attendue : BusinessDataController nom-job-controle"); System.Console.WriteLine("nom-job-controle est une section dans le fichier job.config"); System.Console.WriteLine("Une section a la forme :"); System.Console.WriteLine("[data-control : nom-job-controle]"); System.Console.WriteLine(" trace = chemin/vers/fichier-de-trace.txt"); System.Console.WriteLine(" profil = chemin/vers/fichier-de-profil.rng"); System.Console.WriteLine(" data = chemin/vers/fichier-de-donnees-metier.txt"); System.Console.WriteLine(""); System.Console.WriteLine("Aucun job demandé, le premier job sera exécuté"); System.Console.WriteLine(""); jobName = String.Empty; } else { jobName = args[0]; } SimpleConfig config = new SimpleConfig(); String erreur = config.loadFile("./job.config"); if (erreur != String.Empty) // on tient compte du fait qu'en environnement de développement, l'exe est dans bin/Release erreur = config.loadFile("../../job.config"); if (erreur != String.Empty) { System.Console.WriteLine(erreur); System.Environment.Exit(-1); } ProfileControlConfig control = config.getProfileConfig(jobName); if (control == null) { System.Console.WriteLine("Aucun job 'profile-control: " + jobName + "' trouvé dans le fichier job.config. Vérifiez la syntaxe ou créez une tâche."); System.Environment.Exit(-1); } System.Console.WriteLine("Contrôle profil du job '" + control.nomJob + "' du profil '" + control.profileFile + "'"); String profileFile = control.profileFile; String traceFile = control.traceFile; // String traceFile = @"D:\DEV_PPE\devel\gw-quimper\trace-control.txt"; // String profileFile = @"D:\DEV_PPE\devel\gw-quimper\repetition_une_unite_deux_documents_schema.rng"; //String profileFile = @"D:\DEV_PPE\tests\marches\20150619Profil_avec_doc_falcultatif_donne_avant_engagement\EMEG_PROFIL_MP_0002_schema.rng"; //String profileFile = @"D:\DEV_PPE\tests\marches\repetition_une_unite-1-v1_0_schema.rng"; //String profileFile = @"D:\DEV_PPE\tests\marches\repetition_une_unite-trois_documents-optionnels_schema.rng"; //String profileFile = @"D:\DEV_PPE\tests\CGI\Test_MARCHES-V5bis\EMEG_PROFIL_MP_0002-PPE_schema.rng"; //String profileFile = @"D:\DEV_PPE\tests\marches\repetition_une_unite_schema.rng"; //String profileFile = @"D:\DEV_PPE\tests\marches\repetition_une_unite_avec_sous_unites_schema.rng"; //String profileFile = @"D:\DEV_PPE\tests\marches\repetition_deux_unites_avec_sous_unites_schema.rng"; //String profileFile = @"\\cg56.fr\dfs2\BW\DEVT\ArcEspCo\DATA\CG56_PROFIL_PES_0001_v1_schema-duplication.rng"; //String profileFile = "D:/DEV_PPE/devel/RNG/esco-ad/SAE-INT-PROFIL-ESPACE-CO_schema.rng"; //String profileFile = @"\\vm-devshare\d$\DEV_PPE\devel\CG56_PES-transfert-manuel\CG56_PROFIL_PES_0001_v1_schema.rng"; Action<Exception, String> eh = (ex, str) => { Console.WriteLine(ex.GetType().Name + " while trying to use trace file: " + traceFile + ". Complementary message: " + str); System.Environment.Exit(-1); }; try { streamWriter = new StreamWriter(traceFile); } catch (IOException e) { eh(e, "Mauvaise syntaxe de nom de fichier"); } catch (UnauthorizedAccessException e) { eh(e, "Droits d'accès à corriger"); } catch (System.Security.SecurityException e) { eh(e, "Droits d'accès à corriger"); } RngProfileController rpc = new RngProfileController(); rpc.setTracesWriter(streamWriter); rpc.controlProfileFile(profileFile); StringCollection arbre = rpc.getTreeList(); if (arbre != null && arbre.Count != 0) { Console.WriteLine("\nArbre des unités documentaires.\n"); Console.WriteLine("Les unités répétées sont présentées sous la forme UNITE[#1]."); foreach (String str in arbre) { Console.WriteLine(str); streamWriter.WriteLine(str); } } StringCollection errors = rpc.getErrorsList(); if (errors != null && errors.Count != 0) { Console.WriteLine("\n!!!!!!!!!!!!!!!!!!!!!!\nIl y a eu des erreurs.\n"); foreach (String str in errors) { Console.WriteLine(str); streamWriter.WriteLine(str); } } else { Console.WriteLine("\nAucune erreur détectée\n"); } streamWriter.Close(); return errors.Count; }
static int Main(string[] args) { StreamWriter streamWriter = null; String jobName; if (args.Length < 1) { System.Console.WriteLine("Syntaxe attendue : BusinessDataController nom-job-controle"); System.Console.WriteLine("nom-job-controle est une section dans le fichier job.config"); System.Console.WriteLine("Une section a la forme :"); System.Console.WriteLine("[data-control : nom-job-controle]"); System.Console.WriteLine(" trace = chemin/vers/fichier-de-trace.txt"); System.Console.WriteLine(" profil = chemin/vers/fichier-de-profil.rng"); System.Console.WriteLine(" data = chemin/vers/fichier-de-donnees-metier.txt"); System.Console.WriteLine(""); System.Console.WriteLine("Aucun job demandé, le premier job sera exécuté"); System.Console.WriteLine(""); jobName = String.Empty; } else { jobName = args[0]; } SimpleConfig config = new SimpleConfig(); String erreur = config.loadFile("./job.config"); if (erreur != String.Empty) // on tient compte du fait qu'en environnement de développement, l'exe est dans bin/Release erreur = config.loadFile("../../job.config"); if (erreur != String.Empty) { System.Console.WriteLine(erreur); System.Environment.Exit(-1); } GeneratorConfig generatorJob = config.getGeneratorConfig(jobName); if (generatorJob == null) { System.Console.WriteLine("Aucun job 'generator: " + jobName + "' trouvé dans le fichier job.config. Vérifiez la syntaxe ou créez une tâche."); System.Environment.Exit(-1); } System.Console.WriteLine("Génération bordereau du job '" + generatorJob.nomJob + "' : '" + generatorJob.dataFile + "' avec l'accord '" + generatorJob.accordVersement + "'"); String accordVersement = generatorJob.accordVersement; String baseURI = generatorJob.baseURI; String fichier_donnees = generatorJob.dataFile; String repertoire_documents = generatorJob.repDocuments; String fichier_bordereau = generatorJob.bordereauFile; String traceFile = generatorJob.traceFile; String informationsDatabase = ConfigurationManager.AppSettings["databaseConnexion"]; Action<Exception, String> eh = (ex, str) => { Console.WriteLine(ex.GetType().Name + " while trying to use trace file: " + traceFile + ". Complementary message: " + str); System.Environment.Exit(-1); }; try { streamWriter = new StreamWriter(traceFile); } catch (IOException e) { eh(e, "Mauvaise syntaxe de nom de fichier"); } catch (UnauthorizedAccessException e) { eh(e, "Droits d'accès à corriger"); } catch (System.Security.SecurityException e) { eh(e, "Droits d'accès à corriger"); } StringCollection errors; SedaSummaryGenerator.SedaSummaryGenerator ssg = new SedaSummaryRngGenerator(); ssg.setTracesWriter(streamWriter); if (config.hasAccordVersementConfig()) { AccordVersementConfig accordVersementConfig = config.getAccordVersementConfig(accordVersement, baseURI); if (accordVersementConfig == null) { Console.WriteLine("ATTENTION : Impossible de trouver l'accord de versement '" + accordVersement + "' pour le serveur '" + baseURI + "' dans la configuration"); } else { if (accordVersementConfig.SAE_ProfilArchivage.Length == 0) Console.WriteLine("ATTENTION : Le profil d'archivage n'a pas de nom de fichier"); } String dataSha1 = String.Empty; try { dataSha1 = Utils.computeSha1Hash(fichier_donnees); } catch (IOException e) { // Ignorer les exceptions, car si le fichier de données n'est pas accessible, // une exception sera générée plus tard avec un contexte plus explicatif } ssg.prepareInformationsWithConfigFile(config, baseURI, accordVersement, dataSha1); } else { ssg.prepareInformationsWithDatabase(informationsDatabase, baseURI, accordVersement); } ssg.prepareArchiveDocumentsWithFile(repertoire_documents, fichier_donnees); ssg.generateSummaryFile(fichier_bordereau); ssg.close(); streamWriter.Close(); errors = ssg.getErrorsList(); if (errors != null && errors.Count != 0) { Console.WriteLine("Il y a eu des erreurs."); foreach (String str in errors) { Console.WriteLine(str); } } Console.WriteLine("Fin de la liste des erreurs du programme de génération du bordereau"); return errors.Count; }
protected void executeGenerator(String jobName, String sedaVersion) { Action<Exception, String> eh = (ex, str) => { Console.WriteLine(ex.GetType().Name + " while trying to use trace file: " + traceFile + ". Complementary message: " + str); throw ex; }; Action<Exception> ehb = (ex) => { streamWriter.WriteLine("Erreur lors de la préparation du bordereau pour le test '" + fichier_bordereau + "' " + ex.GetType().Name); }; SimpleConfig config = new SimpleConfig(); String erreur = config.loadFile("./job.config"); if (erreur != String.Empty) // on tient compte du fait qu'en environnement de développement, l'exe est dans bin/Release erreur = config.loadFile("../../job.config"); if (erreur != String.Empty) { System.Console.WriteLine(erreur); Assert.Fail(erreur); } GeneratorConfig control = config.getGeneratorConfig(jobName); accordVersement = control.accordVersement; fichier_metier = control.dataFile; path_datafiles = control.repDocuments; fichier_bordereau = control.bordereauFile; traceFile = control.traceFile; baseURI = control.baseURI; try { streamWriter = new StreamWriter(traceFile); } catch (IOException e) { eh(e, "Mauvaise syntaxe de nom de fichier"); } catch (UnauthorizedAccessException e) { eh(e, "Droits d'accès à corriger"); } catch (System.Security.SecurityException e) { eh(e, "Droits d'accès à corriger"); } ssg = new SedaSummaryRngGenerator(); ssg.setTracesWriter(streamWriter); if (config.hasAccordVersementConfig()) { AccordVersementConfig accordVersementConfig = config.getAccordVersementConfig(accordVersement, baseURI); if (accordVersementConfig == null) { Console.WriteLine("ATTENTION : Impossible de trouver l'accord de versement '" + accordVersement + "' dans la configuration"); } else { if (accordVersementConfig.SAE_ProfilArchivage.Length == 0) Console.WriteLine("ATTENTION : Le profil d'archivage n'a pas de nom de fichier"); } String dataSha1 = String.Empty; try { dataSha1 = Utils.computeSha1Hash(fichier_metier); } catch (IOException e) { // Ignorer les exceptions, car si le fichier de données n'est pas accessible, // une exception sera générée plus tard avec un contexte plus explicatif } ssg.prepareInformationsWithConfigFile(config, baseURI, accordVersement, dataSha1); } else { informationsDatabase = ConfigurationManager.AppSettings["databaseConnexion"]; ssg.prepareInformationsWithDatabase(informationsDatabase, baseURI, accordVersement); } ssg.prepareArchiveDocumentsWithFile(path_datafiles, fichier_metier); ssg.generateSummaryFile(fichier_bordereau); ssg.close(); streamWriter.WriteLine("\n---------- ERREURS ----------\n"); StringCollection dumpErrors = ssg.getErrorsList(); if (dumpErrors != null && dumpErrors.Count != 0) { foreach (String err in dumpErrors) { streamWriter.WriteLine(err); } } streamWriter.WriteLine("\n---------- ^^^^^^^ ----------\n"); docBordereau = new XmlDocument(); try { using (StreamReader sr = new StreamReader(fichier_bordereau)) { String line = sr.ReadToEnd(); //Console.WriteLine(line); docBordereau.LoadXml(line); //Instantiate an XmlNamespaceManager object. docInXmlnsManager = new System.Xml.XmlNamespaceManager(docBordereau.NameTable); // Add the namespaces used in xml to the XmlNamespaceManager. // docInXmlnsManager.AddNamespace(String.Empty, sedaVersion.Equals("1.0") ? namespaceSEDA10 : namespaceSEDA02); docInXmlnsManager.AddNamespace("s", sedaVersion.Equals("1.0") ? namespaceSEDA10 : namespaceSEDA02); } } catch (ArgumentException e) { ehb(e); } catch (DirectoryNotFoundException e) { ehb(e); } catch (FileNotFoundException e) { ehb(e); } catch (OutOfMemoryException e) { ehb(e); } catch (IOException e) { ehb(e); } streamWriter.Close(); }
/* * accordVersementConfig contient une configuration d'accord de versement * qui définit toutes les informations relatives au versement (profil, producteur, ...) * */ public override void prepareInformationsWithConfigFile(SimpleConfig config, String baseURI, String accordVersement, String dataSha1) { AccordVersementConfig accordVersementConfig = config.getAccordVersementConfig(accordVersement, baseURI); if (accordVersementConfig == null) { errorsList.Add("Impossible de trouver l'accord de versement '" + accordVersement + "' pour le serveur '" + baseURI + "' dans la configuration"); } else { TransferId = accordVersementConfig.TransferIdPrefix + dataSha1 + "@" + DateTime.UtcNow.ToString("o"); profileFile = accordVersementConfig.SAE_ProfilArchivage; TransferringAgencyId = accordVersementConfig.TransferringAgencyId; TransferringAgencyName = accordVersementConfig.TransferringAgencyName; TransferringAgencyDesc = accordVersementConfig.TransferringAgencyDesc; ArchivalAgencyId = accordVersementConfig.ArchivalAgencyId; ArchivalAgencyName = accordVersementConfig.ArchivalAgencyName; ArchivalAgencyDesc = accordVersementConfig.ArchivalAgencyDesc; if (traceActions) tracesWriter.WriteLineFlush(String.Format("{0}, {1}, {2}" , accordVersementConfig.TransferIdPrefix, TransferId, accordVersementConfig.SAE_ProfilArchivage)); informationsLoaded = true; prepareProfileWithFile(profileFile); } }
public string produireBordereauVersement(string repLog, string repDocuments, string baseURI, string accordVersement, string documentsFile, string bordereauFile) { String traceFile = buildTraceFileName(repLog, "PBV"); StreamWriter streamWriter = null; Action<Exception, String> eh = (ex, str) => { Console.WriteLine(ex.GetType().Name + " while trying to use trace file: " + traceFile + ". Complementary message: " + str); throw ex; }; try { streamWriter = new StreamWriter(traceFile); } catch (IOException e) { eh(e, "Mauvaise syntaxe de nom de fichier"); } catch (UnauthorizedAccessException e) { eh(e, "Droits d'accès à corriger"); } catch (System.Security.SecurityException e) { eh(e, "Droits d'accès à corriger"); } streamWriter.WriteLineFlush("Prepare to 'ConfigurationManager.AppSettings[\"databaseConnexion\"]'"); String informationsDatabase = ConfigurationManager.AppSettings["databaseConnexion"]; streamWriter.WriteLineFlush("informationsDatabase='" + informationsDatabase + "'"); SedaSummaryGenerator.SedaSummaryGenerator ssg = new SedaSummaryRngGenerator(); ssg.setTracesWriter(streamWriter); SimpleConfig config = new SimpleConfig(); String erreurFichierConfig = config.loadFile("../job.config"); streamWriter.WriteLineFlush("INFORMATION : retour lecture ../config '" + erreurFichierConfig + "'"); if (erreurFichierConfig != String.Empty) { erreurFichierConfig = config.loadFile("../../job.config"); streamWriter.WriteLineFlush("INFORMATION : retour lecture ../../config '" + erreurFichierConfig + "'"); } // On a trouvé un fichier de config pour remplacer la base de données if (erreurFichierConfig == String.Empty && config.hasAccordVersementConfig()) { AccordVersementConfig accordVersementConfig = config.getAccordVersementConfig(accordVersement, baseURI); if (accordVersementConfig == null) { streamWriter.WriteLineFlush("ATTENTION : Impossible de trouver l'accord de versement '" + accordVersement + "' dans la configuration"); } else { if (accordVersementConfig.SAE_ProfilArchivage.Length == 0) streamWriter.WriteLineFlush("ATTENTION : Le profil d'archivage n'a pas de nom de fichier"); } String dataSha1 = String.Empty; try { dataSha1 = Utils.computeSha1Hash(documentsFile); } catch (IOException e) { // Ignorer les exceptions, car si le fichier de données n'est pas accessible, // une exception sera générée plus tard avec un contexte plus explicatif } ssg.prepareInformationsWithConfigFile(config, baseURI, accordVersement, dataSha1); } else { ssg.prepareInformationsWithDatabase(informationsDatabase, baseURI, accordVersement); } ssg.prepareArchiveDocumentsWithFile(repDocuments, documentsFile); ssg.generateSummaryFile(bordereauFile); ssg.close(); streamWriter.Close(); StringCollection errors = ssg.getErrorsList(); StringBuilder Response = new StringBuilder(); if (errors != null && errors.Count != 0) { Console.WriteLine("Il y a eu des erreurs."); streamWriter.WriteLine("Il y a eu des erreurs."); foreach (String str in errors) { streamWriter.WriteLine(str); Console.WriteLine(str); Response.Append(str); } } return Response.ToString(); }
static int Main(string[] args) { System.IO.StreamWriter streamWriter = null; String jobName; if (args.Length < 1) { System.Console.WriteLine("Syntaxe attendue : BusinessDataControllerLauncher nom-job-controle"); System.Console.WriteLine("nom-job-controle est une section dans le fichier job.config"); System.Console.WriteLine("Une section a la forme :"); System.Console.WriteLine("[data-control : nom-job-controle]"); System.Console.WriteLine(" trace = chemin/vers/fichier-de-trace.txt"); System.Console.WriteLine(" profil = chemin/vers/fichier-de-profil.rng"); System.Console.WriteLine(" data = chemin/vers/fichier-de-donnees-metier.txt"); System.Console.WriteLine(""); System.Console.WriteLine("Aucun job demandé, le premier job sera exécuté"); System.Console.WriteLine(""); jobName = String.Empty; } else { jobName = args[0]; } SimpleConfig config = new SimpleConfig(); String erreur = config.loadFile("./job.config"); if (erreur != String.Empty) // on tient compte du fait qu'en environnement de développement, l'exe est dans bin/Release erreur = config.loadFile("../../job.config"); if (erreur != String.Empty) { System.Console.WriteLine(erreur); System.Environment.Exit(-1); } DataControlConfig datacontrol = config.getDatacontrolConfig(jobName); if (datacontrol == null) { System.Console.WriteLine("Aucun job 'data-control: " + jobName + "' trouvé dans le fichier job.config. Vérifiez la syntaxe ou créez une tâche."); System.Environment.Exit(-1); } System.Console.WriteLine("Contrôle métier du job '" + datacontrol.nomJob + "' : '" + datacontrol.dataFile + "' avec le profil '" + datacontrol.profileFile + "'"); Action<Exception, String> eh = (ex, str) => { Console.WriteLine(ex.GetType().Name + " while trying to use trace file: " + datacontrol.traceFile + ". Complementary message: " + str); System.Environment.Exit(-1); }; try { streamWriter = new System.IO.StreamWriter(datacontrol.traceFile); } catch (System.IO.IOException e) { eh(e, "Mauvaise syntaxe de nom de fichier"); } catch (UnauthorizedAccessException e) { eh(e, "Droits d'accès à corriger"); } catch (System.Security.SecurityException e) { eh(e, "Droits d'accès à corriger"); } BusinessDataController bdc = new BusinessDataController(); bdc.setTracesWriter(streamWriter); StringCollection errors = bdc.controlDataFormat(datacontrol.dataFile); StringCollection erreursCorrespondance = bdc.controlMatchingBetweenDataAndProfile(datacontrol.dataFile, datacontrol.profileFile); int nbErreurs = 0; if (errors.Count > 0) nbErreurs += errors.Count; if (erreursCorrespondance != null && erreursCorrespondance.Count != 0) nbErreurs += erreursCorrespondance.Count; if (nbErreurs > 0) System.Console.WriteLine("\nDes erreurs ont été rencontrées\n"); if (errors.Count > 0) { System.Console.WriteLine("\nErreurs dans les données :\n"); foreach (String str in errors) { System.Console.WriteLine(str); streamWriter.WriteLine(str); } System.Console.WriteLine("\n"); streamWriter.WriteLine("\n"); } if (erreursCorrespondance != null && erreursCorrespondance.Count != 0) { System.Console.WriteLine("\nErreurs de correspondance entre les données et le profil :\n"); foreach (String err in erreursCorrespondance) { Console.WriteLine(err); streamWriter.WriteLine(err); } System.Console.WriteLine("\n"); streamWriter.WriteLine("\n"); } streamWriter.Flush(); return nbErreurs; }