示例#1
0
        internal void ProcessingData()
        {
            try
            {
                if (_lock)
                {
                    return;
                }

                _lock = true;

                var method = UtilHelper.GetMethodName(MethodBase.GetCurrentMethod());
                _logger?.Info($"{method} => start");
                var watch = System.Diagnostics.Stopwatch.StartNew();

                var data = DataReaderHelper.GetData(
                    _dataReaders, _filtersValidator, _filtersValidatorRepository, _aggregatorsValidator, _aggregatorsValidatorRepository);
                if (!data.Any())
                {
                    _logger?.Debug("No data found...");
                    return;
                }

                var sendedMessages = new Dictionary <SendedMessages, int>();
                foreach (var message in data)
                {
                    if (!_clientsManager.Send(message))
                    {
                        _logger?.Debug("No clients defined to send...");
                        return;
                    }
                    var sendedMessage = new SendedMessages {
                        Name = message.LogicalStorage, Id = message.ReaderId
                    };
                    sendedMessages.AddOrIncrement(sendedMessage, 1);
                }

                foreach (var message in sendedMessages)
                {
                    _logger?.Debug($"Sended: {message.Value} messages from {message.Key}");
                }

                watch.Stop();
                var elapsedMs = watch.ElapsedMilliseconds;
                _logger?.Info($"{method} => end, Time taken: {elapsedMs}ms");
            }
            catch (Exception ex)
            {
                _logger?.Error(ex.Message);
            }
            finally
            {
                _lock = false;
            }
        }
示例#2
0
 public virtual void SendMessageTo(string id, Message message)
 {
     SendedMessages.Add(new Adresse
     {
         From    = this,
         ToID    = id,
         Message = message,
         ID      = Guid.NewGuid(),
         Readed  = false
     });
 }