Exemple #1
0
        private string SearchWord(MonitoringItem item, string[] arrSearchWord, bool isSearchAllWord, string defaultWord = "pass")
        {
            string result = "";

            string itemTitle = item.ItemTitle.Trim().Replace(" ", "").Replace("\r", "").Replace("\n", "").Replace("\t", "").ToUpper();

            if (arrSearchWord != null &&
                arrSearchWord.Length > 0 &&
                arrSearchWord[0].Length > 0)
            {
                if (isSearchAllWord)//모든 단어가 포함되어야 함
                {
                    result = arrSearchWord.All(x => itemTitle.IndexOf(x.ToUpper()) >= 0) ? arrSearchWord[0] : "";
                }
                else
                {
                    result = arrSearchWord.FirstOrDefault(x => itemTitle.IndexOf(x.ToUpper()) >= 0) ?? "";
                }
            }
            else
            {
                result = defaultWord;
            }

            return(result);
        }
Exemple #2
0
        public void Push(MonitoringItem monitoringItem)
        {
            if (_rules == null)
            {
                var searchRules = _monitoringRuleRepository.SearchAsync(x => x.IsEnabled).Result;

                if (searchRules != null)
                {
                    _rules = new ConcurrentBag <MonitoringRule>(searchRules.Result);
                }
            }

            if (_rules == null)
            {
                return;
            }

            foreach (var rule in _rules)
            {
                if (Evaluate(rule, monitoringItem))
                {
                    _monitoringAdapter.WriteEvent(rule, monitoringItem).Wait();
                }
            }
        }
        private void Store(MonitoringItem item)
        {
            var times       = (item.Timespan.HasValue && (item.Count > 0)) ? string.Format(Resources.Strings.MonitoringTimesInSecondsFormat, item.Count, item.Timespan.Value) : string.Empty;
            var exception   = (item.Exception != null) ? Environment.NewLine + item.Exception : string.Empty;
            var description = item.Description + times + exception;

            // Store monitoring event.
            _storage.Store(item.Timestamp, item.MachineName, item.ModuleName, item.ComponentName, item.Severity, item.Title, description);

            // Notify monitoring event.
            if ((item.Severity >= Severity.Notify) && (item.Severity < Severity.NotifyWithEmail))
            {
                _notify.Notify(item.Timestamp, item.MachineName, item.ModuleName, item.ComponentName, item.Severity, item.Title, description);
            }
            else if (((item.Severity >= Severity.ErrorWithEmail) && (item.Severity < Severity.ErrorWithSms)) || ((item.Severity >= Severity.NotifyWithEmail) && (item.Severity < Severity.NotifyWithSms)))
            {
                _notify.Notify(item.Timestamp, item.MachineName, item.ModuleName, item.ComponentName, item.Severity, item.Title, description);
                _notifyEmail.NotifyWithEmail(item.Timestamp, item.MachineName, item.ModuleName, item.ComponentName, item.Severity, item.Title, description);
            }
            else if (((item.Severity >= Severity.ErrorWithSms) && (item.Severity < Severity.Fatal)) || (item.Severity >= Severity.NotifyWithSms))
            {
                _notify.Notify(item.Timestamp, item.MachineName, item.ModuleName, item.ComponentName, item.Severity, item.Title, description);
                _notifySms.NotifyWithSms(item.Timestamp, item.MachineName, item.ModuleName, item.ComponentName, item.Severity, item.Title, description);
            }
            else if ((item.Severity >= Severity.Fatal) && (item.Severity < Severity.Notify))
            {
                _notify.Notify(item.Timestamp, item.MachineName, item.ModuleName, item.ComponentName, item.Severity, item.Title, description);
                _notifyEmail.NotifyWithEmail(item.Timestamp, item.MachineName, item.ModuleName, item.ComponentName, item.Severity, item.Title, description);
                _notifySms.NotifyWithSms(item.Timestamp, item.MachineName, item.ModuleName, item.ComponentName, item.Severity, item.Title, description);
            }
        }
Exemple #4
0
        private string FindExceptWords(MonitoringItem item)
        {
            string[] arrExceptWord = (ExceptKeywords ?? "").Split(' ');

            string result = SearchWord(item, arrExceptWord, false, "");

            return(result);
        }
Exemple #5
0
 private void WriteExceptedItem(List <ExceptedItem> lstExceptedItem)
 {
     foreach (ExceptedItem excepted in lstExceptedItem)
     {
         MonitoringItem exceptedItem = excepted.Item;
         FormHelper.SetTextBox(txtFilteredItemList
                               , $"{string.Format("{0:#,0.######}", excepted.Item.ItemPrice / 10000.0)}만원 - {excepted.Item.ItemTitle}[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}]제외됨({excepted.ExceptWord})\r\n", "Y");
     }
 }
Exemple #6
0
        private bool Evaluate(MonitoringRule rule, MonitoringItem loggingItem)
        {
            var lambdaParser = new NReco.Linq.LambdaParser();
            var varContext   = new Dictionary <string, object> {
                ["LoggingItem"] = loggingItem, ["Warning"] = LogLevel.Warning, ["Error"] = LogLevel.Error, ["Information"] = LogLevel.Information
            };

            return((bool)lambdaParser.Eval(rule.Rule, varContext));
        }
            public void Update(MonitoringItem item)
            {
                Timestamp     = item.Timestamp;
                MachineName   = item.MachineName;
                ModuleName    = item.ModuleName;
                ComponentName = item.ComponentName;
                Severity      = item.Severity;
                Title         = item.Title;
                Description   = item.Description;
                Exception     = item.Exception;

                Count++;
            }
        internal void RegisterToQueue(MonitoringItem item)
        {
            // Lock monitoring queue resources.
            lock (_monitoringLock)
            {
                // Check disposed flag.
                if (_disposed)
                {
                    return;
                }

                // Add item to the monitoring queue.
                _monitoringQueue.AddItem(item);
            }
        }
            public MonitoringItem(MonitoringItem item)
            {
                Key = item.Key;

                Timestamp     = item.Timestamp;
                MachineName   = item.MachineName;
                ModuleName    = item.ModuleName;
                ComponentName = item.ComponentName;
                Severity      = item.Severity;
                Title         = item.Title;
                Description   = item.Description;
                Exception     = item.Exception;

                Count    = item.Count;
                Timespan = item.Timespan;
            }
Exemple #10
0
        private bool SearchPrice(MonitoringItem item, int minPrice, int maxPrice)
        {
            bool result = true;

            if (item.ItemPrice > 0 &&
                (minPrice > 0 || maxPrice > 0))
            {
                if (item.ItemPrice < minPrice ||
                    item.ItemPrice > maxPrice)
                {
                    //금액 확인
                    result = false;
                }
            }

            return(result);
        }
        private void RegisterCacheToQueue(MonitoringItem item)
        {
            // Lock monitoring queue resources.
            lock (_monitoringLock)
            {
                // Check disposed flag.
                if (_disposed)
                {
                    return;
                }

                MonitoringItem current;
                if (_monitoringCache.TryGetValue(item.Key, out current))
                {
                    if (current.Count > 0)
                    {
                        // Create clone monitoring item.
                        var clone = new MonitoringItem(current);

                        // Add clone item to the monitoring queue.
                        _monitoringQueue.AddItem(clone);

                        // Reset monitoring item in cache.
                        current.Count = 0;

                        // Check for delayed task.
                        if (current.Timespan.HasValue)
                        {
                            // Recreate delayed task to check monitoring cache.
                            Task.Delay(current.Timespan.Value, _monitoringCancellationTokenSource.Token).ContinueWith(task => RegisterCacheToQueue(current), _monitoringCancellationTokenSource.Token);
                        }
                        else
                        {
                            // Remove item from the monitoring cache.
                            _monitoringCache.Remove(item.Key);
                        }
                    }
                    else
                    {
                        // Remove item from the monitoring cache.
                        _monitoringCache.Remove(item.Key);
                    }
                }
            }
        }
Exemple #12
0
        private bool Search(MonitoringItem item)
        {
            string[] arrRequireKeywords = (RequireKeywords ?? "").Split(' ');
            string[] arrOptionKeywords  = (OptionKeywords ?? "").Split(' ');

            string searchWordResult = SearchWord(item, arrRequireKeywords, true);

            if (searchWordResult.Length > 0)
            {
                searchWordResult = SearchWord(item, arrOptionKeywords, false);
            }

            bool result = false;

            if (searchWordResult.Length > 0)
            {
                result = SearchPrice(item, MinPrice, MaxPrice);
            }

            return(result);
        }
        internal void RegisterToCache(MonitoringItem item, TimeSpan timespan)
        {
            // Lock monitoring queue resources.
            lock (_monitoringLock)
            {
                // Check disposed flag.
                if (_disposed)
                {
                    return;
                }

                MonitoringItem current;
                if (_monitoringCache.TryGetValue(item.Key, out current))
                {
                    // UpdateState item in the monitoring cache.
                    current.Update(item);
                }
                else
                {
                    // Add item to the monitoring queue.
                    _monitoringQueue.AddItem(item);

                    // Create clone monitoring item and setup its parameters.
                    var clone = new MonitoringItem(item)
                    {
                        Timespan = timespan
                    };

                    // Create delayed task to check monitoring cache.
                    Task.Delay(timespan, _monitoringCancellationTokenSource.Token).ContinueWith(task => RegisterCacheToQueue(clone), _monitoringCancellationTokenSource.Token);

                    // Add clone item to the monitoring cache.
                    _monitoringCache.Add(clone.Key, clone);
                }
            }
        }
Exemple #14
0
        public async Task <IActionResult> WriteEvent(MonitoringItem monitoringItem)
        {
            var item = await _monitoringService.WriteEvent(monitoringItem);

            return(Ok(item));
        }
Exemple #15
0
        public async Task <MonitoringItem> WriteEvent(MonitoringItem item)
        {
            var result = await _repositoryStore.AddAsync(item);

            return(result.IsSuccessful ? result.Result : null);
        }