Exemplo n.º 1
0
        public static Thermostats ConvertFromDT(DataTable dt)
        {
            Thermostats result = new Thermostats();

            foreach (DataRow row in dt.Rows)
            {
                result.Add(Thermostat.GetThermostat(row));
            }
            return(result);
        }
Exemplo n.º 2
0
        public Thermostats Sort(string column, bool desc)
        {
            var         sortedList = desc ? this.OrderByDescending(x => x.GetPropertyValue(column)) : this.OrderBy(x => x.GetPropertyValue(column));
            Thermostats result     = new Thermostats();

            foreach (var i in sortedList)
            {
                result.Add((Thermostat)i);
            }
            return(result);
        }
Exemplo n.º 3
0
        public static Thermostat LoadThermostat(int locationId, string ipAddress)
        {
            Thermostats thermostats = Thermostats.LoadThermostats("SELECT * FROM Thermostats WHERE LocationId=@LocationId AND IpAddress=@IpAddress", CommandType.Text, new SqlParameter[] { new SqlParameter("@LocationId", locationId), new SqlParameter("@IpAddress", ipAddress) });

            if (thermostats.Count == 0)
            {
                return(null);
            }
            else
            {
                return(thermostats[0]);
            }
        }
Exemplo n.º 4
0
        public static Thermostat LoadByKeyName(string keyName)
        {
            Thermostats thermostats = Thermostats.LoadThermostats("SELECT * FROM Thermostats WHERE KeyName=@KeyName", CommandType.Text, new SqlParameter[] { new SqlParameter("@KeyName", keyName) });

            if (thermostats.Count == 0)
            {
                return(null);
            }
            else
            {
                return(thermostats[0]);
            }
        }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        ThermostatMonitorLib.Locations locations = ThermostatMonitorLib.Locations.LoadLocationsByUserId(AppUser.Current.UserData.Id);
        foreach (ThermostatMonitorLib.Location location in locations)
        {
            sb.Append("<tr><td><a href=\"location.aspx?id=" + location.Id.ToString() + "\">" + location.Name.ToString() + "</a></td><td> - API Key: <b>" + location.ApiKey + "</b></td></tr>");
            ThermostatMonitorLib.Thermostats thermostats = ThermostatMonitorLib.Thermostats.LoadThermostatsByLocationId(location.Id);
            foreach (ThermostatMonitorLib.Thermostat thermostat in thermostats)
            {
                sb.Append("<tr><td></td><td> - <a href=\"thermostat.aspx?id=" + thermostat.Id.ToString() + "\">" + thermostat.DisplayName + "</a> [<a href=\"editthermostat.aspx?id=" + thermostat.Id.ToString() + "\">Edit</a>]</td></tr>");
            }
        }
        ThermostatsLit.Text = sb.ToString();
    }
Exemplo n.º 6
0
    private void LoadSettings(ThermostatMonitorLib.Location location)
    {
        //Build array list of thermostats
        ThermostatMonitorLib.Thermostats thermostats = ThermostatMonitorLib.Thermostats.LoadThermostatsByLocationId(location.Id);
        ArrayList al = new ArrayList();

        foreach (ThermostatMonitorLib.Thermostat thermostat in thermostats)
        {
            System.Collections.Hashtable hash = new System.Collections.Hashtable();
            hash.Add("name", thermostat.DisplayName);
            hash.Add("ipAddress", thermostat.IpAddress);
            hash.Add("brand", thermostat.Brand);
            al.Add(hash);
        }

        Hashtable result = new Hashtable();

        result.Add("thermostats", al);
        result.Add("zipCode", location.ZipCode);

        Response.Write(ThermostatMonitorLib.JSON.JsonEncode(result));
        Response.End();
    }
Exemplo n.º 7
0
 public static Thermostats LoadThermostatsByLocationId(System.Int32 locationId)
 {
     return(Thermostats.LoadThermostats("LoadThermostatsByLocationId", CommandType.StoredProcedure, new SqlParameter[] { new SqlParameter("@LocationId", locationId) }));
 }
Exemplo n.º 8
0
 public static Thermostats LoadAllThermostats()
 {
     return(Thermostats.LoadThermostats("LoadThermostatsAll", CommandType.StoredProcedure, null));
 }
Exemplo n.º 9
0
 public static Thermostats LoadThermostats(string sql, System.Data.CommandType commandType, System.Data.SqlClient.SqlParameter[] parameters)
 {
     return(Thermostats.ConvertFromDT(Utils.ExecuteQuery(sql, commandType, parameters)));
 }
Exemplo n.º 10
0
 public static Thermostats LoadThermostatsByLocationId(int locationId)
 {
     return(Thermostats.LoadThermostats("thermostats_load_by_location_id", CommandType.StoredProcedure, new MySqlParameter[] { new MySqlParameter("@location_id", locationId) }));
 }