public static PDFInfo CreatePdfInfo(string filepath, DTO.Rectangle rectangle) { var pdf = new PDFInfo(); pdf.FilePath = filepath; pdf.CreatedTime = new FileInfo(filepath).CreationTime; pdf.Images = new Imaging.PdfConverter().CovertPdfToImages(filepath); foreach (var image in pdf.Images) { var bcode = Imaging.BarcodeScanner.GetBarcode(image, rectangle); if (bcode.Type != Core.Enums.BarcodeType.Empty) { pdf.Barcode = bcode.Number; pdf.BarcodeType = bcode.Type; pdf.isBarcode = true; break; } } //Loop over the images again to compress them. Can't modify the itterator in the foreach loop for (int i = 0; i < pdf.Images.Count; i++) { var img = pdf.Images[i]; //image has been processed. We can compress it now Imaging.ImageCompressor.CompressImage(ref img); } return(pdf); }
private void SaveInfoToDatabase(PDFInfo pdf) { logger.Info($"Getting req info from the database for {pdf.Barcode}"); var barcode = int.Parse(pdf.Barcode); var req = RequisitionFactory.CreateRequisition(barcode, new ProlisService()); if (req != null) { var doc = new RequisitionDocument() { RequisitionId = req.RequisitionNo, Document = pdf.Pdf, markedDeleted = false }; logger.Info("Req info received. Saving info."); var db = new RequisitionService(); db.SaveRequisition(req); var docService = new LOIS.BLL.services.DocumentService(); docService.SaveDocument(doc); if (req.Patient != null) { db.SavePatient(req.Patient); } logger.Debug("Saved for " + pdf.Barcode); } }
static int Main(string[] args) { Console.WriteLine("Press enter to scan"); Console.ReadLine(); var sw = Stopwatch.StartNew(); //var fileToScan = @"C:\Users\MarWin\Desktop\Praca magisterska\eicar.com"; //var fileToScan = @"C:\Users\MarWin\Desktop\Cities.Skylines.Industries.Update.v1.11.1-f2\Update\Setup.exe"; //var fileToScan = @"C:\Users\MarWin\Downloads\ProtonVPN_win_v1.7.4.exe"; //var fileToScan = @"C:\Users\MarWin\Downloads\MicrosoftSpeechPlatformSDK.msi"; //var fileToScan = @"C:\Users\MarWin\Downloads\TIPS 3.31 wytyczne 2018-2019.doc"; //var fileToScan = @"C:\Users\MarWin\Downloads\Hdk-i-nagrodowy.docx"; //var fileToScan = @"C:\Users\MarWin\Desktop\Praca magisterska\PEReader.dll"; //var fileToScan = @"D:\TS\createfileassoc.exe"; var fileToScan = @"C:\Users\MarWin\Desktop\Praca magisterska\eicardropper.pdf"; //var fileToScan = @"C:\Users\MarWin\Pictures\10a.jpg"; if (!File.Exists(fileToScan)) { Console.WriteLine("Press any key to exit."); Console.ReadKey(); return(0); } //ścieżka do pliku skanowanego var fileInfo = new FileInfo(fileToScan); //wczytanie configu var configFileFromPath = new ConfigParser(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\config.cfg", new ConfigParserSettings { MultiLineValues = MultiLineValues.Simple | MultiLineValues.AllowValuelessKeys, Culture = new CultureInfo("en-US") }); var filenameWithoutPath = Path.GetFileName(fileToScan); var size = fileInfo.Length; string sha256 = SHA256CheckSum(fileToScan); XMLParser raport = new XMLParser(filenameWithoutPath, size, sha256); //stworzenie kolejki skanerów na podstawie configu ScanQueue queue = new ScanQueue(fileToScan, configFileFromPath, ref raport); sw.Stop(); //BasicProperties BasicProperties basic = new BasicProperties(fileToScan, ref raport); //FileVersionInfo FileversionInfo fileversioninfo = new FileversionInfo(fileToScan, ref raport); if (Path.GetExtension(fileToScan) == ".pdf") //jezeli jest PDF { PDFInfo pdfinfo = new PDFInfo(fileToScan, ref raport); } else if (StgIsStorageFile(fileToScan) == 0) // jezeli jest OLE { OLECompoundFileInfo ole = new OLECompoundFileInfo(fileToScan, ref raport); } else { try { //PEHeader PEHeader peheader = new PEHeader(fileToScan, ref raport); PESections pesections = new PESections(fileToScan, ref raport); PEImports peimports = new PEImports(fileToScan, ref raport); PEResources peresources = new PEResources(fileToScan, ref raport); } catch (ArgumentException) //jeżeli nie jest valid PE, ponieważ może nie być OLE i nie być PE { } } //EXIF //Wykorzystanie programu EXIFTOOLS do wybrania metadanych ExIF exif = new ExIF(fileToScan, ref raport); //wypisanie XDocument raport.WritetoFile("raport" + sha256 + ".xml"); Console.WriteLine($"Completed scan in {sw.ElapsedMilliseconds}ms"); Console.WriteLine("Press any key to exit."); Console.ReadKey(); return(0); }