public override void Execute(INotification notification) { this.Debug(CommandNotification); AuthorizationSessionProxy authorizationSessionProxy = (AuthorizationSessionProxy)Facade.RetrieveProxy(AuthorizationSessionProxy.Name); ProgramArgumentsProxy programArgProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name); UploadFileProxy uploadFileProxy = (UploadFileProxy)Facade.RetrieveProxy(UploadFileProxy.Name); if (programArgProxy.TryGetArgument(FolderOption, out string folderToUpload) == false) { throw new TerminateProgramException( $"No folder provided. Did you remember to use {FolderOption}?" ); } if (programArgProxy.TryGetArgument(RootDestinationFolderOption, out string rootDestinationFolder) == false) { throw new TerminateProgramException( $"No root destination folder provided. Did you remember to use {RootDestinationFolderOption}?" ); } uploadFileProxy.AddFolder( () => authorizationSessionProxy.AuthorizationSession, folderToUpload, rootDestinationFolder, programArgProxy.DoesOptionExist(OverrideOption), programArgProxy.DoesOptionExist(DryRunOption) ); }
public override void Execute(INotification notification) { this.Debug(CommandNotification); AuthorizationSessionProxy authorizationSessionProxy = (AuthorizationSessionProxy)Facade.RetrieveProxy(AuthorizationSessionProxy.Name); ConfigProxy configProxy = (ConfigProxy)Facade.RetrieveProxy(ConfigProxy.Name); ProgramArgumentsProxy programArgProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name); UploadFileProxy uploadFileProxy = (UploadFileProxy)Facade.RetrieveProxy(UploadFileProxy.Name); if (programArgProxy.TryGetArgument(FileOption, out string fileToUpload) == false) { throw new TerminateProgramException( $"File to upload not provided. Did you remember to use {FileOption}?" ); } if (programArgProxy.TryGetArgument(DestinationOption, out string remoteDestinationPath) == false) { throw new TerminateProgramException( $"Destination not provided. Did you remember to use {DestinationOption}?" ); } uploadFileProxy.AddLocalFile( authorizationSessionProxy.AuthorizationSession, fileToUpload, remoteDestinationPath, programArgProxy.DoesOptionExist(OverrideOption) ); }
private string GetNewFileName() { ProgramArgumentsProxy programArgsProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name); if (programArgsProxy.TryGetArgument(NewFileNameOption, out string newFilePath) == false) { throw new TerminateProgramException("You must provide a name to rename the file to"); } return(newFilePath); }
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"); }
public override void Execute(INotification notification) { this.Debug(CommandNotification); ProgramArgumentsProxy argProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name); if (argProxy.TryGetArgument(CommandOption, out string configArgument)) { Facade.RegisterProxy(new ConfigProxy(configArgument)); } else { throw new TerminateProgramException("No config file was provided"); } }
private string GetDestinationOfFile(Database.File remoteFileToDownload) { this.Debug($"Getting destination of file {remoteFileToDownload}"); ProgramArgumentsProxy programArgsProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name); if (programArgsProxy.TryGetArgument(DestinationOption, out string localFileDestination) == false) { localFileDestination = Path.Combine( Directory.GetCurrentDirectory(), Path.GetFileName(remoteFileToDownload.FileName) ); } this.Debug($"Destination file is: {localFileDestination}"); return(localFileDestination); }
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); }