Esempio n. 1
0
 public FolderResult(RemoteFolder folder, Uri parent)
 {
     Folder         = folder;
     ParentUri      = parent;
     ChildFileTasks = new Task <FileResult>[] { };
     ChildFolders   = new FolderResult[] { };
     ProcessedAt    = DateTimeOffset.Now;
 }
Esempio n. 2
0
        public OnboardResult(FolderResult rootFolderResult)
        {
            FileUploadsFinished = WaitForFileUploads(rootFolderResult);

            Func <FolderResult, IEnumerable <FolderResult> > f = null;

            f = folderResult => new[] { folderResult }.Concat(folderResult.ChildFolders.SelectMany(f));
            AllFolderResults = f(rootFolderResult).ToArray();
        }
Esempio n. 3
0
        public async Task WaitForFileUploads(FolderResult rootFolderResult)
        {
            Func <FolderResult, IEnumerable <Task <FileResult> > > f = null;

            f = folderResult => folderResult.ChildFileTasks.Concat(folderResult.ChildFolders.SelectMany(f));
            AllFileResults = await Task.WhenAll(f(rootFolderResult));

            Finished = DateTimeOffset.Now;
            Elapsed  = Finished - Start;
        }
Esempio n. 4
0
        private async Task <FolderResult> UploadFolder(RemoteFolder folder, Uri parent)
        {
            var createdAt = DateTimeOffset.Now;
            var fileTasks = parent.AbsoluteUri.Contains("allshared")
                ? new Task <FileResult>[] { }
                : (await folder.GetChildFiles()).Select(file => UploadFile(file, parent)).ToArray();
            var folderTasks = (await folder.GetChildFolders()).Select(childFolder => UploadChildFolder(childFolder, parent)).ToArray();

            await Task.WhenAll(folderTasks);

            var result = new FolderResult(folder, parent) // this parent url is wrong
            {
                CreateSucceeded = true,
                Uri             = parent,
                ChildFileTasks  = fileTasks,
                ChildFolders    = folderTasks.Select(t => t.Result).ToArray(),
                ProcessedAt     = createdAt,
            };

            // result = fileTasks.Select(task => task.Result).Aggregate(result, (folderResult, fileResult) => folderResult.AddChild(fileResult));
            // result = folderTasks.Select(task => task.Result).Aggregate(result, (folderResult, childFolderResult) => folderResult.AddChild(childFolderResult));
            return(result);
        }