/// <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 (RestoreAgent != null) { RestoreAgent.Dispose(); RestoreAgent = null; } if (Versioner != null) { Versioner.Dispose(); Versioner = null; } } this._isDisposed = true; } base.Dispose(disposing); }
public override void Start() { Assert.IsFalse(IsRunning); Assert.IsNotNull(Restore); Assert.IsNotNull(Restore.RestorePlan.StorageAccount); Assert.AreEqual(Models.EStorageAccountType.AmazonS3, Restore.RestorePlan.StorageAccountType); AmazonS3AccountRepository dao = new AmazonS3AccountRepository(); Models.AmazonS3Account s3account = dao.GetForReadOnly(Restore.RestorePlan.StorageAccount.Id); // // Dispose and recycle previous objects, if needed. // if (TransferAgent != null) { TransferAgent.Dispose(); } if (TransferListControl != null) { TransferListControl.ClearTransfers(); } if (RestoreAgent != null) { RestoreAgent.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", Restore.RestorePlan.StorageAccount.Hostname); RestoreAgent = new CustomRestoreAgent(TransferAgent); RestoreAgent.Results.Monitor = TransferListControl; Versioner = new RestoreFileVersioner(CancellationTokenSource.Token); RegisterResultsEventHandlers(Restore, RestoreAgent.Results); Report.PlanType = "restore"; Report.PlanName = Restore.RestorePlan.Name; Report.BucketName = s3account.BucketName; Report.HostName = Restore.RestorePlan.StorageAccount.Hostname; Report.TransferResults = RestoreAgent.Results; Helper = new BaseOperationHelper(Restore.RestorePlan); // // Start the restore. // DoRestore(RestoreAgent, Restore, Options); }