Example #1
0
        /// <summary>
        /// Создает папки и выгружает в них файлы
        /// </summary>
        private static async Task CreateFoldersAndUploadFiles(FileService fileService, FolderService folderService, IEnumerable <string> folderList, IEnumerable <EntityFile> fileList)
        {
            try
            {
                var list  = fileList.ToList();
                var watch = Stopwatch.StartNew();
                var groupedFolderNameList = folderList.ToList();
                await folderService.CreateFoldersFromGroupedList(groupedFolderNameList);

                watch.Stop();
                Utils.LogInfoAndWriteToConsole($"[ Создано {groupedFolderNameList.Count.ToString()} папок {list[0].Entity} за {watch.Elapsed.Hours.ToString()} ч {watch.Elapsed.Minutes.ToString()} м {watch.Elapsed.Seconds.ToString()} с {watch.Elapsed.Milliseconds.ToString()} мс ]");
                watch.Restart();

                var splicedFiles = Utils.SplitList(list, 2).ToList();
                foreach (var files in splicedFiles)
                {
                    await fileService.UploadFiles(files, list);
                }
                watch.Stop();
                Utils.LogInfoAndWriteToConsole($"[ Выгружено {list.Count.ToString()} файлов {list[0].Entity} за {watch.Elapsed.Hours.ToString()} ч {watch.Elapsed.Minutes.ToString()} м {watch.Elapsed.Seconds.ToString()} с {watch.Elapsed.Milliseconds.ToString()} мс ]");
            }
            catch (Exception ex)
            {
                ExceptionHandler.LogExceptionToConsole(ex);
                throw ex;
            }
        }