Ejemplo n.º 1
0
        public void Run()
        {
            var log4NetLogger = LogManager.GetLogger(typeof(Program));
            var logger        = new ProgramLogger(log4NetLogger);

            _container = UnityIoC.Configure(logger);
            _logger    = _container.Resolve <IProgramLogger>();

            _logger.Info("Starting Municipalities service. press Ctrl+C to exit...");
            var inputBehaviour   = _container.Resolve <IUserInputBehaviour>();
            var requestsHandling = _container.Resolve <IRequestsFacade>();

            var inputBehaviourThread = new Thread(() => inputBehaviour.StartListening(_cancelTokenSource.Token))
            {
                IsBackground = true
            };

            inputBehaviourThread.Start();
            var requestsHandlingThread = new Thread(() => requestsHandling.ListenForRequests(_cancelTokenSource.Token))
            {
                IsBackground = true
            };

            requestsHandlingThread.Start();


            WaitHandle.WaitAny(new[] { _cancelTokenSource.Token.WaitHandle });

            _logger.Info("Shutting down...");
        }
 public SingleRSA(
     IGraphInputReader inputReader,
     IProgramLogger infologger,
     ILogger storageLogger,
     IPathSearcher pathSearcher,
     IRSATableFill RSATableFill)
     : base(inputReader, infologger, storageLogger, RSATableFill)
 {
     PathSearcher = pathSearcher;
 }
 public DedicatedProtectionRSA(
     IGraphInputReader inputReader,
     IProgramLogger infologger,
     ILogger storageLogger,
     IDisjointedPathPairSearcher disjointedPathPairSearcher,
     IRSATableFill RSATableFill)
     : base(inputReader, infologger, storageLogger, RSATableFill)
 {
     DisjointedPathPairSearcher = disjointedPathPairSearcher;
 }
Ejemplo n.º 4
0
 public SyncAllService(Func <IParatextSyncRunner> syncRunnerFactory, IRealtimeService realtimeService,
                       IParatextService paratextService,
                       IRepository <UserSecret> userSecretRepo, IProgramLogger logger)
 {
     _syncRunnerFactory = syncRunnerFactory;
     _realtimeService   = realtimeService;
     _paratextService   = paratextService;
     _userSecretRepo    = userSecretRepo;
     _logger            = logger;
 }
Ejemplo n.º 5
0
 public RoutingAndSpectrumAllocation(
     IGraphInputReader inputReader,
     IProgramLogger infologger,
     ILogger storageLogger,
     IRSATableFill RSATableFill)
 {
     InputReader       = inputReader;
     InfoLogger        = infologger;
     StorageLogger     = storageLogger;
     this.RSATableFill = RSATableFill;
 }
Ejemplo n.º 6
0
        public static IUnityContainer Configure(IProgramLogger logger)
        {
            var container = new UnityContainer();

            container.RegisterInstance <IProgramLogger>(logger);
            container.AddExtension(new Diagnostic());
            container.RegisterType <IUserInputBehaviour, UserInputBehaviour>(new ContainerControlledLifetimeManager());
            container.RegisterType <ICommandMapper, CommandMapper>(new ContainerControlledLifetimeManager());

            container.RegisterType <IAddCommand, AddCommand>(new ContainerControlledLifetimeManager());
            container.RegisterType <IGetCommand, GetCommand>(new ContainerControlledLifetimeManager());
            container.RegisterType <IImportCommand, ImportCommand>(new ContainerControlledLifetimeManager());

            container.RegisterType <IRequestsFacade, RequestsFacade>(new ContainerControlledLifetimeManager());
            container.RegisterType <INewRecordRequests, NewRecordRequests>(new ContainerControlledLifetimeManager());

            container.RegisterType <IAppData, AppData>(new ContainerControlledLifetimeManager());

            return(container);
        }
Ejemplo n.º 7
0
 public ImportCommand(IProgramLogger log)
 {
     _log = log;
 }
Ejemplo n.º 8
0
        public static async Task Main(string[] args)
        {
            string mode = Environment.GetEnvironmentVariable("PTDASYNCALL_MODE") ?? "inspect";
            bool   doSynchronizations   = mode == "sync";
            string sfAppDir             = Environment.GetEnvironmentVariable("SF_APP_DIR") ?? "../../SIL.XForge.Scripture";
            string sfProjectIdsSubset   = Environment.GetEnvironmentVariable("SYNC_SET");
            string sfAdminRequestValues = Environment.GetEnvironmentVariable("SF_PROJECT_ADMINS");

            Directory.SetCurrentDirectory(sfAppDir);
            IWebHostBuilder builder = CreateWebHostBuilder(args);
            IWebHost        webHost = builder.Build();

            Logger = webHost.Services.GetService <IProgramLogger>();
            Logger.Log($"Starting. Will sync: {doSynchronizations}");

            HashSet <string> projectSubset = null;

            try
            {
                if (sfProjectIdsSubset != null)
                {
                    projectSubset = new HashSet <string>(sfProjectIdsSubset.Split(' '));
                }
            }
            catch
            {
                Logger.Log($"There was a problem parsing the SYNC_SET SF project ids "
                           + $"environment variable. Rethrowing.");
                throw;
            }

            Dictionary <string, string> sfAdminsToUse = null;

            try
            {
                if (sfAdminRequestValues != null)
                {
                    sfAdminsToUse = new Dictionary <string, string>();
                    foreach (string sfAdminRequest in sfAdminRequestValues.Split(' '))
                    {
                        string[] request = sfAdminRequest.Split(':');
                        sfAdminsToUse.Add(request[0], request[1]);
                    }
                }
            }
            catch
            {
                Logger.Log($"There was a problem parsing SF_PROJECT_ADMINS. Rethrowing.");
                throw;
            }

            try
            {
                await webHost.StartAsync();
            }
            catch (HttpRequestException)
            {
                Logger.Log("There was an error starting the program before getting to the inspection or migration. "
                           + "Maybe the SF server is running on this machine and needs shut down? Rethrowing.");
                throw;
            }
            ISyncAllService tool = webHost.Services.GetService <ISyncAllService>();
            await tool.SynchronizeAllProjectsAsync(doSynchronizations, projectSubset, sfAdminsToUse);

            await webHost.StopAsync();

            Logger.Log("Done.");
        }
Ejemplo n.º 9
0
 public AddCommand(IProgramLogger log)
 {
     _log = log;
 }
Ejemplo n.º 10
0
 public GetCommand(IProgramLogger log)
 {
     _log = log;
 }
Ejemplo n.º 11
0
 public UserInputBehaviour(IProgramLogger log, ICommandMapper mapper)
 {
     _log    = log;
     _mapper = mapper;
 }