public Hotbox GetWriteableHotBoxData() { var hotboxxml = facadedal.GetDALHttpGateway().GetWriteableHotBoxXML(); Hotbox hotboxdata = facade.GetXMLLogic().XMLSerializeToHotbox(hotboxxml); return(hotboxdata); }
public void Get_Modules_From_HotBox_Test() { HttpResponseMessage response = CreateResponseMessage(); Hotbox hotboxdata = facade.GetXMLLogic().XMLSerializeToHotbox(response); List <Module> modules = facade.GetXMLLogic().GetModules(hotboxdata); Assert.AreEqual("S100", modules[0].Name); }
public void Retrieving_Values_From_HotBox_Test() { HttpResponseMessage response = CreateResponseMessage(); Hotbox hotboxdata = facade.GetXMLLogic().XMLSerializeToHotbox(response); List <HotBoxValues> hbvalues = facade.GetBEConverter().HotboxConverter(hotboxdata); Assert.AreEqual((double)1963848, hbvalues[0].Value); }
public Hotbox XMLSerializeToHotbox(HttpResponseMessage response) { try { XmlSerializer serializer = new XmlSerializer(typeof(Hotbox)); var serializedhotbox = serializer.Deserialize(response.Content.ReadAsStreamAsync().Result); Hotbox hotbox = (Hotbox)serializedhotbox; return(hotbox); } catch { return(null); } }
public void Serializes_XML_To_HotBox_Test() { HttpResponseMessage validresponse = CreateResponseMessage(); Hotbox validhotboxdata = facade.GetXMLLogic().XMLSerializeToHotbox(validresponse); // 71 is the CncAddress attribute value in the XMLString.txt file Assert.AreEqual(71, validhotboxdata.Site.CncAddress); // Returns null if response cannot be serialized HttpResponseMessage invalidresponse = CreateResponseMessage(); Hotbox invalidhotboxdata = facade.GetXMLLogic().XMLSerializeToHotbox(validresponse); Assert.AreEqual(null, invalidhotboxdata); }
// Returns true if the Post request succeeds public bool PostHotBoxValue(string modulename, string value) { value = value.Replace(",", "."); var hotboxxml = facadedal.GetDALHttpGateway().PostHotBoxValue(modulename, value); Hotbox hotboxdata = facade.GetXMLLogic().XMLSerializeToHotbox(hotboxxml); try{ if (hotboxdata != null && hotboxdata.Site.Lan.Device.ServiceResponse.Type == WRITE_OK_MESSAGE) { return(true); } else { return(false); } } catch { return(false); } }
// Values in the Params list are converted to a HotBoxValues List // for easier access in front-end implementation. public List <HotBoxValues> HotboxConverter(Hotbox hotbox) { if (hotbox == null) { return(null); } List <HotBoxValues> values = new List <HotBoxValues>(); foreach (Module item in facadebll.GetXMLLogic().GetModules(hotbox)) { values.Add(new HotBoxValues() { Module = item.Name, Label = item.Params[2].Value, // This parsing method was necessary to maintain the decimal points from the Value string Value = double.Parse(item.Params[0].Value, CultureInfo.InvariantCulture), Unit = item.Params[1].Value }); } return(values); }
// Returns the Module List<> of a HotBox object public List <DAL.HotboxXML.Module> GetModules(Hotbox hbdata) { return(hbdata == null ? null : hbdata.Site.Lan.Device.Modules); }