예제 #1
0
        private Task HandleMessage(Message message, CancellationToken cancellationToken)
        {
            try
            {
                LogVerbose?.Invoke(this, $"New message {message.MessageId}");
                var jObject    = JObject.Parse(Encoding.UTF8.GetString(message.Body));
                var definition = new BuildDefinition
                                 (
                    Guid.Parse(jObject["resourceContainers"]["collection"].Value <string>("id")),
                    Guid.Parse(jObject["resourceContainers"]["project"].Value <string>("id")),
                    jObject["resource"]["definition"].Value <int>("id")
                                 );
                var status = ParseStatus(jObject["resource"].Value <string>("result"));

                _status.AddOrUpdate(definition, status, (buildDefinition, b) => status);

                var hasFailingBuild = _status.Any(d => !d.Value);
                PinponChanged?.Invoke(this, hasFailingBuild);
            }
            catch (Exception e)
            {
                LogError?.Invoke(this, e.ToString());
            }

            return(Task.CompletedTask);
        }
예제 #2
0
        public void LogCommand(LogVerbose mode)
        {
            _logVerbose = mode;

            if (mode != LogVerbose.Off)
            {
                _log.OnLog -= Log_OnLog;
                _log.OnLog += Log_OnLog;

                _logger.LogDebug("Log output is enabled");
            }
            else
            {
                _logs.Clear();
                _logger.LogDebug("Log output is disabled");

                _log.OnLog -= Log_OnLog;
            }
        }
예제 #3
0
 private static Level GetLevel(LogVerbose verbose)
 {
     if (verbose == LogVerbose.Debug)
     {
         return(Level.Debug);
     }
     else if (verbose == LogVerbose.Info)
     {
         return(Level.Info);
     }
     else if (verbose == LogVerbose.Error)
     {
         return(Level.Error);
     }
     else if (verbose == LogVerbose.Warn)
     {
         return(Level.Warn);
     }
     else
     {
         return(Level.Fatal);
     }
 }