1.debug: 共用 Sensor 無 Value 問題
2. email Winform 測試界面
This commit is contained in:
parent
5c58b583d7
commit
be187bb93a
Binary file not shown.
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 6.7 KiB |
@ -179,7 +179,7 @@ namespace solarApp.Service
|
||||
// from " + _siteDB + @".device a
|
||||
// where left(UID, 11) = @siteID and deleted = 0 and enabled = 1 and `status` = 1 ";
|
||||
sql = @$"select a.id, CONCAT( {_siteID} ,'01') SiteID, a.`name` sensorName, type, DBName, TableName, colname
|
||||
from {_siteDB}.device a join {_siteDB}.sharedevice b on a.id = b.deviceID
|
||||
from {_siteDB}.device a left join {_siteDB}.sharedevice b on a.id = b.deviceID
|
||||
where (left(UID, 11) = @siteID or b.PowerStationID = {_powerStationID}) and deleted = 0 and enabled = 1 and `status` = 1 ";
|
||||
List<sensor_model> ds_sensor = conn.Query<sensor_model>(sql, new { siteID = _siteID01 }).AsList<sensor_model>();
|
||||
|
||||
|
||||
343
solarApp/fmArchive.Designer.cs
generated
343
solarApp/fmArchive.Designer.cs
generated
@ -30,8 +30,8 @@ namespace solarApp
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
@ -61,18 +61,23 @@ namespace solarApp
|
||||
this.lbSiteName_sensor = new System.Windows.Forms.Label();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.dateTimePicker2 = new System.Windows.Forms.DateTimePicker();
|
||||
this.dataGridView2 = new System.Windows.Forms.DataGridView();
|
||||
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.button9 = new System.Windows.Forms.Button();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.lbReceiver = new System.Windows.Forms.Label();
|
||||
this.tbReceiver = new System.Windows.Forms.TextBox();
|
||||
this.gbox = new System.Windows.Forms.GroupBox();
|
||||
this.lbContent = new System.Windows.Forms.Label();
|
||||
this.tbContent = new System.Windows.Forms.TextBox();
|
||||
this.lbTitle = new System.Windows.Forms.Label();
|
||||
this.tbTitle = new System.Windows.Forms.TextBox();
|
||||
this.rbNoSSL = new System.Windows.Forms.RadioButton();
|
||||
this.rbSSL = new System.Windows.Forms.RadioButton();
|
||||
this.lbPort = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.tbPassword = new System.Windows.Forms.TextBox();
|
||||
this.lbUserName = new System.Windows.Forms.Label();
|
||||
this.tbUserName = new System.Windows.Forms.TextBox();
|
||||
this.btSendMail = new System.Windows.Forms.Button();
|
||||
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
@ -85,11 +90,10 @@ namespace solarApp
|
||||
this.panel1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
|
||||
this.splitContainer2.Panel1.SuspendLayout();
|
||||
this.splitContainer2.Panel2.SuspendLayout();
|
||||
this.splitContainer2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
|
||||
this.panel2.SuspendLayout();
|
||||
this.gbox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tabControl1
|
||||
@ -170,9 +174,8 @@ namespace solarApp
|
||||
this.bt_sensor_lackData.Name = "bt_sensor_lackData";
|
||||
this.bt_sensor_lackData.Size = new System.Drawing.Size(107, 44);
|
||||
this.bt_sensor_lackData.TabIndex = 14;
|
||||
this.bt_sensor_lackData.Text = "LackData";
|
||||
this.bt_sensor_lackData.Text = "全電站";
|
||||
this.bt_sensor_lackData.UseVisualStyleBackColor = true;
|
||||
this.bt_sensor_lackData.Visible = false;
|
||||
this.bt_sensor_lackData.Click += new System.EventHandler(this.bt_sensor_lackData_Click);
|
||||
//
|
||||
// bt_updateInstantValue
|
||||
@ -229,7 +232,7 @@ namespace solarApp
|
||||
this.bt_archive.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.bt_archive.Location = new System.Drawing.Point(9, 846);
|
||||
this.bt_archive.Name = "bt_archive";
|
||||
this.bt_archive.Size = new System.Drawing.Size(282, 61);
|
||||
this.bt_archive.Size = new System.Drawing.Size(220, 61);
|
||||
this.bt_archive.TabIndex = 8;
|
||||
this.bt_archive.Text = "單日歸檔";
|
||||
this.bt_archive.UseVisualStyleBackColor = true;
|
||||
@ -324,8 +327,8 @@ namespace solarApp
|
||||
//
|
||||
this.gv_inv_detail.AllowUserToAddRows = false;
|
||||
this.gv_inv_detail.AllowUserToDeleteRows = false;
|
||||
dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
|
||||
this.gv_inv_detail.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3;
|
||||
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
|
||||
this.gv_inv_detail.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
|
||||
this.gv_inv_detail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.gv_inv_detail.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.gv_inv_detail.Location = new System.Drawing.Point(768, 75);
|
||||
@ -341,8 +344,8 @@ namespace solarApp
|
||||
//
|
||||
this.gv_rpt_invDay.AllowUserToAddRows = false;
|
||||
this.gv_rpt_invDay.AllowUserToDeleteRows = false;
|
||||
dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
|
||||
this.gv_rpt_invDay.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle4;
|
||||
dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
|
||||
this.gv_rpt_invDay.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle2;
|
||||
this.gv_rpt_invDay.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.gv_rpt_invDay.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.gv_rpt_invDay.Location = new System.Drawing.Point(0, 75);
|
||||
@ -438,6 +441,7 @@ namespace solarApp
|
||||
//
|
||||
// splitContainer2
|
||||
//
|
||||
this.splitContainer2.Cursor = System.Windows.Forms.Cursors.VSplit;
|
||||
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer2.Location = new System.Drawing.Point(3, 3);
|
||||
this.splitContainer2.Name = "splitContainer2";
|
||||
@ -445,139 +449,188 @@ namespace solarApp
|
||||
// splitContainer2.Panel1
|
||||
//
|
||||
this.splitContainer2.Panel1.BackColor = System.Drawing.Color.OldLace;
|
||||
this.splitContainer2.Panel1.Controls.Add(this.button3);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.label1);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.dateTimePicker1);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.button2);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.flowLayoutPanel2);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.dateTimePicker2);
|
||||
this.splitContainer2.Panel1.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
//
|
||||
// splitContainer2.Panel2
|
||||
//
|
||||
this.splitContainer2.Panel2.Controls.Add(this.dataGridView2);
|
||||
this.splitContainer2.Panel2.Controls.Add(this.richTextBox1);
|
||||
this.splitContainer2.Panel2.Controls.Add(this.panel2);
|
||||
this.splitContainer2.Size = new System.Drawing.Size(1768, 912);
|
||||
this.splitContainer2.SplitterDistance = 299;
|
||||
this.splitContainer2.SplitterWidth = 10;
|
||||
this.splitContainer2.TabIndex = 1;
|
||||
//
|
||||
// button3
|
||||
// richTextBox1
|
||||
//
|
||||
this.button3.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.button3.Location = new System.Drawing.Point(10, 640);
|
||||
this.button3.Name = "button3";
|
||||
this.button3.Size = new System.Drawing.Size(135, 44);
|
||||
this.button3.TabIndex = 12;
|
||||
this.button3.Text = "Sensor 歸檔";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(10, 569);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(20, 19);
|
||||
this.label1.TabIndex = 10;
|
||||
this.label1.Text = "~";
|
||||
//
|
||||
// dateTimePicker1
|
||||
//
|
||||
this.dateTimePicker1.Location = new System.Drawing.Point(10, 593);
|
||||
this.dateTimePicker1.Name = "dateTimePicker1";
|
||||
this.dateTimePicker1.Size = new System.Drawing.Size(145, 27);
|
||||
this.dateTimePicker1.TabIndex = 9;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.button2.Location = new System.Drawing.Point(9, 846);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(282, 61);
|
||||
this.button2.TabIndex = 8;
|
||||
this.button2.Text = "單日歸檔";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// flowLayoutPanel2
|
||||
//
|
||||
this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.flowLayoutPanel2.Location = new System.Drawing.Point(0, 0);
|
||||
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
|
||||
this.flowLayoutPanel2.Size = new System.Drawing.Size(299, 530);
|
||||
this.flowLayoutPanel2.TabIndex = 4;
|
||||
//
|
||||
// dateTimePicker2
|
||||
//
|
||||
this.dateTimePicker2.Location = new System.Drawing.Point(10, 536);
|
||||
this.dateTimePicker2.Name = "dateTimePicker2";
|
||||
this.dateTimePicker2.Size = new System.Drawing.Size(145, 27);
|
||||
this.dateTimePicker2.TabIndex = 3;
|
||||
//
|
||||
// dataGridView2
|
||||
//
|
||||
this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGridView2.Location = new System.Drawing.Point(0, 125);
|
||||
this.dataGridView2.Name = "dataGridView2";
|
||||
this.dataGridView2.RowHeadersWidth = 51;
|
||||
this.dataGridView2.RowTemplate.Height = 29;
|
||||
this.dataGridView2.Size = new System.Drawing.Size(1459, 787);
|
||||
this.dataGridView2.TabIndex = 1;
|
||||
this.richTextBox1.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.richTextBox1.Location = new System.Drawing.Point(0, 321);
|
||||
this.richTextBox1.Name = "richTextBox1";
|
||||
this.richTextBox1.Size = new System.Drawing.Size(1459, 591);
|
||||
this.richTextBox1.TabIndex = 1;
|
||||
this.richTextBox1.Text = "";
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.BackColor = System.Drawing.Color.Moccasin;
|
||||
this.panel2.Controls.Add(this.button9);
|
||||
this.panel2.Controls.Add(this.label2);
|
||||
this.panel2.Controls.Add(this.label3);
|
||||
this.panel2.Controls.Add(this.label4);
|
||||
this.panel2.Controls.Add(this.lbReceiver);
|
||||
this.panel2.Controls.Add(this.tbReceiver);
|
||||
this.panel2.Controls.Add(this.gbox);
|
||||
this.panel2.Controls.Add(this.btSendMail);
|
||||
this.panel2.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel2.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(1459, 125);
|
||||
this.panel2.Size = new System.Drawing.Size(1459, 321);
|
||||
this.panel2.TabIndex = 0;
|
||||
//
|
||||
// button9
|
||||
// lbReceiver
|
||||
//
|
||||
this.button9.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.button9.Location = new System.Drawing.Point(635, 8);
|
||||
this.button9.Name = "button9";
|
||||
this.button9.Size = new System.Drawing.Size(158, 44);
|
||||
this.button9.TabIndex = 12;
|
||||
this.button9.Text = "檢核結果";
|
||||
this.button9.UseVisualStyleBackColor = true;
|
||||
this.lbReceiver.AutoSize = true;
|
||||
this.lbReceiver.Location = new System.Drawing.Point(789, 51);
|
||||
this.lbReceiver.Name = "lbReceiver";
|
||||
this.lbReceiver.Size = new System.Drawing.Size(54, 19);
|
||||
this.lbReceiver.TabIndex = 16;
|
||||
this.lbReceiver.Text = "收件人";
|
||||
//
|
||||
// label2
|
||||
// tbReceiver
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new System.Drawing.Font("Microsoft JhengHei UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.label2.Location = new System.Drawing.Point(49, 19);
|
||||
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(79, 24);
|
||||
this.label2.TabIndex = 11;
|
||||
this.label2.Text = "Site_DB";
|
||||
this.tbReceiver.Location = new System.Drawing.Point(789, 73);
|
||||
this.tbReceiver.Name = "tbReceiver";
|
||||
this.tbReceiver.Size = new System.Drawing.Size(217, 27);
|
||||
this.tbReceiver.TabIndex = 15;
|
||||
this.tbReceiver.Text = "cesarliuc@gmail.com";
|
||||
//
|
||||
// label3
|
||||
// gbox
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Font = new System.Drawing.Font("Microsoft JhengHei UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.label3.Location = new System.Drawing.Point(201, 19);
|
||||
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(72, 24);
|
||||
this.label3.TabIndex = 10;
|
||||
this.label3.Text = "Site_ID";
|
||||
this.gbox.Controls.Add(this.lbContent);
|
||||
this.gbox.Controls.Add(this.tbContent);
|
||||
this.gbox.Controls.Add(this.lbTitle);
|
||||
this.gbox.Controls.Add(this.tbTitle);
|
||||
this.gbox.Controls.Add(this.rbNoSSL);
|
||||
this.gbox.Controls.Add(this.rbSSL);
|
||||
this.gbox.Controls.Add(this.lbPort);
|
||||
this.gbox.Controls.Add(this.label1);
|
||||
this.gbox.Controls.Add(this.tbPassword);
|
||||
this.gbox.Controls.Add(this.lbUserName);
|
||||
this.gbox.Controls.Add(this.tbUserName);
|
||||
this.gbox.Cursor = System.Windows.Forms.Cursors.Default;
|
||||
this.gbox.Location = new System.Drawing.Point(80, 30);
|
||||
this.gbox.Name = "gbox";
|
||||
this.gbox.Size = new System.Drawing.Size(551, 246);
|
||||
this.gbox.TabIndex = 7;
|
||||
this.gbox.TabStop = false;
|
||||
this.gbox.Text = "smtp.gmail.com";
|
||||
//
|
||||
// label4
|
||||
// lbContent
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Font = new System.Drawing.Font("Microsoft JhengHei UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.label4.Location = new System.Drawing.Point(360, 19);
|
||||
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(107, 24);
|
||||
this.label4.TabIndex = 9;
|
||||
this.label4.Text = "Site_Name";
|
||||
this.lbContent.AutoSize = true;
|
||||
this.lbContent.Location = new System.Drawing.Point(312, 112);
|
||||
this.lbContent.Name = "lbContent";
|
||||
this.lbContent.Size = new System.Drawing.Size(64, 19);
|
||||
this.lbContent.TabIndex = 16;
|
||||
this.lbContent.Text = "Content";
|
||||
//
|
||||
// tbContent
|
||||
//
|
||||
this.tbContent.Location = new System.Drawing.Point(312, 134);
|
||||
this.tbContent.Name = "tbContent";
|
||||
this.tbContent.Size = new System.Drawing.Size(217, 27);
|
||||
this.tbContent.TabIndex = 15;
|
||||
this.tbContent.Text = "Context Text";
|
||||
//
|
||||
// lbTitle
|
||||
//
|
||||
this.lbTitle.AutoSize = true;
|
||||
this.lbTitle.Location = new System.Drawing.Point(312, 43);
|
||||
this.lbTitle.Name = "lbTitle";
|
||||
this.lbTitle.Size = new System.Drawing.Size(38, 19);
|
||||
this.lbTitle.TabIndex = 14;
|
||||
this.lbTitle.Text = "Title";
|
||||
//
|
||||
// tbTitle
|
||||
//
|
||||
this.tbTitle.Location = new System.Drawing.Point(312, 65);
|
||||
this.tbTitle.Name = "tbTitle";
|
||||
this.tbTitle.Size = new System.Drawing.Size(217, 27);
|
||||
this.tbTitle.TabIndex = 13;
|
||||
this.tbTitle.Text = "Title Test";
|
||||
this.tbTitle.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
|
||||
//
|
||||
// rbNoSSL
|
||||
//
|
||||
this.rbNoSSL.AutoSize = true;
|
||||
this.rbNoSSL.Location = new System.Drawing.Point(170, 209);
|
||||
this.rbNoSSL.Name = "rbNoSSL";
|
||||
this.rbNoSSL.Size = new System.Drawing.Size(101, 23);
|
||||
this.rbNoSSL.TabIndex = 12;
|
||||
this.rbNoSSL.Text = "NoSSL-25";
|
||||
this.rbNoSSL.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// rbSSL
|
||||
//
|
||||
this.rbSSL.AutoSize = true;
|
||||
this.rbSSL.Checked = true;
|
||||
this.rbSSL.Location = new System.Drawing.Point(22, 209);
|
||||
this.rbSSL.Name = "rbSSL";
|
||||
this.rbSSL.Size = new System.Drawing.Size(89, 23);
|
||||
this.rbSSL.TabIndex = 8;
|
||||
this.rbSSL.TabStop = true;
|
||||
this.rbSSL.Text = "SSL-587";
|
||||
this.rbSSL.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lbPort
|
||||
//
|
||||
this.lbPort.AutoSize = true;
|
||||
this.lbPort.Location = new System.Drawing.Point(18, 178);
|
||||
this.lbPort.Name = "lbPort";
|
||||
this.lbPort.Size = new System.Drawing.Size(38, 19);
|
||||
this.lbPort.TabIndex = 11;
|
||||
this.lbPort.Text = "Port";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(18, 112);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(77, 19);
|
||||
this.label1.TabIndex = 9;
|
||||
this.label1.Text = "Password";
|
||||
//
|
||||
// tbPassword
|
||||
//
|
||||
this.tbPassword.Location = new System.Drawing.Point(18, 134);
|
||||
this.tbPassword.Name = "tbPassword";
|
||||
this.tbPassword.Size = new System.Drawing.Size(217, 27);
|
||||
this.tbPassword.TabIndex = 8;
|
||||
this.tbPassword.Text = "qwe2015qwe";
|
||||
//
|
||||
// lbUserName
|
||||
//
|
||||
this.lbUserName.AutoSize = true;
|
||||
this.lbUserName.Location = new System.Drawing.Point(18, 43);
|
||||
this.lbUserName.Name = "lbUserName";
|
||||
this.lbUserName.Size = new System.Drawing.Size(83, 19);
|
||||
this.lbUserName.TabIndex = 7;
|
||||
this.lbUserName.Text = "UserName";
|
||||
//
|
||||
// tbUserName
|
||||
//
|
||||
this.tbUserName.Location = new System.Drawing.Point(18, 65);
|
||||
this.tbUserName.Name = "tbUserName";
|
||||
this.tbUserName.Size = new System.Drawing.Size(217, 27);
|
||||
this.tbUserName.TabIndex = 6;
|
||||
this.tbUserName.Text = "ficgreen01@gmail.com";
|
||||
//
|
||||
// btSendMail
|
||||
//
|
||||
this.btSendMail.Location = new System.Drawing.Point(652, 52);
|
||||
this.btSendMail.Name = "btSendMail";
|
||||
this.btSendMail.Size = new System.Drawing.Size(94, 29);
|
||||
this.btSendMail.TabIndex = 6;
|
||||
this.btSendMail.Text = "Send";
|
||||
this.btSendMail.UseVisualStyleBackColor = true;
|
||||
this.btSendMail.Click += new System.EventHandler(this.btSendMail_Click);
|
||||
//
|
||||
// fmArchive
|
||||
//
|
||||
@ -600,14 +653,13 @@ namespace solarApp
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.tabPage2.ResumeLayout(false);
|
||||
this.splitContainer2.Panel1.ResumeLayout(false);
|
||||
this.splitContainer2.Panel1.PerformLayout();
|
||||
this.splitContainer2.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
|
||||
this.splitContainer2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
|
||||
this.panel2.ResumeLayout(false);
|
||||
this.panel2.PerformLayout();
|
||||
this.gbox.ResumeLayout(false);
|
||||
this.gbox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -639,23 +691,28 @@ namespace solarApp
|
||||
private System.Windows.Forms.Button bt_meter;
|
||||
private System.Windows.Forms.Button bt_rpt_invDay;
|
||||
private System.Windows.Forms.SplitContainer splitContainer2;
|
||||
private System.Windows.Forms.Button button3;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.DateTimePicker dateTimePicker1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
|
||||
private System.Windows.Forms.DateTimePicker dateTimePicker2;
|
||||
private System.Windows.Forms.DataGridView dataGridView2;
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
private System.Windows.Forms.Button button9;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Button bt_invDay;
|
||||
private System.Windows.Forms.DataGridView gv_inv_detail;
|
||||
private System.Windows.Forms.Button bt_updateInstantValue;
|
||||
private System.Windows.Forms.Button bt_sensor_lackData;
|
||||
private System.Windows.Forms.Button bt_lackStation;
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
private System.Windows.Forms.RichTextBox richTextBox1;
|
||||
private System.Windows.Forms.Button btSendMail;
|
||||
private System.Windows.Forms.GroupBox gbox;
|
||||
private System.Windows.Forms.RadioButton rbSSL;
|
||||
private System.Windows.Forms.Label lbPort;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox tbPassword;
|
||||
private System.Windows.Forms.Label lbUserName;
|
||||
private System.Windows.Forms.TextBox tbUserName;
|
||||
private System.Windows.Forms.Label lbTitle;
|
||||
private System.Windows.Forms.TextBox tbTitle;
|
||||
private System.Windows.Forms.RadioButton rbNoSSL;
|
||||
private System.Windows.Forms.Label lbContent;
|
||||
private System.Windows.Forms.TextBox tbContent;
|
||||
private System.Windows.Forms.Label lbReceiver;
|
||||
private System.Windows.Forms.TextBox tbReceiver;
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Net.Mail;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using solarApp.Service;
|
||||
@ -372,15 +374,35 @@ namespace solarApp
|
||||
|
||||
private void bt_sensor_lackData_Click(object sender, EventArgs e)
|
||||
{
|
||||
procSensorSvc sensorSvc = new procSensorSvc();
|
||||
getSensorSvc GetSensor = new getSensorSvc();
|
||||
var ds = GetSensor.get_lack_sensorData(dtSelect1.Value.ToString("yyyy-MM-dd"));
|
||||
//foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
foreach (var item in ds)
|
||||
{
|
||||
sensorSvc.archiveData(item.SITEID, item.TIMESTAMP.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
//procSensorSvc sensorSvc = new procSensorSvc();
|
||||
//getSensorSvc GetSensor = new getSensorSvc();
|
||||
//var ds = GetSensor.get_lack_sensorData(dtSelect1.Value.ToString("yyyy-MM-dd"));
|
||||
////foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
//foreach (var item in ds)
|
||||
//{
|
||||
// sensorSvc.archiveData(item.SITEID, item.TIMESTAMP.ToString("yyyy-MM-dd"));
|
||||
//}
|
||||
|
||||
var site_list = stationSvc.get_station_list();
|
||||
|
||||
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
|
||||
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
|
||||
procSensorSvc sensorSvc = new procSensorSvc();
|
||||
procInvSvc invSvc = new procInvSvc();
|
||||
//procStationSvc siteSvc = new procStationSvc();
|
||||
int i = 0;
|
||||
foreach (var item in site_list)
|
||||
{
|
||||
|
||||
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
{
|
||||
sensorSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
//invSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
//siteSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
invSvc.report_invDay(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
MessageBox.Show("OK");
|
||||
}
|
||||
|
||||
@ -420,5 +442,140 @@ namespace solarApp
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<string> user = new List<string>();
|
||||
user.Add(tbReceiver.Text.Trim());
|
||||
List<string> file = new List<string>();
|
||||
|
||||
var result = Send(user, tbTitle.Text, tbContent.Text, file);
|
||||
|
||||
if (result.CompareTo("成功") == 0)
|
||||
{
|
||||
MessageBox.Show("【SendEmailJob】 寄送成功! ");
|
||||
}
|
||||
}
|
||||
private string Send(List<string> recipientEmails, string subject, string content, List<string> attachments)
|
||||
{
|
||||
var reason = string.Empty;
|
||||
var CanDoSend = true;
|
||||
MailMessage MyMail = new MailMessage();
|
||||
|
||||
MyMail.SubjectEncoding = System.Text.Encoding.UTF8;//郵件標題編碼
|
||||
MyMail.BodyEncoding = System.Text.Encoding.UTF8; //郵件內容編碼
|
||||
MyMail.IsBodyHtml = true; //是否使用html格式
|
||||
var kkk = $"FIC 太陽能電站管理系統通知 <{tbUserName.Text.Trim()}>";
|
||||
MyMail.From = new System.Net.Mail.MailAddress(kkk); //寄件人
|
||||
foreach (var email in recipientEmails)
|
||||
{
|
||||
MyMail.To.Add(email); //設定收件者Email
|
||||
}
|
||||
|
||||
MyMail.Subject = subject; //主題
|
||||
MyMail.Body = content; //設定信件內容
|
||||
|
||||
foreach (var attachment in attachments)
|
||||
{
|
||||
var directoryBase = Directory.GetCurrentDirectory();
|
||||
var filePath = @$"{directoryBase}\wwwroot{attachment}";
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
var data = new Attachment(filePath);
|
||||
MyMail.Attachments.Add(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
CanDoSend = false;
|
||||
reason = "失敗 - 檔案遺失";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//讀取 SMTP Config
|
||||
if (CanDoSend)
|
||||
{
|
||||
SMTPConfig smtp = new SMTPConfig(); ;
|
||||
smtp.Host = "smtp.gmail.com";
|
||||
//smtp.UserName = "ficgreen01@gmail.com";
|
||||
//smtp.Password = "qwe2015qwe";
|
||||
//smtp.UserName = "ficgreen02@gmail.com";
|
||||
//smtp.Password = "qwe20150504qwe";
|
||||
//smtp.UserName = "shanghohui@gmail.com";
|
||||
//smtp.Password = "wswgnluvoodfexrb";
|
||||
//smtp.EnableSsl = true;
|
||||
//smtp.Port = 587;
|
||||
smtp.UserName = tbUserName.Text;
|
||||
smtp.Password = tbPassword.Text;
|
||||
if (rbSSL.Checked)
|
||||
{
|
||||
smtp.EnableSsl = true;
|
||||
smtp.Port = 587;
|
||||
}
|
||||
else
|
||||
{
|
||||
smtp.EnableSsl = false;
|
||||
smtp.Port = 25;
|
||||
}
|
||||
|
||||
SmtpClient MySMTP = new SmtpClient(smtp.Host, smtp.Port);
|
||||
MySMTP.EnableSsl = smtp.EnableSsl;
|
||||
|
||||
MySMTP.Credentials = new System.Net.NetworkCredential(smtp.UserName, smtp.Password);
|
||||
try
|
||||
{
|
||||
MySMTP.Send(MyMail);
|
||||
MySMTP.Dispose();
|
||||
MyMail.Dispose(); //釋放資源
|
||||
//richTextBox1.Text.Insert(0, "成功");
|
||||
return "成功";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(recipientEmails);
|
||||
|
||||
//MessageBox.Show("【SendEmailJob】 " + "寄送信件失敗" + json + " Exception:" + ex.Message);
|
||||
|
||||
return "失敗 - " + ex.Message;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
public class SMTPConfig
|
||||
{
|
||||
public string Host { get; set; }
|
||||
public int Port { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool EnableSsl { get; set; }
|
||||
}
|
||||
|
||||
private void textBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void btSendMail_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<string> user = new List<string>();
|
||||
user.Add(tbReceiver.Text.Trim());
|
||||
List<string> file = new List<string>();
|
||||
|
||||
var result = Send(user, tbTitle.Text, tbContent.Text, file);
|
||||
|
||||
if (result.CompareTo("成功") == 0)
|
||||
{
|
||||
// MessageBox.Show("【SendEmailJob】 寄送成功! ");
|
||||
richTextBox1.AppendText(Environment.NewLine + System.DateTime.Now.ToString() + " " + result.ToString());
|
||||
|
||||
}
|
||||
else {
|
||||
richTextBox1.AppendText(Environment.NewLine + System.DateTime.Now.ToShortTimeString() + " " + result.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user