Ejemplo n.º 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtZoneName.Text))
            {
                Exception ex = new Exception("Validation Exception : Please provide a new zone name!");
                HandleException(ex);
            }
            else
            {
                try
                {
                    lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
                    zoneDAO.ConnectionString = _connectionString;
                    zoneDAO.Insert(txtZoneName.Text, DateTime.Now);

                    HandleInformationMesssage("Data successfully saved! Please refresh the form data!");

                    this.Close();
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
            }
        }
Ejemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtZoneName.Text))
            {
                Exception ex = new Exception("Validation Exception : Please provide a new zone name!");
                HandleException(ex);
            }
            else
            {

                try
                {
                    lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
                    zoneDAO.ConnectionString = _connectionString;
                    zoneDAO.Insert(txtZoneName.Text, DateTime.Now);

                    HandleInformationMesssage("Data successfully saved! Please refresh the form data!");

                    this.Close();
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
            }
        }
Ejemplo n.º 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (_loadComplete)
            {
                switch (_currentModule)
                {
                case "Rules":

                    if (grdMain.SelectedRows.Count == 0)
                    {
                        Exception ex = new Exception("Please selected a ruleset to delete!");
                        HandleException(ex);
                    }
                    else
                    {
                        DeleteRuleset();
                    }
                    break;

                case "LoadShed":
                    HandleInformationMesssage("Load shedding data can not be deleted! Data is only for control purposes!");
                    break;

                case "Configuration":
                    try
                    {
                        int selectedZoneId = int.Parse(grdMain.SelectedRows[0].Cells[0].Value.ToString());

                        lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
                        zoneDAO.ConnectionString = _connectionString;
                        zoneDAO.Delete(selectedZoneId);

                        HandleInformationMesssage("Data successfully deleted! Please refresh the data!");
                    }
                    catch (Exception ex)
                    {
                        HandleException(ex);
                    }
                    break;

                case "Schedule":
                    try
                    {
                        int selectedScheduleId = int.Parse(grdMain.SelectedRows[0].Cells[0].Value.ToString());

                        lfa.pmgmt.data.DAO.Schedule.Schedule scheduleDAO = new data.DAO.Schedule.Schedule();
                        scheduleDAO.ConnectionString = _connectionString;
                        scheduleDAO.Delete(selectedScheduleId);

                        HandleInformationMesssage("Data successfully deleted! Please refresh the data!");
                    }
                    catch (Exception ex)
                    {
                        HandleException(ex);
                    }
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        public bool EntireLoadShed()
        {
            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)
            {
                int current = loadList[0].CurrentLoad;
                int maxLoad = loadList[0].MaximumLoad;

                if (current >= maxLoad)
                {
                    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;
                    zones = zoneDAO.List();

                    foreach (lfa.pmgmt.data.DTO.Configuration.Zone zone in zones)
                    {
                        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(2, device.Id, device.Id_Unit);

                                UpdateDeviceStatus(device.Id, 2);
                            }
                        }
                    }

                    hasShedAll = true;
                }
            }

            return(hasShedAll);
        }
Ejemplo n.º 5
0
        public bool EntireLoadShed()
        {
            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)
            {
                int current = loadList[0].CurrentLoad;
                int maxLoad = loadList[0].MaximumLoad;

                if (current >= maxLoad)
                {
                    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;
                    zones = zoneDAO.List();

                    foreach (lfa.pmgmt.data.DTO.Configuration.Zone zone in zones)
                    {
                        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(2, device.Id, device.Id_Unit);

                                UpdateDeviceStatus(device.Id, 2);
                            }
                        }
                    }

                    hasShedAll = true;
                }
            }

            return hasShedAll;
        }
Ejemplo n.º 6
0
        private void BindRuleData()
        {
            dataGridView1.DataSource = null;

            lfa.pmgmt.data.DAO.BusinessRule.Rule ruleDAO = new data.DAO.BusinessRule.Rule();
            ruleDAO.ConnectionString = _connectionString;

            List <lfa.pmgmt.data.DTO.BusinessRule.Rule> rules = new List <data.DTO.BusinessRule.Rule>();

            rules = ruleDAO.List(_ruleId);

            dataGridView1.Rows.Clear();
            dataGridView1.DataSource = null;

            dataGridView1.DataSource = rules;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                string deviceOnOff = "Off";
                string rule        = row.Cells[1].Value.ToString();
                string result      = row.Cells[2].Value.ToString();

                string[] ruleArray = rule.Split(".".ToCharArray());
                int      unitId    = int.Parse(ruleArray[0].ToString());
                string   comparer  = ruleArray[2].ToString();
                string   value     = ruleArray[3].ToString();

                string[] resultArray = result.Split(".".ToCharArray());
                int      deviceId    = int.Parse(resultArray[1].ToString());
                int      status      = int.Parse(resultArray[2].ToString());

                if (status == 1)
                {
                    deviceOnOff = "On";
                }

                lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
                zoneDAO.ConnectionString = _connectionString;

                lfa.pmgmt.data.DTO.Configuration.Zone zoneItem = zoneDAO.Get(unitId);

                string zoneName = zoneItem.Name;

                row.Cells[1].Value = "If " + zoneName + " load is " + comparer + " " + value + " Then";
                row.Cells[2].Value = "Switch " + deviceOnOff;
                row.Cells[3].Value = row.Cells[3].Value;
            }

            dataGridView1.Columns[1].Width = 180;
            dataGridView1.Columns[2].Width = 150;
        }
Ejemplo n.º 7
0
 private void BulkUpdateZones()
 {
     if (grdMain.Rows.Count > 0)
     {
         foreach (DataGridViewRow grdMainRow in grdMain.Rows)
         {
             lfa.pmgmt.data.DAO.Configuration.Zone zoneDOA = new data.DAO.Configuration.Zone();
             zoneDOA.ConnectionString = _connectionString;
             zoneDOA.Update(int.Parse(grdMainRow.Cells[0].Value.ToString()), grdMainRow.Cells[1].Value.ToString());
             zoneDOA.EnableDisable(int.Parse(grdMainRow.Cells[0].Value.ToString()),
                                   Convert.ToBoolean(grdMainRow.Cells[3].Value.ToString()));
         }
     }
 }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        private void Frm_Manage_Log_Load_1(object sender, EventArgs e)
        {
            _connectionString = GetConnectionString();

            lfa.pmgmt.data.DAO.Configuration.Zone zoneDOA = new data.DAO.Configuration.Zone();
            zoneDOA.ConnectionString = _connectionString;
            List <lfa.pmgmt.data.DTO.Configuration.Zone> zoneList = zoneDOA.List();

            foreach (lfa.pmgmt.data.DTO.Configuration.Zone zone in zoneList)
            {
                ComboItem item = new ComboItem();
                item.Id   = zone.Id;
                item.Name = zone.Name;

                comboBox1.Items.Add(item);
            }
        }
Ejemplo n.º 10
0
        private void BindZonesComboBox()
        {
            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;

            zones = zoneDAO.List();

            foreach (lfa.pmgmt.data.DTO.Configuration.Zone zone in zones)
            {
                ComboItem item = new ComboItem();
                item.Id   = zone.Id;
                item.Name = zone.Name;

                comboBox1.Items.Add(item);
            }
        }
Ejemplo n.º 11
0
        private void BindConfigurationData()
        {
            _loadComplete = false;

            lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
            zoneDAO.ConnectionString = _connectionString;

            List <lfa.pmgmt.data.DTO.Configuration.Zone> zoneList = zoneDAO.List();

            btnGrdMainHeader.Text = "Zones";
            grdMain.DataSource    = zoneList;

            btnGrdChildOneHeader.Text = "Units";

            btnGrdChildTwoHeader.Text = "Devices";

            _loadComplete = true;
        }
Ejemplo n.º 12
0
        private void BindRuleData()
        {
            dataGridView1.DataSource = null;

            lfa.pmgmt.data.DAO.BusinessRule.Rule ruleDAO = new data.DAO.BusinessRule.Rule();
            ruleDAO.ConnectionString = _connectionString;

            List<lfa.pmgmt.data.DTO.BusinessRule.Rule> rules = new List<data.DTO.BusinessRule.Rule>();
            rules = ruleDAO.List(_ruleId);

            dataGridView1.Rows.Clear();
            dataGridView1.DataSource = null;

            dataGridView1.DataSource = rules;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                string deviceOnOff = "Off";
                string rule = row.Cells[1].Value.ToString();
                string result = row.Cells[2].Value.ToString();

                string[] ruleArray = rule.Split(".".ToCharArray());
                int unitId = int.Parse(ruleArray[0].ToString());
                string comparer = ruleArray[2].ToString();
                string value = ruleArray[3].ToString();

                string[] resultArray = result.Split(".".ToCharArray());
                int deviceId = int.Parse(resultArray[1].ToString());
                int status = int.Parse(resultArray[2].ToString());

                if(status == 1)
                {
                    deviceOnOff = "On";
                }

                lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
                zoneDAO.ConnectionString = _connectionString;

                lfa.pmgmt.data.DTO.Configuration.Zone zoneItem = zoneDAO.Get(unitId);

                string zoneName = zoneItem.Name;

                row.Cells[1].Value = "If " + zoneName + " load is " + comparer + " " + value + " Then";
                row.Cells[2].Value = "Switch " + deviceOnOff;
                row.Cells[3].Value = row.Cells[3].Value;
            }

            dataGridView1.Columns[1].Width = 180;
            dataGridView1.Columns[2].Width = 150;
        }
Ejemplo n.º 13
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            int status = 2;

            if (string.IsNullOrEmpty(textBox1.Text))
            {
                Exception ex = new Exception("Validation Exception : Please provide a load value!");
                HandleException(ex);
            }
            else
            {
                ComboItem zone = comboBox1.SelectedItem as ComboItem;

                string comparer = comboBox4.SelectedItem.ToString();
                string deviceOnOff = comboBox5.SelectedItem.ToString();

                switch (comparer)
                {
                    case "Smaller Then Equal":
                        comparer = "<";
                        break;
                    case "Bigger Then Equal":
                        comparer = ">=";
                        break;
                    case "Smaller Then":
                        comparer = "<";
                        break;
                    case "Bigger Then":
                        comparer = ">";
                        break;
                    case "Equal":
                        comparer = "==";
                        break;
                }

                if (deviceOnOff == "Switch On")
                {
                    status = 1;
                }

                string condition = zone.Id + ".1." + comparer + "." + textBox1.Text;

                string result = zone.Id + ".1." + status.ToString();

                lfa.pmgmt.data.DAO.BusinessRule.Rule ruleDAO = new data.DAO.BusinessRule.Rule();
                ruleDAO.ConnectionString = _connectionString;
                ruleDAO.Insert(_ruleId, condition, result);

                int ruleId = ruleDAO.GetLastInsertedRuleId();

                //if (!comboBox2.SelectedItem.ToString().ToLower().Equals("none"))
                //{
                    lfa.pmgmt.data.DAO.BusinessRule.RuleSet rulesetDAO = new data.DAO.BusinessRule.RuleSet();
                    rulesetDAO.ConnectionString = _connectionString;
                    rulesetDAO.InsertPriority(_ruleId, ruleId, comboBox2.SelectedItem.ToString());
                //}

                List<lfa.pmgmt.data.DTO.BusinessRule.Rule> rules = new List<data.DTO.BusinessRule.Rule>();
                rules = ruleDAO.List(_ruleId);

                dataGridView1.DataSource = null;

                dataGridView1.DataSource = rules;

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    string sdeviceOnOff = "Off";
                    string rule = row.Cells[1].Value.ToString();
                    string sresult = row.Cells[2].Value.ToString();

                    string[] ruleArray = rule.Split(".".ToCharArray());
                    int unitId = int.Parse(ruleArray[0].ToString());
                    string scomparer = ruleArray[2].ToString();
                    string value = ruleArray[3].ToString();

                    string[] resultArray = sresult.Split(".".ToCharArray());
                    int deviceId = int.Parse(resultArray[1].ToString());
                    int sstatus = int.Parse(resultArray[2].ToString());

                    if (sstatus == 1)
                    {
                        sdeviceOnOff = "On";
                    }

                    lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
                    zoneDAO.ConnectionString = _connectionString;

                    lfa.pmgmt.data.DTO.Configuration.Zone zoneItem = zoneDAO.Get(unitId);

                    string zoneName = zoneItem.Name;

                    row.Cells[1].Value = "If " + zoneName + " load is " + scomparer + " " + value + " Then";
                    row.Cells[2].Value = "Switch " + sdeviceOnOff;
                }

                dataGridView1.Columns[1].Width = 180;
                dataGridView1.Columns[2].Width = 150;
            }
        }
Ejemplo n.º 14
0
        private void BindZonesComboBox()
        {
            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;

            zones = zoneDAO.List();

            foreach (lfa.pmgmt.data.DTO.Configuration.Zone zone in zones)
            {
                ComboItem item = new ComboItem();
                item.Id = zone.Id;
                item.Name = zone.Name;

                comboBox1.Items.Add(item);
            }
        }
Ejemplo n.º 15
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            int status = 2;

            if (string.IsNullOrEmpty(textBox1.Text))
            {
                Exception ex = new Exception("Validation Exception : Please provide a load value!");
                HandleException(ex);
            }
            else
            {
                ComboItem zone = comboBox1.SelectedItem as ComboItem;

                string comparer    = comboBox4.SelectedItem.ToString();
                string deviceOnOff = comboBox5.SelectedItem.ToString();

                switch (comparer)
                {
                case "Smaller Then Equal":
                    comparer = "<";
                    break;

                case "Bigger Then Equal":
                    comparer = ">=";
                    break;

                case "Smaller Then":
                    comparer = "<";
                    break;

                case "Bigger Then":
                    comparer = ">";
                    break;

                case "Equal":
                    comparer = "==";
                    break;
                }

                if (deviceOnOff == "Switch On")
                {
                    status = 1;
                }

                string condition = zone.Id + ".1." + comparer + "." + textBox1.Text;

                string result = zone.Id + ".1." + status.ToString();

                lfa.pmgmt.data.DAO.BusinessRule.Rule ruleDAO = new data.DAO.BusinessRule.Rule();
                ruleDAO.ConnectionString = _connectionString;
                ruleDAO.Insert(_ruleId, condition, result);

                int ruleId = ruleDAO.GetLastInsertedRuleId();

                //if (!comboBox2.SelectedItem.ToString().ToLower().Equals("none"))
                //{
                lfa.pmgmt.data.DAO.BusinessRule.RuleSet rulesetDAO = new data.DAO.BusinessRule.RuleSet();
                rulesetDAO.ConnectionString = _connectionString;
                rulesetDAO.InsertPriority(_ruleId, ruleId, comboBox2.SelectedItem.ToString());
                //}

                List <lfa.pmgmt.data.DTO.BusinessRule.Rule> rules = new List <data.DTO.BusinessRule.Rule>();
                rules = ruleDAO.List(_ruleId);

                dataGridView1.DataSource = null;

                dataGridView1.DataSource = rules;

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    string sdeviceOnOff = "Off";
                    string rule         = row.Cells[1].Value.ToString();
                    string sresult      = row.Cells[2].Value.ToString();

                    string[] ruleArray = rule.Split(".".ToCharArray());
                    int      unitId    = int.Parse(ruleArray[0].ToString());
                    string   scomparer = ruleArray[2].ToString();
                    string   value     = ruleArray[3].ToString();

                    string[] resultArray = sresult.Split(".".ToCharArray());
                    int      deviceId    = int.Parse(resultArray[1].ToString());
                    int      sstatus     = int.Parse(resultArray[2].ToString());

                    if (sstatus == 1)
                    {
                        sdeviceOnOff = "On";
                    }

                    lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
                    zoneDAO.ConnectionString = _connectionString;

                    lfa.pmgmt.data.DTO.Configuration.Zone zoneItem = zoneDAO.Get(unitId);

                    string zoneName = zoneItem.Name;

                    row.Cells[1].Value = "If " + zoneName + " load is " + scomparer + " " + value + " Then";
                    row.Cells[2].Value = "Switch " + sdeviceOnOff;
                }

                dataGridView1.Columns[1].Width = 180;
                dataGridView1.Columns[2].Width = 150;
            }
        }
Ejemplo n.º 16
0
        private void Frm_Manage_Log_Load_1(object sender, EventArgs e)
        {
            _connectionString = GetConnectionString();

            lfa.pmgmt.data.DAO.Configuration.Zone zoneDOA = new data.DAO.Configuration.Zone();
            zoneDOA.ConnectionString = _connectionString;
            List<lfa.pmgmt.data.DTO.Configuration.Zone> zoneList = zoneDOA.List();

            foreach (lfa.pmgmt.data.DTO.Configuration.Zone zone in zoneList)
            {
                ComboItem item = new ComboItem();
                item.Id = zone.Id;
                item.Name = zone.Name;

                comboBox1.Items.Add(item);
            }
        }
Ejemplo n.º 17
0
        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;
        }
Ejemplo n.º 18
0
 private void BulkUpdateZones()
 {
     if (grdMain.Rows.Count > 0)
     {
         foreach (DataGridViewRow grdMainRow in grdMain.Rows)
         {
             lfa.pmgmt.data.DAO.Configuration.Zone zoneDOA = new data.DAO.Configuration.Zone();
             zoneDOA.ConnectionString = _connectionString;
             zoneDOA.Update(int.Parse(grdMainRow.Cells[0].Value.ToString()), grdMainRow.Cells[1].Value.ToString());
             zoneDOA.EnableDisable(int.Parse(grdMainRow.Cells[0].Value.ToString()),
                                   Convert.ToBoolean(grdMainRow.Cells[3].Value.ToString()));
         }
     }
 }
Ejemplo n.º 19
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (_loadComplete)
            {
                switch (_currentModule)
                {
                    case "Rules":

                        if (grdMain.SelectedRows.Count == 0)
                        {
                            Exception ex = new Exception("Please selected a ruleset to delete!");
                            HandleException(ex);
                        }
                        else
                        {
                            DeleteRuleset();
                        }
                        break;
                    case "LoadShed":
                        HandleInformationMesssage("Load shedding data can not be deleted! Data is only for control purposes!");
                       break;
                    case "Configuration":
                       try
                       {
                           int selectedZoneId = int.Parse(grdMain.SelectedRows[0].Cells[0].Value.ToString());

                           lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
                           zoneDAO.ConnectionString = _connectionString;
                           zoneDAO.Delete(selectedZoneId);

                           HandleInformationMesssage("Data successfully deleted! Please refresh the data!");
                       }
                       catch (Exception ex)
                       {
                           HandleException(ex);
                       }
                        break;
                    case "Schedule":
                        try
                        {
                            int selectedScheduleId = int.Parse(grdMain.SelectedRows[0].Cells[0].Value.ToString());

                            lfa.pmgmt.data.DAO.Schedule.Schedule scheduleDAO = new data.DAO.Schedule.Schedule();
                            scheduleDAO.ConnectionString = _connectionString;
                            scheduleDAO.Delete(selectedScheduleId);

                            HandleInformationMesssage("Data successfully deleted! Please refresh the data!");
                        }
                        catch (Exception ex)
                        {
                            HandleException(ex);
                        }
                        break;
                }
            }
        }
Ejemplo n.º 20
0
        private void BindLoadShedData()
        {
            _loadComplete = false;

            lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
            zoneDAO.ConnectionString = _connectionString;

            List<lfa.pmgmt.data.DTO.Configuration.Zone> zoneList = zoneDAO.List();

            btnGrdMainHeader.Text = "Zones";
            grdMain.DataSource = zoneList;

            btnGrdChildOneHeader.Text = "Units";

            btnGrdChildTwoHeader.Text = "Devices";

            _loadComplete = true;
        }