public static void MakeReport(FileInfo fileIn) { Report report = new Report(); report.LoadDCMFile(fileIn.FullName, Config.sSRBegin); int accessionNumber = report.GetAccessionNumber(); string tempFullPath = Path.Combine(Config.tempPath, accessionNumber.ToString()); Utilities.Folders.CheckIfNotExistAndCreate(tempFullPath); Utilities.Folders.Copy(Config.templatePath, tempFullPath, true); foreach (string contentFile in Properties.Settings.Default.contentFiles) { report.ReplaceValuesOnFile(contentFile); } FileInfo fileOut = new FileInfo(CrapFixer.CrapFixer.AmbulatorioReportPath( Config.fileOutPath, accessionNumber + ".doc")); if (fileOut.Exists) { fileOut.Delete(); } Console.WriteLine("Creating report: {0}", fileOut); Utilities.Zippit.MakeZip(fileIn.FullName, fileOut.FullName); Directory.Delete(fileOut.DirectoryName, true); }
private void OnModify(object sender, FileSystemEventArgs e) { Utilities.Files fileUtil = new Utilities.Files(); while (fileUtil.IsFileLocked(e.FullPath)) { Thread.Sleep(500); } if (e.Name.StartsWith("SR")) // cannot use Config.Filter cause the * at the end of string... { Console.WriteLine("[INFO] New Structured Report"); Console.WriteLine(e.FullPath); Console.WriteLine(); Report report = new Report(); report.CreateFullReport(new FileInfo(e.FullPath), Config.tempOut); } File.Delete(e.FullPath); }
static void ParseFilesOnFolder(DirectoryInfo sourceDir) { // Search for SR on folder foreach (FileInfo file in sourceDir.EnumerateFiles(Config.fileFilter)) { Report report = new Report(); try { report.CreateFullReport(file, Config.tempOut); file.Delete(); } catch (Exception ex) { Console.WriteLine("[ERROR] Main -> There was an error trying to create the report:\n{0}", file.FullName); continue; } } // Remove garbage foreach (FileInfo file in sourceDir.EnumerateFiles()) { Report report = new Report(); try { file.Delete(); } catch (Exception ex) { Console.WriteLine("[ERROR] Main -> There was an error trying to delete garbage:\n{0}\n{1}", file.FullName, ex.Message); continue; } } }