示例#1
0
        public IActionResult ProcessFile(IFormFile file)
        {
            if (file == null || file.Length == 0)
            {
                return(Content("file not selected"));
            }


            using (var engine = new TesseractEngine(Path.Combine(_environment.WebRootPath, "tessdata"), "eng", EngineMode.Default))
            {
                using (var image = new Bitmap(file.OpenReadStream()))
                {
                    using (var page = engine.Process(image))
                    {
                        IndexViewModel model = new IndexViewModel();
                        model.Text           = page.GetText();
                        model.MeanConfidence = page.GetMeanConfidence();

                        using (var context = new OCRContext())
                        {
                            var a = new Receipt();

                            var b = new AspNetUsers();
                            a.Faktura = model.Text;

                            context.Receipt.Add(a);
                            context.SaveChanges();
                        }

                        return(View("Index", model));
                    }
                }
            }
        }
示例#2
0
        public ActionResult Create([FromBody] User u)
        {
            using (var context = new OCRContext())
            {
                User test = new User();
                test.Emri = u.Emri;

                context.User.Add(test);
                context.SaveChanges();
            }
            return(View());
        }
示例#3
0
 public OcrTemplateController(IOptions <OcrTemplateConfiguration> configSettings, OCRContext ctx)
 {
     this.configSettings = configSettings.Value;
     this.dbContext      = ctx;
 }