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 }); }
public JsonResult Upload(String virtualPath) { String jsonRet = ""; if (String.IsNullOrEmpty(virtualPath) || virtualPath == "/") { virtualPath = UtilityOperations.GetDockerRootPath(Server); } String userName = HttpContext.User.Identity.Name; foreach (String file in Request.Files) { var fileContent = Request.Files[file]; var fileNiceName = Request.Form["fileNiceName"]; var fileDesc = Request.Form["fileDesc"]; if (fileContent != null && fileContent.ContentLength > 0) { String filePath = Path.Combine(UtilityOperations.GetServerMapPath(virtualPath), Path.GetFileName(fileContent.FileName)); DocumentsOperations docOps = new DocumentsOperations(); //docOps.InsertFile(fileContent.FileName, virtualPath, fileNiceName, fileDesc); docOps.InsertFileEncodeFileName(fileContent.FileName, virtualPath + "/" + fileContent.FileName, fileNiceName, fileDesc, userName, false); fileContent.SaveAs(filePath); jsonRet = "Uploaded"; } } return(new JsonResult() { Data = jsonRet }); }
public JsonResult UploadTemplate() { String retJsonMsg = String.Empty; foreach (String file in Request.Files) { var fileContent = Request.Files[file]; var docType = Request.Form["DocType"]; var docDesc = Request.Form["DocDesc"]; var skipPages = Request.Form["SkipPages"]; List <int> pagesToSkill = new List <int>(); if (skipPages.Length > 0) { List <String> skippages = skipPages.Split(',').ToList(); foreach (String skip in skippages) { int number; bool retInt = int.TryParse(skip, out number); if (retInt) { pagesToSkill.Add(number); } else { retJsonMsg = "ERROR - Skip page value [" + skip + "] is not a number!"; break; } } } if (fileContent != null && fileContent.ContentLength > 0 && String.IsNullOrEmpty(retJsonMsg)) { String virtualPath = UtilityOperations.GetDCEDockerRootPath(); String physicalPath = DecodePath(Path.Combine(UtilityOperations.GetServerMapPath(virtualPath), Path.GetFileName(fileContent.FileName))); String userName = HttpContext.User.Identity.Name; DocumentsOperations docOps = new DocumentsOperations(); if (docOps.GetFileByVirtualPath(virtualPath + "/" + fileContent.FileName) == null) { System.IO.Directory.CreateDirectory(UtilityOperations.GetServerMapPath(virtualPath)); fileContent.SaveAs(physicalPath); docOps.InsertFileEncodeFileName(fileContent.FileName, virtualPath + "/" + fileContent.FileName, "_DCEDockerFile", docDesc, userName, false); DCEOperations dceOps = new DCEOperations(); dceOps.InsertTemplate(virtualPath + "/" + fileContent.FileName, docType, docDesc, userName); List <String> retStrArr = GetPDFContents(physicalPath, pagesToSkill); dceOps.InsertOCRContents(fileContent.FileName, retStrArr[0], retStrArr[1]); } else { retJsonMsg = "ERROR - The file already eixsts."; } } } return(new JsonResult() { Data = retJsonMsg }); }