This commit is contained in:
b110212000 2021-12-20 14:27:17 +08:00
commit 181300a852
17 changed files with 1261 additions and 208 deletions

2
.gitignore vendored
View File

@ -344,3 +344,5 @@ healthchecksdb
/SolarPower/wwwroot/upload/operation_recode/1
/SolarPower/wwwroot/upload/report/20210819
/SolarPower/SolarPower.zip
/SolarPower.zip

View File

@ -21,7 +21,9 @@ namespace SolarPower.Models.PowerStation
EMM = 4, //環境濕度計
VAN = 5, //風速計
FOM = 6, //落塵計
PWR = 7 //電錶
PWR = 7, //電錶
WIN = 8, //風向計
TPY = 9 //累計日照量
}
public class PowerStation : Created
@ -729,6 +731,8 @@ namespace SolarPower.Models.PowerStation
public double Humidity { get; set; } //濕度
public double Vane { get; set; } //風速
public double Dust { get; set; } //落塵計
public double WingDirection { get; set; } //風向計
public double IrrDay { get; set; } //累計日照量
}
public class AvgPyrheliometerHistory

View File

@ -428,7 +428,7 @@ namespace SolarPower.Quartz.Jobs
logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
}
//5. 計算該電站 - 落塵計(FOM)
//6. 計算該電站 - 落塵計(FOM)
try
{
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的落塵計設備資訊】", powerStation.Code, dateTime);
@ -452,6 +452,54 @@ namespace SolarPower.Quartz.Jobs
logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
}
//7. 計算該電站 - 風向計(WIN)
try
{
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的風向計設備資訊】", powerStation.Code, dateTime);
var WINdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, SensorTypeEnum.WIN.ToString(), powerStation.SiteDB);
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的風向計設備資訊】", powerStation.Code, dateTime);
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的風向計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(WINdeviceInfos));
if (WINdeviceInfos != null && WINdeviceInfos.Count() > 0)
{
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的風向計的平均%】", powerStation.Code, dateTime);
var WINHistory = await powerStationRepository.CalcSensorHistoryPerHour(dateTime, WINdeviceInfos, Convert.ToInt32(SensorTypeEnum.WIN));
if (WINHistory != null)
{
sensorHistory.WingDirection = WINHistory.WingDirection;
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的風向計的平均值】", powerStation.Code, dateTime);
}
}
}
catch (Exception ex)
{
logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的風向計的平均值】", powerStation.Code, dateTime);
logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
}
//8. 計算該電站 - 累計日照量(TPY)
try
{
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的累計日照量設備資訊】", powerStation.Code, dateTime);
var TPYdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, SensorTypeEnum.TPY.ToString(), powerStation.SiteDB);
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的累計日照量備資訊】", powerStation.Code, dateTime);
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的累計日照量設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(TPYdeviceInfos));
if (TPYdeviceInfos != null && TPYdeviceInfos.Count() > 0)
{
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的累計日照量的平均%】", powerStation.Code, dateTime);
var TPYHistory = await powerStationRepository.CalcSensorHistoryPerHour(dateTime, TPYdeviceInfos, Convert.ToInt32(SensorTypeEnum.TPY));
if (TPYHistory != null)
{
sensorHistory.IrrDay = TPYHistory.IrrDay;
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的累計日照量的平均值】", powerStation.Code, dateTime);
}
}
}
catch (Exception ex)
{
logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的累計日照量的平均值】", powerStation.Code, dateTime);
logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
}
sensorHistoriesHour.Add(sensorHistory);
}

View File

@ -2523,26 +2523,41 @@ namespace SolarPower.Repository.Implement
{
SensorTypeEnum SensorTypeEnum = (SensorTypeEnum)type;
var typename = "";
var calc = "";
switch (SensorTypeEnum)
{
case SensorTypeEnum.PYR: //日照計
calc = "AVG";
typename = "Irradiance";
break;
case SensorTypeEnum.MTR: //模組溫度計
calc = "AVG";
typename = "Temperature";
break;
case SensorTypeEnum.ETR: //環境溫度計
calc = "AVG";
typename = "EnvTemperature";
break;
case SensorTypeEnum.EMM: //環境濕度計
calc = "AVG";
typename = "Humidity";
break;
case SensorTypeEnum.VAN: //風速計
calc = "AVG";
typename = "Vane";
break;
case SensorTypeEnum.FOM: //落塵計
calc = "AVG";
typename = "Dust";
break;
case SensorTypeEnum.WIN: //風向計
calc = "AVG";
typename = "WingDirection";
break;
case SensorTypeEnum.TPY: //累計日照量
calc = "MAX";
typename = "IrrDay";
break;
}
PyrheliometerHistory result;
@ -2563,7 +2578,7 @@ namespace SolarPower.Repository.Implement
sql_per_device.Add(str);
}
var sql = @$"SELECT a.TIMESTAMP, AVG(a.SENSOR) AS {typename} FROM(" + string.Join(" UNION ", sql_per_device) + @") a GROUP BY `TIMESTAMP`";
var sql = @$"SELECT a.TIMESTAMP, {calc}(a.SENSOR) AS {typename} FROM(" + string.Join(" UNION ", sql_per_device) + @") a GROUP BY `TIMESTAMP`";
result = await conn.QueryFirstOrDefaultAsync<PyrheliometerHistory>(sql, new { DateTime = dateTime });
}

View File

@ -7,7 +7,7 @@
}
},
"LoginExpireMinute": 60, //()
"GoBackDay": 3, //(())
"GoBackDay": 1, //(())
"DBConfig": {
"Server": "MVgHWzR3rGDgD57TUoFunA==",
"port": "r4AoXMUDodcQjIzofGNCcg==",

View File

@ -8,7 +8,7 @@
},
"AllowedHosts": "*",
"LoginExpireMinute": 60, //()
"GoBackDay": 3, //(())
"GoBackDay": 1, //(())
"mySql": "server=60.251.164.103;user=webuser;Database=solar_master;Port=11306;password=FICadmin99;charset='utf8';pooling=true;sslmode=none;",
//"DBConfig": {
// "Server": "MVgHWzR3rGDgD57TUoFunA==",

View File

@ -2,7 +2,7 @@
<configuration>
<connectionStrings>
<add name="mySql" connectionString="server=60.251.164.103;user=webuser;Database=solar_master;Port=11306;password=FICadmin99;charset='utf8';pooling=true;sslmode=none;" providerName="MySql.Data.MySqlClient" />
<add name="mySql" connectionString="server=60.251.164.103;user=webuser;Database=solar_master;Port=11306;password=FICadmin99;charset='utf8';pooling=true;sslmode=none;;Connection Timeout=6000" providerName="MySql.Data.MySqlClient" />
<!--<add name="mySql" connectionString="server=localhost;user=root;Database=solar_master;Port=3306;password=zxcvb123;charset='utf8';pooling=true;sslmode=none;" providerName="MySql.Data.MySqlClient" />-->
<!-- kai -->
<!--<add name="mySql" connectionString="server=210.61.91.43;port=10068;user=idafenweb;Database=solar_power_test;Port=3306;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;" providerName="MySql.Data.MySqlClient" />-->

View File

@ -124,4 +124,159 @@ namespace solarApp.Model
public string date { get; set; }
public string count { get; set; }
}
public class ck_inv_day
{
public int PowerStationId { get; set; }
public string station_code { get; set; }
public string station_name { get; set; }
public int dataRows_A { get; set; }
public int invCT_B { get; set; }
public double AdivB_C { get; set; }
public int periodDay_B { get; set; }
public double CsubstrctionB { get; set; }
}
public class ck_inv_day_detail1
{
public int PowerStationId { get; set; }
public string inverterid { get; set; }
public double todaykWh { get; set; }
public int RowCT { get; set; }
}
public class ck_inv_day_detail2
{
public int PowerStationId { get; set; }
public string crdDate { get; set; }
public string inverterid { get; set; }
public double kwh { get; set; }
public double todaykWh { get; set; }
public double pr { get; set; }
}
public class station_inv_list
{
public int PowerStationId { get; set; }
public string station_name { get; set; }
public string inverterid { get; set; }
public string station_code { get; set; }
}
public class report_inv_resualt
{
public string report_date { get; set; }
public int PowerStationId { get; set; }
public string inv_01 { get; set; }
public string inv_02 { get; set; }
public string inv_03 { get; set; }
public string inv_04 { get; set; }
public string inv_05 { get; set; }
public string inv_06 { get; set; }
public string inv_07 { get; set; }
public string inv_08 { get; set; }
public string inv_09 { get; set; }
public string inv_10 { get; set; }
public string inv_11 { get; set; }
public string inv_12 { get; set; }
public string inv_13 { get; set; }
public string inv_14 { get; set; }
public string inv_15 { get; set; }
public string inv_16 { get; set; }
public string inv_17 { get; set; }
public string inv_18 { get; set; }
public string inv_19 { get; set; }
public string inv_20 { get; set; }
public string inv_21 { get; set; }
public string inv_22 { get; set; }
public string inv_23 { get; set; }
public string inv_24 { get; set; }
public string inv_25 { get; set; }
public string inv_26 { get; set; }
public string inv_27 { get; set; }
public string inv_28 { get; set; }
public string inv_29 { get; set; }
public string inv_30 { get; set; }
public string inv_31 { get; set; }
public string inv_32 { get; set; }
public string inv_33 { get; set; }
public string inv_34 { get; set; }
public string inv_35 { get; set; }
public string inv_36 { get; set; }
public string inv_37 { get; set; }
public string inv_38 { get; set; }
public string inv_39 { get; set; }
public string inv_40 { get; set; }
public string inv_41 { get; set; }
public string inv_42 { get; set; }
public string inv_43 { get; set; }
public string inv_44 { get; set; }
public string inv_45 { get; set; }
public string inv_46 { get; set; }
public string inv_47 { get; set; }
public string inv_48 { get; set; }
public string inv_49 { get; set; }
public string inv_50 { get; set; }
public string inv_51 { get; set; }
public string inv_52 { get; set; }
public string inv_53 { get; set; }
public string inv_54 { get; set; }
public string inv_55 { get; set; }
public string inv_56 { get; set; }
public string inv_57 { get; set; }
public string inv_58 { get; set; }
public string inv_59 { get; set; }
public string inv_60 { get; set; }
public string inv_61 { get; set; }
public string inv_62 { get; set; }
public string inv_63 { get; set; }
public string inv_64 { get; set; }
public string inv_65 { get; set; }
public string inv_66 { get; set; }
public string inv_67 { get; set; }
public string inv_68 { get; set; }
public string inv_69 { get; set; }
public string inv_70 { get; set; }
public string inv_71 { get; set; }
public string inv_72 { get; set; }
public string inv_73 { get; set; }
public string inv_74 { get; set; }
public string inv_75 { get; set; }
public string inv_76 { get; set; }
public string inv_77 { get; set; }
public string inv_78 { get; set; }
public string inv_79 { get; set; }
public string inv_80 { get; set; }
public string inv_81 { get; set; }
public string inv_82 { get; set; }
public string inv_83 { get; set; }
public string inv_84 { get; set; }
public string inv_85 { get; set; }
public string inv_86 { get; set; }
public string inv_87 { get; set; }
public string inv_88 { get; set; }
public string inv_89 { get; set; }
public string inv_90 { get; set; }
public string inv_91 { get; set; }
public string inv_92 { get; set; }
public string inv_93 { get; set; }
public string inv_94 { get; set; }
public string inv_95 { get; set; }
public string inv_96 { get; set; }
public string inv_97 { get; set; }
public string inv_98 { get; set; }
public string inv_99 { get; set; }
public string inv_100 { get; set; }
public double hourKWH { get; set; }
public double hourKWHp { get; set; }
public double irradiance { get; set; }
public double temperature { get; set; }
public double hourmoney { get; set; }
public double totKWH { get; set; }
public double totKWHKWP { get; set; }
public double totmoney { get; set; }
public double daymoney { get; set; }
public double tothour { get; set; }
public double pr { get; set; }
}
}

View File

@ -74,8 +74,9 @@ namespace solarApp.Service
int i = 0;
foreach (DataRow row in dt.Rows)
{
//ss.Append(@"INSERT INTO solar_import.auo_taiping(`No.`, `雲端收到時間`, `資料取得時間`, `交流電壓`, `交流電流`, `交流功率`, `溫度`, `累積發電量`, `頻率`, `狀態`, saveDate, filename, inverterID)
ss.Append(@"INSERT INTO solar_import.auo_aimai(`No.`, `雲端收到時間`, `資料取得時間`, `交流電壓`, `交流電流`, `交流功率`, `溫度`, `累積發電量`, `頻率`, `狀態`, saveDate, filename, inverterID)
//ss.Append(@"INSERT INTO solar_import.auo_taiping_October(`No.`, `雲端收到時間`, `資料取得時間`, `交流電壓`, `交流電流`, `交流功率`, `溫度`, `累積發電量`, `頻率`, `狀態`, saveDate, filename, inverterID)
//ss.Append(@"INSERT INTO solar_import.auo_aimai(`No.`, `雲端收到時間`, `資料取得時間`, `交流電壓`, `交流電流`, `交流功率`, `溫度`, `累積發電量`, `頻率`, `狀態`, saveDate, filename, inverterID)
ss.Append(@"INSERT INTO solar_import.auo_aimai_october(`No.`, `雲端收到時間`, `資料取得時間`, `交流電壓`, `交流電流`, `交流功率`, `溫度`, `累積發電量`, `頻率`, `狀態`, saveDate, filename, inverterID)
values( '"
+ row.Field<string>("1").ToString() + "' ,'"
+ row.Field<string>("2").ToString() + "' ,'"
@ -202,7 +203,7 @@ values( '"
return result;
}
public bool insert_dailyReport2DB(DataTable dt, string filename)
public bool insert_dailyReport2DB(DataTable dt, string filename, string tablename)
{
bool result = false;
StringBuilder ss = new StringBuilder();
@ -211,9 +212,9 @@ values( '"
conn.Open();
int i = 0;
foreach (DataRow row in dt.Rows)
{
//ss.Append(@"INSERT INTO solar_import.auo_taiping(`No.`, `雲端收到時間`, `資料取得時間`, `交流電壓`, `交流電流`, `交流功率`, `溫度`, `累積發電量`, `頻率`, `狀態`, saveDate, filename, inverterID)
ss.Append(@"INSERT INTO solar_import.iPVita_temp (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, insertDate)
{ //c10, c11, c12, c13, c14, c15, c16,
//iPVita_temp ss.Append(@"INSERT INTO solar_import.auo_taiping(`No.`, `雲端收到時間`, `資料取得時間`, `交流電壓`, `交流電流`, `交流功率`, `溫度`, `累積發電量`, `頻率`, `狀態`, saveDate, filename, inverterID)
ss.Append(@"INSERT INTO solar_import."+ tablename + @"(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13 , c14, c15, c16, insertDate)
values( '"
+ row.Field<string>("1").ToString() + "' ,'"
+ row.Field<string>("2").ToString() + "' ,'"
@ -229,9 +230,8 @@ values( '"
+ row.Field<string>("12").ToString() + "' ,'"
+ row.Field<string>("13").ToString() + "' ,'"
+ row.Field<string>("14").ToString() + "' ,'"
+ row.Field<string>("15").ToString() + "', '"
+ row.Field<string>("15").ToString() + "', '"
+ row.Field<string>("Column1").ToString() + "', now());");
if (i % 10 == 0)
{
conn.Execute(ss.ToString());

View File

@ -101,8 +101,11 @@ namespace solarApp.Service
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
conn.Open();
//string sql = @"select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H:%i') reportdate, inverterid, KWH, TODAYKWH, TOTALKWH, round(PR, 2) PR
// from inverter_history_hour where left(`TIMESTAMP`, 10) = '" + reportDate + "' and inverterid = '" + invID + "' ";
string sql = @"select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H:%i') reportdate, inverterid, KWH, TODAYKWH, TOTALKWH, round(PR, 2) PR
from inverter_history_hour where left(`TIMESTAMP`, 10) = '" + reportDate + "' and inverterid = '" + invID + "' ";
from inverter_history_hour where crdDate = '" + reportDate + "' and inverterid = '" + invID + "' ";
List<web_inv_hour> ds = conn.Query<web_inv_hour>(sql).AsList<web_inv_hour>();
conn.Close();
return ds;
@ -122,11 +125,11 @@ select DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') reportdate, a.inverterid, round(a.K
from inverter_history_day a left join (
select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') reportdate, inverterid, count(*) count
from inverter_history_hour
where left(`TIMESTAMP`, 10) between '" + date1 + "' and '" + date2 + @"' and inverterid = '" + invID + @"'
where crdDate between '" + date1 + "' and '" + date2 + @"' and inverterid = '" + invID + @"'
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), inverterid
) b on a.inverterid = b.inverterid and DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') = b.reportdate
where left(a.`TIMESTAMP`, 10) between '" + date1 + "' and '" + date2 + "' and a.inverterid = '" + invID + "' order by 1";
where crdDate between '" + date1 + "' and '" + date2 + "' and a.inverterid = '" + invID + "' order by 1";
List<web_inv_hour> ds = conn.Query<web_inv_hour>(sql).AsList<web_inv_hour>();
conn.Close();
return ds;
@ -163,5 +166,69 @@ where left(a.`TIMESTAMP`, 10) between '" + date1 + "' and '" + date2 + "' and a.
return ds;
}
}
/// <summary>
/// 總計每天應有數據, inv hour --> day
/// </summary>
/// <param name="siteDB"></param>
/// <param name="siteID"></param>
/// <returns></returns>
public List<ck_inv_day> get_ck_invDay_list(string date1, string date2)
{
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
conn.Open();
string sql = @$"select PowerStationId, station_code, station_name, dataRows as dataRows_A, invCT as invCT_B, periodCT AdivB_C, periodDay periodDay_B, (periodCT - periodDay) CsubstrctionB from
(
select a.PowerStationId, station_code, station_name, b.ct dataRows, a.ct invCT, ifnull(round((b.ct / a.ct), 2), 0) periodCT, (DATEDIFF('{date2}' , '{date1}') + 1) periodDay
from
( -- inv
select b.id PowerStationId, b.`name` station_name, left(inverterid, 11) station_code, count(*) ct
from v_company_inv a join power_station b on left(a.inverterid, 9) = b.`code`
where b.Deleted = 0 and a.`enabled` = 1 and b.`status` = 1 #
group by left(inverterid, 11)
) a left outer join
(
select PowerStationId , left(crddate, 7) crddate , a.inverterid, round(a.TODAYKWH, 2) todaykWh, count(*) ct
from inverter_history_day a
where a.crddate between '{date1}' and '{date2}'
group by a.PowerStationId , left(crddate, 7)
)b on a.PowerStationId = b.PowerStationId
)x ";
List<ck_inv_day> ds = conn.Query<ck_inv_day>(sql).AsList<ck_inv_day>();
conn.Close();
return ds;
}
}
public List<ck_inv_day_detail1> get_ck_invDay_detail1(string powerstationID, string date1, string date2)
{
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
conn.Open();
string sql = @$"select PowerStationId , a.inverterid, round(avg(a.TODAYKWH), 2) todaykWh, count(*) RowCT
from inverter_history_day a
where PowerStationId = '{powerstationID}' and a.crddate between '{date1}' and '{date2}'
group by a.PowerStationId , inverterid ";
List<ck_inv_day_detail1> ds = conn.Query<ck_inv_day_detail1>(sql).AsList<ck_inv_day_detail1>();
conn.Close();
return ds;
}
}
public List<ck_inv_day_detail2> get_ck_invDay_detail2(string inverterid, string date1, string date2)
{
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
conn.Open();
string sql = @$"select a.PowerStationId, left(crddate, 10) crdDate , a.inverterid, round(a.kwh, 2) kwh, round(a.TODAYKWH, 2) todaykWh, round(a.pr, 2) pr
from inverter_history_day a
where inverterid = '{inverterid}' and a.crddate between '{date1}' and '{date2}'
";
List<ck_inv_day_detail2> ds = conn.Query<ck_inv_day_detail2>(sql).AsList<ck_inv_day_detail2>();
conn.Close();
return ds;
}
}
}
}

View File

@ -81,20 +81,24 @@ namespace solarApp.Service
// { "Name":"環境濕度計","EName":"EMM"},
// { "Name":"風速計","EName":"VAN"},
// { "Name":" 電表","EName":"PWR"}]}
// { "Name":" 累計日照量","EName":"TPY"}]}
var irrlst = ds_sensor.FindAll(x => x.type.Contains("PYR"));
var modelTemplst = ds_sensor.FindAll(x => x.type.Contains("MTR"));
var envTemplst = ds_sensor.FindAll(x => x.type.Contains("ETR"));
var humlst = ds_sensor.FindAll(x => x.type.Contains("EMM"));
var windlst = ds_sensor.FindAll(x => x.type.Contains("VAN"));
var dustlst = ds_sensor.FindAll(x => x.type.Contains("DST")); //需要新增於DB
var totIrrlst = ds_sensor.FindAll(x => x.type.Contains("TPY")); //累計日照量
//var meterlst = ds_sensor.FindAll(x => x.type.Contains("PWR")); 電錶暫不處理
string irrCol = string.Empty; string modelTempCol = string.Empty; string evnTempCol = string.Empty; string humCol = string.Empty; string windCol = string.Empty; string meterCol = string.Empty; string dustCol = string.Empty;
string irrCol = string.Empty; string modelTempCol = string.Empty; string evnTempCol = string.Empty; string humCol = string.Empty; string windCol = string.Empty; string meterCol = string.Empty; string dustCol = string.Empty; string totIrrCol = string.Empty;
irrCol = ConcatColumn(irrlst);//日照計
modelTempCol = ConcatColumn(modelTemplst);
evnTempCol = ConcatColumn(envTemplst);
humCol = ConcatColumn(humlst);
windCol = ConcatColumn(windlst);
dustCol = ConcatColumn(dustlst);
totIrrCol = ConcatColumn(totIrrlst);
string irrNot0 = string.Empty; // and 日照1 <> 0 and 日照2 <> 0
# region 0

View File

@ -15,6 +15,7 @@ namespace solarApp.Service
string Connection1 = string.Empty;
ILogger _logger;
public procInvSvc(string Connection_parame = null, ILogger logger = null)
{
if (!string.IsNullOrEmpty(Connection_parame))
@ -54,10 +55,15 @@ namespace solarApp.Service
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器清除資料表的資料", _siteID, _date1);
}
//string sql = @"
// delete from inverter_history_15min where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
// delete from inverter_history_hour where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
// delete from inverter_history_day where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
// delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;";
string sql = @"
delete from inverter_history_15min where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
delete from inverter_history_hour where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
delete from inverter_history_day where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
delete from inverter_history_15min where powerstationID = @powerStationID and CrdDate = @date1;
delete from inverter_history_hour where powerstationID = @powerStationID and CrdDate = @date1;
delete from inverter_history_day where powerstationID = @powerStationID and CrdDate = @date1;
delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;";
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
@ -85,21 +91,33 @@ namespace solarApp.Service
public bool archiveData(string siteID, string date1)
{
bool result = false;
try
{
_siteID = siteID;
_date1 = date1;
get_siteInfo();
clearData();
insert_inv();
result = true;
}
catch (Exception ex)
{
throw ex;
}
_siteID = siteID;
_date1 = date1;
get_siteInfo();
clearData();
insert_inv();
//日報表
insert_report_invDay(); //get_ck_invDay_list
return result;
}
public bool report_invDay(string siteID, string date1)
{
bool result = false;
_siteID = siteID;
_date1 = date1;
get_siteInfo();
//日報表
insert_report_invDay(); //get_ck_invDay_list
result = true;
return result;
}
public bool get_siteInfo()
{
bool result = false;
@ -150,8 +168,8 @@ namespace solarApp.Service
bool insert_inv()
{
bool result = false;
try
{
//try
//{
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
conn.Open();
@ -168,44 +186,76 @@ namespace solarApp.Service
}
sql = @"
INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
(
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
(
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
from " + _siteDB + ".s" + _siteID01 + @"_inv
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '00' and '10'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
union
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':15:00')reportdate, inverterid,
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
from " + _siteDB + ".s" + _siteID01 + @"_inv
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
union
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':30:00')reportdate, inverterid,
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
from " + _siteDB + ".s" + _siteID01 + @"_inv
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
union
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':45:00')reportdate, inverterid,
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
from " + _siteDB + ".s" + _siteID01 + @"_inv
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '00' and '10'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
union
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':15:00')reportdate, inverterid,
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
from " + _siteDB + ".s" + _siteID01 + @"_inv
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
union
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':30:00')reportdate, inverterid,
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
from " + _siteDB + ".s" + _siteID01 + @"_inv
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
union
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':45:00')reportdate, inverterid,
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
from " + _siteDB + ".s" + _siteID01 + @"_inv
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '45' and '55'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
from " + _siteDB + ".s" + _siteID01 + @"_inv
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '45' and '55'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
// sql = @"
// INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
// select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
// (
//select @PowerStationId PowerStationId,CONCAT(left(CrdTime, 13), '%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where left(CrdTime, 10) = @date1 and CONCAT(left(CrdTime, 13), '%Y-%m-%d %H:%i') , 2) between '00' and '10'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// union
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':15:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where left(CrdTime, 10) = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// union
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':30:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where left(CrdTime, 10) = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// union
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':45:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where left(CrdTime, 10) = @date1 and MINUTE(CrdTime) between '45' and '55'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// ) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
if (_logger != null)
{
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器15min補償", _siteID, _date1);
}
}
catch (Exception ex)
{
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償", _siteID, _date1);
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償 - [Exception]{2}", _siteID, _date1, ex.ToString());
if (_logger != null)
{
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償", _siteID, _date1);
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償 - [Exception]{2}", _siteID, _date1, ex.ToString());
}
throw ex;
}
#endregion
@ -214,63 +264,112 @@ namespace solarApp.Service
try
{
if (_logger != null)
{
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器hour補償", _siteID, _date1);
}
sql = @"
insert into solar_master.inverter_history_hour (PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
AC3V, AC3A, AC3W, AC3F, AC3WH, DC1V, DC1A, DC1W, DC1WH, DC2V, DC2A, DC2W, DC2WH, DC3V, DC3A, DC3W, DC3WH, DC4V, DC4A, DC4W, DC4WH, DC5V, DC5A, DC5W, DC5WH,
PR, RA1, RA2, RA3, RA4, RA5, DCKW, ACKW, KWH, TODAYKWH, TOTALKWH, KWHKWP)
//sql = @"
// insert into solar_master.inverter_history_hour (PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
// AC3V, AC3A, AC3W, AC3F, AC3WH, DC1V, DC1A, DC1W, DC1WH, DC2V, DC2A, DC2W, DC2WH, DC3V, DC3A, DC3W, DC3WH, DC4V, DC4A, DC4W, DC4WH, DC5V, DC5A, DC5W, DC5WH,
// PR, RA1, RA2, RA3, RA4, RA5, DCKW, ACKW, KWH, TODAYKWH, TOTALKWH, KWHKWP)
SELECT @powerstationID powerStationID, a.INVERTERID, a.reportDate, IFNULL(Irradiance, 0), a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH,
inv_pr.PR, a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, ((DC1W + DC2W + DC3W + DC4W+ DC5W) / 1000) DCKW,
((AC1W + AC2W + AC3W) / 1000) ACKW, a.KWH, a.TODAYKWH, a.TOTALKWH, (a.KWH / i.Capacity) AS KWHKWP
from
( -- KWH
SELECT concat(FROM_UNIXTIME(a.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') reportDate, a.INVERTERID,
AVG(a.AC1V) AS AC1V, AVG(a.AC1A) AS AC1A, round(SUM(a.AC1W), 5) AS AC1W, AVG(a.AC1F) AS AC1F, SUM(a.AC1WH) AS AC1WH, AVG(a.AC2V) AS AC2V,
AVG(a.AC2A) AS AC2A, round(SUM(a.AC2W), 5) AS AC2W, AVG(a.AC2F) AS AC2F, SUM(a.AC2WH) AS AC2WH,AVG(a.AC3V) AS AC3V, AVG(a.AC3A) AS AC3A,
round(SUM(a.AC3W),5) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W,
SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V,
AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W,
SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH,
AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3,
AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, MAX(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, (SUM(a.WH)/1000) AS KWH
FROM " + _siteDB + ".s" + _siteID01 + @"_inv a
WHERE left(FROM_UNIXTIME(a.TIMESTAMP / 1000, '%Y-%m-%d'), 10) = @date1
GROUP BY left(FROM_UNIXTIME(a.TIMESTAMP/ 1000, '%Y-%m-%d %H'), 13), a.INVERTERID
) a
LEFT JOIN( -- PR
SELECT concat(FROM_UNIXTIME(inv.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') AS reportDate, inv.INVERTERID, inv.PR
FROM " + _siteDB + ".s" + _siteID01 + @"_inv inv
WHERE left(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 10) = @date1
and right(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 2) = '55'
GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/ 1000, '%Y-%m-%d %H'), inv.INVERTERID
) inv_pr
ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID
--
LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
-- ---------------------
left join (
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H'), ':00:00') AS reportDate, Irradiance
from sensor_history_hour a
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
)irr on a.reportDate = irr.reportDate
order by a.INVERTERID, a.reportDate;";
int ct = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
// SELECT @powerstationID powerStationID, a.INVERTERID, a.reportDate, IFNULL(Irradiance, 0), a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
// a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
// a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH,
// inv_pr.PR, a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, ((DC1W + DC2W + DC3W + DC4W+ DC5W) / 1000) DCKW,
// ((AC1W + AC2W + AC3W) / 1000) ACKW, a.KWH, a.TODAYKWH, a.TOTALKWH, (a.KWH / i.Capacity) AS KWHKWP
// from
// ( -- 取得該時間區間的KWH
// SELECT concat(FROM_UNIXTIME(a.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') reportDate, a.INVERTERID,
// AVG(a.AC1V) AS AC1V, AVG(a.AC1A) AS AC1A, round(SUM(a.AC1W), 5) AS AC1W, AVG(a.AC1F) AS AC1F, SUM(a.AC1WH) AS AC1WH, AVG(a.AC2V) AS AC2V,
// AVG(a.AC2A) AS AC2A, round(SUM(a.AC2W), 5) AS AC2W, AVG(a.AC2F) AS AC2F, SUM(a.AC2WH) AS AC2WH,AVG(a.AC3V) AS AC3V, AVG(a.AC3A) AS AC3A,
// round(SUM(a.AC3W),5) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W,
// SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V,
// AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W,
// SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH,
// AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3,
// AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, MAX(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, (SUM(a.WH)/1000) AS KWH
// FROM " + _siteDB + ".s" + _siteID01 + @"_inv a
// WHERE left(FROM_UNIXTIME(a.TIMESTAMP / 1000, '%Y-%m-%d'), 10) = @date1
// GROUP BY left(FROM_UNIXTIME(a.TIMESTAMP/ 1000, '%Y-%m-%d %H'), 13), a.INVERTERID
// ) a
// LEFT JOIN( -- 取得整點值PR
// SELECT concat(FROM_UNIXTIME(inv.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') AS reportDate, inv.INVERTERID, inv.PR
// FROM " + _siteDB + ".s" + _siteID01 + @"_inv inv
// WHERE left(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 10) = @date1
// and right(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 2) = '55'
// GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/ 1000, '%Y-%m-%d %H'), inv.INVERTERID
// ) inv_pr
// ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID
// -- 取得逆變器容量
// LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
// -- 取日照度 ---------------------
// left join (
// select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H'), ':00:00') AS reportDate, Irradiance
// from sensor_history_hour a
// where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
// )irr on a.reportDate = irr.reportDate
// order by a.INVERTERID, a.reportDate;";
//int ct = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
if (_logger != null)
{
sql = @$"DROP TEMPORARY TABLE IF EXISTS Inv_day_"+ _powerStationID + @"_s1;
CREATE TEMPORARY TABLE Inv_day_" + _powerStationID + @"_s1
select * from " + _siteDB + ".s" + _siteID01 + @"_inv a
WHERE left(crdTime, 10) = @date1;
# 2. add index
ALTER TABLE Inv_day_" + _powerStationID + @"_s1 ADD INDEX `temp_index` (crdTime, inverterid);";
int ct = conn.Execute(sql, new { date1 = _date1});
sql = @$"DROP TEMPORARY TABLE IF EXISTS Inv_day_" + _powerStationID + @"_s2;
CREATE TEMPORARY TABLE Inv_day_" + _powerStationID + @"_s2
SELECT " + _powerStationID + @" powerStationID, a.INVERTERID, a.reportDate,a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH,
a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, a.KWH, a.TODAYKWH, a.TOTALKWH,
IFNULL(Irradiance, 0) irr, 0 as PR, ((DC1W + DC2W + DC3W + DC4W + DC5W) / 1000) DCKW, ((AC1W + AC2W + AC3W) / 1000) ACKW, (a.KWH / i.Capacity) AS KWHKWP
from
(-- KWH
SELECT concat(left(crdTime, 13), ':00:00') reportDate, INVERTERID,
AVG(AC1V) AS AC1V, AVG(AC1A) AS AC1A, round(SUM(AC1W), 5) AS AC1W, AVG(AC1F) AS AC1F, SUM(AC1WH) AS AC1WH, AVG(AC2V) AS AC2V,
AVG(AC2A) AS AC2A, round(SUM(AC2W), 5) AS AC2W, AVG(AC2F) AS AC2F, SUM(AC2WH) AS AC2WH, AVG(AC3V) AS AC3V, AVG(AC3A) AS AC3A,
round(SUM(AC3W), 5) AS AC3W, AVG(AC3F) AS AC3F, SUM(AC3WH) AS AC3WH, AVG(DC1V) AS DC1V, AVG(DC1A) AS DC1A, SUM(DC1W) AS DC1W,
SUM(DC1WH) AS DC1WH, AVG(DC2V) AS DC2V, AVG(DC2A) AS DC2A, SUM(DC2W) AS DC2W, SUM(DC2WH) AS DC2WH, AVG(DC3V) AS DC3V,
AVG(DC3A) AS DC3A, AVG(DC3W) AS DC3W, AVG(DC3WH) AS DC3WH, AVG(DC4V) AS DC4V, AVG(DC4A) AS DC4A, SUM(DC4W) AS DC4W,
SUM(DC4WH) AS DC4WH, AVG(DC5V) AS DC5V, AVG(DC5A) AS DC5A, SUM(DC5W) AS DC5W, SUM(DC5WH) AS DC5WH,
AVG(RA1) AS RA1, AVG(RA2) AS RA2, AVG(RA3) AS RA3,
AVG(RA4) AS RA4, AVG(RA5) AS RA5, MAX(TODAYKWH) AS TODAYKWH, MAX(TOTALKWH) AS TOTALKWH, (SUM(WH) / 1000) AS KWH
FROM Inv_day_" + _powerStationID + @"_s1
GROUP BY left(crdTime, 13), INVERTERID
) a
--
LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
-- -------------------- -
left join(
select concat(DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d %H'), ':00:00') AS reportDate, Irradiance
from sensor_history_hour
where powerstationID = " + _powerStationID + @" and DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d') = @date1
)irr on a.reportDate = irr.reportDate; ";
ct = conn.Execute(sql, new { date1 = _date1 });
//# 3. insert ans
sql = @$"
INSERT INTO solar_master.inverter_history_hour(`powerStationID`, `INVERTERID`, `TIMESTAMP`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `KWH`, `TODAYKWH`, `TOTALKWH`, `Irradiance`, `PR`, `DCKW`, `ACKW`, `KWHKWP`)
select `powerStationID`, a.`INVERTERID`, a.`reportDate`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `KWH`, `TODAYKWH`, `TOTALKWH`, `irr`, inv_pr.`PR`, `DCKW`, `ACKW`, `KWHKWP`
from Inv_day_" + _powerStationID + @"_s2 a left JOIN( -- PR
SELECT concat(left(crdTime, 13), ':00:00') AS reportDate, inv.INVERTERID, inv.PR
FROM Inv_day_" + _powerStationID + @"_s1 inv
WHERE minute(crdtime) = '55'
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 });
if (_logger != null)
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器hour補償", _siteID, _date1);
}
}
catch (Exception ex)
{
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器hour補償", _siteID, _date1);
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器hour補償 - [Exception]{2}", _siteID, _date1, ex.ToString());
if (_logger != null)
{
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器hour補償", _siteID, _date1);
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器hour補償 - [Exception]{2}", _siteID, _date1, ex.ToString());
}
throw ex;
}
@ -318,14 +417,15 @@ namespace solarApp.Service
conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
if (_logger != null)
{
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器day補償", _siteID, _date1);
}
}
catch (Exception ex)
{
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器day補償", _siteID, _date1);
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器day補償 - [Exception]{2}", _siteID, _date1, ex.ToString());
if (_logger != null)
{
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器day補償", _siteID, _date1);
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器day補償 - [Exception]{2}", _siteID, _date1, ex.ToString());
}
throw ex;
}
#endregion day
@ -334,9 +434,7 @@ namespace solarApp.Service
try
{
if (_logger != null)
{
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器month補償", _siteID, _date1);
}
sql = @"
delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;
@ -380,8 +478,11 @@ namespace solarApp.Service
}
catch (Exception ex)
{
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器month補償", _siteID, _date1);
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器month補償 - [Exception]{2}", _siteID, _date1, ex.ToString());
if (_logger != null)
{
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器month補償", _siteID, _date1);
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器month補償 - [Exception]{2}", _siteID, _date1, ex.ToString());
}
throw ex;
}
@ -390,11 +491,159 @@ namespace solarApp.Service
conn.Close();
}
result = true;
}
catch (Exception ex)
//}
//catch (Exception ex)
//{
// throw ex;
//}
return result;
}
void ck_empty_archivedData(string siteID, string date1)
{
_siteID = siteID;
_date1 = date1;
get_siteInfo();
}
//建立日報表
bool insert_report_invDay() {
bool result = false;
using (MySqlConnection conn = new MySqlConnection(Connection1))
{
throw ex;
conn.Open();
string ss = @$"delete from report_invday where powerstationid = {_powerStationID} and left(report_date, 10) = '{_date1}'";
conn.Execute(ss);
string sql = string.Empty;
#region get SQL
try
{
if (_logger != null)
{
_logger.LogInformation("【Proc_inv_日報 】開始執行[{0}]在{1}inv_get_SQLStatement", _siteID, _date1);
}
#region temp table
ss = @$"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
from solar_master.inverter_history_hour a
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);
#endregion
#region inv_no01
sql = @$"
insert report_invday(`report_date`, `PowerStationID`, inv_01, `hourKWH`, `hourKWHp`, `irradiance`, `temperature`, `hourmoney`, `pr`, createTime)
select a.report_date, a.powerstationId , ifnull(round(a.kwh, 6), 0) inv_01, ifnull(b.KWH, 0) hourKWH,
ifnull(round((b.KWH / (SELECT MAX(TODAYKWH) FROM power_station_history_hour
WHERE DATE_FORMAT(TIMESTAMP,'%Y-%m-%d') = '{_date1}' and powerstationid = {_powerStationID} ))*100,2)
, 0) 'hourKWHp', ifnull(d.irradiance, 0) 'irradiance', ifnull(d.Temperature, 0) 'temperature',
ifnull(b.money, 0) 'hourmoney', ifnull(round(b.PR, 2), 0) as pr, now() createTime
from temp_invDay{_powerStationID}_s1 a left join
( # inv
select powerStationid, `TIMESTAMP` report_date, siteid, sitetype, round(KWH, 2) KWH,
round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, round(money, 2) money
from power_station_history_hour
where powerstationid = {_powerStationID} and left(`TIMESTAMP`,10) = '{_date1}'
) b on a.powerStationid = b.powerStationid and a.`report_date` = b.report_date
left join
(
select powerStationID, `TIMESTAMP` report_date, irradiance, Temperature
from sensor_history_hour
where powerstationid = {_powerStationID} and left(`TIMESTAMP`,10) = '{_date1}'
) d on a.powerStationid = d.powerStationid and a.`report_date` = d.report_date
where right(a.inverterid, 4) = '0001'
GROUP BY left(a.report_date, 13)
order by a.report_date ;";
conn.Execute(sql);
#endregion
#region inv_02 kwh
#region inv
sql = $@" select b.id PowerStationId, b.`name` station_name, inverterid, b.`code` station_code
from v_company_inv a join power_station b on left(a.inverterid, 9) = b.`code`
where b.`id` = '{_powerStationID}' and b.Deleted = 0 and a.`enabled` = 1 and b.`status` = 1 # ";
var ds = conn.Query<station_inv_list>(sql).AsList<station_inv_list>();
#endregion
StringBuilder sb = new StringBuilder();
StringBuilder sb_column = new StringBuilder();
StringBuilder sb_select = new StringBuilder();
StringBuilder sb_update_columns = new StringBuilder();
for (int i = 0; i < ds.Count; i++)
{
if (i == 0) continue;
if (i < 9)
{
sb_column.Append(@$", `inv_0{(i + 1).ToString()}`");
if (i == 1)
{
sb.Append(@" update report_invday a join (
select a02.powerstationID, a02.report_date, ifnull(a02.inv_02, 0) inv_02");
sb_select.Append(@$" from
(select powerstationID, report_date, ifnull(round(kwh , 6), 0) inv_02 from temp_invDay{_powerStationID}_s1 a
where right(a.inverterid, 4) = '000{(i + 1).ToString()}') a0{(i + 1).ToString()} ");
sb_update_columns.Append($@" ) b
on a.powerstationid = b.powerstationid and a.report_date = b.report_date
set a.inv_02 = b.inv_02 ");
}
else {
sb.Append(@$" , ifnull(a0{(i + 1).ToString()}.inv_0{(i + 1).ToString()}, 0) inv_0{(i + 1).ToString()}");
sb_select.Append($@" left join (select report_date, ifnull(round(kwh , 6), 0) inv_0{(i + 1).ToString()} from temp_invDay{_powerStationID}_s1 a
where right(a.inverterid, 4) = '000{(i + 1).ToString()}') a0{(i + 1).ToString()} on a02.report_date = a0{(i + 1).ToString()}.report_date ");
sb_update_columns.Append($@", a.inv_0{(i + 1).ToString()} = b.inv_0{(i + 1).ToString()}");
}
}
else
{
sb.Append(@$" , ifnull(a{(i + 1).ToString()}.inv_{(i + 1).ToString()}, 0) inv_{(i + 1).ToString()} ");
sb_column.Append(@$", `inv_{(i + 1).ToString()}`");
sb_select.Append($@" left join (select report_date, ifnull(round(kwh , 6), 0) inv_{(i + 1).ToString()} from temp_invDay{_powerStationID}_s1 a
where right(a.inverterid, 4) = '00{(i + 1).ToString()}') a{(i + 1).ToString()} on a02.report_date = a{(i + 1).ToString()}.report_date ");
sb_update_columns.Append($@", a.inv_{(i + 1).ToString()} = b.inv_{(i + 1).ToString()}");
}
}
// sb.Append(", `hourKWH`, `hourKWHp`, `irradiance`, `temperature`, `hourmoney`, `pr`)");
#endregion
#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);
#endregion
if (_logger != null)
_logger.LogInformation("【Proc_inv_日報 table 】執行完成[{0}]在{1} inv_get_SQLStatement", _siteID, _date1);
}
catch (Exception ex)
{
if (_logger != null)
{
_logger.LogError("【Proc_inv_日報 table】執行失敗[{0}]在{1}inv_get_SQLStatement", _siteID, _date1);
_logger.LogError("【Proc_inv_日報 table】執行失敗[{0}]在{1}inv_get_SQLStatement - [Exception]{2}", _siteID, _date1, ex.ToString());
}
throw ex;
}
#endregion
conn.Close();
}
result = true;
return result;
}
}

View File

@ -180,20 +180,26 @@ namespace solarApp.Service
// { "Name":"環境濕度計","EName":"EMM"},
// { "Name":"風速計","EName":"VAN"},
// { "Name":" 電表","EName":"PWR"}]}
// { "Name":"風向計","EName":"WIN"}]}
// { "Name":" 累計日照計","EName":"TPY"}]}
var irrlst = ds_sensor.FindAll(x => x.type.Contains("PYR"));
var modelTemplst = ds_sensor.FindAll(x => x.type.Contains("MTR"));
var envTemplst = ds_sensor.FindAll(x => x.type.Contains("ETR"));
var humlst = ds_sensor.FindAll(x => x.type.Contains("EMM"));
var windlst = ds_sensor.FindAll(x => x.type.Contains("VAN"));
var dustlst = ds_sensor.FindAll(x => x.type.Contains("DST")); //需要新增於DB
var vandlst = ds_sensor.FindAll(x => x.type.Contains("VAN"));
var dustlst = ds_sensor.FindAll(x => x.type.Contains("DST")); //落塵計 add @ 2021-12-12
var winlst = ds_sensor.FindAll(x => x.type.Contains("WIN")); //風向計 add @ 2021-12-12
var irrDaylst = ds_sensor.FindAll(x => x.type.Contains("TPY")); //累計日照計 add @ 2021-12-12
//var meterlst = ds_sensor.FindAll(x => x.type.Contains("PWR")); 電錶暫不處理
string irrCol = string.Empty; string modelTempCol = string.Empty; string evnTempCol = string.Empty; string humCol = string.Empty; string windCol = string.Empty; string meterCol = string.Empty; string dustCol = string.Empty;
string irrCol = string.Empty; string modelTempCol = string.Empty; string evnTempCol = string.Empty; string humCol = string.Empty; string vanCol = string.Empty; string meterCol = string.Empty; string dustCol = string.Empty; string winCol = string.Empty; string irrDayCol = string.Empty;
irrCol = ConcatColumn(irrlst);//日照計
modelTempCol = ConcatColumn(modelTemplst);
evnTempCol = ConcatColumn(envTemplst);
humCol = ConcatColumn(humlst);
windCol = ConcatColumn(windlst);
vanCol = ConcatColumn(vandlst);
dustCol = ConcatColumn(dustlst);
winCol = ConcatColumn(winlst);
irrDayCol = ConcatColumn(irrDaylst);
string irrNot0 = string.Empty; // and 日照1 <> 0 and 日照2 <> 0
# region 0
@ -210,11 +216,11 @@ namespace solarApp.Service
try
{
#region hour
sql = @"insert into sensor_history_hour( `PowerStationId`, `TIMESTAMP`, Irradiance, Temperature, EnvTemperature, Humidity, Vane, Dust)
select a.powerstationID, a.reportdate, ifnull(b.irrAvg, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust from
sql = @"insert into sensor_history_hour( `PowerStationId`, `TIMESTAMP`, Irradiance, Temperature, EnvTemperature, Humidity, Vane, Dust, WingDirection, irrDay)
select a.powerstationID, a.reportdate, ifnull(b.irrAvg, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust, WingDirection, irrDay from
(
select @powerStationID powerstationID, FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') reportdate, round(avg(" + modelTempCol + @"), 4) Temperature,
avg(" + evnTempCol + @") envTemperature, avg(" + humCol + @") humidity, avg(" + windCol + @") Vane, avg(" + dustCol + @") Dust
avg(" + evnTempCol + @") envTemperature, avg(" + humCol + @") humidity, avg(" + vanCol + @") Vane, avg(" + dustCol + @") Dust, avg(" + winCol + @") WingDirection, max(" + irrDayCol + @") irrDay
from " + _siteDB + ".s" + _siteID01 + @"_sensorAvg
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H')
@ -232,11 +238,11 @@ namespace solarApp.Service
#endregion hour
#region day
sql = @"insert into sensor_history_day( `PowerStationId`, `TIMESTAMP`, Irradiance, Temperature, EnvTemperature, Humidity, Vane, Dust)
select a.powerstationID, a.reportdate, ifnull(b.Irradiance, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust from
sql = @"insert into sensor_history_day( `PowerStationId`, `TIMESTAMP`, Irradiance, Temperature, EnvTemperature, Humidity, Vane, Dust, WingDirection, irrDay)
select a.powerstationID, a.reportdate, ifnull(b.Irradiance, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust, a.WingDirection, a.irrDay from
(
select powerStationID , concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(Temperature), 6) Temperature,
envTemperature, humidity, Vane, Dust
envTemperature, humidity, Vane, Dust, WingDirection, irrDay
from solar_master.sensor_history_hour
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
@ -256,11 +262,11 @@ namespace solarApp.Service
sql = @"
delete from sensor_history_month where left(`TIMESTAMP`, 7) = @date1 and PowerStationID = @powerStationID;
insert into sensor_history_month( `PowerStationId`, `TIMESTAMP`, `Irradiance`, Temperature, EnvTemperature, Humidity, Vane, Dust)
select a.powerstationID, a.reportdate, ifnull(b.Irradiance, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust from
insert into sensor_history_month( `PowerStationId`, `TIMESTAMP`, `Irradiance`, Temperature, EnvTemperature, Humidity, Vane, Dust, WingDirection, irrDay)
select a.powerstationID, a.reportdate, ifnull(b.Irradiance, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust, WingDirection, irrDay from
(
select powerStationID , concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(Temperature), 6) Temperature,
envTemperature, humidity, Vane, Dust
envTemperature, humidity, Vane, Dust, WingDirection, irrDay
from solar_master.sensor_history_day
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = @date1
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m')

View File

@ -29,9 +29,12 @@ namespace solarApp
/// </summary>
private void InitializeComponent()
{
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();
this.bt_rpt_invDay = new System.Windows.Forms.Button();
this.bt_meter = new System.Windows.Forms.Button();
this.lbmsg = new System.Windows.Forms.Label();
this.dtSelect2 = new System.Windows.Forms.DateTimePicker();
@ -44,21 +47,45 @@ namespace solarApp
this.bt_site = new System.Windows.Forms.Button();
this.bt_Inv = new System.Windows.Forms.Button();
this.bt_Sensor = new System.Windows.Forms.Button();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.gv_inv_detail = new System.Windows.Forms.DataGridView();
this.gv_rpt_invDay = new System.Windows.Forms.DataGridView();
this.panel1 = new System.Windows.Forms.Panel();
this.bt_invDay = new System.Windows.Forms.Button();
this.btVerifyData = new System.Windows.Forms.Button();
this.lbSiteDB_sensor = new System.Windows.Forms.Label();
this.lbSiteID_sensor = new System.Windows.Forms.Label();
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.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.btInvDay_oldData = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.gv_inv_detail)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.gv_rpt_invDay)).BeginInit();
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.SuspendLayout();
//
// tabControl1
@ -78,7 +105,7 @@ namespace solarApp
this.tabPage1.Controls.Add(this.splitContainer1);
this.tabPage1.Location = new System.Drawing.Point(4, 31);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(1774, 918);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "tabPage1";
@ -93,6 +120,8 @@ namespace solarApp
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.splitContainer1.Panel1.Controls.Add(this.btInvDay_oldData);
this.splitContainer1.Panel1.Controls.Add(this.bt_rpt_invDay);
this.splitContainer1.Panel1.Controls.Add(this.bt_meter);
this.splitContainer1.Panel1.Controls.Add(this.lbmsg);
this.splitContainer1.Panel1.Controls.Add(this.dtSelect2);
@ -108,17 +137,29 @@ namespace solarApp
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.dataGridView1);
this.splitContainer1.Panel2.Controls.Add(this.gv_inv_detail);
this.splitContainer1.Panel2.Controls.Add(this.gv_rpt_invDay);
this.splitContainer1.Panel2.Controls.Add(this.panel1);
this.splitContainer1.Size = new System.Drawing.Size(1768, 912);
this.splitContainer1.SplitterDistance = 299;
this.splitContainer1.SplitterDistance = 400;
this.splitContainer1.SplitterWidth = 10;
this.splitContainer1.TabIndex = 0;
//
// bt_rpt_invDay
//
this.bt_rpt_invDay.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_rpt_invDay.Location = new System.Drawing.Point(262, 790);
this.bt_rpt_invDay.Name = "bt_rpt_invDay";
this.bt_rpt_invDay.Size = new System.Drawing.Size(135, 44);
this.bt_rpt_invDay.TabIndex = 12;
this.bt_rpt_invDay.Text = "日報表";
this.bt_rpt_invDay.UseVisualStyleBackColor = true;
this.bt_rpt_invDay.Click += new System.EventHandler(this.bt_rpt_invDay_Click);
//
// bt_meter
//
this.bt_meter.Location = new System.Drawing.Point(156, 786);
this.bt_meter.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.bt_meter.Location = new System.Drawing.Point(10, 786);
this.bt_meter.Margin = new System.Windows.Forms.Padding(4);
this.bt_meter.Name = "bt_meter";
this.bt_meter.Size = new System.Drawing.Size(135, 56);
this.bt_meter.TabIndex = 11;
@ -159,7 +200,7 @@ namespace solarApp
this.bt_clear_sensor.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_clear_sensor.Location = new System.Drawing.Point(10, 635);
this.bt_clear_sensor.Name = "bt_clear_sensor";
this.bt_clear_sensor.Size = new System.Drawing.Size(135, 44);
this.bt_clear_sensor.Size = new System.Drawing.Size(119, 44);
this.bt_clear_sensor.TabIndex = 7;
this.bt_clear_sensor.Text = "clear data";
this.bt_clear_sensor.UseVisualStyleBackColor = true;
@ -171,7 +212,7 @@ namespace solarApp
this.bt_clear_station.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_clear_station.Location = new System.Drawing.Point(10, 735);
this.bt_clear_station.Name = "bt_clear_station";
this.bt_clear_station.Size = new System.Drawing.Size(135, 44);
this.bt_clear_station.Size = new System.Drawing.Size(119, 44);
this.bt_clear_station.TabIndex = 6;
this.bt_clear_station.Text = "clear data";
this.bt_clear_station.UseVisualStyleBackColor = true;
@ -183,7 +224,7 @@ namespace solarApp
this.bt_clear_inv.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_clear_inv.Location = new System.Drawing.Point(10, 686);
this.bt_clear_inv.Name = "bt_clear_inv";
this.bt_clear_inv.Size = new System.Drawing.Size(135, 44);
this.bt_clear_inv.Size = new System.Drawing.Size(119, 44);
this.bt_clear_inv.TabIndex = 5;
this.bt_clear_inv.Text = "clear data";
this.bt_clear_inv.UseVisualStyleBackColor = true;
@ -194,7 +235,7 @@ namespace solarApp
this.fp_site.Dock = System.Windows.Forms.DockStyle.Top;
this.fp_site.Location = new System.Drawing.Point(0, 0);
this.fp_site.Name = "fp_site";
this.fp_site.Size = new System.Drawing.Size(299, 530);
this.fp_site.Size = new System.Drawing.Size(400, 530);
this.fp_site.TabIndex = 4;
//
// dtSelect1
@ -238,20 +279,45 @@ namespace solarApp
this.bt_Sensor.UseVisualStyleBackColor = true;
this.bt_Sensor.Click += new System.EventHandler(this.bt_Sensor_Click);
//
// dataGridView1
// gv_inv_detail
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(0, 125);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersWidth = 51;
this.dataGridView1.RowTemplate.Height = 29;
this.dataGridView1.Size = new System.Drawing.Size(1459, 787);
this.dataGridView1.TabIndex = 1;
this.gv_inv_detail.AllowUserToAddRows = false;
this.gv_inv_detail.AllowUserToDeleteRows = false;
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);
this.gv_inv_detail.Name = "gv_inv_detail";
this.gv_inv_detail.ReadOnly = true;
this.gv_inv_detail.RowHeadersWidth = 51;
this.gv_inv_detail.RowTemplate.Height = 29;
this.gv_inv_detail.Size = new System.Drawing.Size(590, 837);
this.gv_inv_detail.TabIndex = 2;
this.gv_inv_detail.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gv_inv_detail_CellDoubleClick);
//
// gv_rpt_invDay
//
this.gv_rpt_invDay.AllowUserToAddRows = false;
this.gv_rpt_invDay.AllowUserToDeleteRows = false;
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);
this.gv_rpt_invDay.Name = "gv_rpt_invDay";
this.gv_rpt_invDay.ReadOnly = true;
this.gv_rpt_invDay.RowHeadersWidth = 51;
this.gv_rpt_invDay.RowTemplate.Height = 29;
this.gv_rpt_invDay.Size = new System.Drawing.Size(768, 837);
this.gv_rpt_invDay.TabIndex = 1;
this.gv_rpt_invDay.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.gv_rpt_invDay_CellFormatting);
this.gv_rpt_invDay.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.gv_rpt_invDay_CellMouseDoubleClick);
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
this.panel1.Controls.Add(this.bt_invDay);
this.panel1.Controls.Add(this.btVerifyData);
this.panel1.Controls.Add(this.lbSiteDB_sensor);
this.panel1.Controls.Add(this.lbSiteID_sensor);
@ -259,17 +325,28 @@ namespace solarApp
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1459, 125);
this.panel1.Size = new System.Drawing.Size(1358, 75);
this.panel1.TabIndex = 0;
//
// bt_invDay
//
this.bt_invDay.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_invDay.Location = new System.Drawing.Point(21, 8);
this.bt_invDay.Name = "bt_invDay";
this.bt_invDay.Size = new System.Drawing.Size(159, 44);
this.bt_invDay.TabIndex = 14;
this.bt_invDay.Text = "Inv 檢核";
this.bt_invDay.UseVisualStyleBackColor = true;
this.bt_invDay.Click += new System.EventHandler(this.bt_invDay_Click);
//
// btVerifyData
//
this.btVerifyData.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.btVerifyData.Location = new System.Drawing.Point(635, 8);
this.btVerifyData.Location = new System.Drawing.Point(746, 8);
this.btVerifyData.Name = "btVerifyData";
this.btVerifyData.Size = new System.Drawing.Size(158, 44);
this.btVerifyData.TabIndex = 12;
this.btVerifyData.Text = "檢核結果";
this.btVerifyData.Text = "各資料表明細";
this.btVerifyData.UseVisualStyleBackColor = true;
this.btVerifyData.Click += new System.EventHandler(this.btVerifyData_Click);
//
@ -277,7 +354,7 @@ namespace solarApp
//
this.lbSiteDB_sensor.AutoSize = true;
this.lbSiteDB_sensor.Font = new System.Drawing.Font("Microsoft JhengHei UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.lbSiteDB_sensor.Location = new System.Drawing.Point(49, 19);
this.lbSiteDB_sensor.Location = new System.Drawing.Point(209, 20);
this.lbSiteDB_sensor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbSiteDB_sensor.Name = "lbSiteDB_sensor";
this.lbSiteDB_sensor.Size = new System.Drawing.Size(79, 24);
@ -289,7 +366,7 @@ namespace solarApp
//
this.lbSiteID_sensor.AutoSize = true;
this.lbSiteID_sensor.Font = new System.Drawing.Font("Microsoft JhengHei UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.lbSiteID_sensor.Location = new System.Drawing.Point(201, 19);
this.lbSiteID_sensor.Location = new System.Drawing.Point(361, 20);
this.lbSiteID_sensor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbSiteID_sensor.Name = "lbSiteID_sensor";
this.lbSiteID_sensor.Size = new System.Drawing.Size(72, 24);
@ -300,7 +377,7 @@ namespace solarApp
//
this.lbSiteName_sensor.AutoSize = true;
this.lbSiteName_sensor.Font = new System.Drawing.Font("Microsoft JhengHei UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.lbSiteName_sensor.Location = new System.Drawing.Point(360, 19);
this.lbSiteName_sensor.Location = new System.Drawing.Point(520, 20);
this.lbSiteName_sensor.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbSiteName_sensor.Name = "lbSiteName_sensor";
this.lbSiteName_sensor.Size = new System.Drawing.Size(107, 24);
@ -309,14 +386,169 @@ namespace solarApp
//
// tabPage2
//
this.tabPage2.Controls.Add(this.splitContainer2);
this.tabPage2.Location = new System.Drawing.Point(4, 31);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(1774, 918);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true;
//
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.Location = new System.Drawing.Point(3, 3);
this.splitContainer2.Name = "splitContainer2";
//
// 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);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.dataGridView2);
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
//
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;
//
// 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.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.TabIndex = 0;
//
// button9
//
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;
//
// label2
//
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";
//
// label3
//
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";
//
// label4
//
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";
//
// btInvDay_oldData
//
this.btInvDay_oldData.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.btInvDay_oldData.Location = new System.Drawing.Point(156, 790);
this.btInvDay_oldData.Name = "btInvDay_oldData";
this.btInvDay_oldData.Size = new System.Drawing.Size(100, 44);
this.btInvDay_oldData.TabIndex = 13;
this.btInvDay_oldData.Text = "日報-舊";
this.btInvDay_oldData.UseVisualStyleBackColor = true;
this.btInvDay_oldData.Click += new System.EventHandler(this.btInvDay_oldData_Click);
//
// fmArchive
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F);
@ -333,9 +565,19 @@ namespace solarApp
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gv_inv_detail)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gv_rpt_invDay)).EndInit();
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.ResumeLayout(false);
}
@ -345,7 +587,7 @@ namespace solarApp
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.DataGridView gv_rpt_invDay;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.DateTimePicker dtSelect1;
@ -365,5 +607,22 @@ namespace solarApp
private System.Windows.Forms.Label lbmsg;
private System.Windows.Forms.DateTimePicker dtSelect2;
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 btInvDay_oldData;
}
}

View File

@ -26,13 +26,25 @@ namespace solarApp
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
procSensorSvc sensorSvc = new procSensorSvc();
//invSvc._siteDB = lbSiteDB_sensor.Text;
//invSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
//invSvc._siteID01 = lbSiteID_sensor.Text;
//invSvc._date1 = date1;
//invSvc._date2 = date1;
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
{
//string d1 = day.ToString("yyyy-MM-dd");
sensorSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
}
//sensorSvc._siteDB = lbSiteDB_sensor.Text;
//sensorSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
//sensorSvc._siteID01 = lbSiteID_sensor.Text;
//sensorSvc._date1 = date1;
//sensorSvc._date2 = date1;
sensorSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), date1);
//sensorSvc.archiveData();
MessageBox.Show("OK");
}
@ -56,6 +68,9 @@ namespace solarApp
i++;
}
#endregion
// dtselect_station1.Value = DateTime.Today.AddDays(-1);
dtSelect1.Value = System.DateTime.Today.AddDays(-1);
dtSelect2.Value = System.DateTime.Today.AddDays(-1);
}
private void rb_site_CheckedChanged(object sender, EventArgs e)
@ -82,9 +97,17 @@ namespace solarApp
fm.Show();
}
public IEnumerable<DateTime> EachDay(DateTime from, DateTime thru)
{
for (var day = from.Date; day.Date <= thru.Date; day = day.AddDays(1))
yield return day;
}
private void bt_Inv_Click(object sender, EventArgs e)
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
procInvSvc invSvc = new procInvSvc();
//invSvc._siteDB = lbSiteDB_sensor.Text;
@ -92,7 +115,11 @@ namespace solarApp
//invSvc._siteID01 = lbSiteID_sensor.Text;
//invSvc._date1 = date1;
//invSvc._date2 = date1;
invSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), date1);
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
{
//string d1 = day.ToString("yyyy-MM-dd");
invSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
}
//sensorSvc.archiveData();
MessageBox.Show("OK");
}
@ -140,14 +167,19 @@ namespace solarApp
private void bt_site_Click(object sender, EventArgs e)
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
procStationSvc siteSvc = new procStationSvc();
//siteSvc._siteDB = lbSiteDB_sensor.Text;
//siteSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
//siteSvc._siteID01 = lbSiteID_sensor.Text;
//siteSvc._date1 = date1;
//siteSvc._date2 = date1;
siteSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), date1);
//invSvc._siteDB = lbSiteDB_sensor.Text;
//invSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
//invSvc._siteID01 = lbSiteID_sensor.Text;
//invSvc._date1 = date1;
//invSvc._date2 = date1;
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
{
//string d1 = day.ToString("yyyy-MM-dd");
siteSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
}
//sensorSvc.archiveData();
MessageBox.Show("OK");
}
@ -178,6 +210,7 @@ namespace solarApp
{
fmExcel fm = new fmExcel();
fm.Show();
}
private void bt_meter_Click(object sender, EventArgs e)
@ -188,5 +221,107 @@ namespace solarApp
sensorSvc.archiveMeterData(lbSiteID_sensor.Text.Substring(0, 9), date1);
MessageBox.Show("OK");
}
/// <summary>
/// 日報表 - 每日歸檔
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void bt_rpt_invDay_Click(object sender, EventArgs e)
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
procInvSvc invSvc = new procInvSvc();
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
{
invSvc.report_invDay(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
}
MessageBox.Show("OK");
}
private void bt_invDay_Click(object sender, EventArgs e)
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
get_inv_svc invSvc = new get_inv_svc();
var ds = invSvc.get_ck_invDay_list(date1, date2);
gv_rpt_invDay.DataSource = ds;
gv_rpt_invDay.Columns[0].Width = 60;
gv_rpt_invDay.Columns[1].Width = 70;
gv_rpt_invDay.Columns[2].Width = 80;
gv_rpt_invDay.Columns[3].Width = 90;
gv_rpt_invDay.Columns[4].Width = 90;
gv_rpt_invDay.Columns[5].Width = 90;
gv_rpt_invDay.Columns[6].Width = 90;
gv_rpt_invDay.Columns[7].Width = 90;
}
private void gv_rpt_invDay_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (gv_rpt_invDay.Rows[e.RowIndex].Cells["CsubstrctionB"].Value != null && !string.IsNullOrWhiteSpace(gv_rpt_invDay.Rows[e.RowIndex].Cells["CsubstrctionB"].Value.ToString()))
{
if (gv_rpt_invDay.Rows[e.RowIndex].Cells["CsubstrctionB"].Value.ToString() != "0")
{
gv_rpt_invDay.Rows[e.RowIndex].Cells["CsubstrctionB"].Style = new DataGridViewCellStyle { ForeColor = Color.Red, BackColor = Color.White };
}
}
}
private void gv_rpt_invDay_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
string powerStationID = gv_rpt_invDay.Rows[e.RowIndex].Cells[0].Value.ToString();
// MessageBox.Show(powerStationID);
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
get_inv_svc invSvc = new get_inv_svc();
var ds = invSvc.get_ck_invDay_detail1( powerStationID, date1, date2);
gv_inv_detail.DataSource = ds;
gv_inv_detail.Columns[0].Width = 60;
gv_inv_detail.Columns[1].Width = 160; //invID
gv_inv_detail.Columns[2].Width = 80;
gv_inv_detail.Columns[3].Width = 90;
//switch (e.ColumnIndex)
//{
// case 0:
// MessageBox.Show("这是第零列得");
// break;
// default:
// break;
//}
}
private void gv_inv_detail_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (gv_inv_detail.Columns.Count == 5) return;
string inverterID = gv_inv_detail.Rows[e.RowIndex].Cells[1].Value.ToString();
//MessageBox.Show(inverterID);
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
get_inv_svc invSvc = new get_inv_svc();
var ds = invSvc.get_ck_invDay_detail2(inverterID, date1, date2);
gv_inv_detail.DataSource = ds;
gv_inv_detail.Columns[0].Width = 60;
gv_inv_detail.Columns[1].Width = 150;
gv_inv_detail.Columns[2].Width = 80;
gv_inv_detail.Columns[3].Width = 100;
gv_inv_detail.Columns[4].Width = 80;
gv_inv_detail.Columns[5].Width = 80;
}
private void btInvDay_oldData_Click(object sender, EventArgs e)
{
//procInvSvc invSvc = new procInvSvc();
//foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
//{
// invSvc.report_invDay(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
//}
}
}
}

View File

@ -42,6 +42,7 @@ namespace solarApp
this.panel1 = new System.Windows.Forms.Panel();
this.lbSiteName_sensor = new System.Windows.Forms.Label();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.bt_dailyReport = new System.Windows.Forms.Button();
this.bt_sun_yadong = new System.Windows.Forms.Button();
this.bt_sun_taoyuan = new System.Windows.Forms.Button();
this.bt_gong34 = new System.Windows.Forms.Button();
@ -51,7 +52,9 @@ namespace solarApp
this.rt1 = new System.Windows.Forms.RichTextBox();
this.tb1 = new System.Windows.Forms.TabPage();
this.tabControl = new System.Windows.Forms.TabControl();
this.bt_dailyReport = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -97,7 +100,7 @@ namespace solarApp
// bt_archive
//
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(3, 640);
this.bt_archive.Location = new System.Drawing.Point(0, 682);
this.bt_archive.Name = "bt_archive";
this.bt_archive.Size = new System.Drawing.Size(226, 60);
this.bt_archive.TabIndex = 8;
@ -120,7 +123,7 @@ namespace solarApp
// bt_read_taiping
//
this.bt_read_taiping.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_read_taiping.Location = new System.Drawing.Point(0, 337);
this.bt_read_taiping.Location = new System.Drawing.Point(3, 286);
this.bt_read_taiping.Name = "bt_read_taiping";
this.bt_read_taiping.Size = new System.Drawing.Size(192, 47);
this.bt_read_taiping.TabIndex = 6;
@ -131,7 +134,7 @@ namespace solarApp
// bt_inv_day_hj
//
this.bt_inv_day_hj.Font = new System.Drawing.Font("Microsoft JhengHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_inv_day_hj.Location = new System.Drawing.Point(0, 270);
this.bt_inv_day_hj.Location = new System.Drawing.Point(0, 236);
this.bt_inv_day_hj.Name = "bt_inv_day_hj";
this.bt_inv_day_hj.Size = new System.Drawing.Size(143, 44);
this.bt_inv_day_hj.TabIndex = 5;
@ -202,6 +205,9 @@ namespace solarApp
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.BackColor = System.Drawing.Color.PaleGoldenrod;
this.splitContainer1.Panel1.Controls.Add(this.button3);
this.splitContainer1.Panel1.Controls.Add(this.button2);
this.splitContainer1.Panel1.Controls.Add(this.button1);
this.splitContainer1.Panel1.Controls.Add(this.bt_dailyReport);
this.splitContainer1.Panel1.Controls.Add(this.bt_sun_yadong);
this.splitContainer1.Panel1.Controls.Add(this.bt_sun_taoyuan);
@ -225,32 +231,45 @@ namespace solarApp
this.splitContainer1.SplitterWidth = 10;
this.splitContainer1.TabIndex = 0;
//
// bt_dailyReport
//
this.bt_dailyReport.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_dailyReport.Location = new System.Drawing.Point(7, 748);
this.bt_dailyReport.Name = "bt_dailyReport";
this.bt_dailyReport.Size = new System.Drawing.Size(237, 74);
this.bt_dailyReport.TabIndex = 15;
this.bt_dailyReport.Text = "daily_report 太陽能光電-桃園全虹";
this.bt_dailyReport.UseVisualStyleBackColor = true;
this.bt_dailyReport.Click += new System.EventHandler(this.bt_dailyReport_Click);
//
// bt_sun_yadong
//
this.bt_sun_yadong.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_sun_yadong.Location = new System.Drawing.Point(5, 576);
this.bt_sun_yadong.Location = new System.Drawing.Point(3, 479);
this.bt_sun_yadong.Name = "bt_sun_yadong";
this.bt_sun_yadong.Size = new System.Drawing.Size(213, 47);
this.bt_sun_yadong.TabIndex = 14;
this.bt_sun_yadong.Text = "太陽能光電-亞東觀音";
this.bt_sun_yadong.UseVisualStyleBackColor = true;
this.bt_sun_yadong.Visible = false;
this.bt_sun_yadong.Click += new System.EventHandler(this.bt_sun_yadong_Click);
//
// bt_sun_taoyuan
//
this.bt_sun_taoyuan.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_sun_taoyuan.Location = new System.Drawing.Point(3, 523);
this.bt_sun_taoyuan.Location = new System.Drawing.Point(3, 433);
this.bt_sun_taoyuan.Name = "bt_sun_taoyuan";
this.bt_sun_taoyuan.Size = new System.Drawing.Size(213, 47);
this.bt_sun_taoyuan.TabIndex = 13;
this.bt_sun_taoyuan.Text = "太陽能光電-桃園全虹";
this.bt_sun_taoyuan.UseVisualStyleBackColor = true;
this.bt_sun_taoyuan.Visible = false;
this.bt_sun_taoyuan.Click += new System.EventHandler(this.bt_sun_taoyuan_Click);
//
// bt_gong34
//
this.bt_gong34.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_gong34.Location = new System.Drawing.Point(0, 443);
this.bt_gong34.Location = new System.Drawing.Point(3, 392);
this.bt_gong34.Name = "bt_gong34";
this.bt_gong34.Size = new System.Drawing.Size(189, 47);
this.bt_gong34.TabIndex = 12;
@ -261,7 +280,7 @@ namespace solarApp
// bt_AUO_aimai
//
this.bt_AUO_aimai.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_AUO_aimai.Location = new System.Drawing.Point(0, 390);
this.bt_AUO_aimai.Location = new System.Drawing.Point(3, 339);
this.bt_AUO_aimai.Name = "bt_AUO_aimai";
this.bt_AUO_aimai.Size = new System.Drawing.Size(189, 47);
this.bt_AUO_aimai.TabIndex = 11;
@ -283,7 +302,7 @@ namespace solarApp
// bt_day_archive_hj
//
this.bt_day_archive_hj.Font = new System.Drawing.Font("Microsoft JhengHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_day_archive_hj.Location = new System.Drawing.Point(149, 270);
this.bt_day_archive_hj.Location = new System.Drawing.Point(149, 236);
this.bt_day_archive_hj.Name = "bt_day_archive_hj";
this.bt_day_archive_hj.Size = new System.Drawing.Size(119, 44);
this.bt_day_archive_hj.TabIndex = 9;
@ -325,16 +344,38 @@ namespace solarApp
this.tabControl.Size = new System.Drawing.Size(1782, 853);
this.tabControl.TabIndex = 1;
//
// bt_dailyReport
// button1
//
this.bt_dailyReport.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.bt_dailyReport.Location = new System.Drawing.Point(5, 706);
this.bt_dailyReport.Name = "bt_dailyReport";
this.bt_dailyReport.Size = new System.Drawing.Size(237, 74);
this.bt_dailyReport.TabIndex = 15;
this.bt_dailyReport.Text = "daily_report 太陽能光電-桃園全虹";
this.bt_dailyReport.UseVisualStyleBackColor = true;
this.bt_dailyReport.Click += new System.EventHandler(this.bt_dailyReport_Click);
this.button1.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.button1.Location = new System.Drawing.Point(5, 527);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(213, 47);
this.button1.TabIndex = 16;
this.button1.Text = "太陽能光電-高雄臨廣";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// 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(3, 569);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(213, 47);
this.button2.TabIndex = 17;
this.button2.Text = "太陽能光電-翔億大";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
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(3, 613);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(213, 47);
this.button3.TabIndex = 18;
this.button3.Text = "太陽能光電-翔億小";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// fmExcel
//
@ -383,5 +424,8 @@ namespace solarApp
private System.Windows.Forms.Button bt_sun_taoyuan;
private System.Windows.Forms.Button bt_sun_yadong;
private System.Windows.Forms.Button bt_dailyReport;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button3;
}
}

View File

@ -697,7 +697,7 @@ namespace solarApp
//str = inverterID.Split(" ");
//inverterID = str[str.Length - 1];
xlsSvc.insert_dailyReport2DB(dt, filename);
xlsSvc.insert_dailyReport2DB(dt, filename, "daily_taoyuan_quanhong");
dt.Rows.Clear();
x++;
}
@ -716,8 +716,73 @@ namespace solarApp
private void bt_dailyReport_Click(object sender, EventArgs e)
{
ImporExcel_dailyReport("");
ImporExcel_dailyReport("daily_taoyuan_quanhong");
//insert_dailyReport2DB("daily_taoyuan_quanhong");
}
private void button2_Click(object sender, EventArgs e)
{
insert_sunLightCsv("sun_zhanghua_xy1");
}
private void button3_Click(object sender, EventArgs e)
{
insert_sunLightCsv("sun_zhanghua_xy2");
}
private void button1_Click(object sender, EventArgs e)
{
insert_sunLightCsv("sun_gaoxiong_linguang");
}
void insert_sunLightCsv(string tableName) {
string fname = "";
string[] fileEntries = new string[0];
Array.Clear(fileEntries, 0, fileEntries.Length);
//取得選取檔案的路徑
string dir;//= Path.GetDirectoryName(fname);
using (var fbd = new FolderBrowserDialog())
{
DialogResult result = fbd.ShowDialog();
if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
{
//dir = Path.GetDirectoryName(fname);
//fileEntries = Directory.GetFiles(fbd.SelectedPath);
fileEntries = Directory.GetFiles(fbd.SelectedPath, "*.*", SearchOption.AllDirectories);
MessageBox.Show("Files found: " + fileEntries.Length.ToString(), "Message");
}
}
Service.operateCSV csvSvc = new Service.operateCSV(); // readCsvTxt
System.Data.DataTable dt = new System.Data.DataTable();
bool isFirst = true;
foreach (string fileName in fileEntries)
{
#region filename InvID
string fName = Path.GetFileName(fileName);
rt1.AppendText(fName + " ");
rt1.SelectionStart = rt1.Text.Length;
rt1.ScrollToCaret();
#endregion
if (isFirst)
{
//csvSvc.clear_inv("hour");
csvSvc.taoYuan_createColumnHour(ref dt, fileName);
csvSvc.taoYuan_readCsvFile(ref dt, fileName, dt.Columns.Count, isFirst);
isFirst = false;
}
else
csvSvc.taoYuan_readCsvFile(ref dt, fileName, dt.Columns.Count, isFirst);
}
MessageBox.Show(" 共 " + dt.Rows.Count.ToString());
//System.Data.DataTable dt = solarApp.Service.csvHelper.OpenCSV(fname);
csvSvc.taoYuan_insertHour2DB(ref dt, tableName);
MessageBox.Show("OK");
}
}
}