Example #1
0
        public static HotspotEventsRec JsonToHotspotEventsRec(string txt)
        {
            try
            {
                var retval         = new HotspotEventsRec();
                var jHotspotEvents = JObject.Parse(txt);

                foreach (var jRec in jHotspotEvents["area_events"])
                {
                    var rec = new HotspotEvent();
                    rec.Hotspot = IntToId((int)jRec["area"]["id"]);
                    rec.Object  = IntToId((int)jRec["object"]["id"]);
                    rec.Time    = DoubleToTime((double)jRec["time"]);
                    rec.Type    = IntToType((int)jRec["type"]);
                    retval.HotspotEvents.Add(rec);
                }

                return(retval);
            }
            catch (Exception ex)
            {
                var newEx = new Exception("Invalid JSON data format returned for 'State'.", ex);
                throw newEx;
            }
        }
Example #2
0
        public HttpStatusCode GetHotspotEvents(DateTime start, DateTime end, out HotspotEventsRec rec)
        {
            ValidateIsBound();

            var    client       = new MoveRestClient(_device, _port, _username, _password);
            string body         = null;
            var    responseCode = client.GetHotspotEvents(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.JsonToHotspotEventsRec(body);
            return(responseCode);
        }