Beispiel #1
0
        public void DeleteFiles(string jlist)
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            List<string> list = serializer.Deserialize<List<string>>(jlist);
            List<string> archives = new List<string>();
            foreach (string path in list)
            {

                FileAttributes attr = System.IO.File.GetAttributes(path);
                if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    if (Directory.Exists(path))
                    {
                        Directory.Delete(path, true); //delete folder and all subdirectories
                        // return RedirectToAction("Repository", "Repository");
                    }
                }
                else
                {
                    if (System.IO.File.Exists(path))
                    {
                        string previousVirtualPath = UtilityOperations.GetVirtualPath(path);//.Replace("~/", "~//");
                        DocumentsOperations documentsOperations = new DocumentsOperations();
                        documentsOperations.DeleteFile(previousVirtualPath);
                        System.IO.File.Delete(path);
                        // return RedirectToAction("Repository", "Repository");
                    }
                }
            }

            //return View();
        }
Beispiel #2
0
        public JsonResult DeleteTemplate(String virtualPath)
        {
            bool retJsonBool           = false;
            DocumentsOperations docOps = new DocumentsOperations();

            if (docOps.GetFileByVirtualPath(virtualPath) != null)
            {
                DCEOperations dceOps = new DCEOperations();
                Guid          fileID = dceOps.GetFileIDFromTemplateByVirtualPath(virtualPath);
                if (fileID != Guid.Empty)
                {
                    dceOps.DeleteUploadedTemplateKeywords(fileID);
                    dceOps.DeleteUploadedTemplates(virtualPath);
                    docOps.DeleteFile(virtualPath);
                    String physicalPath = UtilityOperations.GetServerMapPath(virtualPath);
                    physicalPath = DecodePath(physicalPath);
                    if (System.IO.File.Exists(physicalPath))
                    {
                        System.IO.File.Delete(physicalPath);
                    }
                    retJsonBool = true;
                }
            }
            return(new JsonResult()
            {
                Data = retJsonBool
            });
        }
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
            });
        }