Esempio n. 1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;

            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            Utils.Common.WriteVerboseEndpointMessage(this, Client.Config, "GetJobOutput");

            using (var transferManager = new ArchiveTransferManager(client))
            {
                var runner          = new ProgressRunner(this);
                var downloadOptions = new DownloadOptions
                {
                    AccountId = cmdletContext.AccountId
                };

                var tracker = new DownloadProgressTracker(runner, handler => downloadOptions.StreamTransferProgress += handler, cmdletContext.FilePath);

                var output = runner.SafeRun(() =>
                {
#if DESKTOP
                    transferManager.DownloadJob(cmdletContext.VaultName, cmdletContext.JobId, cmdletContext.FilePath, downloadOptions);
#else
                    transferManager.DownloadJobAsync(cmdletContext.VaultName, cmdletContext.JobId, cmdletContext.FilePath, downloadOptions).Wait();
#endif
                }, tracker);

                return(output);
            }
        }
Esempio n. 2
0
        public void Execute()
        {
            bool fileExists = File.Exists(_vaultInventoryFile);

            if (fileExists)
            {
                string errorMessage = string.Format("Can't download inventory. File already exists, use a different name [{0}]",
                                                    _vaultInventoryFile);

                throw new InvalidOperationException(errorMessage);
            }

            using (var mgr = new ArchiveTransferManager(RegionEndpoint.USWest2))
            {
                mgr.DownloadJob(vaultName: "backup-home",
                                jobId: _jobId,
                                filePath: _vaultInventoryFile);
            }

            string result = string.Format("Inventory saved at [{0}]", _vaultInventoryFile);

            ConsoleView.Show(result);
        }