Beispiel #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
            });
        }
Beispiel #2
0
        public void DownloadFile(String virtualPath, String userID)
        {
            String physicalPath = UtilityOperations.GetServerMapPath(virtualPath);

            physicalPath = UtilityOperations.DecodePath(physicalPath, Server);
            List <String> archives = new List <String>();

            archives.Add(physicalPath);
            RecordFileDownload(virtualPath, userID);
            UtilityOperations.DownloadFiles(archives, this.HttpContext.ApplicationInstance.Context);
        }
Beispiel #3
0
        public ActionResult CommonFolderMgt(CommonFolderManagement cfm, String submit, String tableSelectedFolder)
        {
            DocumentsOperations docOps = new DocumentsOperations();
            String virtualPath = "", physicalPath = "", folderPath = "";

            switch (submit)
            {
            case "Create":
                virtualPath  = UtilityOperations.GetDockerCommonFolderPath();
                physicalPath = UtilityOperations.GetServerMapPath(virtualPath);
                folderPath   = Path.Combine(UtilityOperations.DecodePath(physicalPath, Server), cfm.FolderName);
                if (folderPath != "\\")
                {
                    if (!Directory.Exists(folderPath))
                    {
                        docOps.InsertNewFolder(virtualPath, folderPath, HttpContext.User.Identity.Name, cfm.FolderName);
                    }
                    else
                    {
                        TempData["CommonFolderMgtErrorMsg"] = "Warning - Folder already existed.";
                    }
                }
                break;

            case "Edit":
                return(RedirectToAction("EditCommonFolder", new { virtualPath = tableSelectedFolder }));

            case "Delete":
                physicalPath = UtilityOperations.DecodePath(UtilityOperations.GetServerMapPath(tableSelectedFolder), Server);
                FileAttributes attr = System.IO.File.GetAttributes(physicalPath);
                if (Directory.Exists(physicalPath))
                {
                    if (docOps.GetFilesStartsWithVirtualPath(tableSelectedFolder) != null)
                    {
                        docOps.DeleteFile(tableSelectedFolder);
                    }
                    Directory.Delete(physicalPath, true);
                }
                else
                {
                    TempData["CommonFolderMgtErrorMsg"] = "Warning - Folder not exist in the system.";
                }
                break;
            }
            return(RedirectToAction("CommonFolderMgt"));
        }
Beispiel #4
0
        public JsonResult DeleteFile(String virtualPath)
        {
            bool retJsonBool = false;

            if (virtualPath.Length > 1)
            {
                String physicalPath = UtilityOperations.GetServerMapPath(virtualPath);
                physicalPath = UtilityOperations.DecodePath(physicalPath, Server);
                FileAttributes attr = System.IO.File.GetAttributes(physicalPath);
                if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    if (Directory.Exists(physicalPath))
                    {
                        DocumentsOperations docOps = new DocumentsOperations();
                        if (docOps.GetFilesStartsWithVirtualPath(virtualPath) != null)
                        {
                            docOps.DeleteFile(virtualPath);
                        }
                        Directory.Delete(physicalPath, true);
                        retJsonBool = true;
                    }
                }
                else
                {
                    if (System.IO.File.Exists(physicalPath))
                    {
                        DocumentsOperations docOps = new DocumentsOperations();
                        if (docOps.GetFileByVirtualPath(virtualPath) != null)
                        {
                            docOps.DeleteFile(virtualPath);
                        }
                        System.IO.File.Delete(physicalPath);
                        retJsonBool = true;
                    }
                }
            }
            return(new JsonResult()
            {
                Data = retJsonBool
            });
        }
Beispiel #5
0
        public JsonResult Rename()
        {
            var            virtualPath   = Request.Form["virtualPath"];
            var            newName       = Request.Form["newName"];
            var            oldName       = Request.Form["oldName"];
            String         decodePath    = UtilityOperations.DecodePath(UtilityOperations.GetServerMapPath(virtualPath), Server);
            String         newDecodePath = decodePath.Replace(oldName, newName);
            String         retJsonMsg    = "";
            FileAttributes attr          = System.IO.File.GetAttributes(decodePath);

            if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
            {
                if (System.IO.Directory.Exists(decodePath))
                {
                    System.IO.Directory.Move(decodePath, decodePath.Replace(oldName, newName));
                    retJsonMsg += " DirRenamed";
                }
            }
            else
            {
                if (System.IO.File.Exists(decodePath))
                {
                    System.IO.File.Move(decodePath, decodePath.Replace(oldName, newName));
                    retJsonMsg += " FileRenamed";
                }
            }
            DocumentsOperations docOps = new DocumentsOperations();

            if (docOps.GetFileByVirtualPath(virtualPath) != null)
            {
                docOps.RenameFile(newName, virtualPath, virtualPath.Replace(oldName, newName));
                retJsonMsg += " DBRenamed";
            }
            return(new JsonResult()
            {
                Data = retJsonMsg
            });
        }
Beispiel #6
0
        public JsonResult CreateNewFolder(String virtualPath, String userName, String folderName)
        {
            String physicalPath = UtilityOperations.GetServerMapPath(virtualPath);
            String decodePath   = UtilityOperations.DecodePath(physicalPath, Server);
            String folderPath   = Path.Combine(decodePath, folderName);
            String retJsonMsg   = "";

            if (folderPath != "\\")
            {
                if (!Directory.Exists(folderPath))
                {
                    DocumentsOperations docOps = new DocumentsOperations();
                    docOps.InsertNewFolder(virtualPath, folderPath, userName, folderName);
                }
                else
                {
                    retJsonMsg += "Folder name already exists. Please enter a different folder name";
                }
            }
            return(new JsonResult()
            {
                Data = retJsonMsg
            });
        }