示例#1
0
        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));
        }
示例#2
0
        static int Main(string[] args)
        {
            StreamWriter streamWriter = null;

            String jobName;

            if (args.Length < 1)
            {
                System.Console.WriteLine("Syntaxe attendue : RngProfileControllerLauncher nom-job-controle");
                System.Console.WriteLine("nom-job-controle est une section dans le fichier job.config");
                System.Console.WriteLine("Une section de contrôle de profil a la forme :");
                System.Console.WriteLine("[profile-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("");
                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;

            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.setDataFile(control.dataFile);
            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 expectedTagsList = rpc.getExpectedTagsList();

            if (expectedTagsList != null && expectedTagsList.Count != 0)
            {
                Console.WriteLine("\nTags attendus par le profil.\n");
                foreach (String str in expectedTagsList)
                {
                    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);
        }
示例#3
0
        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 de contrôle de données métier 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);
        }
示例#4
0
        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());
        }
示例#5
0
        static int Main(string[] args)
        {
            StreamWriter streamWriter = null;

            String jobName;

            if (args.Length < 1)
            {
                System.Console.WriteLine("Syntaxe attendue : SedaSummaryGeneratorLauncher nom-job-generation");
                System.Console.WriteLine("nom-job-generation est une section dans le fichier job.config");
                System.Console.WriteLine("Une section de génération de bordereau a la forme :");
                System.Console.WriteLine("[data-control : nom-job-controle]");
                System.Console.WriteLine("  trace = chemin/vers/fichier-de-trace.txt");
                System.Console.WriteLine("  accord = nom-accord-versement");
                System.Console.WriteLine("  baseURI = chemin/vers/repertoire-des-documents");
                System.Console.WriteLine("  data = chemin/vers/fichier-de-donnees-metier.txt");
                System.Console.WriteLine("  bordereau = chemin/vers/bordereau-a-generer.xml");
                System.Console.WriteLine("");
                System.Console.WriteLine("Où nom-accord-versemnt et baseURI renvoient vers une section accord-versement/SAE_Serveur");
                System.Console.WriteLine("[accord-versement : nom-accord-versement]");
                System.Console.WriteLine("	SAE_Serveur = http://test");
                System.Console.WriteLine("	TransferIdPrefix = PREFIX_");
                System.Console.WriteLine("	SAE_ProfilArchivage = chemin-vers-fichier");
                System.Console.WriteLine("	TransferringAgencyId = TA_ID");
                System.Console.WriteLine("	TransferringAgencyName = TA_NAME");
                System.Console.WriteLine("	TransferringAgencyDesc = TA_DESC");
                System.Console.WriteLine("	ArchivalAgencyId = AA_ID");
                System.Console.WriteLine("	ArchivalAgencyName = AA_NAME");
                System.Console.WriteLine("	ArchivalAgencyDesc = AA_DESC");
                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);
        }