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 tracerContextEntryProviders = new ITracerContextEntryProvider[] { new TracerContextConstEntryProvider(TracerContextKeys.Required.Environment, environmentSettings.EnvironmentName), new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPoint, environmentSettings.EntryPointName), new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPointHost, NetworkInfo.ComputerFQDN), new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPointInstanceId, Guid.NewGuid().ToString()), new TracerContextSelfHostedEntryProvider(TracerContextKeys.Required.UserAccount) }; var tracerContextManager = new TracerContextManager(tracerContextEntryProviders); var tracer = Log4NetTracerBuilder.Use .DefaultXmlConfig .Console .EventLog .Logstash(new Uri(connectionStringSettings.GetConnectionString(LoggingConnectionStringIdentity.Instance))) .Build; IUnityContainer container = null; try { container = Bootstrapper.ConfigureUnity(settingsContainer, tracer, tracerContextManager); var schedulerManager = container.Resolve <ISchedulerManager>(); if (IsConsoleMode(args)) { schedulerManager.Start(); Console.WriteLine("Advanced Search Replication service successfully started."); Console.WriteLine("Press ENTER to stop..."); Console.ReadLine(); Console.WriteLine("Advanced Search Replication service is stopping..."); schedulerManager.Stop(); Console.WriteLine("Advanced Search Replication service stopped successfully. Press ENTER to exit..."); Console.ReadLine(); } else { using (var replicationService = new ReplicationService(schedulerManager)) { ServiceBase.Run(replicationService); } } } finally { if (container != null) { 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 tracerContextEntryProviders = new ITracerContextEntryProvider[] { new TracerContextConstEntryProvider(TracerContextKeys.Required.Environment, environmentSettings.EnvironmentName), new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPoint, environmentSettings.EntryPointName), new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPointHost, NetworkInfo.ComputerFQDN), new TracerContextConstEntryProvider(TracerContextKeys.Required.EntryPointInstanceId, Guid.NewGuid().ToString()), new TracerContextSelfHostedEntryProvider(TracerContextKeys.Required.UserAccount) }; var tracerContextManager = new TracerContextManager(tracerContextEntryProviders); var tracer = Log4NetTracerBuilder.Use .DefaultXmlConfig .Console .EventLog .Logstash(new Uri(connectionStringSettings.GetConnectionString(LoggingConnectionStringIdentity.Instance))) .Build; IUnityContainer container = null; try { container = Bootstrapper.ConfigureUnity(settingsContainer, tracer, tracerContextManager); var schedulerManager = container.Resolve<ISchedulerManager>(); if (IsConsoleMode(args)) { schedulerManager.Start(); Console.WriteLine("Advanced Search Replication service successfully started."); Console.WriteLine("Press ENTER to stop..."); Console.ReadLine(); Console.WriteLine("Advanced Search Replication service is stopping..."); schedulerManager.Stop(); Console.WriteLine("Advanced Search Replication service stopped successfully. Press ENTER to exit..."); Console.ReadLine(); } else { using (var replicationService = new ReplicationService(schedulerManager)) { ServiceBase.Run(replicationService); } } } finally { if (container != null) { container.Dispose(); } } }