public DataObject.Zone Get(int Id) { DataObject.Zone dataObjectZone = null; using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "Exec [Configuration].[GetActiveZone] {0}"; using (SqlCommand command = new SqlCommand(string.Format(query, Id), connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { dataObjectZone = new DataObject.Zone(); dataObjectZone.Id = int.Parse(reader.GetValue(0).ToString()); dataObjectZone.Name = reader.GetValue(1).ToString(); dataObjectZone.DateAdded = Convert.ToDateTime(reader.GetValue(2).ToString()); dataObjectZone.IsActive = Convert.ToBoolean(reader.GetValue(3).ToString()); } } } } return dataObjectZone; }
public DataObject.Zone Get(int Id) { DataObject.Zone dataObjectZone = null; using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "Exec [Configuration].[GetActiveZone] {0}"; using (SqlCommand command = new SqlCommand(string.Format(query, Id), connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { dataObjectZone = new DataObject.Zone(); dataObjectZone.Id = int.Parse(reader.GetValue(0).ToString()); dataObjectZone.Name = reader.GetValue(1).ToString(); dataObjectZone.DateAdded = Convert.ToDateTime(reader.GetValue(2).ToString()); dataObjectZone.IsActive = Convert.ToBoolean(reader.GetValue(3).ToString()); } } } } return(dataObjectZone); }
public List <DataObject.Zone> List() { List <DataObject.Zone> zoneList = new List <DataObject.Zone>(); using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "Exec [Configuration].[ListActiveZone]"; using (SqlCommand command = new SqlCommand(query, connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DataObject.Zone dataObjectZone = new DataObject.Zone(); dataObjectZone.Id = int.Parse(reader.GetValue(0).ToString()); dataObjectZone.Name = reader.GetValue(1).ToString(); dataObjectZone.DateAdded = Convert.ToDateTime(reader.GetValue(2).ToString()); dataObjectZone.IsActive = Convert.ToBoolean(reader.GetValue(3).ToString()); zoneList.Add(dataObjectZone); } } } } return(zoneList); }
public bool EntireLoadShed(int zoneId, int status) { bool hasShedAll = false; List <lfa.pmgmt.data.DTO.BusinessRule.Load> loadList = new List <data.DTO.BusinessRule.Load>(); lfa.pmgmt.data.DAO.BusinessRule.Load loadDAO = new data.DAO.BusinessRule.Load(); loadDAO.ConnectionString = _connectionString; loadList = loadDAO.List(); if (loadList.Count > 0) { List <lfa.pmgmt.data.DTO.Configuration.Zone> zones = new List <data.DTO.Configuration.Zone>(); lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone(); zoneDAO.ConnectionString = _connectionString; lfa.pmgmt.data.DTO.Configuration.Zone zone = zoneDAO.Get(zoneId); List <lfa.pmgmt.data.DTO.Configuration.Unit> units = new List <data.DTO.Configuration.Unit>(); lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit(); unitDAO.ConnectionString = _connectionString; units = unitDAO.List(zone.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Unit unit in units) { List <lfa.pmgmt.data.DTO.Configuration.Device> devices = new List <data.DTO.Configuration.Device>(); lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device(); deviceDAO.ConnectionString = _connectionString; devices = deviceDAO.List(unit.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Device device in devices) { SwitchDeviceOnOff(status, device.Id, device.Id_Unit); UpdateDeviceStatus(device.Id, status); } } hasShedAll = true; } return(hasShedAll); }
public List<DataObject.Zone> List() { List<DataObject.Zone> zoneList = new List<DataObject.Zone>(); using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); string query = "Exec [Configuration].[ListActiveZone]"; using (SqlCommand command = new SqlCommand(query, connection)) { SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { DataObject.Zone dataObjectZone = new DataObject.Zone(); dataObjectZone.Id = int.Parse(reader.GetValue(0).ToString()); dataObjectZone.Name = reader.GetValue(1).ToString(); dataObjectZone.DateAdded = Convert.ToDateTime(reader.GetValue(2).ToString()); dataObjectZone.IsActive = Convert.ToBoolean(reader.GetValue(3).ToString()); zoneList.Add(dataObjectZone); } } } } return zoneList; }