protected override void GetAttributes() { attrs.Clear(); attrs.Add("CityId", CityId.ToString()); attrs.Add("ProvinceId", ProvinceId.ToString()); attrs.Add("IndoorTemperature", IndoorTemperature.ToString()); attrs.Add("GraphScale", GraphScale.ToString()); attrs.Add("ActiveTab", ActiveTab.ToString()); attrs.Add("buildingwidth", BuildingOutlineWidth.ToString()); attrs.Add("blockscale", BlockScale.ToString()); attrs.Add("pipeLineScale", PipeLineScale.ToString()); attrs.Add("elecprice", ElecPrice.ToString()); attrs.Add("gasprice", GasPrice.ToString()); if (rasterImageID.IsNull == false) { attrs.Add("rasterImage", rasterImageID.Handle.ToString()); } }
/** * Primary Get method for getting a graph model. Chooses a query based on parameters. * @param sensor Enum for the sensor type (Electrical, NaturalGas, Water, OutsideTemperature) * @param start DateTime for the beginin of the time frame. (Greater than or equal) * @param end DateTime for the end of the time frame. (Less than or equal) * @param sensorData Enum for type of data returned (amount "runing total" or change "how much amount changes in time period") * @param pointScale Enum for scaling the amount of points returned. (All, Hour, Day, Week, Month or Year) * @return GraphPoints is a class that takes the parameter points and splits into to independent arrays. **/ public GraphPoints GetGraphPoints(DateTime end, int numTicks, SensorType sensorType, SensorData sensorData, GraphScale graphScale) { //incase numTicks was not set then set to default if (numTicks <= 0) { numTicks = DEFAULT_NUM_TICKS; } if (end > DateTime.Now) { end = DateTime.Now; } //holds the results for the context var points = Enumerable.Empty <GraphPoint>(); //get the context for the sensorType var context = getSenorRecordCollectionFromDb(sensorType); //check if a sensor was found if (context.Any()) { //check if sensor data was set to amount if (sensorData == SensorData.Amount) { //switch on different scales switch (graphScale) { case GraphScale.All: points = getGraphAmountAll(end, numTicks, context); break; case GraphScale.Hour: points = getGraphAmountHour(end, numTicks, context); break; case GraphScale.Day: points = getGraphAmountDay(end, numTicks, context); break; case GraphScale.Month: points = getGraphAmountMonth(end, numTicks, context); break; case GraphScale.Year: points = getGraphAmountYear(end, numTicks, context); break; } } //check for sensor is set to change else if (sensorData == SensorData.Change) { //switch on different scales switch (graphScale) { case GraphScale.All: points = getGraphChangeAll(end, numTicks, context); break; case GraphScale.Hour: points = getGraphChangeHour(end, numTicks, context); break; case GraphScale.Day: points = getGraphChangeDay(end, numTicks, context); break; case GraphScale.Month: points = getGraphChangeMonth(end, numTicks, context); break; case GraphScale.Year: points = getGraphChangeYear(end, numTicks, context); break; } } } //return a converted IEnumerable to a GraphPoint object return(convertEnumerableToGraphPoints(points)); }
//get a custom set of graph points from the parameters public JsonResult GetGraphPoints(DateTime end, int numTicks, SensorType sensor, SensorData dataType, GraphScale scale) { return(Json(_eodRepository.GetGraphPoints(end, numTicks, sensor, dataType, scale))); }