private void CreateMeasureUnit(string rowData, DateTime timeStamp)
        {
            // only if any settings are available
            var setts = MeasureSettings.Where(x => x.IsReadyToUse && x.IsActive);

            if (rowData != null && setts.Any())
            {
                MeasureSettingViewModel set = setts.FirstOrDefault(x => (x.UseContainsEvaluation ? rowData.Contains(x.StartCode) : x.StartCode == rowData) && x.MeasuredUnits.All(y => !y.IsRunning));
                if (set != null)
                {
                    string matchKey = null;
                    if (set.UseKeyLockedMatch)
                    {
                        matchKey = Regex.Match(rowData, String.Format(MeasureSettingViewModel.KeyLockedPatternFormat, MeasureSettingViewModel.KeyLockedPattern)).Value;
                    }
                    set.MeasuredUnits.Add(new MeasuredUnitViewModel(set, matchKey)
                    {
                        StartTime      = timeStamp,
                        MeasureSetting = set
                    });
                }

                var setting = setts.FirstOrDefault(x =>
                                                   (x.UseContainsEvaluation ? rowData.Contains(x.StopCode) : x.StopCode == rowData) && x.MeasuredUnits.Any(y => y.IsRunning));
                if (setting != null)
                {
                    var unit = setting.MeasuredUnits.FirstOrDefault(x => x.IsRunning &&
                                                                    (x.MeasureSetting.UseKeyLockedMatch ? Regex.IsMatch(rowData, String.Format(MeasureSettingViewModel.KeyLockedPatternFormat, $"({x.MatchKey})"), RegexOptions.IgnoreCase) : true));
                    if (unit != null)
                    {
                        unit.StopTime = timeStamp;
                    }
                }
            }
        }
        private void EvaluateUnitData()
        {
            var setts = MeasureSettings.Where(x => x.IsActive && x.IsReadyToUse).ToList();

            if (setts.All(x => x.IsMeasureOverLimit() == null))
            {
                IsMeasurementOverLimit = null;
            }
            else
            {
                IsMeasurementOverLimit = setts.Any(x => x.IsMeasureOverLimit() != null && x.IsMeasureOverLimit().Value);
            }
        }
        public void Start()
        {
            switch (LoggingSourceType)
            {
            case LoggingTypeSourceEnum.Console:
                if (ConsoleProcess != null)
                {
                    if (ConsoleProcess.HasExited)
                    {
                        ConsoleProcess.Start();
                    }

                    return;
                }
                else
                {
                    if (File.Exists(FilePath))
                    {
                        ConsoleOutputStream = new ObservableCollection <OutputText>();

                        var startInfo = new ProcessStartInfo(FilePath)
                        {
                            WorkingDirectory       = RootFolderPath,
                            Arguments              = StartingArguments,
                            RedirectStandardOutput = true,
                            UseShellExecute        = false,
                            CreateNoWindow         = true
                        };
                        ConsoleProcess = new System.Diagnostics.Process {
                            StartInfo = startInfo
                        };

                        ConsoleProcess.EnableRaisingEvents = true;

                        var setts = MeasureSettings.Where(x => x.IsReadyToUse && x.IsActive);

                        ConsoleProcess.OutputDataReceived += (sender, args) =>
                        {
                            if (!_isAppClosing && args.Data != null)
                            {
                                App.Current.Dispatcher.Invoke((System.Action) delegate
                                {
                                    var rowData = args.Data.Trim();

                                    CreateMeasureUnit(rowData, DateTime.Now);
                                    PublishMessageToConsole(rowData);
                                });
                            }
                        };
                        ConsoleProcess.Exited += (sender, args) =>
                        {
                            InProgress = false;
                        };

                        ConsoleProcess.Start();
                        ConsoleProcess.BeginOutputReadLine();
                    }
                    else
                    {
                        Console.WriteLine("File not found.");
                        InProgress = false;
                    }
                }

                _calculationCancellationTokenSource = new CancellationTokenSource();
                _calculationWorker = RepeatHelper.Interval(TimeSpan.FromSeconds(LoopingDelay), () => EvaluateUnitData(), _calculationCancellationTokenSource.Token);

                break;

            case LoggingTypeSourceEnum.RabbitMQ:

                var con = ConfigurationManager.AppSettings.Get(Constants.RabbitMQConnectionName);

                if (con == null)
                {
                    con = @"host=localhost;port=5672;virtualHost=/;username=admin;password=admin;requestedHeartbeat=0";
                }

                var processMQId = $"{FileName}_{Guid.NewGuid()}";
                bus = RabbitHutch.CreateBus(con);
                var exchange = bus.Advanced.ExchangeDeclare("Ariane.MQ", ExchangeType.Topic, autoDelete: true);

                // stops disposes bus and kills queue
                //queue = bus.Advanced.QueueDeclare(processMQId, autoDelete: true, perQueueMessageTtl: 10000);
                queue = bus.Advanced.QueueDeclare(processMQId, autoDelete: true);
                var q = bus.Advanced.Bind(exchange, queue, RabbitMQTopicName);

                bus.Advanced.Consume <LogMessageBase>(queue, (x, a) => {
                    var log = x.Body;

                    string rowData;
                    var m = $"{log.TimeStamp.ToString("HH:mm:ss")} -{log.Level}- {log.FormattedMessage}";

                    // apply aditional formatting
                    if (!String.IsNullOrEmpty(log.Message))
                    {
                        rowData = String.Format(log.Message, m);
                    }
                    else
                    {
                        rowData = m;
                    }

                    var timeStamp = log.TimeStamp;

                    CreateMeasureUnit(rowData, timeStamp);
                    Application.Current.Dispatcher.Invoke(delegate
                    {
                        PublishMessageToConsole(rowData);
                    });

                    //}, x => {
                    //x.WithTopic(RabbitMQTopicName);
                });

                InProgress = true;

                break;

            default:
                throw new Exception($"Logging source '{LoggingSourceType}' has not supported.");
            }
        }