GetHourlyStats() public method

public GetHourlyStats ( int timezoneOffset ) : DataTable
timezoneOffset int
return System.Data.DataTable
Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        thermostatId       = Convert.ToInt32(Request["thermostatId"]);
        TimezoneDifference = Convert.ToInt32(Request["TimezoneDifference"]);

        if (Request["startDate"] != null)
        {
            startDate = Convert.ToDateTime(Request["startDate"]).AddHours(TimezoneDifference);
        }
        if (Request["endDate"] != null)
        {
            endDate = Convert.ToDateTime(Request["endDate"]).AddDays(1).AddSeconds(-1).AddHours(TimezoneDifference);
        }

        if (Request["prevStartDate"] != null)
        {
            prevStartDate = Convert.ToDateTime(Request["prevStartDate"]).AddHours(TimezoneDifference);
        }
        if (Request["prevEndDate"] != null)
        {
            prevEndDate = Convert.ToDateTime(Request["prevEndDate"]).AddDays(1).AddSeconds(-1).AddHours(TimezoneDifference);
        }


        ThermostatMonitorLib.Snapshots snapshots = ThermostatMonitorLib.Snapshots.LoadRange(thermostatId, startDate, endDate);
        DataTable dt = snapshots.GetHourlyStats(TimezoneDifference);

        if (Request["prevStartDate"] != null)
        {
            AppendHistorical(dt);
        }

        Output(dt);
    }
Exemplo n.º 2
0
    private void AppendHistorical(DataTable outputDt)
    {
        includeHistorical = true;
        outputDt.Columns.Add("PrevCool", typeof(double));
        outputDt.Columns.Add("PrevHeat", typeof(double));

        ThermostatMonitorLib.Snapshots snapshots = ThermostatMonitorLib.Snapshots.LoadRange(thermostatId, prevStartDate, prevEndDate);
        DataTable dt = snapshots.GetHourlyStats(TimezoneDifference);

        foreach (DataRow row in dt.Rows)
        {
            int     hour        = Convert.ToInt32(row["Hour"]);
            double  cool        = Convert.ToDouble(row["Cool"]);
            double  heat        = Convert.ToDouble(row["Heat"]);
            DataRow existingRow = GetRowByHour(outputDt, hour);
            existingRow["PrevCool"] = cool;
            existingRow["PrevHeat"] = heat;
        }
    }