예제 #1
0
파일: FileModel.cs 프로젝트: qiugs/dms
        public FileModel(String virtualPath, String userPath)
        {
            Name        = virtualPath;
            FullPath    = Encode("\\");
            Category    = new Category(FileType.DiscRoot);
            VirtualPath = virtualPath;
            String physicalPath = UtilityOperations.GetServerMapPath(virtualPath);

            CurrentFolderFiles = GetFoldersAndFiles(physicalPath);
            IsFolder           = true;
            if (String.Equals(virtualPath, UtilityOperations.GetDockerCommonFolderPath()))
            {
                IsCommonFolder = true;
            }
            if (String.Equals(virtualPath, UtilityOperations.GetDockerRootPath() + userPath))
            {
                IsRootDir         = true;
                parentVirtualPath = virtualPath;
            }
            else
            {
                IsRootDir         = false;
                parentVirtualPath = UtilityOperations.GetVirtualPath(Directory.GetParent(physicalPath).FullName);
            }
        }
예제 #2
0
 public ActionResult SubFolder(String virtualPath)
 {
     if (String.Equals(virtualPath, IsSystemAdministrator(HttpContext.User.Identity.Name)) ||
         String.Equals(virtualPath, UtilityOperations.GetDockerCommonFolderPath()))
     {
         return(RedirectToAction("Files"));
     }
     return(View(FilterAccessibleFolderAndFiles(virtualPath, HttpContext.User.Identity.Name)));
 }
예제 #3
0
        public ActionResult SearchFile(String searchValue, String virtualPath)
        {
            FileModel fileModel = new FileModel(virtualPath, "");

            fileModel.IsRootDir      = true;
            fileModel.IsSearchResult = true;
            String userName            = HttpContext.User.Identity.Name;
            DocumentsOperations docOps = new DocumentsOperations();
            AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations();

            if (aNaOps.IsSystemAdministratorUser(userName) || aNaOps.IsDMSAdministratorUser(userName))
            {
                userName = null;
            }
            String[]         usersPath           = docOps.GetAllUsersFolderInArray(UtilityOperations.GetDockerRootPath() + "/");
            List <FileModel> searchCurrentResult = new List <FileModel>();
            List <FileModel> searchCommonResult  = new List <FileModel>();

            foreach (String vPath in docOps.GetVirtualPathsBySearchValue(searchValue, userName))
            {
                FileModel file = null;
                if (vPath.StartsWith(UtilityOperations.GetDockerCommonFolderPath()))
                {
                    file = (new FileModel()).GetFolderOrFile(vPath);
                    file.IsCommonFolder = true;
                    if (usersPath.Contains(file.VirtualPath))
                    {
                        file.IsUserFolder = true;
                    }
                    searchCommonResult.Add(file);
                }
                else if (vPath.StartsWith(virtualPath) && !String.Equals(vPath, virtualPath))
                {
                    file = (new FileModel()).GetFolderOrFile(vPath);
                    if (usersPath.Contains(file.VirtualPath))
                    {
                        file.IsUserFolder = true;
                    }
                    searchCurrentResult.Add(file);
                }
            }
            fileModel.CurrentFolderFiles = searchCurrentResult;
            fileModel.CommonFolderFiles  = searchCommonResult;
            fileModel.Tags = new List <String>();
            return(View(fileModel));
        }
예제 #4
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"));
        }
예제 #5
0
        private FileModel FilterAccessibleFolderAndFiles(String virtualPath, String userName)
        {
            FileModel fileModel = null;
            AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations();
            DocumentsOperations docOps          = new DocumentsOperations();
            FileModel           commonFileModel = new FileModel(UtilityOperations.GetDockerCommonFolderPath(), "");

            if (!aNaOps.IsSystemAdministratorUser(userName) && !aNaOps.IsDMSAdministratorUser(userName))
            {
                fileModel = new FileModel(virtualPath, "/" + userName);
                List <String> dbFilesVPath = docOps.GetFilesByUserName(userName).Select(file => file.VirtualPath).ToList();
                if (fileModel.IsRootDir)
                {
                    fileModel.CommonFolderFiles = commonFileModel.CurrentFolderFiles.Where(file => dbFilesVPath.Contains(file.VirtualPath)).ToList();
                }
                else
                {
                    fileModel.CommonFolderFiles = new List <FileModel>();
                }
                fileModel.Tags = docOps.GetAllTagsByUserId(aNaOps.GetUserIDByUserName(userName));
            }
            else
            {
                fileModel = new FileModel(virtualPath, "");
                String[] usersPath = docOps.GetAllUsersFolderInArray(UtilityOperations.GetDockerRootPath() + "/");
                foreach (FileModel file in fileModel.CurrentFolderFiles)
                {
                    if (usersPath.Contains(file.VirtualPath))
                    {
                        file.IsUserFolder = true;
                    }
                }
                if (fileModel.IsRootDir)
                {
                    fileModel.CommonFolderFiles = commonFileModel.CurrentFolderFiles;
                }
                else
                {
                    fileModel.CommonFolderFiles = new List <FileModel>();
                }
                fileModel.Tags = docOps.GetAllTagsByUserId(aNaOps.GetUserIDByUserName(userName));
            }
            return(fileModel);
        }
예제 #6
0
        public ActionResult CommonFolderMgt()
        {
            CommonFolderManagement        cfm     = new CommonFolderManagement();
            List <CommonFolderAssignment> cfaList = new List <CommonFolderAssignment>();
            DocumentsOperations           docOps  = new DocumentsOperations();

            foreach (var item in docOps.GetFilesStartsWithVirtualPath(UtilityOperations.GetDockerCommonFolderPath()))
            {
                cfaList.Add(new CommonFolderAssignment {
                    FolderName  = item.Name,
                    CreatedAt   = item.DateTimeUploaded.ToString(),
                    VirtualPath = item.VirtualPath,
                    UsersName   = docOps.GetUsersNameByFileID(item.ID),
                    RolesName   = docOps.GetRolesNameByFileID(item.ID)
                });
            }
            cfm.CommonFolderAssignment = cfaList;
            return(View(cfm));
        }
예제 #7
0
        public ActionResult SearchTags(String virtualPath, String tagName)
        {
            FileModel fileModel = new FileModel(virtualPath, "");

            fileModel.IsRootDir      = true;
            fileModel.IsSearchResult = true;
            DocumentsOperations docOps = new DocumentsOperations();
            AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations();

            String[]         usersPath           = docOps.GetAllUsersFolderInArray(UtilityOperations.GetDockerRootPath() + "/");
            List <FileModel> searchCurrentResult = new List <FileModel>();
            List <FileModel> searchCommonResult  = new List <FileModel>();

            foreach (String vPath in docOps.GetVirtualPathsByTagName(aNaOps.GetUserIDByUserName(HttpContext.User.Identity.Name), tagName))
            {
                FileModel file = null;
                if (vPath.StartsWith(UtilityOperations.GetDockerCommonFolderPath()))
                {
                    file = (new FileModel()).GetFolderOrFile(vPath);
                    file.IsCommonFolder = true;
                    if (usersPath.Contains(file.VirtualPath))
                    {
                        file.IsUserFolder = true;
                    }
                    searchCommonResult.Add(file);
                }
                else
                {
                    file = (new FileModel()).GetFolderOrFile(vPath);
                    if (usersPath.Contains(file.VirtualPath))
                    {
                        file.IsUserFolder = true;
                    }
                    searchCurrentResult.Add(file);
                }
            }
            fileModel.CurrentFolderFiles = searchCurrentResult;
            fileModel.CommonFolderFiles  = searchCommonResult;
            fileModel.Tags = new List <String>();
            return(View(fileModel));
        }