From be187bb93a1ffbd5da270b709dca70ec4b020da0 Mon Sep 17 00:00:00 2001 From: cesar liu Date: Mon, 13 Jun 2022 12:18:41 +0800 Subject: [PATCH] =?UTF-8?q?1.debug:=20=E5=85=B1=E7=94=A8=20Sensor=20=20?= =?UTF-8?q?=E7=84=A1=20Value=20=E5=95=8F=E9=A1=8C=202.=20email=20Winform?= =?UTF-8?q?=20=E6=B8=AC=E8=A9=A6=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/wwwroot/upload/company_logo/2.png | Bin 3996 -> 6872 bytes solarApp/Service/procSensorSvc.cs | 2 +- solarApp/fmArchive.Designer.cs | 343 +++++++++++-------- solarApp/fmArchive.cs | 173 +++++++++- 4 files changed, 366 insertions(+), 152 deletions(-) diff --git a/SolarPower/wwwroot/upload/company_logo/2.png b/SolarPower/wwwroot/upload/company_logo/2.png index a25b21f11e5b3524093e2658bf12a5210da89e95..5526549aa8a094adae93f7658d10e4716c342b07 100644 GIT binary patch literal 6872 zcmV;}8Ykt6P)m>g$)=RfaTReelfbKm#qmMq!Wk}S(M#w507gGHWj2RnuY_8|{}Y&K68 zo`-!x!mim}2n!)R30~L-5(o*HgaF21VPinPC0W*C>#(HJNSc}MnV#wCySu91cmJrG zo{>C~tlNfs^*mB*rmDK?)4%#%@2^^Dt$7_P48&Ze`|_2_8m06`Ex1`JHHbL31D(3L z_J1nS=-Ml9JAK;y#7Qp&AQ2So3W;DyM?=A1ndf#|S5z&)l9BZE+KGH&&9Ujs;uG22 zK&Dt~%#@0OY^5SAwgM>-r_dA9`&T0nc<_({3EsA~9YpQ_LTewI@b(iP=-ExhyuT3w z;U8NI2pb0Dg#wM?I{tXW+UFOCf`9UQ0KGC-F5mUySn9UDqsbfgr&8g=lT(ambL8wQ zXfO?lWtd3egOYO?1RxFR0TXlfsij70i4fu>(9#Djg$G*u2!)X7xkG!1Yt(hk@=Ymm zm11~mn*Vb1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rRYfJt7d2@fxFw|#LdQvN zBCe>3QC0x1P#DFTsRXQVAxP6MlrbwZDnnFRCPYmTmpFHcwh*`tSAa_yL=G9!bw(rB z+yGIEVak1AV(f7H85EdrZFMFD(?}D|ah;(|^Qe?@J+j3AO1S3ufAqfbj1=-aJhGtGF!blR3B@!ZNWt&(5r|`BE1TB=I^wLRp3E3^OLRb>^sfA?Z^D1SxEx?08Y793JKtE zZY(Kq!7(f=(uEUb43dVawhI1~jHJvmW~tQ$%2>Egw2(#%q)TaO#ARPvX+gdW&y|YY zAz48Q<*?iaZsrOexj<2->jXr_;bO^^1j7I@3bX(T%B3b07nwm>q%y2bV&De@%gGR@ z?(_XpTTvD%Q;6$GFwjko0l-O_E(pydj)=*P(3YBz>q2KzQkSfih!g2l8EFXMbZCgQ zLQ2pysUj_KE678sktrW(WZ)D6l)BZ|RDTi_ea2d1tm zfeWb&h%fLW=kAL==BAX9&mmZ;xc1iRMJ~`>81o+^g0m~(6Izu30000 ds_sensor = conn.Query(sql, new { siteID = _siteID01 }).AsList(); diff --git a/solarApp/fmArchive.Designer.cs b/solarApp/fmArchive.Designer.cs index 9f08291..2018b04 100644 --- a/solarApp/fmArchive.Designer.cs +++ b/solarApp/fmArchive.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/solarApp/fmArchive.cs b/solarApp/fmArchive.cs index 01929b0..cfc1f33 100644 --- a/solarApp/fmArchive.cs +++ b/solarApp/fmArchive.cs @@ -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 user = new List(); + user.Add(tbReceiver.Text.Trim()); + List file = new List(); + + var result = Send(user, tbTitle.Text, tbContent.Text, file); + + if (result.CompareTo("成功") == 0) + { + MessageBox.Show("【SendEmailJob】 寄送成功! "); + } + } + private string Send(List recipientEmails, string subject, string content, List 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 user = new List(); + user.Add(tbReceiver.Text.Trim()); + List file = new List(); + + 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()); + } + } } }