Esempio n. 1
0
        public async Task <CleanupResult> Cleanup(
            IEnumerable <PathInfo> cleanupPaths)
        {
            var result = new CleanupResult();

            var cleanupTasks = cleanupPaths
                               .ToList()
                               .Select(x => Task.Run(
                                           () => Cleanup(x, result)));

            await Task.WhenAll(cleanupTasks);

            await _mediator.Publish(new CleanupCompleted(result));

            return(result);
        }
Esempio n. 2
0
        private void Cleanup(PathInfo cleanupPath, CleanupResult result)
        {
            try
            {
                var movePath = _movingHelper.Move(cleanupPath);

                _deletionHelper.Delete(movePath);

                result.AddSuccess(cleanupPath, movePath);

                _mediator.Publish(new CleanupSuccess(cleanupPath, movePath));
            }
            catch (Exception ex)
            {
                result.AddError(cleanupPath, ex);

                _mediator.Publish(new CleanupError(cleanupPath, ex));
            }
        }