Пример #1
0
        private void process()
        {
            //Get all sub-directories to be operated on
            string[] dirs = Directory.GetDirectories(SOURCE_DIRECTORY);
            foreach (String dir in dirs)
            {
                //Create output directory and prepare filename for OCR log
                string outputDir    = createOutputDirectory(dirNameFromPath(dir));
                string outputLogDir = concatPath(outputDir, OCR_LOG_DIR_NAME);

                String[] files = Directory.GetFiles(dir);

                bool certNotFound = true;
                foreach (String file in files)
                {
                    String filename       = fileNameFromPath(file);
                    String outputFilePath = concatPath(outputDir, filename);
                    String outputLogPath  = concatPath(concatPath(outputDir, OCR_LOG_DIR_NAME), replaceFileExtension(filename, "txt"));

                    //Run tesseract on the file
                    string outputLogPathArg = removeFileExtension(outputLogPath);
                    readFileText(file, outputLogPathArg);

                    //Search newly created txt file to see if it the certificate of inspection
                    bool isCert = checkForCertificate(outputLogPath);

                    if (isCert)
                    {
                        String certName = "CERTIFICATE_OF_INSPECTION.txt";

                        string newFilePath = concatPath(outputLogDir, certName);

                        //Directory.CreateDirectory(outputLogDir); //- Not needed
                        File.Move(outputLogPath, newFilePath);

                        certNotFound = false;

                        OMIC_Information om = new OMIC_Information(newFilePath);
                        outputData.Add(omicAsString(om));

                        break;
                    }
                }
                if (certNotFound)
                {
                    //Decide what to do if a certificate is not found
                    Debug.WriteLine("Certificate could not be found in " + dir);
                    readErrorLog.Add("Certificate could not be found in " + dir);
                }
                //moveAllFilesInDir(dir, outputDir);
                deleteDirIfEmpty(dir);
            }
        }
Пример #2
0
        private void process()
        {
            removeAllSpaces();
            string[] dirs = Directory.GetDirectories(SOURCE_DIRECTORY);
            foreach (String dir in dirs)
            {
                string outputDir    = createOutputDirectory(dirNameFromPath(dir));
                string outputLogDir = concatPath(outputDir, OCR_LOG_DIR_NAME);

                String[] files = Directory.GetFiles(dir);

                bool certNotFound = true;
                foreach (String file in files)
                {
                    String filename       = fileNameFromPath(file);
                    String outputFilePath = concatPath(outputDir, filename);
                    String outputLogPath  = concatPath(concatPath(outputDir, OCR_LOG_DIR_NAME), replaceFileExtension(filename, "txt"));

                    readFileText(file, removeFileExtension(outputLogPath));

                    if (checkForCertificate(outputLogPath))
                    {
                        String certName = "CERTIFICATE_OF_INSPECTION.txt";

                        //Will not overwrite
                        string renamedOutputPath = concatPath(outputLogDir, certName);
                        File.Move(outputLogPath, renamedOutputPath);
                        certNotFound = false;
                        OMIC_Information om = new OMIC_Information(renamedOutputPath);
                        outputData.Add(omicAsString(om));
                        break;
                    }
                }
                if (certNotFound)
                {
                    //Decide what to do if a certificate is not found
                    Debug.WriteLine("Certificate could not be found in ", dir);
                }
                //moveAllFilesInDir(dir, outputDir);
                deleteDirIfEmpty(dir);
            }
        }
Пример #3
0
        private string omicAsString(OMIC_Information om)
        {
            string s = ",";

            string p1 = "";
            string p2 = "";

            int numUnits = om.searchForNumBoxCom();

            if (om.boxesOrCombos().Equals("BOXES"))
            {
                p1 = numUnits.ToString();
            }
            else
            {
                p2 = numUnits.ToString();
            }

            return(om.searchForDate() + s + om.searchForOMIC() + s + p1 + s + p2 + s + om.searchForWeight() + s + "LBS");
        }