Ejemplo n.º 1
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");
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
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
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
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());
            }
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
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
                             }
                           }
                        }
                    }
               }
        }
Ejemplo n.º 8
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();
        }