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); }
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); }
public override void Execute(INotification notification) { this.Debug(CommandNotification); AuthorizationSessionProxy authorizationSessionProxy = (AuthorizationSessionProxy)Facade.RetrieveProxy(AuthorizationSessionProxy.Name); ProgramArgumentsProxy programArgProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name); CompactShardsProxy compactShardsProxy = (CompactShardsProxy)Facade.RetrieveProxy(CompactShardsProxy.Name); compactShardsProxy.CompactShards( authorizationSessionProxy.AuthorizationSession, programArgProxy.DoesOptionExist(DryRunOption) ); }
public override void Execute(INotification notification) { this.Debug(CommandNotification); ProgramArgumentsProxy programArgsProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name); if (TryGetCommand(programArgsProxy.ProgramArguments, out CommandType command)) { this.Debug($"Got command: {command}"); InitializeModelIfNecessary(command); HookUpCancellationToken(command); SendNotification(CommandTypeToNotification[command], null, null); } else { this.Critical("Could not find command"); SendNotification(PrintHelp.CommandNotification, null, null); } }
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); }
public override void Execute(INotification notification) { ProgramArgumentsProxy programArgumentsProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name); bool verboseLoggingSwitch = programArgumentsProxy.DoesOptionExist(ConsoleMediator.VerboseLevelSwitch); bool debugLoggingSwitch = programArgumentsProxy.DoesOptionExist(ConsoleMediator.DebugLevelSwitch); LogLevel logLevel = LogLevel.INFO; if (verboseLoggingSwitch) { logLevel = LogLevel.VERBOSE; } if (debugLoggingSwitch) { logLevel = LogLevel.DEBUG; } Facade.RegisterMediator(new ConsoleMediator(logLevel)); this.Debug("View is initialized"); }
public override void Execute(INotification notification) { this.Debug(CommandNotification); AuthorizationSessionProxy authorizationProxy = (AuthorizationSessionProxy)Facade.RetrieveProxy(AuthorizationSessionProxy.Name); DeleteFileProxy deleteFileProxy = (DeleteFileProxy)Facade.RetrieveProxy(DeleteFileProxy.Name); ProgramArgumentsProxy programArgsProxy = (ProgramArgumentsProxy)Facade.RetrieveProxy(ProgramArgumentsProxy.Name); bool isDryRun = programArgsProxy.DoesOptionExist(DryRunOption); foreach (Database.File file in GetFilesToDelete()) { CancellationEventRouter.GlobalCancellationToken.ThrowIfCancellationRequested(); if (isDryRun == false) { deleteFileProxy.DeleteFile(() => authorizationProxy.AuthorizationSession, file); } else { this.Info($"[DRY-RUN|: Would have deleted file: {file.FileName}"); } } this.Info("Finished deleting all files"); }