Exemplo n.º 1
0
        public void Execute()
        {
            CreateUploadTaskIfNeeded(_settings.S3Settings, UploadToS3, _backupResult.S3Backup, S3Name);
            CreateUploadTaskIfNeeded(_settings.GlacierSettings, UploadToGlacier, _backupResult.GlacierBackup, GlacierName);
            CreateUploadTaskIfNeeded(_settings.AzureSettings, UploadToAzure, _backupResult.AzureBackup, AzureName);
            CreateUploadTaskIfNeeded(_settings.GoogleCloudSettings, UploadToGoogleCloud, _backupResult.GoogleCloudBackup, GoogleCloudName);
            CreateUploadTaskIfNeeded(_settings.FtpSettings, UploadToFtp, _backupResult.FtpBackup, FtpName);

            _threads.ForEach(x => x.Join(int.MaxValue));

            if (_exceptions.Count > 0)
            {
                if (_exceptions.Count == 1)
                {
                    throw _exceptions.First();
                }

                if (_exceptions.All(x => x is OperationCanceledException))
                {
                    throw _exceptions.First();
                }

                throw new AggregateException(_exceptions);
            }
        }
Exemplo n.º 2
0
        private void Execute()
        {
            _threads.ForEach(x => x.Join(int.MaxValue));

            if (_exceptions.Count > 0)
            {
                if (_exceptions.Count == 1)
                {
                    throw _exceptions.First();
                }

                if (_exceptions.All(x => x is OperationCanceledException))
                {
                    throw _exceptions.First();
                }

                throw new AggregateException(_exceptions);
            }
        }