/// <inheritdoc /> public void ReceiveOneWireXmlPost(Stream postData) { XDocument xDoc; IEnumerable<XElement> xElements; long javascriptUtcTimestamp; decimal temperatureCelsius; string romID; string thermometerXmlNodeName; // flot plots time data using javascript timestamps in UTC // so we timestamp on the server using javascript timestamps javascriptUtcTimestamp = UtcJavascriptTimestampHelper.Now; try { // convert POST data into an xDocument xDoc = ConvertXmlPostDataToXDocument(postData); // get the descendent thermometers thermometerXmlNodeName = WebConfigurationManager.AppSettings["thermometer_xml_node_name"]; xElements = xDoc.Descendants(thermometerXmlNodeName); // for each child device foreach (XElement xElement in xElements) { // get its romID romID = null; if (xElement.Elements("ROMId").FirstOrDefault() != null) { romID = xElement.Elements("ROMId").FirstOrDefault().Value.ToString(); } // get its temperature temperatureCelsius = Decimal.MinValue; if (xElement.Elements("Temperature").FirstOrDefault() != null) { temperatureCelsius = Convert.ToDecimal(xElement.Elements("Temperature").FirstOrDefault().Value.ToString()); } if (TemperatureHasExceededThreshold(temperatureCelsius, romID)) { Emailer emailer = new Emailer(); emailer.SendWarningEmail(romID, temperatureCelsius, javascriptUtcTimestamp); } // get the data store FlotDataTable flotDataTable = new FlotDataTable(romID); // delete old data from the data store flotDataTable.DeleteStaleData(); // append a new data point to the data store flotDataTable.AppendDataPoint(javascriptUtcTimestamp, temperatureCelsius); // save changes to the FlotDataTable flotDataTable.Save(); FlotDataSet flotDataSet; flotDataSet = new FlotDataSet(false, false); flotDataSet.RecompleTheIndividualDataTableFilesIntoOneLargeDataSetFileIfEnoughTimeHasPassed(true); } } catch (Exception ex) { } }
/// <inheritdoc /> public FlotDataSet[] SendFlotDataSet() { FlotDataSet[] flotDataSets = new FlotDataSet[] { new FlotDataSet(true, true), new FlotDataSet(true, false) }; // do high resolution iff browser supports canvas. return flotDataSets; }