예제 #1
0
        public override void Start()
        {
            Assert.IsFalse(IsRunning);
            Assert.IsNotNull(Synchronization);
            Assert.IsNotNull(Synchronization.StorageAccount);
            Assert.AreEqual(Models.EStorageAccountType.AmazonS3, Synchronization.StorageAccountType);

            AmazonS3AccountRepository dao = new AmazonS3AccountRepository();

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

            //
            // Dispose and recycle previous objects, if needed.
            //
            if (TransferAgent != null)
            {
                TransferAgent.Dispose();
            }
            if (TransferListControl != null)
            {
                TransferListControl.ClearTransfers();
            }
            if (SyncAgent != null)
            {
                SyncAgent.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", s3account.Hostname);

            RemoteObjects = new List <ListingObject>(4096);            // Avoid small resizes without compromising memory.
            SyncAgent     = new CustomSynchronizationAgent(TransferAgent);

            RegisterEventHandlers(Synchronization);

            Report.PlanType    = "synchronization";
            Report.PlanName    = "No plan";
            Report.BucketName  = s3account.BucketName;
            Report.HostName    = Synchronization.StorageAccount.Hostname;
            Report.SyncResults = SyncAgent.Results;

            //
            // Start the sync.
            //
            DoSynchronization(SyncAgent, Synchronization, Options);
        }
예제 #2
0
        public AmazonS3CreateBucketForm(Models.AmazonS3Account account)
        {
            if (account.Type != Models.EStorageAccountType.AmazonS3)
            {
                throw new ArgumentException("Attempt to create a bucket using an account with an incompatible type");
            }

            InitializeComponent();

            LoadBucketRegions();
            LoadStorageClasses();

            _account = account;
        }
예제 #3
0
        public AmazonS3AccountForm(Models.AmazonS3Account account)
        {
            if (account.Type != Models.EStorageAccountType.AmazonS3)
            {
                throw new ArgumentException("Attempt to edit an account of an incompatible type");
            }

            InitializeComponent();
            _account = account;

            // Setup data bindings
            tbDisplayName.DataBindings.Add(new Binding("Text", _account,
                                                       this.GetPropertyName((Models.AmazonS3Account x) => x.DisplayName)));
            tbAccessKey.DataBindings.Add(new Binding("Text", _account,
                                                     this.GetPropertyName((Models.AmazonS3Account x) => x.AccessKey)));
            tbSecretKey.DataBindings.Add(new Binding("Text", _account,
                                                     this.GetPropertyName((Models.AmazonS3Account x) => x.SecretKey)));
            cbBucketName.DataBindings.Add(new Binding("Text", _account,
                                                      this.GetPropertyName((Models.AmazonS3Account x) => x.BucketName)));
        }
예제 #4
0
        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);
        }
예제 #5
0
 public AmazonS3AccountSaveEventArgs(Models.AmazonS3Account account)
 {
     _account = account;
 }
예제 #6
0
 public AmazonS3CreateBucketEventArgs(Models.AmazonS3Account account)
 {
     _account = account;
 }