Exemplo n.º 1
0
        public ActionResult DocClassification(HttpPostedFileBase file)
        {
            DocClassification docCls = new DocClassification();

            try {
                String physicalPath = "";
                if (file.ContentLength > 0)
                {
                    String fileHashName = (DateTime.Now).ToString("yyyyMMddHHmmssffff") + file.FileName;
                    physicalPath = DecodePath(
                        Path.Combine(
                            UtilityOperations.GetServerMapPath(
                                UtilityOperations.GetDCEDockerRootPath()) + "\\_temp",
                            Path.GetFileName(fileHashName)));
                    file.SaveAs(physicalPath);
                    String   varet        = (new DocumentsOperations()).IdentifyDocumentType(physicalPath);
                    FileInfo uploadedFile = new FileInfo(physicalPath);
                    docCls.DocClassifiedOutcome += "<input hidden id=\"UploadedFileName\" value=\"" + uploadedFile.Name + "\"/>";
                    docCls.DocClassifiedOutcome += "<span>File Name : " + (uploadedFile.Name).Substring(18) + "</span><br/>";
                    docCls.DocClassifiedOutcome += "<span>Document Type : " + varet + "</span><br/>";
                    docCls.DocClassifiedOutcome += "<span>File Uploaded @ : " + uploadedFile.CreationTime + "</span><br/>";
                }
                else
                {
                    docCls.DocClassifiedMsg = "Error - Please attach the file ...";
                }
            } catch (Exception ex) {
                docCls.DocClassifiedMsg = "Error - File upload failed! " + ex.Message;
            }

            return(View(docCls));
        }
Exemplo n.º 2
0
        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
            });
        }