예제 #1
0
        private void LogEntryMonitor_NewLogEntry(object sender, DataProcessingServiceLog logEntry)
        {
            Application.Current.Dispatcher.BeginInvoke((Action)(() =>
            {
                var logEntryViewModel = new LogEntryViewModel(logEntry);
                if (IsAppropriateForAllMessagesList(logEntry))
                {
                    AllLogMessages.Add(logEntryViewModel);
                }
                if (logEntryViewModel.IsError)
                {
                    ErrorLogMessages.Add(logEntryViewModel);
                }
                if (logEntryViewModel.ExecutorType.HasValue)
                {
                    switch (logEntryViewModel.ExecutorType.Value)
                    {
                    case DataProcessingServiceExecutorType.Processor:
                        if (logEntryViewModel.ProcessorName != "Unknown")
                        {
                            var matchingProcessor = Processors.SingleOrDefault(p => p.Details.Name == logEntryViewModel.ProcessorName);
                            if (matchingProcessor == null)
                            {
                                matchingProcessor = new ProcessorViewModel(
                                    new ProcessorDetails(
                                        logEntryViewModel.ProcessorName,
                                        logEntryViewModel.InputTypeName,
                                        logEntryViewModel.OutputTypeName)
                                    );
                                // Sort alphabetically
                                var insertIndex = Processors.Count(processor =>
                                                                   processor.Details.Name.CompareTo(matchingProcessor.Details.Name) < 0);
                                Processors.Insert(insertIndex, matchingProcessor);
                            }

                            matchingProcessor.LogEntries.Add(logEntryViewModel);
                        }
                        break;

                    case DataProcessingServiceExecutorType.Task:
                        var matchingTask = Tasks.SingleOrDefault(t => t.Details.Name == logEntryViewModel.ProcessorName);
                        if (matchingTask == null)
                        {
                            matchingTask = new TaskViewModel(new TaskDetails(logEntryViewModel.ProcessorName));
                            // Sort alphabetically
                            var insertIndex = Tasks.Count(task => task.Details.Name.CompareTo(matchingTask.Details.Name) <= 0);
                            Tasks.Insert(insertIndex, matchingTask);
                        }
                        matchingTask.LogEntries.Add(logEntryViewModel);
                        if (logEntry.Details is ExecutionSummaryLogEntryDetails &&
                            (!matchingTask.LastExecutionTime.HasValue || matchingTask.LastExecutionTime < logEntry.Timestamp))
                        {
                            matchingTask.LastExecutionTime = logEntry.Timestamp;
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }));
        }
예제 #2
0
 public static string Get(ErrorLogMessages code, params string[] values)
 {
     return(string.Format(EnumUtils.GetEnumMemberValue(code), values));
 }