Пример #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            StartupBox.Checked = Properties.Settings.Default.Startup;

            Bidirectional.Checked = Properties.Settings.Default.Bidir;

            TimerBox.Checked        = Properties.Settings.Default.Timer;
            comboBox1.SelectedIndex = Properties.Settings.Default.TimeType;
            timeBox.Value           = Properties.Settings.Default.TimeAmount;

            numDayHour.Value   = Properties.Settings.Default.DayHour;
            numDayMinute.Value = Properties.Settings.Default.DayMinute;

            SyncTimer.Interval = (1000) * Convert.ToInt32(timeBox.Value) * Convert.ToInt32(Math.Pow(60, comboBox1.SelectedIndex));

            if (TimerBox.Checked)
            {
                SyncTimer.Start();
                timeBox.Enabled   = true;
                comboBox1.Enabled = true;
            }
            else
            {
                SyncTimer.Stop();
                timeBox.Enabled   = false;
                comboBox1.Enabled = false;
            }

            destBox.Text = Properties.Settings.Default.Destination;
            if (destBox.Text[0] == '\\' && destBox.Text[1] == '\\')
            {
                IsUNCPath = true;
            }
            destBox.SelectionLength = 0;
            destBox.SelectionStart  = destBox.Text.Length;

            richTextBox1.Text = Properties.Settings.Default.Folders;

            FixTimer();
            DayCheck.Checked = Properties.Settings.Default.DayTimer;
            if (DayCheck.Checked)
            {
                DailyTimer.Start();
                numDayHour.Enabled   = true;
                numDayMinute.Enabled = true;
            }
            else
            {
                DailyTimer.Stop();
                numDayHour.Enabled   = false;
                numDayMinute.Enabled = false;
            }

            SyncTimer.Tick  += new EventHandler(SyncButton_Click);
            DailyTimer.Tick += new EventHandler(SyncDailyTimer);
        }
Пример #2
0
 private void ProcessCheckChanged()
 {
     if (DayCheck.Checked)
     {
         FixTimer();
         numDayHour.Enabled   = true;
         numDayMinute.Enabled = true;
     }
     else
     {
         DailyTimer.Stop();
         numDayHour.Enabled   = false;
         numDayMinute.Enabled = false;
     }
 }
Пример #3
0
        public static void SchaduleDailyTimer(TimerMsg.Type timerType, int hours, int minutes = 0, int seconds = 0, bool todayExecuted = false)
        {
            var dailyTimer = TimerDict.GetValueOrDefault(timerType, (DailyTimer)null);

            if (dailyTimer != null && dailyTimer.Running)
            {
                dailyTimer.Release();
            }
            dailyTimer = new DailyTimer(hours, minutes, seconds, callBackEnum =>
            {
                MessageBus.Main.Publish(new TimerMsg(timerType, onTime: callBackEnum == CallBackEnum.OnTime));
                if (callBackEnum == CallBackEnum.OnTime)
                {
                    new Agp2pDataContext().AppendAdminLogAndSave("Timer", "全局定时器执行了一次:" + timerType);
                }
            }, ex =>
            {
                new Agp2pDataContext().AppendAdminLogAndSave("Timer", "全局定时器报错:" + ex.GetSimpleCrashInfo());
                //if (Utils.IsDebugging()) throw ex;
            });
            TimerDict[timerType] = dailyTimer;
        }
    private bool IsTimeToProcess()
    {
        var dailyTimer = new DailyTimer();

        return(dailyTimer.IsNewDay());
    }