public XDocument FormatPollResponse(string queryName, QueryEventResponse events) { var epcisQueryNamespace = XNamespace.Get("urn:epcglobal:epcis-query:xsd:1"); var formatted = _eventFormatter.Format(events); return(new XDocument(new XDeclaration("1.0", "UTF-8", "yes"), new XElement(epcisQueryNamespace + "QueryResult", new XAttribute(XNamespace.Xmlns + "a", epcisQueryNamespace), new XElement("queryName", queryName), new XElement("resultBody", new XElement("EventList", formatted.ToArray <object>())) ) )); }
/// <summary> /// ConsoleLogger类对象写入一条事件信息。 /// </summary> /// <param name="eventType">日志事件类型。</param> /// <param name="eventText">日志事件记录文本。</param> /// <param name="lineFeed">回车换行标志。</param> /// <returns> /// 日志写入成功与否标志。 /// </returns> public virtual bool WriteEvent(LogEventType eventType, string eventText, bool lineFeed) { ConsoleColor color = Console.ForegroundColor; // ConsoleColor.Gray switch (eventType) { case LogEventType.Critical: case LogEventType.Error: Console.ForegroundColor = ConsoleColor.Red; break; case LogEventType.Warning: Console.ForegroundColor = ConsoleColor.Yellow; break; case LogEventType.Notice: Console.ForegroundColor = ConsoleColor.Green; break; } Console.Write(m_formatter.Format(eventType, eventText, lineFeed)); Console.ForegroundColor = color; return(true); }
/// <summary> /// Produces a string-ified version of the event that uses the text logger format. /// </summary> /// <param name="formatter">A previously created EventStringFormatter which will be overwritten with the contents /// of the entry</param> /// <returns>A string</returns> public string ToString(IEventFormatter formatter) { if (formatter == null) { throw new ArgumentNullException("formatter"); } return(formatter.Format(this)); }
public virtual QueryResults Poll(PollRequest request) { var queryParameters = request.parameters?.Select(x => new QueryParam { Name = x.Name, Values = x.Values }); var results = _queryPerformer.ExecutePollQuery(request.QueryName, queryParameters); var formattedResponse = _eventFormatter.Format(results); return(new QueryResults { QueryName = request.QueryName, EventList = new EventList { Elements = formattedResponse } }); }
public string FormatSubscriptionResponse(Subscription subscription, QueryEventResponse response) { var root = new XElement(XName.Get("EPCISQueryDocument", EpcisQueryNamespace)); root.Add(new XAttribute("creationDate", SystemContext.Clock.Now)); root.Add(new XAttribute("schemaVersion", "1.0")); var body = new XElement("EPCISBody"); var queryResults = new XElement(XName.Get("QueryResults", EpcisQueryNamespace)); queryResults.Add(new XElement("queryName", subscription.QueryName)); queryResults.Add(new XElement("subscriptionID", subscription.Id)); var eventList = new XElement("resultsBody", new XElement("EventList", _eventFormatter.Format(response))); queryResults.Add(eventList); body.Add(queryResults); root.Add(body); return(root.ToString(SaveOptions.DisableFormatting)); }
public string ToString(IEventFormatter formatter) { return formatter.Format(this); }
public void Accept(IEventFormatter formatter) => formatter.Format(this);
/// <summary> /// AbstratFileLogger类对象写入一条事件信息。 /// </summary> /// <param name="eventType">日志事件类型。</param> /// <param name="eventText">日志事件记录文本。</param> /// <param name="lineFeed">回车换行标志。</param> /// <returns> /// 日志写入成功与否标志。 /// </returns> public virtual bool WriteEvent(LogEventType eventType, string eventText, bool lineFeed) { Debug.Assert(m_encoding != null); byte[] bytes = m_encoding.GetBytes(m_formatter.Format(eventType, eventText, lineFeed)); return(do_Write(bytes, 0, bytes.Length)); }