Пример #1
0
 public void CopyFrom(TimerConfig sourcePar)
 {
     this.LastTime1 = sourcePar.LastTime1;
     this.LastTime2 = sourcePar.LastTime2;
     this.LastTime3 = sourcePar.LastTime3;
     this.LastTime4 = sourcePar.LastTime4;
     this.LastTime5 = sourcePar.LastTime5;
 }
Пример #2
0
        public TaskTimerControl()
        {
            InitializeComponent();

            _timerDesign = new TimerModuleDesign();

            _timerDesign.Interval = 5;

            _timerConfig = new TimerConfig();

            _timerConfig.LastTime1 = default(DateTime);
            _timerConfig.LastTime1 = default(DateTime);
            _timerConfig.LastTime1 = default(DateTime);
            _timerConfig.LastTime1 = default(DateTime);
            _timerConfig.LastTime1 = default(DateTime);
        }
Пример #3
0
        static public TimerConfig GetConfig(string sectionName)
        {
            TimerConfig tc = new TimerConfig();

            try
            {
                SettingItem timerSetting = AppSettingHelper.GetSpecifySection(sectionName);

                tc.LastTime1 = timerSetting.ReadDatetime("LastTime1");
                tc.LastTime1 = timerSetting.ReadDatetime("LastTime2");
                tc.LastTime1 = timerSetting.ReadDatetime("LastTime3");
                tc.LastTime1 = timerSetting.ReadDatetime("LastTime4");
                tc.LastTime5 = timerSetting.ReadDatetime("LastTime5");
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex);
            }

            return(tc);
        }
Пример #4
0
        static public void SetConfig(TimerConfig tc, string sectionName)
        {
            SettingItem timerSetting = AppSettingHelper.GetSpecifySection(sectionName);

            timerSetting.BatchBegin();
            try
            {
                timerSetting.WriteDateTime("LastTime1", tc.LastTime1);
                timerSetting.WriteDateTime("LastTime2", tc.LastTime2);
                timerSetting.WriteDateTime("LastTime3", tc.LastTime3);
                timerSetting.WriteDateTime("LastTime4", tc.LastTime4);
                timerSetting.WriteDateTime("LastTime5", tc.LastTime5);

                timerSetting.BatchCommit();
            }
            catch (Exception ex)
            {
                timerSetting.BatchCancel();

                MsgBox.ShowException(ex);
            }
        }
Пример #5
0
        public override void ModuleLoaded()
        {
            _timerConfig = TimerConfig.GetConfig(_moduleName);

            //timer1.Enabled = true;
        }
Пример #6
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                DoInterval();

                bool isDo = false;
                if (WakeTime(_timerDesign.Timing1, _timerConfig.LastTime1))
                {
                    if (_designEvents.ContainsKey(TimerEventDefine.Time1))
                    {
                        EventActionReleation ea = _designEvents[TimerEventDefine.Time1];

                        DoActions(ea, timer1);

                        _timerConfig.LastTime1 = DateTime.Now;
                        isDo = true;
                    }
                }

                if (WakeTime(_timerDesign.Timing2, _timerConfig.LastTime2))
                {
                    if (_designEvents.ContainsKey(TimerEventDefine.Time2))
                    {
                        EventActionReleation ea = _designEvents[TimerEventDefine.Time2];

                        DoActions(ea, timer1);

                        _timerConfig.LastTime2 = DateTime.Now;
                        isDo = true;
                    }
                }

                if (WakeTime(_timerDesign.Timing3, _timerConfig.LastTime3))
                {
                    if (_designEvents.ContainsKey(TimerEventDefine.Time3))
                    {
                        EventActionReleation ea = _designEvents[TimerEventDefine.Time3];

                        DoActions(ea, timer1);

                        _timerConfig.LastTime3 = DateTime.Now;
                        isDo = true;
                    }
                }

                if (WakeTime(_timerDesign.Timing4, _timerConfig.LastTime4))
                {
                    if (_designEvents.ContainsKey(TimerEventDefine.Time4))
                    {
                        EventActionReleation ea = _designEvents[TimerEventDefine.Time4];

                        DoActions(ea, timer1);

                        _timerConfig.LastTime4 = DateTime.Now;
                        isDo = true;
                    }
                }

                if (WakeTime(_timerDesign.Timing5, _timerConfig.LastTime5))
                {
                    if (_designEvents.ContainsKey(TimerEventDefine.Time5))
                    {
                        EventActionReleation ea = _designEvents[TimerEventDefine.Time5];

                        DoActions(ea, timer1);

                        _timerConfig.LastTime5 = DateTime.Now;
                        isDo = true;
                    }
                }

                if (isDo)
                {
                    TimerConfig.SetConfig(_timerConfig, _moduleName);
                }
            }
            catch
            {
            }
        }