private static void SaveStartDocument(IFolderDao folderDao, IFileDao fileDao, object folderId, string path, IDataStore storeTemplate) { foreach (var file in storeTemplate.ListFilesRelative("", path, "*", false)) { SaveFile(fileDao, folderId, path + file, storeTemplate); } if (storeTemplate is S3Storage) { return; } foreach (var folderUri in storeTemplate.List(path, false)) { var folderName = Path.GetFileName(folderUri.ToString()); var subFolderId = folderDao.SaveFolder(new Folder { Title = folderName, ParentFolderID = folderId }); SaveStartDocument(folderDao, fileDao, subFolderId, path + folderName + "/", storeTemplate); } }
private void SaveStartDocument(FileMarker fileMarker, IFolderDao folderDao, IFileDao fileDao, object folderId, string path, IDataStore storeTemplate) { foreach (var file in storeTemplate.ListFilesRelative("", path, "*", false)) { SaveFile(fileMarker, fileDao, folderId, path + file, storeTemplate); } foreach (var folderName in storeTemplate.ListDirectoriesRelative(path, false)) { var folder = ServiceProvider.GetService <Folder>(); folder.Title = folderName; folder.ParentFolderID = folderId; var subFolderId = folderDao.SaveFolder(folder); SaveStartDocument(fileMarker, folderDao, fileDao, subFolderId, path + folderName + "/", storeTemplate); } }
private static void SaveStartDocument(IFolderDao folderDao, IFileDao fileDao, object folderId, string path, IDataStore storeTemplate) { foreach (var file in storeTemplate.ListFilesRelative("", path, "*", false)) { SaveFile(fileDao, folderId, path + file, storeTemplate); } foreach (var folderName in storeTemplate.ListDirectoriesRelative(path, false)) { var subFolderId = folderDao.SaveFolder(new Folder { Title = folderName, ParentFolderID = folderId }); SaveStartDocument(folderDao, fileDao, subFolderId, path + folderName + "/", storeTemplate); } }
public static void ReassignItems(object parentId, Guid fromUserId, Guid toUserId, IFolderDao folderDao, IFileDao fileDao) { var files = fileDao.GetFiles(parentId, new OrderBy(SortedByType.AZ, true), FilterType.ByUser, fromUserId, null, withSubfolders: true) .Where(file => file.CreateBy == fromUserId); foreach (var file in files) { file.CreateBy = toUserId; fileDao.SaveFile(file, null); } var folders = folderDao.GetFolders(parentId, new OrderBy(SortedByType.AZ, true), FilterType.ByUser, fromUserId, null, true) .Where(folder => folder.CreateBy == fromUserId); foreach (var folder in folders) { folder.CreateBy = toUserId; folderDao.SaveFolder(folder); } }
private static void SaveStartDocument(IFolderDao folderDao, IFileDao fileDao, object folderId, string path, IDataStore storeTemp) { foreach (var file in storeTemp.ListFilesRelative("", path, "*", false)) { SaveFile(fileDao, folderId, path + file, storeTemp); } foreach (var folderUri in storeTemp.List(path, false)) { var folderName = Path.GetFileName(folderUri.ToString()); var subFolderid = folderDao.SaveFolder(new Folder { Title = ReplaceInvalidCharsAndTruncate(folderName), ParentFolderID = folderId }); SaveStartDocument(folderDao, fileDao, subFolderid, path + folderName + "/", storeTemp); } }
public Folder <TTo> PerformCrossDaoFolderCopy <TFrom, TTo> (TFrom fromFolderId, IFolderDao <TFrom> fromFolderDao, IFileDao <TFrom> fromFileDao, Func <TFrom, TFrom> fromConverter, TTo toRootFolderId, IFolderDao <TTo> toFolderDao, IFileDao <TTo> toFileDao, Func <TTo, TTo> toConverter, bool deleteSourceFolder, CancellationToken?cancellationToken) { var fromFolder = fromFolderDao.GetFolder(fromConverter(fromFolderId)); var toFolder1 = ServiceProvider.GetService <Folder <TTo> >(); toFolder1.Title = fromFolder.Title; toFolder1.ParentFolderID = toConverter(toRootFolderId); var toFolder = toFolderDao.GetFolder(fromFolder.Title, toConverter(toRootFolderId)); var toFolderId = toFolder != null ? toFolder.ID : toFolderDao.SaveFolder(toFolder1); var foldersToCopy = fromFolderDao.GetFolders(fromConverter(fromFolderId)); var fileIdsToCopy = fromFileDao.GetFiles(fromConverter(fromFolderId)); Exception copyException = null; //Copy files first foreach (var fileId in fileIdsToCopy) { if (cancellationToken.HasValue) { cancellationToken.Value.ThrowIfCancellationRequested(); } try { PerformCrossDaoFileCopy(fileId, fromFileDao, fromConverter, toFolderId, toFileDao, toConverter, deleteSourceFolder); } catch (Exception ex) { copyException = ex; } } foreach (var folder in foldersToCopy) { if (cancellationToken.HasValue) { cancellationToken.Value.ThrowIfCancellationRequested(); } try { PerformCrossDaoFolderCopy(folder.ID, fromFolderDao, fromFileDao, fromConverter, toFolderId, toFolderDao, toFileDao, toConverter, deleteSourceFolder, cancellationToken); } catch (Exception ex) { copyException = ex; } } if (deleteSourceFolder) { var securityDao = ServiceProvider.GetService <SecurityDao <TFrom> >(); var fromFileShareRecords = securityDao.GetPureShareRecords(fromFolder) .Where(x => x.EntryType == FileEntryType.Folder); if (fromFileShareRecords.Any()) { fromFileShareRecords.ToList().ForEach(x => { x.EntryId = toFolderId; securityDao.SetShare(x); }); } var tagDao = ServiceProvider.GetService <TagDao <TFrom> >(); var fromFileNewTags = tagDao.GetNewTags(Guid.Empty, fromFolder).ToList(); if (fromFileNewTags.Any()) { fromFileNewTags.ForEach(x => x.EntryId = toFolderId); tagDao.SaveTags(fromFileNewTags); } if (copyException == null) { fromFolderDao.DeleteFolder(fromConverter(fromFolderId)); } } if (copyException != null) { throw copyException; } return(toFolderDao.GetFolder(toConverter(toFolderId))); }
private static void SaveStartDocument(IFolderDao folderDao, IFileDao fileDao, object folderId, string path, IDataStore storeTemp) { foreach (var file in storeTemp.ListFilesRelative("", path, "*", false)) { SaveFile(fileDao, folderId, path + file, storeTemp); } if (storeTemp is S3Storage) return; foreach (var folderUri in storeTemp.List(path, false)) { var folderName = Path.GetFileName(folderUri.ToString()); var subFolder = folderDao.SaveFolder(new Folder { Title = folderName, ParentFolderID = folderId }); SaveStartDocument(folderDao, fileDao, subFolder.ID, path + folderName + "/", storeTemp); } }