Beispiel #1
0
        private async Task CopyFiles(string monthDirectory, IEnumerable <Model.FileDetails> files)
        {
            FilesPrivider destinationFilesProvider = new FilesPrivider(_destinationPath);
            CopyService   copyService = new CopyService();

            if (destinationFilesProvider.FilesPaths.Count() > 0)
            {
                files.ToList().ForEach(x => x.AddDeviceToPath());
            }

            List <Model.FileDetails> filesInDestination = CreateFileDetailsFromPaths(destinationFilesProvider.FilesPaths);

            foreach (var file in files)
            {
                Task.Run(() => copyService.CopyFile(file));
            }

            foreach (var file in filesInDestination)
            {
                if (file.IsFilePathContainDevice() == false)
                {
                    file.AddDeviceToPath();
                    Task.Run(() => copyService.MoveFile(file));
                }
            }
        }
Beispiel #2
0
        public void ExportAndReoganizeFiles()
        {
            FilesPrivider sourceFilesPrivider = new FilesPrivider(_sourcePath);


            List <Model.FileDetails> filesSource = CreateFileDetailsFromPaths(sourceFilesPrivider.FilesPaths);

            var yearGroups = filesSource.GroupBy(y => y.YearOfCreate);

            foreach (var yearGroup in yearGroups)
            {
                var monthGroups = yearGroup.GroupBy(m => m.MonthOfCreate);

                foreach (var monthGroup in monthGroups)
                {
                    string monthDirectory = Path.Combine(_destinationPath, yearGroup.Key.ToString(), monthGroup.Key.ToString());

                    Task.Run(() => CopyFiles(monthDirectory, monthGroup));
                }
            }
        }