示例#1
0
        public static void Main(string[] args)
        {
            var isRunning = true;

            ConfigureModules("Settings.xml");
            Console.WriteLine($"Программа сконфигурирована.\nИнтервал получения данных {MonitorModule.GetPerformanceInterval} мс ({MonitorModule.GetPerformanceInterval/1000} с).");
            Console.WriteLine($"Адресс сервера {SenderModule.ServerEndPoint}");
            Console.WriteLine($"Интервал повоторных попыток: {SenderModule.IntervalAttempts}");
            MonitorModule.GotPerformance += SendPerformance;
            MonitorModule.Start();
            Console.WriteLine("Запущен анализирующий модуль.");
            while (isRunning)
            {
                if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)
                {
                    isRunning = false;
                }
                Thread.Sleep(500);
            }
            SenderModule.Dispose();
            MonitorModule.Dispose();
            Thread.Sleep(1000);
        }
        public void AddMonitorInfo(string subjectType, string subjectId, string errorMessage, string operationUser, string operationName, MonitorLevel level = MonitorLevel.Info, MonitorModule module = MonitorModule.Other)
        {
            var parms = new object[] { subjectType, subjectId, errorMessage, operationUser, operationName, level, module };

            TuHuThreadPool.QueueUserWorkItem(HandlerAddMonitorInfo, parms);
        }
        public void AddMonitorInfo(string subjectType, string subjectId, string errorMessage, string operationUser, string operationName, MonitorLevel level = MonitorLevel.Info, MonitorModule module = MonitorModule.Other)
        {
            try
            {
                handler.AddMonitorInfo(subjectType, subjectId, errorMessage, operationUser, operationName, level, module);
            }
            catch (Exception innerEx)
            {
                var exception = new MonitorException(BizErrorCode.SystemError, "查询异常订单错误", innerEx);
                Logger.Log(Level.Error, "Error occurred in GetExceptionOrders.", exception);

                throw exception;
            }
        }
示例#4
0
        public void GetActiveAlarms_Test()
        {
            //Set up a monitor with ID 1 and save in database
            Monitor monitor = new Monitor();

            monitor.Id     = 1;
            monitor.Active = true;
            monitor.Save();

            //Set up a module and save. Id is given by IDENTITY in database
            Module module = new Module();

            module.Name       = "Module name";
            module.Icon       = "icon";
            module.DefaultMin = 10F;
            module.DefaultMax = 20F;
            Nullable <int> insertedModuleId = module.Save();

            // Ensure that the ID is set by retrieving inserted record from DB
            module = new Module(insertedModuleId);


            //Set up a monitorModule and save
            MonitorModule monitorModule = new MonitorModule();

            monitorModule.Monitor     = monitor;
            monitorModule.Module      = module;
            monitorModule.AssignedMin = 11F;
            monitorModule.AssignedMax = 19F;
            Nullable <int> insertedMonitorModuleId = monitorModule.Save();

            // Ensure that the ID is set by retrieving inserted record from DB
            monitorModule = MonitorModule.GetOne((int)insertedMonitorModuleId);


            //Create an active alarm for monitor 1
            Alarm          activeAlarm           = new Alarm(monitorModule, 10F);
            Nullable <int> insertedActiveAlarmID = activeAlarm.Save();

            activeAlarm.Id = (int)insertedActiveAlarmID;


            //Create an inactive alarm for monitor 1
            Alarm          inactiveAlarm           = new Alarm(monitorModule, 20F);
            Nullable <int> insertedInactiveAlarmID = inactiveAlarm.Save();

            inactiveAlarm.Id = (int)insertedInactiveAlarmID;

            // update alarm to mark as inactive
            inactiveAlarm.EndDateTime = DateTime.Now.AddDays(-1);
            inactiveAlarm.Update();


            // At this stage we have two alarms for the monitor with ID 1.
            // One of the is inactive because EndDateTime is set to yesterday.

            List <Alarm> retrievedActiveAlarms = new List <Alarm>();

            // Retrieve all active alarms for monitor 1
            retrievedActiveAlarms = monitor.GetActiveAlarms();

            // The retrievedActiveAlarms list should contain 1 record, 1 less than
            // the 2 that the alarmFixtures contains.
            Assert.AreEqual(1, retrievedActiveAlarms.Count);
        }
示例#5
0
 public static void AddNewMonitor(string subjectType, Exception ex, string operationName, MonitorLevel level = MonitorLevel.Info, MonitorModule module = MonitorModule.Other)
 {
     AddNewMonitor(subjectType, string.Empty, ex.ToString(), ThreadIdentity.Operator.Name, operationName, level, module);
 }
示例#6
0
 public static void AddNewMonitor(string subjectType, string subjectId, string errorMessage, string operationUser,
                                  string operationName, MonitorLevel level = MonitorLevel.Info, MonitorModule module = MonitorModule.Other)
 {
     try
     {
         Manager.AddMonitorInfo(subjectType, subjectId, errorMessage, operationUser, operationName, level, module);
     }
     catch (Exception ex)
     {
         var exception = new MonitorException(BizErrorCode.SystemError, "添加异常监控错误", ex);
         Logger.Log(Level.Error, "Error occurred in AddNewMonitor.", exception);
     }
 }