/// <summary>
 /// <para>
 /// Downloads an archive from Amazon Glacier from the specified vault for the
 /// current user's account. Saves the archive to the specified file.
 /// </para>
 ///
 /// <para>
 /// This method creates an Amazon SNS topic, and an Amazon SQS queue that is subscribed
 /// to that topic.  It then initiates the archive retrieval job and polls the queue
 /// for the archive to be available.  This polling takes about 4 hours. Once the archive
 /// is available, download will begin.
 /// </para>
 ///
 /// <para>
 /// Additional options can be set using the UploadDirectoryOptions object. For example, you
 /// can set the FilesTransferProgress property to a delegate to track progress.
 /// </para>
 /// </summary>
 /// <param name="filePath">The file path to save the archive at.</param>
 /// <param name="vaultName">The name of the vault to download the archive from.</param>
 /// <param name="archiveId">The unique ID of the archive to download.</param>
 /// <param name="options">Additional options that can be used for the download.</param>
 public void Download(string vaultName, string archiveId, string filePath, DownloadOptions options)
 {
     using (var command = new DownloadFileCommand(this, vaultName, archiveId, filePath, options))
     {
         command.Execute();
     }
 }
示例#2
0
        public void Test1()
        {
            ShowdirCommand      commandOne   = new ShowdirCommand();
            ShowdiskCommand     commandTwo   = new ShowdiskCommand();
            DirectoryCommand    commandThree = new DirectoryCommand();
            StartAppCommand     commandFour  = new StartAppCommand();
            DeleteFileCommand   commandFive  = new DeleteFileCommand();
            UploadFileCommand   commandSix   = new UploadFileCommand();
            ChangeDirCommand    commandSeven = new ChangeDirCommand();
            DownloadFileCommand commandEight = new DownloadFileCommand();
            List <ICommand>     container    = new List <ICommand>();

            container.Add(commandOne);
            container.Add(commandTwo);
            container.Add(commandThree);
            container.Add(commandFour);
            container.Add(commandFive);
            container.Add(commandSix);
            container.Add(commandSeven);
            container.Add(commandEight);
            foreach (var value in container)
            {
                bool finders = false;
                foreach (var value2 in _macroCommand._commands)
                {
                    if (value2.GetType() == value.GetType())
                    {
                        finders = true;
                    }
                }
                Assert.True(finders);
            }
        }
示例#3
0
 /// <summary>
 /// Add item list to the queue
 /// </summary>
 /// <param name="fileFolderList"></param>
 public void Synchronize(List <FileFolderInfo> fileFolderList)
 {
     //Create commands
     foreach (var item in fileFolderList)
     {
         if (item.FileFolder == null)
         {
             var command = new CreateDirectoryCommand(item.GroupId, item.Path, item.SyncFolder);
             command.ExecuteError += new ExecuteErrorEventHandler(OnExecuteError);
             _commandProcessor.AddCommand(command);
         }
         else
         if (item.FileFolder.type == "F")
         {
             var command = new CreateDirectoryCommand(item.GroupId, item.FileFolder, item.Path, item.SyncFolder);
             command.ExecuteError += new ExecuteErrorEventHandler(OnExecuteError);
             _commandProcessor.AddCommand(command);
         }
         else
         {
             var command = new DownloadFileCommand(_ticket, item.GroupId, item.FolderId, item.FileFolder, item.Path, _path);
             command.ExecuteError += new ExecuteErrorEventHandler(OnExecuteError);
             _commandProcessor.AddCommand(command);
         }
     }
 }
示例#4
0
 public async Task ShouldThrowErrorForInvalidInput()
 {
     var command = new DownloadFileCommand
     {
         Location = ""
     };
     await Assert.ThrowsAsync <ValidationException>(() => SendAsync(command));
 }
示例#5
0
        public void Visit(DownloadFileCommand command)
        {
            if (!TryGetPrefixedPathTo(command.Id, out var path, out var normalPath))
            {
                return;
            }
            if (!File.Exists(path))
            {
                return;
            }

            Payload     = File.ReadAllBytes(path);
            PayloadPath = normalPath;
        }
        public void Visit(DownloadFileCommand command)
        {
            Visit((ICommand)command);

            if (Root.TryFindNode(command.Id, out var node) &&
                node is File)
            {
                AwaitResponse = true;
            }
            else
            {
                OnFileDoesNotExist(command.Id);
            }
        }
示例#7
0
        /// <summary>
        /// <para>
        /// Downloads an archive from Amazon Glacier from the specified vault for the
        /// current user's account. Saves the archive to the specified file.
        /// </para>
        ///
        /// <para>
        /// This method creates an Amazon SNS topic, and an Amazon SQS queue that is subscribed
        /// to that topic.  It then initiates the archive retrieval job and polls the queue
        /// for the archive to be available.  This polling takes about 4 hours. Once the archive
        /// is available, download will begin.
        /// </para>
        ///
        /// <para>
        /// Additional options can be set using the UploadDirectoryOptions object. For example, you
        /// can set the FilesTransferProgress property to a delegate to track progress.
        /// </para>
        /// </summary>
        /// <param name="filePath">The file path to save the archive at.</param>
        /// <param name="vaultName">The name of the vault to download the archive from.</param>
        /// <param name="archiveId">The unique ID of the archive to download.</param>
        /// <param name="options">Additional options that can be used for the download.</param>
        public Task DownloadAsync(string vaultName, string archiveId, string filePath, DownloadOptions options)
        {
            var command = new DownloadFileCommand(this, vaultName, archiveId, filePath, options);

            return(command.ExecuteAsync());
        }
示例#8
0
        private async Task SynchronizeOnlineFilesFolders()
        {
            var folders = SyncTableManager.GetFolders();

            foreach (var folder in folders)
            {
                try
                {
                    var filesFolders = await DokuFlexService.GetFilesFoldersAsync(_ticket, folder.GroupId, folder.FolderId);

                    foreach (var fileFolder in filesFolders)
                    {
                        if (fileFolder.type == "C")
                        {
                            //Check if file exists in sync table
                            var file = SyncTableManager.GetByFileId(fileFolder.id);

                            if (file != null)
                            {
                                if (fileFolder.modifiedTime > file.ModifiedTime)
                                {
                                    SyncTableManager.ChangeSyncStatusToPending(file.Path);
                                    var command = new DownloadFileCommand(_ticket, folder.GroupId, folder.FolderId, fileFolder, file.Path, _path);
                                    command.ExecuteError += new ExecuteErrorEventHandler(OnExecuteError);
                                    _commandProcessor.AddCommand(command);
                                }
                            }
                            else
                            {
                                var path = string.Format("{0}\\{1}", folder.Path, fileFolder.name);

                                //Add item as pending
                                var item = new SyncTableItem
                                {
                                    Name          = fileFolder.name,
                                    Path          = path,
                                    LastWriteTime = 0,
                                    Type          = "C",
                                    GroupId       = folder.GroupId,
                                    FolderId      = folder.FolderId,
                                    FileId        = string.Empty,
                                    ModifiedTime  = 0,
                                    SyncFolder    = false,
                                    SyncStatus    = SyncTableItemStatus.Pending
                                };

                                SyncTableManager.Add(item);

                                var command = new DownloadFileCommand(_ticket, folder.GroupId, folder.FolderId, fileFolder, path, _path);
                                command.ExecuteError += new ExecuteErrorEventHandler(OnExecuteError);
                                _commandProcessor.AddCommand(command);
                            }
                        }
                        else
                        {
                            //Check if folder exists
                            if (!folders.Any(f => f.FolderId.Equals(fileFolder.id) && f.Type == "F"))
                            {
                                var path    = String.Format("{0}\\{1}", folder.Path, fileFolder.name);
                                var command = new CreateDirectoryCommand(folder.GroupId, fileFolder, path);
                                command.ExecuteError += new ExecuteErrorEventHandler(OnExecuteError);
                                _commandProcessor.AddCommand(command);
                            }
                        }
                    }

                    var files = SyncTableManager.GetFiles(folder.FolderId);

                    foreach (var file in files)
                    {
                        if (!filesFolders.Any(f => f.id.Equals(file.FileId)))
                        {
                            SyncTableManager.ChangeSyncStatusToPending(file.Path);
                            var command = new DeleteFileCommand(file.Path);
                            command.ExecuteError += new ExecuteErrorEventHandler(OnExecuteError);
                            _commandProcessor.AddCommand(command);
                        }
                    }
                }
                catch (Exception ex)
                {
                    //Check is folder doesn't exists
                    if (ex is RestResponseException)
                    {
                        var exception = ex as RestResponseException;

                        //Folder doesn't exists
                        if (exception.ErrorCode == 1)
                        {
                            var command = new DeleteDirectoryCommand(folder.Path);
                            command.ExecuteError += new ExecuteErrorEventHandler(OnExecuteError);
                            _commandProcessor.AddCommand(command);
                        }
                    }
                }
            }
        }
示例#9
0
        public void Setup()
        {
            DownloadFileCommand downloadFile = new DownloadFileCommand();

            _downloadFile = downloadFile;
        }
示例#10
0
 public override void RaiseCommandCanExecuteChanged()
 {
     UploadFileCommand.RaiseCanExecuteChanged();
     DownloadFileCommand.RaiseCanExecuteChanged();
     DeleteFileCommand.RaiseCanExecuteChanged();
 }