Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            try
            {
                int workerThreads;
                int completionPortThreads;
                System.Threading.ThreadPool.GetMinThreads(out workerThreads, out completionPortThreads);
                if (workerThreads < 16)
                {
                    workerThreads = 16;
                    System.Threading.ThreadPool.SetMinThreads(workerThreads, completionPortThreads);
                }

                IConfigurationBuilder builder = new ConfigurationBuilder()
                    .SetBasePath(Directory.GetCurrentDirectory())
                    .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                    .AddEnvironmentVariables()
                    .AddCommandLine(args);

                IConfigurationRoot configuration = builder.Build();

                int port = 14050;
                IConfigurationSection section = configuration.GetSection("ChangeNotification");
                if (section != null)
                {
                    section = section.GetSection("NotificationTCPPort");
                    if (section != null)
                    {
                        if (!int.TryParse(section.Value, out port))
                            port = 14050;
                    }
                }

                Version version = Assembly.GetExecutingAssembly().GetName().Version;
                Console.Write("ChangeNotification (");
                Console.Write(version.ToString());
                Console.WriteLine(")");

                ServiceConfiguration.DisplayConfig();

                ApplicationEventLog.LogLevel = System.Diagnostics.EventLogEntryType.Information;
                BusinessLogicFactory.NotificationOrchestrator.Start();
                NotificationTcpServer server = new NotificationTcpServer();
                server.StartListening(port);
                _ShutdownEvent = new ManualResetEvent(false);
                Console.CancelKeyPress += delegate (object sender, ConsoleCancelEventArgs e)
                {
                    _ShutdownEvent.Set();
                    e.Cancel = true;
                };
                Console.WriteLine("Press Ctrl+C to stop the server.");
                _ShutdownEvent.WaitOne();
                Console.WriteLine("Exiting.");
                server.StopListening();
                BusinessLogicFactory.NotificationOrchestrator.Stop();

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            try
            {
                int workerThreads;
                int completionPortThreads;
                System.Threading.ThreadPool.GetMinThreads(out workerThreads, out completionPortThreads);
                if (workerThreads < 16)
                {
                    workerThreads = 16;
                    System.Threading.ThreadPool.SetMinThreads(workerThreads, completionPortThreads);
                }

                IConfigurationBuilder builder = new ConfigurationBuilder()
                                                .SetBasePath(Directory.GetCurrentDirectory())
                                                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                                .AddEnvironmentVariables()
                                                .AddCommandLine(args);

                IConfigurationRoot configuration = builder.Build();


                int port = 14050;
                IConfigurationSection section = configuration.GetSection("ChangeNotification");
                if (section != null)
                {
                    section = section.GetSection("NotificationTCPPort");
                    if (section != null)
                    {
                        if (!int.TryParse(section.Value, out port))
                        {
                            port = 14050;
                        }
                    }
                }

                Version version = Assembly.GetExecutingAssembly().GetName().Version;
                Console.Write("ChangeNotification (");
                Console.Write(version.ToString());
                Console.WriteLine(")");

                ServiceConfiguration.DisplayConfig();

                ApplicationEventLog.LogLevel = System.Diagnostics.EventLogEntryType.Information;
                BusinessLogicFactory.NotificationOrchestrator.Start();
                NotificationTcpServer server = new NotificationTcpServer();
                server.StartListening(port);
                _ShutdownEvent          = new ManualResetEvent(false);
                Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
                {
                    _ShutdownEvent.Set();
                    e.Cancel = true;
                };
                Console.WriteLine("Press Ctrl+C to stop the server.");
                _ShutdownEvent.WaitOne();
                Console.WriteLine("Exiting.");
                server.StopListening();
                BusinessLogicFactory.NotificationOrchestrator.Stop();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }