Пример #1
0
        private void FireEvent(SchedulerItem I)
        {
            try
            {
                // save chagnes before it fires in case its chagned during the fire
                I = m_database.SaveHistory(I);

                if (I.RunOnce)
                {
                    I.Enabled = false;
                }
                if (I.Enabled)
                {
                    I.CalculateNextRunTime(I.TimeToRun);
                }

                if (!I.HisotryKeep)
                {
                    m_database.HistoryDeleteOld(I);
                }
                m_database.SchedulerSave(I);

                // now fire
                List <Object> reciept = EventManager.FireGenericEventHandler(I.FireFunction, I.FireParams);
                if (!I.HistoryReciept)
                {
                    I = m_database.SaveHistoryComplete(I);
                }
                else
                {
#if (!ISWIN)
                    foreach (Object o in reciept)
                    {
                        string results = (string)o;
                        if (results != "")
                        {
                            m_database.SaveHistoryCompleteReciept(I.HistoryLastID, results);
                        }
                    }
#else
                    foreach (string results in reciept.Cast <string>().Where(results => results != ""))
                    {
                        m_database.SaveHistoryCompleteReciept(I.HistoryLastID, results);
                    }
#endif
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.Error("[Scheduler] FireEvent Error " + I.id, e);
            }
        }
Пример #2
0
        private void FireEvent(SchedulerItem I)
        {
            try
            {
                I = m_database.SaveHistory(I);
                List <Object> reciept = EventManager.FireGenericEventHandler(I.FireFunction, I.FireParams);
                if (!I.HistoryReciept)
                {
                    I = m_database.SaveHistoryComplete(I);
                }
                else
                {
                    foreach (Object o in reciept)
                    {
                        string results = (string)o;
                        if (results != "")
                        {
                            m_database.SaveHistoryCompleteReciept(I.HistoryLastID, results);
                        }
                    }
                }

                if (I.RunOnce)
                {
                    I.Enabled = false;
                }
                if (I.Enabled)
                {
                    I.TimeToRun = I.TimeToRun.AddSeconds(I.RunEvery);
                }

                if (!I.HisotryKeep)
                {
                    m_database.HistoryDeleteOld(I);
                }

                m_database.SchedulerSave(I);
            }
            catch (Exception e)
            {
                MainConsole.Instance.Error("[Scheduler] FireEvent Error " + I.id, e);
            }
        }