Esempio n. 1
0
        private static void StartSchedule()
        {
            string connectionString = @"Data Source=DLMHS10V\BTS2;Initial Catalog=lfa_PowerMgmt;user id=sa;password=Orgaleon12;";

            lfa.pmgmt.schedule.Scheduling schedule = new Scheduling(connectionString);
            schedule.Execute(9000);
        }
Esempio n. 2
0
        private static void ExecuteScheduleOnNonRuleEnabledUnits()
        {
            Scheduling schedule = new Scheduling(_connectionString);

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

            schedule.ExecuteSchedule(scheduleList, _ruleEnabledUnits,
                                    int.Parse(ConfigurationManager.AppSettings["DefaultPort"].ToString()));
        }
Esempio n. 3
0
        private void tmrManager_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            bool _doLogging = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableLogging"].ToString());
            int _defaultPort = int.Parse(ConfigurationManager.AppSettings["DefaultPort"].ToString());
            int _interval = int.Parse(ConfigurationManager.AppSettings["Interval"].ToString());
            string _connectionString = ConfigurationManager.AppSettings["ConnectionString"];

            try
            {
                #region OLD Timer Stop
                tmrManager.Stop();
                #endregion

                Rules loadShed = new Rules(_connectionString,_defaultPort);

                bool hasLoadShedAll = false;

                if (!hasLoadShedAll)
                {
                    if (!HasRulesToExecute(_connectionString))
                    {
                        Scheduling schedule = new Scheduling(_connectionString);
                        schedule.Execute(_defaultPort);
                        ((IDisposable)schedule).Dispose();
                    }
                    else
                    {
                        _ruleEnabledUnits = new List<int>();

                        Rules loadshedRules = new Rules(_connectionString, _defaultPort);
                        List<lfa.pmgmt.data.DTO.BusinessRule.RuleSet> ruleSets = loadshedRules.ListActiveRuleSets();

                        if (ruleSets.Count > 0)
                        {
                            ExecuteScheduleOnNonRuleEnabledUnits(_connectionString);

                            _ruleEnabledUnits.Clear();
                        }
                        else
                        {
                            Scheduling schedule = new Scheduling(_connectionString);
                            schedule.Execute(int.Parse(ConfigurationManager.AppSettings["DefaultPort"].ToString()));
                            ((IDisposable)schedule).Dispose();
                        }
                    }

                    LogLoadShedRulesExecuted(_doLogging);
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
            finally
            {
                GC.WaitForPendingFinalizers();

                this.Dispose(true);

                tmrManager.Interval = _interval;
                tmrManager.Start();

                #region OLD Timer Start
                //    tmrManager = new System.Timers.Timer();
            //    tmrManager.Enabled = true;
            //    tmrManager.Interval = _interval;
            //    tmrManager.Elapsed += new System.Timers.ElapsedEventHandler(tmrManager_Elapsed);
                //    tmrManager.Start();
                #endregion
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting power management controller service...");

            try
            {
                _connectionString = ConfigurationManager.AppSettings["ConnectionString"];
                int defaultPort = int.Parse(ConfigurationManager.AppSettings["DefaultPort"].ToString());

                Console.WriteLine("Power management controller service running...");

                Rules loadShed = new Rules(_connectionString,defaultPort);
                //bool hasLoadShedAll = loadShed.EntireLoadShed();
                bool hasLoadShedAll = false;

                if (!hasLoadShedAll)
                {
                    if (!HasRulesToExecute())
                    {
                        Scheduling schedule = new Scheduling(_connectionString);
                        schedule.Execute(defaultPort);
                    }
                    else
                    {
                        _ruleEnabledUnits = new List<int>();

                        Rules loadshedRules = new Rules(_connectionString, defaultPort);
                        List<lfa.pmgmt.data.DTO.BusinessRule.RuleSet> ruleSets = loadshedRules.ListActiveRuleSets();

                        if (ruleSets.Count > 0)
                        {
                            ExecuteScheduleOnNonRuleEnabledUnits();

                            //ExecuteLoadShedRules(loadshedRules, ruleSets);

                            _ruleEnabledUnits.Clear();
                        }
                        else
                        {
                            Scheduling schedule = new Scheduling(_connectionString);
                            schedule.Execute(int.Parse(ConfigurationManager.AppSettings["DefaultPort"].ToString()));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
Esempio n. 5
0
        private void tmrManager_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                tmrManager.Stop();
                tmrManager.Enabled = false;

                _connectionString = ConfigurationManager.AppSettings["ConnectionString"];

                Rules loadShed = new Rules(_connectionString,_defaultPort);

                bool hasLoadShedAll = false;

                if (!hasLoadShedAll)
                {
                    if (!HasRulesToExecute())
                    {
                        Scheduling schedule = new Scheduling(_connectionString);
                        schedule.Execute(_defaultPort);
                    }
                    else
                    {
                        _ruleEnabledUnits = new List<int>();

                        Rules loadshedRules = new Rules(_connectionString, _defaultPort);
                        List<lfa.pmgmt.data.DTO.BusinessRule.RuleSet> ruleSets = loadshedRules.ListActiveRuleSets();

                        if (ruleSets.Count > 0)
                        {
                            ExecuteScheduleOnNonRuleEnabledUnits();

                            _ruleEnabledUnits.Clear();
                        }
                        else
                        {
                            Scheduling schedule = new Scheduling(_connectionString);
                            schedule.Execute(int.Parse(ConfigurationManager.AppSettings["DefaultPort"].ToString()));
                        }
                    }

                    LogLoadShedRulesExecuted();
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
            finally
            {
                tmrManager = new System.Timers.Timer();
                tmrManager.Enabled = true;
                tmrManager.Interval = _interval;
                tmrManager.Elapsed += new System.Timers.ElapsedEventHandler(tmrManager_Elapsed);
                tmrManager.Start();
            }
        }