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(); }