コード例 #1
0
ファイル: BuildLogFlow.cs プロジェクト: DevTeam/flow
        public bool ProcessMessage(IMessageProcessor processor, IBuildVisitor buildVisitor, IServiceMessage message)
        {
            var processed = false;

            switch (message.Name?.ToLowerInvariant())
            {
            case "message":
                var text = message.GetValue("text");
                if (text != null)
                {
                    var status = message.GetValue("status")?.ToUpperInvariant();
                    switch (status)
                    {
                    case "ERROR":
                        _log.Trace(() => new[] { new Text($"Add error {text}") });
                        buildVisitor.Visit(new BuildError(text));
                        break;

                    case "WARNING":
                        _log.Trace(() => new[] { new Text($"Add warning {text}") });
                        buildVisitor.Visit(new BuildWarning(text));
                        break;
                    }
                }

                var parseInternal = message.GetValue("tc:tags")?.ToLowerInvariant() == "tc:parseservicemessagesinside";
                if (!parseInternal || !processor.ProcessServiceMessages(text, buildVisitor))
                {
                    WriteLine(text);
                }

                processed = true;
                break;

            case "blockopened":
                var blockName = message.GetValue("name");
                _log.Trace(() => new [] { new Text($"Open block {blockName}") });
                WriteLine(blockName);
                _tabs++;
                _tabsString = new string(' ', _tabs *Text.Tab.Value.Length);
                processed   = true;
                break;

            case "blockclosed":
                _log.Trace(() => new[] { new Text("Close block") });
                _tabs--;
                _tabsString = new string(' ', _tabs *Text.Tab.Value.Length);
                processed   = true;
                break;
            }

            return(processed);
        }
            public override void AddServiceMessage(IServiceMessage serviceMessage)
            {
                if (serviceMessage.DefaultValue != null)
                {
                    base.AddServiceMessage(serviceMessage);
                    return;
                }

                if (serviceMessage.Name == "flowStarted")
                {
                    serviceMessage = new PatchedServiceMessage(serviceMessage)
                    {
                        { "parent", FlowToString(serviceMessage.GetValue("parent")) }
                    }
                }
                ;

                var flowId = serviceMessage.GetValue("flowId");

                if (flowId != null)
                {
                    serviceMessage = new PatchedServiceMessage(serviceMessage)
                    {
                        { "flowId", FlowToString(flowId) }
                    }
                }
                ;

                base.AddServiceMessage(serviceMessage);
            }
コード例 #3
0
        private static bool VerifyServiceMessage(TableRow row, IServiceMessage serviceMessage)
        {
            var messageNameRegex = new Regex(row[""]);

            if (!messageNameRegex.IsMatch(serviceMessage.Name))
            {
                return(false);
            }

            foreach (var key in row.Keys)
            {
                if (string.IsNullOrWhiteSpace(key))
                {
                    continue;
                }

                string rowValue;
                if (!row.TryGetValue(key, out rowValue))
                {
                    continue;
                }

                var serviceMessageValue = serviceMessage.GetValue(key) ?? "";
                var rowValueRegex       = new Regex(rowValue ?? "");
                if (!rowValueRegex.IsMatch(serviceMessageValue))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #4
0
            public Message(IServiceMessage message)
            {
                if (message == null)
                {
                    throw new ArgumentNullException("message");
                }

                Name = message.Name;

                FlowIdAttr = message.GetValue("flowId");
                IsNotEmpty(FlowIdAttr);

                NameAttr   = message.GetValue("name");
                ParentAttr = message.GetValue("parent");
                CaptureStandardOutputAttr = message.GetValue("captureStandardOutput");
                DurationAttr = message.GetValue("duration");
                OutAttr      = message.GetValue("duration");
                MessageAttr  = message.GetValue("message");
                DetailsAttr  = message.GetValue("details");
                TcTagsAttr   = message.GetValue("tc:tags");
            }
コード例 #5
0
        private static string CreateErrorMessage(TableRow row, IServiceMessage serviceMessage)
        {
            var rowInfo            = string.Join(", ", from key in row.Keys select $"{key} = {row[key]}");
            var serviceMessageInfo = string.Join(", ", from key in serviceMessage.Keys select $"{key} = {serviceMessage.GetValue(key)}");

            return($"Expected service message should has:\n{rowInfo}\nbut it has:\n{serviceMessageInfo}");
        }
コード例 #6
0
 /// <summary>
 /// Serializes service message
 /// </summary>
 /// <param name="serviceMessage">parser service message</param>
 /// <returns></returns>
 public string FormatMessage(IServiceMessage serviceMessage)
 {
     if (serviceMessage.DefaultValue != null)
     {
         return(FormatMessage(serviceMessage.Name, serviceMessage.DefaultValue));
     }
     return(FormatMessage(serviceMessage.Name, serviceMessage.Keys.Select(key => new ServiceMessageProperty(key, serviceMessage.GetValue(key) ?? ""))));
 }
コード例 #7
0
        /// <summary>
        /// Serializes service message
        /// </summary>
        /// <param name="serviceMessage">parser service message</param>
        /// <returns></returns>
        public string FormatMessage(IServiceMessage serviceMessage)
        {
            if (serviceMessage == null)
            {
                throw new ArgumentNullException(nameof(serviceMessage));
            }
            if (serviceMessage.DefaultValue != null)
            {
                return(FormatMessage(serviceMessage.Name, serviceMessage.DefaultValue));
            }

            return(FormatMessage(serviceMessage.Name, serviceMessage.Keys.Select(key => new ServiceMessageProperty(key, serviceMessage.GetValue(key) ?? ""))));
        }
コード例 #8
0
 public Message(IServiceMessage message)
 {
     if (message == null)
     {
         throw new ArgumentNullException(nameof(message));
     }
     Name       = message.Name;
     FlowIdAttr = message.GetValue("flowId") ?? string.Empty;
     NameAttr   = message.GetValue("name");
     ParentAttr = message.GetValue("parent");
     CaptureStandardOutputAttr = message.GetValue("captureStandardOutput");
     DurationAttr    = message.GetValue("duration");
     OutAttr         = message.GetValue("duration");
     MessageAttr     = message.GetValue("message");
     DetailsAttr     = message.GetValue("details");
     TcTagsAttr      = message.GetValue("tc:tags");
     IdentityAttr    = message.GetValue("identity");
     DescriptionAttr = message.GetValue("description");
     KeyAttr         = message.GetValue("key");
     ValueAttr       = message.GetValue("value");
 }