Example #1
0
        private void Frm_AddNew_Unit_Load_1(object sender, EventArgs e)
        {
            _connectionString = GetConnectionString();

            lfa.pmgmt.data.DAO.Schedule.Unit scheduleDAO = new data.DAO.Schedule.Unit();
            scheduleDAO.ConnectionString = _connectionString;
            List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleList = scheduleDAO.ListConfigurationUnits();

            foreach (lfa.pmgmt.data.DTO.Schedule.Unit scheduleItem in scheduleList)
            {
                ComboItem item = new ComboItem();
                item.Id   = scheduleItem.Id;
                item.Name = scheduleItem.Name;

                comboBox1.Items.Add(item);
            }
        }
        private void Frm_AddNew_Unit_Load_1(object sender, EventArgs e)
        {
            _connectionString = GetConnectionString();

            lfa.pmgmt.data.DAO.Schedule.Unit scheduleDAO = new data.DAO.Schedule.Unit();
            scheduleDAO.ConnectionString = _connectionString;
            List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleList = scheduleDAO.ListConfigurationUnits();

            foreach (lfa.pmgmt.data.DTO.Schedule.Unit scheduleItem in scheduleList)
            {
                ComboItem item = new ComboItem();
                item.Id = scheduleItem.Id;
                item.Name = scheduleItem.Name;

                comboBox1.Items.Add(item);
            }
        }
Example #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            switch (_currentModule)
            {
            case "LoadShed":
                HandleInformationMesssage("Load shedding data can not be deleted! Data is only for control purposes!");
                break;

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

                    lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit();
                    unitDAO.ConnectionString = _connectionString;
                    unitDAO.Delete(selectedUnitId);

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

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

                    lfa.pmgmt.data.DAO.Schedule.Unit s_unitDAO = new data.DAO.Schedule.Unit();
                    s_unitDAO.ConnectionString = _connectionString;
                    s_unitDAO.Delete(s_selectedUnitId, selectedSchedule);

                    HandleInformationMesssage("Data successfully deleted! Please refresh the data!");
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
                break;
            }
        }
Example #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                ComboItem item         = comboBox1.SelectedItem as ComboItem;
                int       selectedItem = item.Id;
                lfa.pmgmt.data.DAO.Schedule.Unit DAO = new data.DAO.Schedule.Unit();
                DAO.ConnectionString = _connectionString;
                DAO.Insert(selectedItem, scheduleId);

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

                this.Close();
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                ComboItem item = comboBox1.SelectedItem as ComboItem;
                int selectedItem = item.Id;
                lfa.pmgmt.data.DAO.Schedule.Unit DAO = new data.DAO.Schedule.Unit();
                DAO.ConnectionString = _connectionString;
                DAO.Insert(selectedItem,scheduleId);

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

                this.Close();
             }
             catch (Exception ex)
             {
                HandleException(ex);
             }
        }
Example #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            switch (_currentModule)
            {
                case "LoadShed":
                    HandleInformationMesssage("Load shedding data can not be deleted! Data is only for control purposes!");
                    break;
                case "Configuration":
                    try
                    {
                        int selectedUnitId = int.Parse(grdChildOne.SelectedRows[0].Cells[0].Value.ToString());

                        lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit();
                        unitDAO.ConnectionString = _connectionString;
                        unitDAO.Delete(selectedUnitId);

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

                        lfa.pmgmt.data.DAO.Schedule.Unit s_unitDAO = new data.DAO.Schedule.Unit();
                        s_unitDAO.ConnectionString = _connectionString;
                        s_unitDAO.Delete(s_selectedUnitId, selectedSchedule);

                        HandleInformationMesssage("Data successfully deleted! Please refresh the data!");
                    }
                    catch (Exception ex)
                    {
                        HandleException(ex);
                    }
                    break;
            }
        }
Example #7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                ComboItem selectedItem = comboBox1.SelectedItem as ComboItem;
                int       zoneId       = selectedItem.Id;

                bool status = false;

                lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit();
                unitDAO.ConnectionString = _connectionString;

                List <lfa.pmgmt.data.DTO.Configuration.Unit> units = unitDAO.List(zoneId);

                foreach (lfa.pmgmt.data.DTO.Configuration.Unit unit in units)
                {
                    lfa.pmgmt.data.DAO.Schedule.Unit sunitDAO = new data.DAO.Schedule.Unit();
                    sunitDAO.ConnectionString = _connectionString;
                    sunitDAO.Insert(unit.Id, _scheduleId);

                    lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device();
                    deviceDAO.ConnectionString = _connectionString;

                    List <lfa.pmgmt.data.DTO.Configuration.Device> devices = deviceDAO.List(unit.Id);

                    foreach (lfa.pmgmt.data.DTO.Configuration.Device device in devices)
                    {
                        lfa.pmgmt.data.DAO.Schedule.Device sdeviceDAO = new data.DAO.Schedule.Device();
                        sdeviceDAO.ConnectionString = _connectionString;
                        sdeviceDAO.Insert(device.Id, unit.Id, status, _scheduleId);
                    }

                    lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule();
                    dao.ConnectionString = _connectionString;
                    dao.LinkZone(_scheduleId, zoneId);
                }

                bool switch1On = checkBox1.Checked;
                bool switch2On = checkBox2.Checked;
                bool switch3On = checkBox3.Checked;
                bool switch4On = checkBox4.Checked;
                bool switch5On = checkBox5.Checked;
                bool switch6On = checkBox6.Checked;
                bool switch7On = checkBox7.Checked;
                bool switch8On = checkBox8.Checked;

                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO2 = new data.DAO.Schedule.Unit();
                unitDAO2.ConnectionString = _connectionString;
                List <lfa.pmgmt.data.DTO.Schedule.Unit> unitList = unitDAO2.ListWithZone(_scheduleId);

                foreach (lfa.pmgmt.data.DTO.Schedule.Unit unit in unitList)
                {
                    if (unit.Id_Zone == zoneId)
                    {
                        lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
                        deviceDAO.ConnectionString = _connectionString;

                        List <lfa.pmgmt.data.DTO.Schedule.Device> deviceList = deviceDAO.ListWithDeviceId(unit.Id, _scheduleId);

                        foreach (lfa.pmgmt.data.DTO.Schedule.Device device in deviceList)
                        {
                            lfa.pmgmt.data.DAO.Configuration.Device configDeviceDAO = new data.DAO.Configuration.Device();
                            configDeviceDAO.ConnectionString = _connectionString;
                            lfa.pmgmt.data.DTO.Configuration.Device configDevice = configDeviceDAO.Get(device.DeviceId);

                            switch (configDevice.Switch)
                            {
                            case "Switch 1":
                                deviceDAO.Update(device.Id, 0, 0, switch1On);
                                break;

                            case "Switch 2":
                                deviceDAO.Update(device.Id, 0, 0, switch2On);
                                break;

                            case "Switch 3":
                                deviceDAO.Update(device.Id, 0, 0, switch3On);
                                break;

                            case "Switch 4":
                                deviceDAO.Update(device.Id, 0, 0, switch4On);
                                break;

                            case "Switch 5":
                                deviceDAO.Update(device.Id, 0, 0, switch5On);
                                break;

                            case "Switch 6":
                                deviceDAO.Update(device.Id, 0, 0, switch6On);
                                break;

                            case "Switch 7":
                                deviceDAO.Update(device.Id, 0, 0, switch7On);
                                break;

                            case "Switch 8":
                                deviceDAO.Update(device.Id, 0, 0, switch8On);
                                break;
                            }
                        }
                    }
                }

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

                this.Close();
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
Example #8
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboItem selectedItem = comboBox1.SelectedItem as ComboItem;
            int       zoneId       = selectedItem.Id;

            lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
            unitDAO.ConnectionString = _connectionString;
            List <lfa.pmgmt.data.DTO.Schedule.Unit> unitList = unitDAO.ListWithZone(_scheduleId);

            lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
            deviceDAO.ConnectionString = _connectionString;

            foreach (lfa.pmgmt.data.DTO.Schedule.Unit unit in unitList)
            {
                if (unit.Id_Zone == zoneId)
                {
                    List <lfa.pmgmt.data.DTO.Schedule.Device> deviceList = deviceDAO.ListWithDeviceId(unit.Id, _scheduleId);

                    foreach (lfa.pmgmt.data.DTO.Schedule.Device device in deviceList)
                    {
                        lfa.pmgmt.data.DAO.Configuration.Device configDeviceDAO = new data.DAO.Configuration.Device();
                        configDeviceDAO.ConnectionString = _connectionString;

                        lfa.pmgmt.data.DTO.Configuration.Device configDevice = configDeviceDAO.Get(device.DeviceId);

                        switch (configDevice.Switch)
                        {
                        case "Switch 1":
                            checkBox1.Checked = device.DeviceOn;
                            break;

                        case "Switch 2":
                            checkBox2.Checked = device.DeviceOn;
                            break;

                        case "Switch 3":
                            checkBox3.Checked = device.DeviceOn;
                            break;

                        case "Switch 4":
                            checkBox4.Checked = device.DeviceOn;
                            break;

                        case "Switch 5":
                            checkBox5.Checked = device.DeviceOn;
                            break;

                        case "Switch 6":
                            checkBox6.Checked = device.DeviceOn;
                            break;

                        case "Switch 7":
                            checkBox7.Checked = device.DeviceOn;
                            break;

                        case "Switch 8":
                            checkBox8.Checked = device.DeviceOn;
                            break;
                        }
                    }
                }
            }
        }
Example #9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                ComboItem selectedItem = comboBox1.SelectedItem as ComboItem;
                int zoneId = selectedItem.Id;

                bool status = false;

                lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit();
                unitDAO.ConnectionString = _connectionString;

                List<lfa.pmgmt.data.DTO.Configuration.Unit> units = unitDAO.List(zoneId);

                foreach (lfa.pmgmt.data.DTO.Configuration.Unit unit in units)
                {
                    lfa.pmgmt.data.DAO.Schedule.Unit sunitDAO = new data.DAO.Schedule.Unit();
                    sunitDAO.ConnectionString = _connectionString;
                    sunitDAO.Insert(unit.Id, _scheduleId);

                    lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device();
                    deviceDAO.ConnectionString = _connectionString;

                    List<lfa.pmgmt.data.DTO.Configuration.Device> devices = deviceDAO.List(unit.Id);

                    foreach (lfa.pmgmt.data.DTO.Configuration.Device device in devices)
                    {
                        lfa.pmgmt.data.DAO.Schedule.Device sdeviceDAO = new data.DAO.Schedule.Device();
                        sdeviceDAO.ConnectionString = _connectionString;
                        sdeviceDAO.Insert(device.Id, unit.Id, status, _scheduleId);
                    }

                    lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule();
                    dao.ConnectionString = _connectionString;
                    dao.LinkZone(_scheduleId, zoneId);
                }

                bool switch1On = checkBox1.Checked;
                bool switch2On = checkBox2.Checked;
                bool switch3On = checkBox3.Checked;
                bool switch4On = checkBox4.Checked;
                bool switch5On = checkBox5.Checked;
                bool switch6On = checkBox6.Checked;
                bool switch7On = checkBox7.Checked;
                bool switch8On = checkBox8.Checked;

                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO2 = new data.DAO.Schedule.Unit();
                unitDAO2.ConnectionString = _connectionString;
                List<lfa.pmgmt.data.DTO.Schedule.Unit> unitList = unitDAO2.ListWithZone(_scheduleId);

                foreach (lfa.pmgmt.data.DTO.Schedule.Unit unit in unitList)
                {
                    if (unit.Id_Zone == zoneId)
                    {
                        lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
                        deviceDAO.ConnectionString = _connectionString;

                        List<lfa.pmgmt.data.DTO.Schedule.Device> deviceList = deviceDAO.ListWithDeviceId(unit.Id, _scheduleId);

                        foreach (lfa.pmgmt.data.DTO.Schedule.Device device in deviceList)
                        {
                            lfa.pmgmt.data.DAO.Configuration.Device configDeviceDAO = new data.DAO.Configuration.Device();
                            configDeviceDAO.ConnectionString = _connectionString;
                            lfa.pmgmt.data.DTO.Configuration.Device configDevice = configDeviceDAO.Get(device.DeviceId);

                            switch (configDevice.Switch)
                            {
                                case "Switch 1":
                                    deviceDAO.Update(device.Id, 0, 0, switch1On);
                                    break;
                                case "Switch 2":
                                    deviceDAO.Update(device.Id, 0, 0, switch2On);
                                    break;
                                case "Switch 3":
                                    deviceDAO.Update(device.Id, 0, 0, switch3On);
                                    break;
                                case "Switch 4":
                                    deviceDAO.Update(device.Id, 0, 0, switch4On);
                                    break;
                                case "Switch 5":
                                    deviceDAO.Update(device.Id, 0, 0, switch5On);
                                    break;
                                case "Switch 6":
                                    deviceDAO.Update(device.Id, 0, 0, switch6On);
                                    break;
                                case "Switch 7":
                                    deviceDAO.Update(device.Id, 0, 0, switch7On);
                                    break;
                                case "Switch 8":
                                    deviceDAO.Update(device.Id, 0, 0, switch8On);
                                    break;
                            }
                        }
                    }
                }

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

                this.Close();
            }
            catch (Exception ex)
            {
               HandleException(ex);
            }
        }
Example #10
0
        public void ExecuteSchedule(List <lfa.pmgmt.data.DTO.Schedule.Schedule> scheduleList,
                                    List <int> ruleEnabledUnits, int defaultPort)
        {
            _executed     = new List <string>();
            _defaultUnits = new Dictionary <string, List <lfa.pmgmt.data.DTO.Schedule.Unit> >();

            foreach (lfa.pmgmt.data.DTO.Schedule.Schedule schedule in scheduleList)
            {
                if (schedule.IsActive)
                {
                    string scheduleStartTime = schedule.StartTime;
                    string scheduleEndTime   = schedule.EndTime;

                    DateTime currentTime   = DateTime.Now;
                    DateTime scheduleStart = Convert.ToDateTime(scheduleStartTime);
                    DateTime scheduleEnd   = Convert.ToDateTime(scheduleEndTime);

                    if (currentTime <= scheduleEnd)
                    {
                        if (currentTime >= scheduleStart)
                        {
                            lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                            DAO.ConnectionString = _connectionString;

                            string priorityValue = DAO.GetPriority(schedule.Id);

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                priorityValue = "None";
                            }

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                GetScheduleUnitDetailsForId(scheduleUnits, schedule.Id, ruleEnabledUnits, defaultPort);
                            }
                            else
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                if (ExecutePriority(_connectionString, priorityValue))
                                {
                                    GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                    _executed.Add("true");
                                }

                                #region OBSOLETE
                                //if (ExecutePriority(_connectionString))
                                //{
                                //    lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                //    unitDAO.ConnectionString = _connectionString;
                                //    List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                //    if (priorityValue.ToLower().Equals("low"))
                                //    {
                                //        GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);
                                //    }

                                //    if (priorityValue.ToLower().Equals("medium"))
                                //    {
                                //        GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                //        lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule();

                                //        dao.ConnectionString = _connectionString;
                                //        int zoneid = dao.GetLinkedZone(schedule.Id);

                                //        List<int> scheduleIds = dao.ListPrioritySchedules(zoneid, "Low");

                                //        foreach (int id in scheduleIds)
                                //        {
                                //            List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                //            GetScheduleUnitDetails(i_scheduleUnits, id, defaultPort);
                                //        }

                                //    }

                                //    if (priorityValue.ToLower().Equals("high"))
                                //    {
                                //        GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                //        lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule();

                                //        dao.ConnectionString = _connectionString;
                                //        int zoneid = dao.GetLinkedZone(schedule.Id);

                                //        List<int> scheduleIds = dao.ListPrioritySchedules(zoneid, "Medium");

                                //        foreach (int id in scheduleIds)
                                //        {
                                //            List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                //            GetScheduleUnitDetails(i_scheduleUnits, id, defaultPort);
                                //        }

                                //        List<int> lowscheduleIds = dao.ListPrioritySchedules(zoneid, "Low");

                                //        foreach (int id in lowscheduleIds)
                                //        {
                                //            List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                //            GetScheduleUnitDetails(i_scheduleUnits,id, defaultPort);
                                //        }
                                //    }
                                //}
                                #endregion
                            }
                        }
                    }

                    if (scheduleEndTime == "00:00" && scheduleStartTime == "00:00")
                    {
                        lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                        DAO.ConnectionString = _connectionString;

                        string priorityValue = DAO.GetPriority(schedule.Id);

                        if (string.IsNullOrEmpty(priorityValue))
                        {
                            priorityValue = "None";
                        }

                        if (string.IsNullOrEmpty(priorityValue))
                        {
                            lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                            unitDAO.ConnectionString = _connectionString;
                            List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                            GetScheduleUnitDetailsForId(scheduleUnits, schedule.Id, ruleEnabledUnits, defaultPort);
                        }
                        else
                        {
                            lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                            unitDAO.ConnectionString = _connectionString;
                            List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                            _defaultUnits.Add(schedule.Id.ToString(), scheduleUnits);

                            //if (ExecutePriority(_connectionString, priorityValue))
                            //{
                            //GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);
                            //}
                        }
                    }
                }
            }


            if (_defaultUnits.Count > 0)
            {
                if (_executed.Count <= 0)
                {
                    foreach (string id in _defaultUnits.Keys)
                    {
                        List <lfa.pmgmt.data.DTO.Schedule.Unit> units = _defaultUnits[id];

                        GetScheduleUnitDetails(units, int.Parse(id), defaultPort);
                    }
                }
            }

            _defaultUnits.Clear();
            _executed.Clear();
        }
Example #11
0
        public void Execute(int defaultPort)
        {
            try
            {
                Dictionary<string, string>  _switchStates = new Dictionary<string, string>();

                List<string> _executed = new List<string>();

                int ruleCount = 0;

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

                List<lfa.pmgmt.data.DTO.Schedule.Schedule> scheduleList = scheduleDAO.List();

                foreach (lfa.pmgmt.data.DTO.Schedule.Schedule schedule in scheduleList)
                {
                    if (schedule.IsActive)
                    {
                        string scheduleStartTime = schedule.StartTime;
                        string scheduleEndTime = schedule.EndTime;

                        DateTime currentTime = DateTime.Now;
                        DateTime scheduleStart = Convert.ToDateTime(scheduleStartTime);
                        DateTime scheduleEnd = Convert.ToDateTime(scheduleEndTime);

                        if (scheduleStart > scheduleEnd)
                        {
                            scheduleEnd = scheduleEnd.AddDays(1);
                        }

                        if (currentTime <= scheduleEnd)
                        {
                            if (currentTime >= scheduleStart)
                            {
                                lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                                DAO.ConnectionString = _connectionString;

                                string priorityValue = DAO.GetPriority(schedule.Id);

                                if (string.IsNullOrEmpty(priorityValue))
                                {
                                    int status = 0;
                                    lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                    unitDAO.ConnectionString = _connectionString;
                                    List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                    GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort, status);
                                }
                                else
                                {
                                    int status = 0;
                                    lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                    unitDAO.ConnectionString = _connectionString;
                                    List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                    if (ExecutePriority(_connectionString, priorityValue, out status, out ruleCount))
                                    {
                                        GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort, status);

                                        _executed.Add("true");
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                //File.AppendAllText(@"c:\smartpower\logerr2.txt", ex.ToString());
            }
        }
Example #12
0
        public void ExecuteSchedule(List<lfa.pmgmt.data.DTO.Schedule.Schedule> scheduleList, 
                                    List<int> ruleEnabledUnits, int defaultPort)
        {
            List<string> _executed = new List<string>();
            Dictionary<string, List<lfa.pmgmt.data.DTO.Schedule.Unit>> _defaultUnits = new Dictionary<string, List<lfa.pmgmt.data.DTO.Schedule.Unit>>();

            int status = 0;
            int ruleCount = 0;

            foreach (lfa.pmgmt.data.DTO.Schedule.Schedule schedule in scheduleList)
            {
                if (schedule.IsActive)
                {
                    string scheduleStartTime = schedule.StartTime;
                    string scheduleEndTime = schedule.EndTime;

                    DateTime currentTime = DateTime.Now;
                    DateTime scheduleStart = Convert.ToDateTime(scheduleStartTime);
                    DateTime scheduleEnd = Convert.ToDateTime(scheduleEndTime);

                    if (scheduleStart > scheduleEnd)
                    {
                        scheduleEnd = scheduleEnd.AddDays(1);
                    }

                    if (currentTime.TimeOfDay <= scheduleEnd.TimeOfDay)
                    {
                        if (currentTime.TimeOfDay >= scheduleStart.TimeOfDay)
                        {
                            lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                            DAO.ConnectionString = _connectionString;

                            string priorityValue = DAO.GetPriority(schedule.Id);

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                priorityValue = "None";
                            }

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                GetScheduleUnitDetailsForId(scheduleUnits, schedule.Id, ruleEnabledUnits, defaultPort, status);
                            }
                            else
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                if (ExecutePriority(_connectionString, priorityValue, out status,out ruleCount))
                                {
                                   //File.AppendAllText(@"c:\smartpower\log.txt", priorityValue + " " + System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\r\n");

                                    GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort, status);

                                    _executed.Add("true");
                                }
                                else
                                {
                                    if (ruleCount <= 0)
                                    {
                                        status = 0;

                                        GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort, status);
                                    }

                                    _executed.Add("true");
                                }
                            }
                        }
                    }

                    if (scheduleEndTime == "00:00" && scheduleStartTime == "00:00")
                    {
                        lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                        DAO.ConnectionString = _connectionString;

                        string priorityValue = DAO.GetPriority(schedule.Id);

                        if (string.IsNullOrEmpty(priorityValue))
                        {
                            priorityValue = "None";
                        }

                        if (string.IsNullOrEmpty(priorityValue))
                        {
                            lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                            unitDAO.ConnectionString = _connectionString;
                            List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                            GetScheduleUnitDetailsForId(scheduleUnits, schedule.Id, ruleEnabledUnits, defaultPort,0);
                        }
                        else
                        {
                            lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                            unitDAO.ConnectionString = _connectionString;
                            List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                            _defaultUnits.Add(schedule.Id.ToString(), scheduleUnits);
                        }
                    }
                }
            }

            if (_defaultUnits.Count > 0)
            {
                if (_executed.Count <= 0)
                {
                    foreach (string id in _defaultUnits.Keys)
                    {
                        List<lfa.pmgmt.data.DTO.Schedule.Unit> units = _defaultUnits[id];

                        GetScheduleUnitDetails(units, int.Parse(id), defaultPort,0);
                    }
                }
            }

            _defaultUnits.Clear();
            _executed.Clear();
        }
Example #13
0
        public void Execute(int defaultPort)
        {
            _executed = new List<string>();

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

            List<lfa.pmgmt.data.DTO.Schedule.Schedule> scheduleList = scheduleDAO.List();

            foreach (lfa.pmgmt.data.DTO.Schedule.Schedule schedule in scheduleList)
            {
                if (schedule.IsActive)
                {
                    string scheduleStartTime = schedule.StartTime;
                    string scheduleEndTime = schedule.EndTime;

                    DateTime currentTime = DateTime.Now;
                    DateTime scheduleStart = Convert.ToDateTime(scheduleStartTime);
                    DateTime scheduleEnd = Convert.ToDateTime(scheduleEndTime);

                    if (currentTime <= scheduleEnd)
                    {
                        if (currentTime >= scheduleStart)
                        {
                            lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                            DAO.ConnectionString = _connectionString;

                            string priorityValue = DAO.GetPriority(schedule.Id);

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);
                            }
                            else
                            {
                                    lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                    unitDAO.ConnectionString = _connectionString;
                                    List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                    if (ExecutePriority(_connectionString, priorityValue))
                                    {
                                        GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                        _executed.Add("true");
                                    }

                                #region OBSOLETE
                                //if (priorityValue.ToLower().Equals("low"))
                                    //{
                                    //    ExecutePriority(connectionString,priority)
                                    //    {
                                    //      GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);
                                    //    }
                                    //}

                                    //if (priorityValue.ToLower().Equals("medium"))
                                    //{
                                    //    GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                    //    lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule();

                                    //    dao.ConnectionString = _connectionString;
                                    //    int zoneid = dao.GetLinkedZone(schedule.Id);

                                    //    List<int> scheduleIds = dao.ListPrioritySchedules(zoneid, "Low");

                                    //    foreach (int id in scheduleIds)
                                    //    {
                                    //        List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                    //        GetScheduleUnitDetails(i_scheduleUnits, id, defaultPort);
                                    //    }

                                    //}

                                    //if (priorityValue.ToLower().Equals("high"))
                                    //{
                                    //    GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                    //    lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule();

                                    //    dao.ConnectionString = _connectionString;
                                    //    int zoneid = dao.GetLinkedZone(schedule.Id);

                                    //    List<int> scheduleIds = dao.ListPrioritySchedules(zoneid, "Medium");

                                    //    foreach (int id in scheduleIds)
                                    //    {
                                    //        List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                    //        GetScheduleUnitDetails(i_scheduleUnits, id, defaultPort);
                                    //    }

                                    //    List<int> lowscheduleIds = dao.ListPrioritySchedules(zoneid, "Low");

                                    //    foreach (int id in lowscheduleIds)
                                    //    {
                                    //        List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                    //        GetScheduleUnitDetails(i_scheduleUnits, id, defaultPort);
                                    //    }
                                //}
                                #endregion
                             }
                           }
                        }
                    }
               }
        }
Example #14
0
        public void ExecuteSchedule(List<lfa.pmgmt.data.DTO.Schedule.Schedule> scheduleList, 
                                    List<int> ruleEnabledUnits, int defaultPort)
        {
            _executed = new List<string>();
            _defaultUnits = new Dictionary<string, List<lfa.pmgmt.data.DTO.Schedule.Unit>>();

            foreach (lfa.pmgmt.data.DTO.Schedule.Schedule schedule in scheduleList)
            {
                if (schedule.IsActive)
                {
                    string scheduleStartTime = schedule.StartTime;
                    string scheduleEndTime = schedule.EndTime;

                    DateTime currentTime = DateTime.Now;
                    DateTime scheduleStart = Convert.ToDateTime(scheduleStartTime);
                    DateTime scheduleEnd = Convert.ToDateTime(scheduleEndTime);

                    if (currentTime <= scheduleEnd)
                    {
                        if (currentTime >= scheduleStart)
                        {
                            lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                            DAO.ConnectionString = _connectionString;

                            string priorityValue = DAO.GetPriority(schedule.Id);

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                priorityValue = "None";
                            }

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                GetScheduleUnitDetailsForId(scheduleUnits, schedule.Id, ruleEnabledUnits, defaultPort);
                            }
                            else
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                if (ExecutePriority(_connectionString, priorityValue))
                                {
                                    GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                    _executed.Add("true");
                                }

                                #region OBSOLETE
                                //if (ExecutePriority(_connectionString))
                                //{
                                //    lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                //    unitDAO.ConnectionString = _connectionString;
                                //    List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                //    if (priorityValue.ToLower().Equals("low"))
                                //    {
                                //        GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);
                                //    }

                                //    if (priorityValue.ToLower().Equals("medium"))
                                //    {
                                //        GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                //        lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule();

                                //        dao.ConnectionString = _connectionString;
                                //        int zoneid = dao.GetLinkedZone(schedule.Id);

                                //        List<int> scheduleIds = dao.ListPrioritySchedules(zoneid, "Low");

                                //        foreach (int id in scheduleIds)
                                //        {
                                //            List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                //            GetScheduleUnitDetails(i_scheduleUnits, id, defaultPort);
                                //        }

                                //    }

                                //    if (priorityValue.ToLower().Equals("high"))
                                //    {
                                //        GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                //        lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule();

                                //        dao.ConnectionString = _connectionString;
                                //        int zoneid = dao.GetLinkedZone(schedule.Id);

                                //        List<int> scheduleIds = dao.ListPrioritySchedules(zoneid, "Medium");

                                //        foreach (int id in scheduleIds)
                                //        {
                                //            List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                //            GetScheduleUnitDetails(i_scheduleUnits, id, defaultPort);
                                //        }

                                //        List<int> lowscheduleIds = dao.ListPrioritySchedules(zoneid, "Low");

                                //        foreach (int id in lowscheduleIds)
                                //        {
                                //            List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                //            GetScheduleUnitDetails(i_scheduleUnits,id, defaultPort);
                                //        }
                                //    }
                                //}
                                #endregion
                            }
                        }
                    }

                    if (scheduleEndTime == "00:00" && scheduleStartTime == "00:00")
                    {
                          lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                            DAO.ConnectionString = _connectionString;

                            string priorityValue = DAO.GetPriority(schedule.Id);

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                priorityValue = "None";
                            }

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                GetScheduleUnitDetailsForId(scheduleUnits, schedule.Id, ruleEnabledUnits, defaultPort);
                            }
                            else
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                _defaultUnits.Add(schedule.Id.ToString(),scheduleUnits);

                                //if (ExecutePriority(_connectionString, priorityValue))
                                //{
                                    //GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);
                                //}
                           }
                    }
                }
            }

            if (_defaultUnits.Count > 0)
            {
                if (_executed.Count <= 0)
                {
                    foreach (string id in _defaultUnits.Keys)
                    {
                        List<lfa.pmgmt.data.DTO.Schedule.Unit> units = _defaultUnits[id];

                        GetScheduleUnitDetails(units, int.Parse(id), defaultPort);
                    }
                }
            }

            _defaultUnits.Clear();
            _executed.Clear();
        }
Example #15
0
        public void ExecuteSchedule(List <lfa.pmgmt.data.DTO.Schedule.Schedule> scheduleList,
                                    List <int> ruleEnabledUnits, int defaultPort)
        {
            _executed     = new List <string>();
            _defaultUnits = new Dictionary <string, List <lfa.pmgmt.data.DTO.Schedule.Unit> >();

            int status    = 0;
            int ruleCount = 0;

            foreach (lfa.pmgmt.data.DTO.Schedule.Schedule schedule in scheduleList)
            {
                if (schedule.IsActive)
                {
                    string scheduleStartTime = schedule.StartTime;
                    string scheduleEndTime   = schedule.EndTime;

                    DateTime currentTime   = DateTime.Now;
                    DateTime scheduleStart = Convert.ToDateTime(scheduleStartTime);
                    DateTime scheduleEnd   = Convert.ToDateTime(scheduleEndTime);

                    if (scheduleStart > scheduleEnd)
                    {
                        scheduleEnd = scheduleEnd.AddDays(1);
                    }

                    if (currentTime.TimeOfDay <= scheduleEnd.TimeOfDay)
                    {
                        if (currentTime.TimeOfDay >= scheduleStart.TimeOfDay)
                        {
                            lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                            DAO.ConnectionString = _connectionString;

                            string priorityValue = DAO.GetPriority(schedule.Id);

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                priorityValue = "None";
                            }

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                GetScheduleUnitDetailsForId(scheduleUnits, schedule.Id, ruleEnabledUnits, defaultPort, status);
                            }
                            else
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);


                                if (ExecutePriority(_connectionString, priorityValue, out status, out ruleCount))
                                {
                                    GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort, status);

                                    _executed.Add("true");
                                }
                                else
                                {
                                    if (ruleCount <= 0)
                                    {
                                        status = 0;

                                        GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort, status);
                                    }

                                    _executed.Add("true");
                                }
                            }
                        }
                    }

                    if (scheduleEndTime == "00:00" && scheduleStartTime == "00:00")
                    {
                        lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                        DAO.ConnectionString = _connectionString;

                        string priorityValue = DAO.GetPriority(schedule.Id);

                        if (string.IsNullOrEmpty(priorityValue))
                        {
                            priorityValue = "None";
                        }

                        if (string.IsNullOrEmpty(priorityValue))
                        {
                            lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                            unitDAO.ConnectionString = _connectionString;
                            List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                            GetScheduleUnitDetailsForId(scheduleUnits, schedule.Id, ruleEnabledUnits, defaultPort, 0);
                        }
                        else
                        {
                            lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                            unitDAO.ConnectionString = _connectionString;
                            List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                            _defaultUnits.Add(schedule.Id.ToString(), scheduleUnits);
                        }
                    }
                }
            }

            if (_defaultUnits.Count > 0)
            {
                if (_executed.Count <= 0)
                {
                    foreach (string id in _defaultUnits.Keys)
                    {
                        List <lfa.pmgmt.data.DTO.Schedule.Unit> units = _defaultUnits[id];

                        GetScheduleUnitDetails(units, int.Parse(id), defaultPort, 0);
                    }
                }
            }

            _defaultUnits.Clear();
            _executed.Clear();
        }
Example #16
0
        public void Execute(int defaultPort)
        {
            _executed = new List <string>();

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

            List <lfa.pmgmt.data.DTO.Schedule.Schedule> scheduleList = scheduleDAO.List();

            foreach (lfa.pmgmt.data.DTO.Schedule.Schedule schedule in scheduleList)
            {
                if (schedule.IsActive)
                {
                    string scheduleStartTime = schedule.StartTime;
                    string scheduleEndTime   = schedule.EndTime;

                    DateTime currentTime   = DateTime.Now;
                    DateTime scheduleStart = Convert.ToDateTime(scheduleStartTime);
                    DateTime scheduleEnd   = Convert.ToDateTime(scheduleEndTime);

                    if (currentTime <= scheduleEnd)
                    {
                        if (currentTime >= scheduleStart)
                        {
                            lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                            DAO.ConnectionString = _connectionString;

                            string priorityValue = DAO.GetPriority(schedule.Id);

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);
                            }
                            else
                            {
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                if (ExecutePriority(_connectionString, priorityValue))
                                {
                                    GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                    _executed.Add("true");
                                }

                                #region OBSOLETE
                                //if (priorityValue.ToLower().Equals("low"))
                                //{
                                //    ExecutePriority(connectionString,priority)
                                //    {
                                //      GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);
                                //    }
                                //}

                                //if (priorityValue.ToLower().Equals("medium"))
                                //{
                                //    GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                //    lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule();

                                //    dao.ConnectionString = _connectionString;
                                //    int zoneid = dao.GetLinkedZone(schedule.Id);

                                //    List<int> scheduleIds = dao.ListPrioritySchedules(zoneid, "Low");

                                //    foreach (int id in scheduleIds)
                                //    {
                                //        List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                //        GetScheduleUnitDetails(i_scheduleUnits, id, defaultPort);
                                //    }

                                //}

                                //if (priorityValue.ToLower().Equals("high"))
                                //{
                                //    GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort);

                                //    lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule();

                                //    dao.ConnectionString = _connectionString;
                                //    int zoneid = dao.GetLinkedZone(schedule.Id);

                                //    List<int> scheduleIds = dao.ListPrioritySchedules(zoneid, "Medium");

                                //    foreach (int id in scheduleIds)
                                //    {
                                //        List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                //        GetScheduleUnitDetails(i_scheduleUnits, id, defaultPort);
                                //    }

                                //    List<int> lowscheduleIds = dao.ListPrioritySchedules(zoneid, "Low");

                                //    foreach (int id in lowscheduleIds)
                                //    {
                                //        List<lfa.pmgmt.data.DTO.Schedule.Unit> i_scheduleUnits = unitDAO.List(id);

                                //        GetScheduleUnitDetails(i_scheduleUnits, id, defaultPort);
                                //    }
                                //}
                                #endregion
                            }
                        }
                    }
                }
            }
        }
Example #17
0
        public void Execute(int defaultPort)
        {
            _switchStates = new Dictionary <string, string>();

            _executed = new List <string>();
            int ruleCount = 0;

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

            List <lfa.pmgmt.data.DTO.Schedule.Schedule> scheduleList = scheduleDAO.List();

            foreach (lfa.pmgmt.data.DTO.Schedule.Schedule schedule in scheduleList)
            {
                if (schedule.IsActive)
                {
                    string scheduleStartTime = schedule.StartTime;
                    string scheduleEndTime   = schedule.EndTime;

                    DateTime currentTime   = DateTime.Now;
                    DateTime scheduleStart = Convert.ToDateTime(scheduleStartTime);
                    DateTime scheduleEnd   = Convert.ToDateTime(scheduleEndTime);

                    if (scheduleStart > scheduleEnd)
                    {
                        scheduleEnd = scheduleEnd.AddDays(1);
                    }

                    if (currentTime <= scheduleEnd)
                    {
                        if (currentTime >= scheduleStart)
                        {
                            lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule();
                            DAO.ConnectionString = _connectionString;

                            string priorityValue = DAO.GetPriority(schedule.Id);

                            if (string.IsNullOrEmpty(priorityValue))
                            {
                                int status = 0;
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort, status);
                            }
                            else
                            {
                                int status = 0;
                                lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
                                unitDAO.ConnectionString = _connectionString;
                                List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits = unitDAO.List(schedule.Id);

                                if (ExecutePriority(_connectionString, priorityValue, out status, out ruleCount))
                                {
                                    GetScheduleUnitDetails(scheduleUnits, schedule.Id, defaultPort, status);

                                    _executed.Add("true");
                                }
                            }
                        }
                    }
                }
            }
        }
Example #18
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboItem selectedItem = comboBox1.SelectedItem as ComboItem;
            int zoneId = selectedItem.Id;

            lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
            unitDAO.ConnectionString = _connectionString;
            List<lfa.pmgmt.data.DTO.Schedule.Unit> unitList = unitDAO.ListWithZone(_scheduleId);

            lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
            deviceDAO.ConnectionString = _connectionString;

            foreach (lfa.pmgmt.data.DTO.Schedule.Unit unit in unitList)
            {
                if (unit.Id_Zone == zoneId)
                {
                    List<lfa.pmgmt.data.DTO.Schedule.Device> deviceList = deviceDAO.ListWithDeviceId(unit.Id, _scheduleId);

                    foreach (lfa.pmgmt.data.DTO.Schedule.Device device in deviceList)
                    {
                        lfa.pmgmt.data.DAO.Configuration.Device configDeviceDAO = new data.DAO.Configuration.Device();
                        configDeviceDAO.ConnectionString = _connectionString;

                        lfa.pmgmt.data.DTO.Configuration.Device configDevice = configDeviceDAO.Get(device.DeviceId);

                        switch (configDevice.Switch)
                        {
                            case "Switch 1":
                                checkBox1.Checked = device.DeviceOn;
                                break;
                            case "Switch 2":
                                checkBox2.Checked = device.DeviceOn;
                                break;
                            case "Switch 3":
                                checkBox3.Checked = device.DeviceOn;
                                break;
                            case "Switch 4":
                                checkBox4.Checked = device.DeviceOn;
                                break;
                            case "Switch 5":
                                checkBox5.Checked = device.DeviceOn;
                                break;
                            case "Switch 6":
                                checkBox6.Checked = device.DeviceOn;
                                break;
                            case "Switch 7":
                                checkBox7.Checked = device.DeviceOn;
                                break;
                            case "Switch 8":
                                checkBox8.Checked = device.DeviceOn;
                                break;
                        }
                    }
                }
            }
        }