Пример #1
0
 protected void UploadButton_Click(object sender, EventArgs e)
 {
     if (ocrFileUpload.HasFile)
     {
         try
         {
             string filename      = Path.GetFileName(ocrFileUpload.FileName);
             var    ocrFile       = ocrFileUpload.FileContent;
             var    ocrFileReader = new OCRFile(ocrFile);
             var    results       = ocrFileReader.Parse();
             AccountNumbers.Text = string.Join("<br/>", results.ToArray());
             // Display results back to user?
             uploadStatus.Text = "Upload status: File uploaded!";
         }
         catch (Exception ex)
         {
             uploadStatus.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
         }
     }
 }
Пример #2
0
        public void ParseFileTest()
        {
            OCRFile ocrTest;

            using (StreamReader reader = new StreamReader(@"Models\BasicGoodAccountNumbers.txt"))
            {
                ocrTest = new OCRFile(reader.BaseStream);
                var expected = ocrTest.Parse();
                Assert.AreEqual(expected[0], "000000000");
                Assert.AreEqual(expected[1], "111111111");
                Assert.AreEqual(expected[2], "222222222");
                Assert.AreEqual(expected[3], "333333333");
                Assert.AreEqual(expected[4], "444444444");
                Assert.AreEqual(expected[5], "555555555");
                Assert.AreEqual(expected[6], "666666666");
                Assert.AreEqual(expected[7], "777777777");
                Assert.AreEqual(expected[8], "888888888");
                Assert.AreEqual(expected[9], "999999999");
                Assert.AreEqual(expected[10], "123456789");
            }
        }