Пример #1
0
        /// <summary>
        /// Implements the Dispose pattern
        /// </summary>
        /// <param name="disposing">Whether this object is being disposed via a call to Dispose
        /// or garbage collected.</param>
        protected override void Dispose(bool disposing)
        {
            if (!this._isDisposed)
            {
                if (disposing && _shouldDispose)
                {
                    if (BackupAgent != null)
                    {
                        BackupAgent.Dispose();
                        BackupAgent = null;
                    }

                    if (Versioner != null)
                    {
                        Versioner.Dispose();
                        Versioner = null;
                    }
                }
                this._isDisposed = true;
            }
            base.Dispose(disposing);
        }
Пример #2
0
        protected CustomBackupAgent BackupAgent;         // IDisposable

        public override void Start()
        {
            Assert.IsFalse(IsRunning);
            Assert.IsNotNull(Backup);
            Assert.IsNotNull(Backup.BackupPlan);
            Assert.IsNotNull(Backup.BackupPlan.StorageAccount);
            Assert.AreEqual(Models.EStorageAccountType.AmazonS3, Backup.BackupPlan.StorageAccountType);
            Assert.AreEqual(CurrentState, BackupOperationState.UNKNOWN);

            AmazonS3AccountRepository dao = new AmazonS3AccountRepository();

            Models.AmazonS3Account s3account = dao.GetForReadOnly(Backup.BackupPlan.StorageAccount.Id);

            //
            // Dispose and recycle previous objects, if needed.
            //
            if (TransferAgent != null)
            {
                TransferAgent.Dispose();
            }
            if (TransferListControl != null)
            {
                TransferListControl.ClearTransfers();
            }
            if (BackupAgent != null)
            {
                BackupAgent.Dispose();
            }
            if (Versioner != null)
            {
                Versioner.Dispose();
            }

            //
            // Setup agents.
            //
            AWSCredentials       awsCredentials = new BasicAWSCredentials(s3account.AccessKey, s3account.SecretKey);
            TransferAgentOptions options        = new TransferAgentOptions
            {
                UploadChunkSizeInBytes = Teltec.Everest.Settings.Properties.Current.UploadChunkSize * 1024 * 1024,
            };

            TransferAgent = new S3TransferAgent(options, awsCredentials, s3account.BucketName, CancellationTokenSource.Token);
            TransferAgent.RemoteRootDir = TransferAgent.PathBuilder.CombineRemotePath("TELTEC_BKP",
                                                                                      Backup.BackupPlan.StorageAccount.Hostname);

            BackupAgent = new CustomBackupAgent(TransferAgent);
            BackupAgent.Results.Monitor = TransferListControl;

            Versioner = new IncrementalFileVersioner(CancellationTokenSource.Token);

            RegisterResultsEventHandlers(Backup, BackupAgent.Results);

            Report.PlanType        = "backup";
            Report.PlanName        = Backup.BackupPlan.Name;
            Report.BucketName      = s3account.BucketName;
            Report.HostName        = Backup.BackupPlan.StorageAccount.Hostname;
            Report.TransferResults = BackupAgent.Results;

            Helper = new BaseOperationHelper(Backup.BackupPlan);

            //
            // Start the backup.
            //
            DoBackup(BackupAgent, Backup, Options);
        }