예제 #1
0
        private static void Main(string[] args)
        {
            var isDebuggerMode = IsDebuggerMode(args);

            if (isDebuggerMode && !Debugger.IsAttached)
            {
                Debugger.Launch();
            }

            IUnityContainer container = null;

            try
            {
                container = Bootstrapper.ConfigureUnity();
                var schedulerManagers = container.ResolveAll <ISchedulerManager>().ToList();
                if (IsConsoleMode(args))
                {
                    foreach (var schedulerManager in schedulerManagers)
                    {
                        schedulerManager.Start();
                    }

                    Console.WriteLine("ERM Validation Rules Replication service successfully started.");
                    Console.WriteLine("Press ENTER to stop...");

                    Console.ReadLine();

                    Console.WriteLine("ERM Validation Rules Replication service is stopping...");

                    foreach (var schedulerManager in schedulerManagers)
                    {
                        schedulerManager.Stop();
                    }

                    Console.WriteLine("ERM Validation Rules Replication service stopped successfully. Press ENTER to exit...");
                    Console.ReadLine();
                }
                else
                {
                    using (var replicationService = new ReplicationService(schedulerManagers))
                    {
                        ServiceBase.Run(replicationService);
                    }
                }
            }
            finally
            {
                container?.Dispose();
            }
        }
        private static void Main(string[] args)
        {
            var isDebuggerMode = IsDebuggerMode(args);
            if (isDebuggerMode && !Debugger.IsAttached)
            {
                Debugger.Launch();
            }

            var settingsContainer = new ReplicationServiceSettings();
            var environmentSettings = settingsContainer.AsSettings<IEnvironmentSettings>();
            var connectionStringSettings = settingsContainer.AsSettings<IConnectionStringSettings>();

            var tracer = Log4NetTracerBuilder.Use
                                             .ApplicationXmlConfig
                                             .Console
                                             .EventLog
                                             .WithGlobalProperties(x =>
                                                x.Property(TracerContextKeys.Tenant, environmentSettings.EnvironmentName)
                                                .Property(TracerContextKeys.EntryPoint, environmentSettings.EntryPointName)
                                                .Property(TracerContextKeys.EntryPointHost, NetworkInfo.ComputerFQDN)
                                                .Property(TracerContextKeys.EntryPointInstanceId, Guid.NewGuid().ToString()))
                                             .Logstash(new Uri(connectionStringSettings.GetConnectionString(LoggingConnectionStringIdentity.Instance)),
                                                appender => { appender.LogstashLayout.IncrementalCounter = true; } )
                                             .Build;

            IUnityContainer container = null;
            try
            {
                container = Bootstrapper.ConfigureUnity(settingsContainer, tracer);
                var schedulerManagers = container.ResolveAll<ISchedulerManager>().ToList();
                if (IsConsoleMode(args))
                {
                    foreach (var schedulerManager in schedulerManagers)
                    {
                        schedulerManager.Start();
                    }

                    Console.WriteLine("ERM Validation Rules Replication service successfully started.");
                    Console.WriteLine("Press ENTER to stop...");

                    Console.ReadLine();

                    Console.WriteLine("ERM Validation Rules Replication service is stopping...");

                    foreach (var schedulerManager in schedulerManagers)
                    {
                        schedulerManager.Stop();
                    }

                    Console.WriteLine("ERM Validation Rules Replication service stopped successfully. Press ENTER to exit...");
                    Console.ReadLine();
                }
                else
                {
                    using (var replicationService = new ReplicationService(schedulerManagers))
                    {
                        ServiceBase.Run(replicationService);
                    }
                }
            }
            finally
            {
                container?.Dispose();
            }
        }