private void TmRunTick_Interval() { TmRun.Enabled = false; using (FacebookWebBrowser frm = new FacebookWebBrowser(jobConfig, dBHelper.GetPostWallMessages().ToList(), dBHelper.GetSendMessages().ToList())) { frm.ShowDialog(); } TmRun.Enabled = true; }
private void TmRunTick_Timming() { TmRun.Enabled = false; if (jobConfig.TimmingConfig.IsUsedOne && DateTime.Now.TimeOfDay.TotalSeconds - jobConfig.TimmingConfig.TimeOne > 0 && DateTime.Now.TimeOfDay.TotalSeconds - jobConfig.TimmingConfig.TimeOne < 2) { using (FacebookWebBrowser frm = new FacebookWebBrowser(jobConfig, dBHelper.GetPostWallMessages().ToList(), dBHelper.GetSendMessages().ToList())) { frm.ShowDialog(); } } else if (jobConfig.TimmingConfig.IsUsedTwo && DateTime.Now.TimeOfDay.TotalSeconds - jobConfig.TimmingConfig.TimeTwo > 0 && DateTime.Now.TimeOfDay.TotalSeconds - jobConfig.TimmingConfig.TimeTwo < 2) { using (FacebookWebBrowser frm = new FacebookWebBrowser(jobConfig, dBHelper.GetPostWallMessages().ToList(), dBHelper.GetSendMessages().ToList())) { frm.ShowDialog(); } } else if (jobConfig.TimmingConfig.IsUsedThree && DateTime.Now.TimeOfDay.TotalSeconds - jobConfig.TimmingConfig.TimeThree > 0 && DateTime.Now.TimeOfDay.TotalSeconds - jobConfig.TimmingConfig.TimeThree < 2) { using (FacebookWebBrowser frm = new FacebookWebBrowser(jobConfig, dBHelper.GetPostWallMessages().ToList(), dBHelper.GetSendMessages().ToList())) { frm.ShowDialog(); } } else if (jobConfig.TimmingConfig.IsUsedFour && DateTime.Now.TimeOfDay.TotalSeconds - jobConfig.TimmingConfig.TimeFour > 0 && DateTime.Now.TimeOfDay.TotalSeconds - jobConfig.TimmingConfig.TimeFour < 2) { using (FacebookWebBrowser frm = new FacebookWebBrowser(jobConfig, dBHelper.GetPostWallMessages().ToList(), dBHelper.GetSendMessages().ToList())) { frm.ShowDialog(); } } TmRun.Enabled = true; }
private void BtnRun_Click(object sender, EventArgs e) { if (BtnRun.Text == "Run") { // TODO Run GrpJob.Enabled = false; BtnRun.Text = "Stop"; jobConfig = new JobConfig() { Type = Cbtype.SelectedIndex, TimmingConfig = new TimmingConfig() { IsUsedOne = chbtimming1.Checked, IsUsedTwo = chbtimming2.Checked, IsUsedThree = chbtimming3.Checked, IsUsedFour = chbtimming4.Checked, TimeOne = (int)dttimming1.Value.TimeOfDay.TotalSeconds, TimeTwo = (int)dttimming2.Value.TimeOfDay.TotalSeconds, TimeThree = (int)dttimming3.Value.TimeOfDay.TotalSeconds, TimeFour = (int)dttimming4.Value.TimeOfDay.TotalSeconds }, IntervalConfig = new IntervalConfig() { IsRunNow = chbRunNow.Checked, Interval = (int)nudinterval.Value }, NotifyBeforeTime = (int)nudnotify.Value, UserConfigs = new List <User>(), IsSendMessage = chbsendmessage.Checked, IsPostWall = chbpostwall.Checked, CountPeople = (int)nudpeoplecount.Value }; var users = dBHelper.GetUsers(); foreach (string item in chblusers.CheckedItems) { var user = users.Where(u => u.UserName.Equals((string)item)).FirstOrDefault(); if (user != null) { jobConfig.UserConfigs.Add(user); } } if (jobConfig.UserConfigs.Count == 0) { if (Until.ShowYesNoQuestionWarning("This job isn't implement any users to run, can you want to run it?") == DialogResult.No) { GrpJob.Enabled = true; BtnRun.Text = "Run"; return; } } switch (jobConfig.Type) { case 0: if (!jobConfig.TimmingConfig.IsUsedOne && !jobConfig.TimmingConfig.IsUsedTwo && !jobConfig.TimmingConfig.IsUsedThree && !jobConfig.TimmingConfig.IsUsedFour) { if (Until.ShowYesNoQuestionWarning("This job isn't implement any time to run, can you want to run it?") == DialogResult.No) { GrpJob.Enabled = true; BtnRun.Text = "Run"; return; } } OnTimeRunTick = TmRunTick_Timming; TmRun.Interval = 500; TmRun.Enabled = true; break; case 1: OnTimeRunTick = TmRunTick_Interval; TmRun.Interval = jobConfig.IntervalConfig.Interval * 1000; if (jobConfig.IntervalConfig.IsRunNow) { using (FacebookWebBrowser frm = new FacebookWebBrowser(jobConfig, dBHelper.GetPostWallMessages().ToList(), dBHelper.GetSendMessages().ToList())) { frm.ShowDialog(); } } TmRun.Enabled = true; break; default: break; } } else { // TODO Stop TmRun.Enabled = false; GrpJob.Enabled = true; BtnRun.Text = "Run"; } }