debug Inv 歸檔超時
This commit is contained in:
parent
d4c5d3f9b0
commit
9ced5c70ab
@ -28,6 +28,8 @@ namespace solarApp
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
//Application.Run(new fmExcel());
|
||||
Application.Run(new fmArchive());
|
||||
|
||||
//Application.Run(new fmTest());
|
||||
//Application.Run(new fmMain());
|
||||
|
||||
Log.CloseAndFlush();
|
||||
|
||||
@ -191,7 +191,14 @@ namespace solarApp.Service
|
||||
WHERE left(crdTime, 10) = @date1;
|
||||
# 2. add index
|
||||
ALTER TABLE del_Inv_day_" + _powerStationID + @"_s1 ADD INDEX `temp_index` (crdTime, inverterid);";
|
||||
int ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
//int ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 180;
|
||||
cmd.Parameters.AddWithValue("@date1", _date1);
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
sql = @"
|
||||
INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
|
||||
@ -253,7 +260,13 @@ namespace solarApp.Service
|
||||
|
||||
|
||||
|
||||
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
//var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
cmd.Parameters.AddWithValue("@date1", _date1);
|
||||
cmd.Parameters.AddWithValue("@PowerStationID", _powerStationID);
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Dispose();
|
||||
|
||||
if (_logger != null)
|
||||
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器15min補償", _siteID, _date1);
|
||||
@ -349,8 +362,15 @@ namespace solarApp.Service
|
||||
from sensor_history_hour
|
||||
where powerstationID = " + _powerStationID + @" and DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d') = @date1
|
||||
)irr on a.reportDate = irr.reportDate; ";
|
||||
int ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
|
||||
//int ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 180;
|
||||
cmd.Parameters.AddWithValue("@date1", _date1);
|
||||
cmd.Parameters.AddWithValue("@PowerStationID", _powerStationID);
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
|
||||
//# 3. insert ans
|
||||
@ -364,12 +384,16 @@ namespace solarApp.Service
|
||||
GROUP BY left(crdTime, 13), inv.INVERTERID
|
||||
) inv_pr
|
||||
ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID;";
|
||||
ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
//ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
if (_logger != null)
|
||||
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||
|
||||
ss = @$"DROP TABLE IF EXISTS del_Inv_day_" + _powerStationID + @"_s1; ";
|
||||
conn.Execute(ss);
|
||||
//conn.Execute(ss);
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
@ -423,7 +447,16 @@ namespace solarApp.Service
|
||||
from sensor_history_day a
|
||||
where powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m-%d') = @date1 and Irradiance <> 0 limit 1
|
||||
)irr on a.reportDate = irr.reportDate ;";
|
||||
conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
// conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 180;
|
||||
cmd.Parameters.AddWithValue("@date1", _date1);
|
||||
cmd.Parameters.AddWithValue("@PowerStationID", _powerStationID);
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
cmd.Dispose();
|
||||
|
||||
if (_logger != null)
|
||||
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器day補償", _siteID, _date1);
|
||||
@ -478,7 +511,15 @@ namespace solarApp.Service
|
||||
from sensor_history_month a
|
||||
where powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m') = @date1 and Irradiance <> 0
|
||||
)irr on a.reportDate = irr.reportDate ;";
|
||||
conn.Execute(sql, new { date1 = _date1.Substring(0, 7), PowerStationID = _powerStationID });
|
||||
//conn.Execute(sql, new { date1 = _date1.Substring(0, 7), PowerStationID = _powerStationID });
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 180;
|
||||
cmd.Parameters.AddWithValue("@date1", _date1.Substring(0, 7));
|
||||
cmd.Parameters.AddWithValue("@PowerStationID", _powerStationID);
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
if (_logger != null)
|
||||
{
|
||||
@ -522,10 +563,9 @@ namespace solarApp.Service
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
string ss = @$"delete from report_invday where powerstationid = {_powerStationID} and left(report_date, 10) = '{_date1}'";
|
||||
conn.Execute(ss);
|
||||
string sql = @$"delete from report_invday where powerstationid = {_powerStationID} and left(report_date, 10) = '{_date1}'";
|
||||
conn.Execute(sql);
|
||||
|
||||
string sql = string.Empty;
|
||||
#region get SQL
|
||||
try
|
||||
{
|
||||
@ -535,7 +575,7 @@ namespace solarApp.Service
|
||||
}
|
||||
|
||||
#region 建立 temp table
|
||||
ss = @$"DROP TABLE IF EXISTS temp_invDay{_powerStationID}_s1;
|
||||
sql = @$"DROP TABLE IF EXISTS temp_invDay{_powerStationID}_s1;
|
||||
CREATE TABLE temp_invDay{_powerStationID}_s1
|
||||
select a.`TIMESTAMP` report_date, a.powerstationId, a.INVERTERID, a.kwh ,
|
||||
round(TODAYKWH, 6) TODAYKWH, round(KWHKWP, 6) KWHKWP, round(PR, 6) PR
|
||||
@ -543,7 +583,12 @@ CREATE TABLE temp_invDay{_powerStationID}_s1
|
||||
WHERE powerstationid = {_powerStationID} and crdDate = '{_date1}';
|
||||
# 2. add index
|
||||
ALTER TABLE `temp_invDay{_powerStationID}_s1` ADD INDEX `temp_indexs1` (report_date, inverterid);";
|
||||
conn.Execute(ss);
|
||||
//conn.Execute(ss);
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 180;
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
#endregion
|
||||
|
||||
#region 先新增 inv_no01
|
||||
@ -572,7 +617,9 @@ from temp_invDay{_powerStationID}_s1 a join
|
||||
where a.inverterid = '{inv01}' # right(a.inverterid, 4) = '0001'
|
||||
GROUP BY left(a.report_date, 13)
|
||||
order by a.report_date ;";
|
||||
conn.Execute(sql);
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
// conn.Execute(sql);
|
||||
#endregion
|
||||
|
||||
#region inv_02 之後的 kwh
|
||||
@ -628,10 +675,15 @@ set a.inv_02 = b.inv_02 ");
|
||||
#region insert report_invDay
|
||||
sb_column.Clear();
|
||||
sql = sb.ToString() + sb_select.ToString() + sb_update_columns.ToString();
|
||||
conn.Execute(sql);
|
||||
|
||||
ss = @$"DROP TABLE IF EXISTS temp_invDay{_powerStationID}_s1; ";
|
||||
conn.Execute(ss);
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
//conn.Execute(sql);
|
||||
|
||||
sql = @$"DROP TABLE IF EXISTS temp_invDay{_powerStationID}_s1; ";
|
||||
//conn.Execute(ss);
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
#endregion
|
||||
|
||||
if (_logger != null)
|
||||
|
||||
73
solarApp/fmTest.Designer.cs
generated
Normal file
73
solarApp/fmTest.Designer.cs
generated
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
namespace solarApp
|
||||
{
|
||||
partial class fmTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(53, 75);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(94, 29);
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "button1";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// richTextBox1
|
||||
//
|
||||
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.richTextBox1.Location = new System.Drawing.Point(313, 0);
|
||||
this.richTextBox1.Name = "richTextBox1";
|
||||
this.richTextBox1.Size = new System.Drawing.Size(701, 643);
|
||||
this.richTextBox1.TabIndex = 1;
|
||||
this.richTextBox1.Text = "";
|
||||
//
|
||||
// fmTest
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1014, 643);
|
||||
this.Controls.Add(this.richTextBox1);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Name = "fmTest";
|
||||
this.Text = "fmTest";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.RichTextBox richTextBox1;
|
||||
}
|
||||
}
|
||||
49
solarApp/fmTest.cs
Normal file
49
solarApp/fmTest.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace solarApp
|
||||
{
|
||||
public partial class fmTest : Form
|
||||
{
|
||||
public fmTest()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
IsProgramInstalled("") ;
|
||||
}
|
||||
|
||||
public bool IsProgramInstalled(string programDisplayName)
|
||||
{
|
||||
|
||||
Console.WriteLine(string.Format("Checking install status of: {0}", programDisplayName));
|
||||
foreach (var item in Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall").GetSubKeyNames())
|
||||
{
|
||||
|
||||
object programName = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + item).GetValue("DisplayName");
|
||||
|
||||
//Console.WriteLine(programName);
|
||||
//if (!string.IsNullOrEmpty(programName.ToString()))
|
||||
if (!(programName == null))
|
||||
{
|
||||
richTextBox1.AppendText(programName.ToString() + Environment.NewLine);
|
||||
if (string.Equals(programName, programDisplayName))
|
||||
{
|
||||
Console.WriteLine("Install status: INSTALLED");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Install status: NOT INSTALLED");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
60
solarApp/fmTest.resx
Normal file
60
solarApp/fmTest.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Loading…
Reference in New Issue
Block a user