Пример #1
0
        public void Process()
        {
            var entriesStart = _inputRepository.GetStartedEntries();
            var entriesStop  = _inputRepository.GetStoppedEntries();

            foreach (var entry in entriesStart)
            {
                if (!entriesStop.ContainsKey(entry.Key))
                {
                    continue;
                }

                var timeDifferenece = entriesStop[entry.Key].TimeStamp - entry.Value.TimeStamp;

                if (timeDifferenece < 0)
                {
                    continue;
                }

                var value = entry.Value;
                var host  = value.Host ?? entriesStop[entry.Key].Host;
                var type  = value.Type ?? entriesStop[entry.Key].Type;

                var dbEntry = new DBLogEntry()
                {
                    Duration = timeDifferenece,
                    Alert    = timeDifferenece > _alertThreshold,
                    Id       = entry.Key,
                    Host     = host,
                    Type     = !String.IsNullOrEmpty(type) ? type.ToString() : String.Empty
                };

                _dbWriteRepository.InsertLogEntry(dbEntry);
            }
        }
Пример #2
0
        public void InsertLogEntry(DBLogEntry entry)
        {
            var dbLogEntries = _db.GetCollection <DBLogEntry>(_tableName);

            dbLogEntries.Insert(entry);
        }