public static HotspotDefinitionList JsonToHotspotList(string txt) { try { var retval = new HotspotDefinitionList(); var jBorderList = JArray.Parse(txt); // Parse out HOTSPOT Definitions foreach (var jRec in jBorderList) { var rec = new HotspotDefinition(); rec.Active = StringToBool((string)jRec["active"]); rec.Id = (int)jRec["id"]; rec.MaskColor = JsonToMaskColor(jRec["mask_color"]); rec.Name = (string)jRec["name"]; retval.HotspotDefinitions.Add(rec); } return(retval); } catch (Exception ex) { var newEx = new Exception("Invalid JSON data format returned for 'State'.", ex); throw newEx; } }
public HttpStatusCode GetListOfHotspots(out HotspotDefinitionList rec) { // To allow legacy code to work with the new SVG Configuration now used by MOVE, we'll map // the SVG structures into the legacy structures. // todo: CONTROL needs to upgrade to using the new SVG calls and data structures. AreaDefinitionList areasList; LineDefinitionList ignored; rec = new HotspotDefinitionList(); var responseCode = GetSVGLayoutInfo(out areasList, out ignored); // Map SVG structure "AreaDefinitionList" into legacy "HotspotDefinitionList" foreach (var area in areasList.AreaDefinitions) { var hotspot = new HotspotDefinition(); hotspot.Active = area.Active; hotspot.Id = area.Id; hotspot.MaskColor = GetSystemDrawingColorFromHexString(area.Color); hotspot.Name = area.Name; rec.HotspotDefinitions.Add(hotspot); } return(responseCode); }
public HttpStatusCode GetListOfHotspotsDeprecated(out HotspotDefinitionList rec) { // This method used the old MOVE API REST calls that are now deprecated. Call, instead "GetListOfHotspots". ValidateIsBound(); var client = new MoveRestClient(_device, _port, _username, _password); string body = null; var responseCode = client.GetListOfHotspots(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.JsonToHotspotList(body); return(responseCode); }