Beispiel #1
0
        private ItemNameValueCollection GetFilesInFolders(IEnumerable <object> folderIds, string path)
        {
            CancellationToken.ThrowIfCancellationRequested();

            var entriesPathId = new ItemNameValueCollection();

            foreach (var folderId in folderIds)
            {
                var folder = FolderDao.GetFolder(folderId);
                if (folder == null || !FilesSecurity.CanRead(folder))
                {
                    continue;
                }
                var folderPath = path + folder.Title + "/";

                var files = FileDao.GetFiles(folder.ID, null, FilterType.None, Guid.Empty, string.Empty);
                files = FilesSecurity.FilterRead(files).ToList();
                files.ForEach(file => entriesPathId.Add(ExecPathFromFile(file, folderPath)));

                FileMarker.RemoveMarkAsNew(folder);

                var nestedFolders = FolderDao.GetFolders(folder.ID);
                nestedFolders = FilesSecurity.FilterRead(nestedFolders).ToList();
                if (files.Count == 0 && nestedFolders.Count == 0)
                {
                    entriesPathId.Add(folderPath, String.Empty);
                }

                var filesInFolder = GetFilesInFolders(nestedFolders.ConvertAll(f => f.ID), folderPath);
                entriesPathId.Add(filesInFolder);
            }
            return(entriesPathId);
        }
Beispiel #2
0
        private ItemNameValueCollection ExecPathFromFile(File file, string path)
        {
            FileMarker.RemoveMarkAsNew(file);

            var title = file.Title;

            if (_files.ContainsKey(file.ID.ToString()))
            {
                var convertToExt = string.Empty;
                if (_quotaDocsEdition || FileUtility.InternalExtension.Values.Contains(convertToExt))
                {
                    convertToExt = _files[file.ID.ToString()];
                }

                if (!string.IsNullOrEmpty(convertToExt))
                {
                    title = FileUtility.ReplaceFileExtension(title, convertToExt);
                }
            }

            var entriesPathId = new ItemNameValueCollection();

            entriesPathId.Add(path + title, file.ID.ToString());

            return(entriesPathId);
        }
Beispiel #3
0
        private ItemNameValueCollection GetEntriesPathId()
        {
            var entriesPathId = new ItemNameValueCollection();

            if (0 < Files.Count)
            {
                var files = FileDao.GetFiles(Files.ToArray());
                files = FilesSecurity.FilterRead(files).ToList();
                files.ForEach(file => entriesPathId.Add(ExecPathFromFile(file, string.Empty)));
            }
            if (0 < Folders.Count)
            {
                FilesSecurity.FilterRead(FolderDao.GetFolders(Files.ToArray())).ToList().Cast <FileEntry>().ToList()
                .ForEach(folder => FileMarker.RemoveMarkAsNew(folder));

                var filesInFolder = GetFilesInFolders(Folders, string.Empty);
                entriesPathId.Add(filesInFolder);
            }
            return(entriesPathId);
        }
Beispiel #4
0
        private ItemNameValueCollection GetEntriesPathId(out List <File> filesForSend, out List <Folder> folderForSend)
        {
            filesForSend  = new List <File>();
            folderForSend = new List <Folder>();

            var entriesPathId = new ItemNameValueCollection();

            if (0 < Files.Count)
            {
                filesForSend = FilesSecurity.FilterDownload(FileDao.GetFiles(Files));
                filesForSend.ForEach(file => entriesPathId.Add(ExecPathFromFile(file, string.Empty)));
            }
            if (0 < Folders.Count)
            {
                folderForSend = FolderDao.GetFolders(Folders);
                folderForSend = FilesSecurity.FilterDownload(folderForSend);
                folderForSend.ForEach(folder => FileMarker.RemoveMarkAsNew(folder));

                var filesInFolder = GetFilesInFolders(folderForSend.Select(x => x.ID), string.Empty);
                entriesPathId.Add(filesInFolder);
            }

            if (Folders.Count == 1 && Files.Count == 0)
            {
                var entriesPathIdWithoutRoot = new ItemNameValueCollection();

                foreach (var path in entriesPathId.AllKeys)
                {
                    entriesPathIdWithoutRoot.Add(path.Remove(0, path.IndexOf('/') + 1), entriesPathId[path]);
                }

                return(entriesPathIdWithoutRoot);
            }

            return(entriesPathId);
        }
Beispiel #5
0
        private static void ReplaceLongPath(ItemNameValueCollection entriesPathId)
        {
            foreach (var path in new List <string>(entriesPathId.AllKeys))
            {
                if (200 >= path.Length || 0 >= path.IndexOf('/'))
                {
                    continue;
                }

                var ids = entriesPathId[path];
                entriesPathId.Remove(path);

                var newtitle = "LONG_FOLDER_NAME" + path.Substring(path.LastIndexOf('/'));
                entriesPathId.Add(newtitle, ids);
            }
        }
Beispiel #6
0
        private ItemNameValueCollection ExecPathFromFile(IServiceScope scope, File file, string path)
        {
            var fileMarker = scope.ServiceProvider.GetService <FileMarker>();

            fileMarker.RemoveMarkAsNew(file);

            var title = file.Title;

            if (files.ContainsKey(file.ID.ToString()))
            {
                var convertToExt = files[file.ID.ToString()];

                if (!string.IsNullOrEmpty(convertToExt))
                {
                    title = FileUtility.ReplaceFileExtension(title, convertToExt);
                }
            }

            var entriesPathId = new ItemNameValueCollection();

            entriesPathId.Add(path + title, file.ID.ToString());

            return(entriesPathId);
        }