Esempio n. 1
0
        public void test(IDocument doc, IProcessingCallback Processing)
        {
            Processing.ReportMessage("Setting fc_Predefined:InvoicePredefinedVendorId from import folder...");

            IPage  page = doc.Pages[0];
            string path = page.ImageSource;

            string pattern = @"\[(.*?)\]";
            Match  m       = Regex.Match(path, pattern, RegexOptions.IgnoreCase);

            Processing.ReportMessage("Testing RegEx...");

            if (m.Success)
            {
                string BUid = m.Groups[1].Value;

                Processing.ReportMessage("Regex succesfull, setting " + BUid + " as the BU ID!");

                doc.Properties.Set("fc_Predefined:InvoicePredefinedVendorId", BUid);
            }
            else
            {
                Processing.ReportWarning("Could not detect BU ID :-(");
            }
        }
Esempio n. 2
0
        public Processor(string ApplicationId, string password, IProcessingCallback proc)
        {
            this.Processing = proc;
            Processing.ReportMessage("Starting Receipt processing!");

            restClient = new RestServiceClient();
            restClient.Proxy.Credentials = CredentialCache.DefaultCredentials;

            //!!! Please provide your application id and password in Config.txt
            // To create an application and obtain a password,
            // register at http://cloud.ocrsdk.com/Account/Register
            // More info on getting your application id and password at
            // http://ocrsdk.com/documentation/faq/#faq3

            // Name of application you created
            restClient.ApplicationId = ApplicationId;
            // Password should be sent to your e-mail after application was created
            restClient.Password = password;

            // Display hint to provide credentials
            if (String.IsNullOrEmpty(restClient.ApplicationId) ||
                String.IsNullOrEmpty(restClient.Password))
            {
                Processing.ReportError("Please provide access credentials to Cloud OCR SDK service!");
                throw new Exception("Please provide access credentials to Cloud OCR SDK service!");
            }

            Console.WriteLine(String.Format("Application id: {0}\n", restClient.ApplicationId));
        }
Esempio n. 3
0
        public Receipt Process(string imagePath, ProcessingSettings settings)
        {
            string result = null;

            Console.WriteLine("Uploading image...");
            if (this.Processing != null)
            {
                Processing.ReportMessage("Uploading image...");
            }


            OcrSdkTask task = restClient.ProcessImage(imagePath, settings);

            Console.WriteLine("Processing...");

            if (this.Processing != null)
            {
                Processing.ReportMessage("Processing...");
            }

            task = waitForTask(task);

            if (task.Status == TaskStatus.Completed)
            {
                Console.WriteLine("Processing completed.");
                Processing.ReportMessage("Processing completed.");

                result = restClient.DownloadUrl(task.DownloadUrls[0]);

                Console.WriteLine("Download completed.");
                Processing.ReportMessage("Download completed.");
            }
            else if (task.Status == TaskStatus.NotEnoughCredits)
            {
                Processing.ReportMessage("Not enough credits to process the file. Please add more pages to your application balance.");
                throw new Exception("Not enough credits to process the file. Please add more pages to your application balance.");
            }
            else
            {
                Processing.ReportMessage("Error while processing the task");
                throw new Exception("Error while processing the task");
            }

            receipt = new Receipt(result, this.Processing);

            return(receipt);
        }