winform 歸檔自動執行

This commit is contained in:
cesar liu 2022-06-18 12:20:03 +08:00
parent 254a17d6d3
commit 6e5b27c709
2 changed files with 37 additions and 2 deletions

View File

@ -79,6 +79,7 @@ namespace solarApp
this.tbUserName = new System.Windows.Forms.TextBox(); this.tbUserName = new System.Windows.Forms.TextBox();
this.btSendMail = new System.Windows.Forms.Button(); this.btSendMail = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.lbMsgTitle = new System.Windows.Forms.Label();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout(); this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -361,6 +362,7 @@ namespace solarApp
// panel1 // panel1
// //
this.panel1.BackColor = System.Drawing.SystemColors.GradientActiveCaption; this.panel1.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
this.panel1.Controls.Add(this.lbMsgTitle);
this.panel1.Controls.Add(this.bt_invDay); this.panel1.Controls.Add(this.bt_invDay);
this.panel1.Controls.Add(this.btVerifyData); this.panel1.Controls.Add(this.btVerifyData);
this.panel1.Controls.Add(this.lbSiteDB_sensor); this.panel1.Controls.Add(this.lbSiteDB_sensor);
@ -632,6 +634,15 @@ namespace solarApp
this.btSendMail.UseVisualStyleBackColor = true; this.btSendMail.UseVisualStyleBackColor = true;
this.btSendMail.Click += new System.EventHandler(this.btSendMail_Click); this.btSendMail.Click += new System.EventHandler(this.btSendMail_Click);
// //
// lbMsgTitle
//
this.lbMsgTitle.AutoSize = true;
this.lbMsgTitle.Location = new System.Drawing.Point(931, 20);
this.lbMsgTitle.Name = "lbMsgTitle";
this.lbMsgTitle.Size = new System.Drawing.Size(51, 19);
this.lbMsgTitle.TabIndex = 15;
this.lbMsgTitle.Text = "label2";
//
// fmArchive // fmArchive
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F); this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F);
@ -714,5 +725,6 @@ namespace solarApp
private System.Windows.Forms.TextBox tbContent; private System.Windows.Forms.TextBox tbContent;
private System.Windows.Forms.Label lbReceiver; private System.Windows.Forms.Label lbReceiver;
private System.Windows.Forms.TextBox tbReceiver; private System.Windows.Forms.TextBox tbReceiver;
private System.Windows.Forms.Label lbMsgTitle;
} }
} }

View File

@ -14,6 +14,7 @@ namespace solarApp
public partial class fmArchive : Form public partial class fmArchive : Form
{ {
getStationSvc stationSvc = new getStationSvc(); getStationSvc stationSvc = new getStationSvc();
System.Timers.Timer _timer;
public fmArchive() public fmArchive()
{ {
InitializeComponent(); InitializeComponent();
@ -70,17 +71,38 @@ namespace solarApp
i++; i++;
} }
#endregion #endregion
#region
_timer = new System.Timers.Timer();
_timer.Interval = 10000;
_timer.SynchronizingObject = this;
_timer.Elapsed += _timer_Elapsed;
_timer.Start();
#endregion
// dtselect_station1.Value = DateTime.Today.AddDays(-1); // dtselect_station1.Value = DateTime.Today.AddDays(-1);
dtSelect1.Value = System.DateTime.Today.AddDays(-1); dtSelect1.Value = System.DateTime.Today.AddDays(-1);
dtSelect2.Value = System.DateTime.Today.AddDays(-1); dtSelect2.Value = System.DateTime.Today.AddDays(-1);
//#region 自動執行 //
// Run this procedure in an appropriate event. // Run this procedure in an appropriate event.
//counter = 0; //counter = 0;
//timer1.Interval = 600; //timer1.Interval = 600;
//timer1.Enabled = true; //timer1.Enabled = true;
// Hook up timer's tick event handler. // Hook up timer's tick event handler.
//#endregion //
}
private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (System.DateTime.Now.Hour == 00 && DateTime.Now.Minute == 45)
{
MessageBox.Show("ok");
dtSelect1.Value = System.DateTime.Now.AddDays(-1);
dtSelect2.Value = System.DateTime.Now.AddDays(-1);
bt_archive.PerformClick();
//bt_archive_Click.PerformClick();
}
} }
private void rb_site_CheckedChanged(object sender, EventArgs e) private void rb_site_CheckedChanged(object sender, EventArgs e)
@ -224,6 +246,7 @@ namespace solarApp
} }
i++; i++;
} }
lbMsgTitle.Text = System.DateTime.Now.ToString() + " 完成!";
} }
private void bt_clear_sensor_Click(object sender, EventArgs e) private void bt_clear_sensor_Click(object sender, EventArgs e)