Ejemplo n.º 1
0
        private String prepareXmlData(MarkerLabel marker)
        {
            XmlNode newElement;
            XmlDocument markersXml = new XmlDocument();
            //string TimeStamp = DateTime.Now.TimeOfDay.ToString().Substring(0, 12);
            string TimeStamp = DateTime.Now.ToString();
            BoundingBox bb = componentFinder.ObjectBoundingBoxes[marker.ID];

            newElement = markersXml.CreateNode(XmlNodeType.Element, "marker", "");

            // Attributes
            XmlAttribute x1 = markersXml.CreateAttribute("x1");
            x1.InnerText = bb.x1.ToString();
            XmlAttribute x2 = markersXml.CreateAttribute("x2");
            x2.InnerText = bb.x2.ToString();
            XmlAttribute y1 = markersXml.CreateAttribute("y1");
            y1.InnerText = bb.y1.ToString();
            XmlAttribute y2 = markersXml.CreateAttribute("y2");
            y2.InnerText = bb.y2.ToString();

            XmlAttribute code = markersXml.CreateAttribute("code");
            code.InnerText = marker.Code;

            XmlAttribute timestamp = markersXml.CreateAttribute("timestamp");
            timestamp.InnerText = TimeStamp;

            newElement.Attributes.Append(timestamp);
            newElement.Attributes.Append(code);
            newElement.Attributes.Append(x1);
            newElement.Attributes.Append(y1);
            newElement.Attributes.Append(x2);
            newElement.Attributes.Append(y2);
            return newElement.OuterXml;
        }
Ejemplo n.º 2
0
 private String prepareJsonData(MarkerLabel marker)
 {
     JsonMarker jsonMarker = new JsonMarker();
     DateTime currentDateTime = DateTime.Now;
     StringBuilder timestamp = new StringBuilder(currentDateTime.Date.ToString("yyyy-MM-dd"));
     timestamp.Append(" ");
     timestamp.Append(currentDateTime.TimeOfDay.ToString().Substring(0, 12));
     jsonMarker.timestamp = timestamp.ToString();
     BoundingBox bb = componentFinder.ObjectBoundingBoxes[marker.ID];
     jsonMarker.x1 = bb.x1;
     jsonMarker.x2 = bb.x2;
     jsonMarker.y1 = bb.y1;
     jsonMarker.y2 = bb.y2;
     jsonMarker.code = marker.Code;
     StringBuilder json = new StringBuilder();
     return json.AppendLine(JsonConvert.SerializeObject(jsonMarker)).ToString();
 }