예제 #1
0
        public void ImageExtractDocTextTest(string path, string code)
        {
            var extractor    = new DocExtractor(new ContentImageExtractor());
            var rdpExtractor = new RpdContentExtractor(new RpdExtractorConfig(new List <string>(), new List <string>(), @"(?<code>\d\d\.0\d\.\d\d)($|\D)"));
            var bytes        = File.ReadAllBytes(path);

            var content = extractor.ExtractImageText(bytes, path).Result;
            var extract = rdpExtractor.Extract(content.Content);

            Assert.True(extract.Codes.Count > 0);
            Assert.AreEqual(code, extract.Codes.First());
        }
예제 #2
0
        public ActionResult Import(HttpPostedFileBase file)
        {
            // Verify that the user selected a file
            if (file != null && file.ContentLength > 0)
            {
                // extract only the filename
                var fileName = Path.GetFileName(file.FileName);
                // store the file inside ~/App_Data/uploads folder
                var path = Path.Combine(Server.MapPath("~/PDFFiles"), fileName);
                file.SaveAs(path);

                var errors = DocExtractor.ExtractFromFile(path, fileName);
                ViewBag.Message = errors.Count > 0 ? $"File {fileName} import failed! {errors.ToString()}" : $"File {fileName} imported successfully!";

                return(View("Index"));
            }
            // redirect back to the index action to show the form once again
            ViewBag.Message = "File import failed!";

            return(View("Index"));
        }