Ejemplo n.º 1
0
        private static void RunShell()
        {
            MongoFlatMapper.EnableFlatMapping();
            ConfigurationServiceClient.AppDomainInitializer(
                (message, isError, exception) =>
            {
                if (isError)
                {
                    Console.Error.WriteLine(message + "\n" + exception);
                }
                else
                {
                    Console.WriteLine(message);
                }
            },
                "JARVIS_CONFIG_SERVICE",
                null,
                new FileInfo("defaultParameters.config"),
                missingParametersAction: ConfigurationManagerMissingParametersAction.Blank);

            var commands = new Dictionary <String, Func <Boolean> >();

            commands.Add("Check oprhaned blob", () =>
            {
                CheckOrphanedBlobs.PerformCheck(DateTime.UtcNow);
                return(false);
            });
            commands.Add("Check tika scheduled job", () =>
            {
                CheckQueuedTikaScheduledJobs.PerformCheck();
                return(false);
            });

            commands.Add("Start sync artifacts job", () =>
            {
                FullArtifactSyncJob.StartSync();
                return(false);
            });

            Menu(commands.Keys.ToList());
            CommandLoop(c =>
            {
                int menuSelection = 0;
                if (Int32.TryParse(c, out menuSelection))
                {
                    var func = commands.ElementAtOrDefault(menuSelection);
                    Console.WriteLine("Selected {0}", func.Key);
                    func.Value();
                }
                else
                {
                    if (String.Equals(c, "q", StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(true);
                    }

                    Console.WriteLine("Comando non valido! Premere un tasto per continuare");
                    Console.ReadKey();
                }
                Menu(commands.Keys.ToList());
                return(false);
            });
        }
Ejemplo n.º 2
0
        private static void RunShell()
        {
            MongoFlatMapper.EnableFlatMapping();

            if (ConsoleHelper.AskYesNoQuestion("Do you want to use Configuration Service? You should say N if doing tasks like migration that does not require configuration service"))
            {
                ConfigurationServiceClient.AppDomainInitializer(
                    (message, isError, exception) =>
                {
                    if (isError)
                    {
                        Console.Error.WriteLine(message + "\n" + exception);
                    }
                    else
                    {
                        Console.WriteLine(message);
                    }
                },
                    "JARVIS_CONFIG_SERVICE",
                    null,
                    new FileInfo("defaultParameters.config"),
                    missingParametersAction: ConfigurationManagerMissingParametersAction.Blank);
            }
            IWindsorContainer _container = new WindsorContainer();

            _container.AddFacility <LoggingFacility>(f => f
                                                     .LogUsing(LoggerImplementation.ExtendedLog4net)
                                                     .WithConfig("log4net.config"));
            _loggerFactory = _container.Resolve <ILoggerFactory>();

            var commands = new Dictionary <String, Func <Boolean> >();

            commands.Add("Check oprhaned blob", () =>
            {
                CheckOrphanedBlobs.PerformCheck(DateTime.UtcNow);
                return(false);
            });

            commands.Add("Check tika scheduled job", () =>
            {
                CheckQueuedTikaScheduledJobs.PerformCheck();
                return(false);
            });

            commands.Add("Start sync artifacts job", () =>
            {
                FullArtifactSyncJob.StartSync();
                return(false);
            });

            commands.Add("Copy blob from GridFs to FileSystemFs", () =>
            {
                var startFromBeginning = ConsoleHelper.AskYesNoQuestion("Do you want to start from the beginning of the stream?");
                BlobStoreSync command  = new BlobStoreSync(_loggerFactory.Create(typeof(BlobStoreSync)));
                command.SyncAllTenants(BlobStoreType.GridFs, BlobStoreType.FileSystem, startFromBeginning);
                return(false);
            });

            commands.Add("Copy blob from FileSystemFs to GridFs", () =>
            {
                var startFromBeginning = ConsoleHelper.AskYesNoQuestion("Do you want to start from the beginning of the stream?");
                BlobStoreSync command  = new BlobStoreSync(_loggerFactory.Create(typeof(BlobStoreSync)));
                command.SyncAllTenants(BlobStoreType.FileSystem, BlobStoreType.GridFs, startFromBeginning);
                return(false);
            });

            Menu(commands.Keys.ToList());
            CommandLoop(c =>
            {
                int menuSelection = 0;
                if (Int32.TryParse(c, out menuSelection))
                {
                    var func = commands.ElementAtOrDefault(menuSelection);
                    Console.WriteLine("Selected {0}", func.Key);
                    func.Value();
                }
                else
                {
                    if (String.Equals(c, "q", StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(true);
                    }

                    Console.WriteLine("Comando non valido! Premere un tasto per continuare");
                    Console.ReadKey();
                }
                Menu(commands.Keys.ToList());
                return(false);
            });
        }