public static BorderEventsRec JsonToBorderEventsRec(string txt) { try { var retval = new BorderEventsRec(); var jHotspotEvents = JObject.Parse(txt); // Parse out BORDER Events foreach (var jRec in jHotspotEvents["line_events"]) { var rec = new BorderEvent(); rec.Border = IntToId((int)jRec["line"]["id"]); rec.Direction = IntToDirection((int)jRec["direction"]); rec.Object = IntToId((int)jRec["object"]["id"]); rec.Time = DoubleToTime((double)jRec["time"]); retval.BorderEvents.Add(rec); } return(retval); } catch (Exception ex) { var newEx = new Exception("Invalid JSON data format returned for 'State'.", ex); throw newEx; } }
public HttpStatusCode GetBorderEvents(DateTime start, DateTime end, out BorderEventsRec rec) { ValidateIsBound(); var client = new MoveRestClient(_device, _port, _username, _password); string body = null; var responseCode = client.GetBorderEvents(start, end, out body); string msg = (body.Length > _DATA_PREVIEW_SIZE) ? body.Substring(0, _DATA_PREVIEW_SIZE) : body; Trace.TraceInformation("\nRaw JSON data: {0}", msg); rec = JsonHelper.JsonToBorderEventsRec(body); return(responseCode); }