Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        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");
        }
Exemplo n.º 7
0
        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");
        }