예제 #1
0
        private static void Main()
        {
            DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_CLOSE, MF_BYCOMMAND);
            var storageConnection = ConfigurationManager.AppSettings["AzureStorageConnectionString"];
            ServiceBusConnectionStringBuilder builder = new ServiceBusConnectionStringBuilder(ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString.Listen"]);

            EventHubName = ConfigurationManager.AppSettings["EventHubName"];
            var hubProcessor = new EventHubProcessor(builder.ToString(), EventHubName);
            AnalyzerEngineProgram engineProgram = new AnalyzerEngineProgram(Engine, Logger, ErrorLogger, new StatusSnapShotGenerator(ConfigurationManager.AppSettings["jsonPath"], ErrorLogger), hubProcessor);


            var alarmQueueConnS = ConfigurationManager.AppSettings["ServiceBus.Queue.Connectionstring"];
            var alarmQueueName  = ConfigurationManager.AppSettings["ServiceBus.Queue.Name"];

            var alarmQueue  = new ServiceBusConnection <AlarmMessage>(alarmQueueConnS, alarmQueueName);
            var alarmManger = new AlarmMessageManager(alarmQueue);
            var ruleStorage = new DocumentDBRuleStorage(ConfigurationManager.AppSettings["DocDBEndPointUrl"], ConfigurationManager.AppSettings["AuthorizationKey"], ConfigurationManager.AppSettings["RuleDatabaseId"], ConfigurationManager.AppSettings["RuleCollectionId"]);

            var eventStore = new SQLEventStore(Logger, ConfigurationManager.AppSettings["sqleventstoreConnection"]);

            var restartInput = new RestartInput()
            {
                RuleStorage = ruleStorage, AlarmMessageManager = alarmManger, EngineProgram = engineProgram
            };
            var engineRestartTimer = new Timer(RestartLoop, restartInput, 0, 5000);

            Timers.Add(engineRestartTimer);

            var eventProcessorThread = new Thread(() =>
            {
                var recTask = hubProcessor.StartReceiver <EventProcessor>(storageConnection);
                EventProcessor.Init(Engine, Logger, ErrorLogger, eventStore);
                recTask.Wait();
            });

            eventProcessorThread.Name = nameof(eventProcessorThread);

            var gui       = new GuiHandler(engineProgram);
            var guiThread = new Thread(gui.Run);

            guiThread.IsBackground = true;
            guiThread.Start();
            guiThread.Name = nameof(guiThread);
            eventProcessorThread.Priority = ThreadPriority.AboveNormal;
            eventProcessorThread.Start();
        }