TimezoneDifference() public static method

public static TimezoneDifference ( int timezone, bool daylightSavings ) : int
timezone int
daylightSavings bool
return int
示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int      thermostatId = Convert.ToInt32(Request["ThermostatId"]);
        DateTime date         = Convert.ToDateTime(Request["date"]);

        ThermostatMonitorLib.Thermostat thermostat = ThermostatMonitorLib.Thermostat.LoadThermostat(thermostatId);
        ThermostatMonitorLib.Location   location   = ThermostatMonitorLib.Location.LoadLocation(thermostat.LocationId);
        if (location.UserId != AppUser.Current.UserData.Id)
        {
            Response.Redirect("/login.aspx");
        }

        TimezoneDifference = AppUser.TimezoneDifference(location.Timezone, location.DaylightSavings);

        ThermostatName.Text = thermostat.DisplayName;
        DateLit.Text        = date.ToString("ddd, MMMM d, yyyy");
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request["Id"]);

        ThermostatMonitorLib.Thermostat thermostat = ThermostatMonitorLib.Thermostat.LoadThermostat(id);
        ThermostatMonitorLib.Location   location   = ThermostatMonitorLib.Location.LoadLocation(thermostat.LocationId);
        if (location.UserId != AppUser.Current.UserData.Id)
        {
            Response.Redirect("/login.aspx");
        }


        TimezoneDifference = AppUser.TimezoneDifference(location.Timezone, location.DaylightSavings);



        ThermostatName.Text = thermostat.DisplayName + " (" + thermostat.IpAddress + ")";
        //ThermostatMonitorLib.Cycle currentCycle=ThermostatMonitorLib.Cycle.LoadOpenCycle(thermostat.Id);

        ThermostatMonitorLib.OutsideCondition currentCondition   = ThermostatMonitorLib.OutsideCondition.LoadCurrentCondition(location.Id);
        ThermostatMonitorLib.Temperature      currentTemperature = ThermostatMonitorLib.Temperature.LoadCurrentTemperature(thermostat.Id);
        CurrentConditionsLit.Text = "Currently: ";
        //if (currentCycle == null) CurrentConditionsLit.Text += "Off"; else CurrentConditionsLit.Text += currentCycle.CycleType;
        if (currentTemperature != null && currentCondition != null)
        {
            CurrentConditionsLit.Text += " - Inside: " + currentTemperature.Degrees.ToString() + "°";
            CurrentConditionsLit.Text += " - Outside: " + currentCondition.Degrees.ToString() + "°";
        }
        else
        {
            CurrentConditionsLit.Text = "No data has been gathered for this thermostat.";
        }



        ThermostatMonitorLib.Cycles cycles = ThermostatMonitorLib.Cycles.LoadRange(id, DateTime.Now.AddDays(-1).AddHours(AppUser.TimezoneDifference(location.Timezone, location.DaylightSavings)), DateTime.Now.AddHours(AppUser.TimezoneDifference(location.Timezone, location.DaylightSavings)));


        DataTable dt = ThermostatMonitorLib.Cycles.LoadFullSummary(thermostat.LocationId, thermostat.Id, DateTime.Today.AddDays(-7), DateTime.Today, AppUser.TimezoneDifference(location.Timezone, location.DaylightSavings));

        HistorySummary1.Populate(dt, thermostat);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int thermostatId = Convert.ToInt32(Request["thermostatId"]);

        thermostat = ThermostatMonitorLib.Thermostat.LoadThermostat(thermostatId);
        ThermostatMonitorLib.Location location = ThermostatMonitorLib.Location.LoadLocation(thermostat.LocationId);

        timezoneDifference = AppUser.TimezoneDifference(location.Timezone, location.DaylightSavings);


        if (!IsPostBack)
        {
            ThermostatName.Text     = thermostat.DisplayName;
            StartDateText.Text      = startDate.ToString("MM/dd/yyyy");
            EndDateText.Text        = endDate.ToString("MM/dd/yyyy");
            PrevStartDateText.Text  = prevStartDate.ToString("MM/dd/yyyy");
            PrevEndDateText.Text    = prevEndDate.ToString("MM/dd/yyyy");
            IncludePrevious.Checked = true;
        }
    }
示例#4
0
 private void OutputCycles(ThermostatMonitorLib.Thermostat thermostat, ThermostatMonitorLib.Location location)
 {
     ThermostatMonitorLib.Cycles cycles = ThermostatMonitorLib.Cycles.LoadRange(thermostat.Id, new DateTime(2000, 1, 1), DateTime.Now);
     OutputCSV(cycles.GetCSV(thermostat.ACKilowatts, thermostat.FanKilowatts, thermostat.HeatBtuPerHour, AppUser.TimezoneDifference(location.Timezone, location.DaylightSavings)), "cycles.csv");
 }
示例#5
0
    private void OutputSummary(ThermostatMonitorLib.Thermostat thermostat, ThermostatMonitorLib.Location location)
    {
        DataTable dt       = ThermostatMonitorLib.Cycles.LoadFullSummary(thermostat.LocationId, thermostat.Id, new DateTime(2000, 1, 1), DateTime.Today, AppUser.TimezoneDifference(location.Timezone, location.DaylightSavings));
        DataTable resultDt = new DataTable();

        foreach (DataColumn dc in dt.Columns)
        {
            resultDt.Columns.Add(dc.ColumnName.Replace("Seconds", "Minutes"), dc.DataType);
        }
        foreach (DataRow row in dt.Rows)
        {
            DataRow newRow = resultDt.NewRow();
            foreach (DataColumn dc in dt.Columns)
            {
                if (dc.ColumnName.Contains("Seconds"))
                {
                    double minutes = 0;
                    try { minutes = System.Math.Round(Convert.ToDouble(row[dc.ColumnName]) / 60, 2); }
                    catch { }
                    newRow[dc.ColumnName.Replace("Seconds", "Minutes")] = minutes;
                }
                else
                {
                    newRow[dc.ColumnName] = row[dc.ColumnName];
                }
            }
            resultDt.Rows.Add(newRow);
        }

        OutputCSV(ThermostatMonitorLib.Utils.DataTableToCSV(resultDt), "summary.csv");
    }