Esempio n. 1
0
        public override void Execute(INotification notification)
        {
            this.Debug(CommandNotification);
            RemoteFileSystemProxy remoteFileSystemProxy = (RemoteFileSystemProxy)Facade.RetrieveProxy(RemoteFileSystemProxy.Name);

            this.Info(BuildStringFromFiles(remoteFileSystemProxy.AllFiles));
        }
Esempio n. 2
0
        private IEnumerable <Database.File> GetFilesToDelete()
        {
            this.Debug("Getting files to delete");
            ProgramArgumentsProxy programArgsProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name);
            IEnumerable <string>  fileIDs          = programArgsProxy.GetArgsUntilNextSwitch(FileIDsOption);

            if (fileIDs.Any() == false)
            {
                throw new TerminateProgramException(
                          $"No file IDs passed in. Did you use the {FileIDsOption} argument?"
                          );
            }

            IList <Database.File> databaseFiles         = new List <Database.File>();
            RemoteFileSystemProxy remoteFileSystemProxy = (RemoteFileSystemProxy)Facade.RetrieveProxy(RemoteFileSystemProxy.Name);

            foreach (string fileID in fileIDs)
            {
                if (remoteFileSystemProxy.TryGetFileByID(fileID, out Database.File file) == false)
                {
                    throw new TerminateProgramException(
                              $"Could not find file entry for file ID {fileID}"
                              );
                }

                databaseFiles.Add(file);
            }

            return(databaseFiles);
        }
Esempio n. 3
0
        private Database.File GetFile()
        {
            ProgramArgumentsProxy programArgsProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name);

            if (programArgsProxy.TryGetArgument(FileIDOption, out string fileToRename) == false)
            {
                throw new TerminateProgramException("You must provide a file ID to rename");
            }

            RemoteFileSystemProxy remoteFileSystemProxy = (RemoteFileSystemProxy)Facade.RetrieveProxy(RemoteFileSystemProxy.Name);

            if (remoteFileSystemProxy.TryGetFileByID(fileToRename, out Database.File file) == false)
            {
                throw new TerminateProgramException("Could not retrieve the file by ID");
            }

            return(file);
        }
Esempio n. 4
0
        private Database.File GetFile()
        {
            this.Debug("Getting file to download");
            ProgramArgumentsProxy programArgsProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name);
            bool hasFileID   = programArgsProxy.TryGetArgument(FileIDOption, out string fileToDownloadByID);
            bool hasFileName = programArgsProxy.TryGetArgument(FileNameOption, out string fileToDownloadByName);

            if (hasFileID && hasFileName)
            {
                throw new TerminateProgramException("Specific either a file name or a file ID; not both");
            }

            RemoteFileSystemProxy remoteFileSystemProxy = (RemoteFileSystemProxy)Facade.RetrieveProxy(RemoteFileSystemProxy.Name);

            if (hasFileID)
            {
                this.Debug("Searching by File ID");
                if (remoteFileSystemProxy.TryGetFileByID(fileToDownloadByID, out Database.File file))
                {
                    this.Debug($"Found: {file}");
                    return(file);
                }

                throw new TerminateProgramException($"Could not find file ID {fileToDownloadByID}");
            }

            if (hasFileName)
            {
                this.Debug("Searching by file name");
                if (remoteFileSystemProxy.TryGetFileByName(fileToDownloadByName, out Database.File file))
                {
                    this.Debug($"Found: {file}");
                    return(file);
                }

                throw new TerminateProgramException($"Could not find file name {fileToDownloadByName}");
            }

            throw new InvalidOperationException("No file ID or file name provided to download");
        }