コード例 #1
0
        public JsonResult OCRThisFile(String virtualPath)
        {
            String        physicalPath  = UtilityOperations.DecodePath(UtilityOperations.GetServerMapPath(virtualPath), Server);
            SingleFileOCR singleFileOCR = new SingleFileOCR(physicalPath);
            String        retVal        = singleFileOCR.StartOCR();

            if (!retVal.StartsWith("ERROR"))
            {
                DocumentsOperations docOps = new DocumentsOperations();
                var    file       = docOps.GetFileByVirtualPath(virtualPath);
                String oriFileExt = (new System.IO.FileInfo(physicalPath)).Extension;
                String retFileExt = (new System.IO.FileInfo(retVal)).Extension;
                retFileExt = retVal.Substring(retVal.Length - (retFileExt.Length + 4));
                docOps.InsertFileEncodeFileName(file.Name.Replace(oriFileExt, retFileExt), file.VirtualPath.Replace(oriFileExt, retFileExt), "", "OCR Performed @ " + DateTime.Now, HttpContext.User.Identity.Name, false);
                docOps.InsertFileBeenOCR(docOps.GetFileIDByVirtualPath(file.VirtualPath.Replace(oriFileExt, retFileExt)), docOps.IdentifyDocumentType(retVal));
                return(new JsonResult()
                {
                    Data = ""
                });
            }
            return(new JsonResult()
            {
                Data = retVal
            });
        }