import 慧景 inv Data v0.8
This commit is contained in:
parent
18529c7ff0
commit
722a8171cd
@ -114,4 +114,14 @@ namespace solarApp.Model
|
||||
public string dbName { get; set; }
|
||||
public string inverterid { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 慧景 inv hour 匯入後的總計
|
||||
/// </summary>
|
||||
public class src_inv_count
|
||||
{
|
||||
public string inv { get; set; }
|
||||
public string date { get; set; }
|
||||
public string count { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ using System.IO;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System.Configuration;
|
||||
using Dapper;
|
||||
using solarApp.Model;
|
||||
|
||||
namespace solarApp.Service
|
||||
{
|
||||
@ -193,8 +194,6 @@ namespace solarApp.Service
|
||||
string strpath = filepath; //csv檔案的路徑
|
||||
try
|
||||
{
|
||||
bool blnFlag = true;
|
||||
|
||||
DataColumn mydc;
|
||||
DataRow mydr;
|
||||
|
||||
@ -208,47 +207,73 @@ namespace solarApp.Service
|
||||
rowIndex += 1;
|
||||
if (readTitle)
|
||||
{
|
||||
if (rowIndex < 3)
|
||||
{
|
||||
continue;
|
||||
// 欄位需要取:row 3 invId , row 4 欄位名稱也需要讀取完
|
||||
}
|
||||
else if (rowIndex <= 4)
|
||||
{
|
||||
if (rowIndex < 3 && InvID == "")
|
||||
continue;// 欄位需要取:row 3 invId , row 4 欄位名稱也需要讀取完
|
||||
else if (rowIndex <= 4 && InvID == "")
|
||||
readTitle = false;
|
||||
else { //inv
|
||||
if (rowIndex <= 3) continue;
|
||||
readTitle = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (rowIndex < 5) continue;
|
||||
}
|
||||
else if (rowIndex < 4) continue;
|
||||
|
||||
aryline = strline.Split(new char[] { ',' });
|
||||
|
||||
//填充資料並加入到datatable中
|
||||
mydr = mycsvdt.NewRow();
|
||||
for (int i = 0; i < intColCount; i++)
|
||||
if (InvID != "")
|
||||
{ // hour
|
||||
for (int i = 0; i < intColCount - 1; i++)
|
||||
{
|
||||
mydr[i] = aryline[i];
|
||||
}
|
||||
//mydr["inv"] = InvID;
|
||||
if (!string.IsNullOrEmpty(InvID))
|
||||
mydr["inv"] = InvID;
|
||||
}
|
||||
else
|
||||
{ // day
|
||||
for (int i = 0; i < intColCount; i++)
|
||||
mydr[i] = aryline[i];
|
||||
}
|
||||
mycsvdt.Rows.Add(mydr);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception ex)
|
||||
{
|
||||
//throw (Stack.GetErrorStack(strpath + "讀取CSV檔案中的資料出錯." + e.Message, "OpenCSVFile("));
|
||||
//throw (Stack.GetErrorStack(strpath + "讀取CSV檔案中的資料出錯." + e.Message, " readCsvFile"));
|
||||
throw ex;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool insertHour2DB(ref DataTable dt) {
|
||||
|
||||
public bool clear_inv(string timeType)
|
||||
{
|
||||
bool result = false;
|
||||
StringBuilder ss = new StringBuilder();
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
switch (timeType)
|
||||
{
|
||||
case "hour": ss.Append("truncate table solar_import.src_inv;"); break;
|
||||
case "day": ss.Append("truncate table solar_import.src_inv_day;"); break;
|
||||
}
|
||||
conn.Execute(ss.ToString());
|
||||
conn.Clone();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<src_inv_count> insertHour2DB(ref DataTable dt) {
|
||||
List<src_inv_count> ds;
|
||||
StringBuilder ss = new StringBuilder();
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
ss.Clear();
|
||||
|
||||
int i = 0;
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
@ -265,21 +290,6 @@ namespace solarApp.Service
|
||||
{
|
||||
conn.Execute(ss.ToString());
|
||||
ss.Clear();
|
||||
//ss.Append(@"insert into solar_import.src_inv(c1 ,c2 ,c3 ,c4 ,c5 ,c6 ,c7 ,c8 ,c9 ,c10 ,c11 ,c12 ,c13 ,c14 ,c15 ,c16 ,c17 ,c18 ,c19 ,inv)
|
||||
// values( @c1 ,@c2 ,@c3 ,@c4 ,@c5 ,@c6 ,@c7 ,@c8 ,@c9 ,@c10 ,@c11 ,@c12 ,@c13 ,@c14 ,@c15 , @c16, @c17, @c18,@c19 ,@inv );");
|
||||
//conn.Execute(ss.ToString(), new
|
||||
//{
|
||||
// c1 = row.Field<string>("1").ToString(), c2 = row.Field<string>("2").ToString(),
|
||||
// c3 = row.Field<string>("3").ToString(), c4 = row.Field<string>("4").ToString(),
|
||||
// c5 = row.Field<string>("5").ToString(), c6 = row.Field<string>("6").ToString(),
|
||||
// c7 = row.Field<string>("7").ToString(), c8 = row.Field<string>("8").ToString(),
|
||||
// c9 = row.Field<string>("9").ToString(), c10 = row.Field<string>("10").ToString(),
|
||||
// c11 = row.Field<string>("11").ToString(), c12 = row.Field<string>("12").ToString(),
|
||||
// c13 = row.Field<string>("13").ToString(), c14 = row.Field<string>("14").ToString(),
|
||||
// c15 = row.Field<string>("15").ToString(), c16 = row.Field<string>("16").ToString(),
|
||||
// c17 = row.Field<string>("17").ToString(), c18 = row.Field<string>("18").ToString(),
|
||||
// c19 = row.Field<string>("19").ToString(), inv = row.Field<string>("inv").ToString()
|
||||
//});
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@ -288,9 +298,12 @@ namespace solarApp.Service
|
||||
conn.Execute(ss.ToString());
|
||||
ss.Clear();
|
||||
}
|
||||
ss.Clear();
|
||||
ss.Append(@"select inv, left(c1, 10) date, count(*) ct from src_inv where c1 <> '欄位名稱' group by inv, left(c1, 10)");
|
||||
ds = conn.Query<src_inv_count>(ss.ToString()).AsList<src_inv_count>();
|
||||
conn.Clone();
|
||||
}
|
||||
return false;
|
||||
return ds;
|
||||
}
|
||||
|
||||
public bool insertDay2DB(ref DataTable dt)
|
||||
@ -375,7 +388,292 @@ values( '"
|
||||
}
|
||||
conn.Clone();
|
||||
}
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool archive_data(string timeType)
|
||||
{
|
||||
bool result = false;
|
||||
string ss;
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
if (timeType == "hour")
|
||||
{ //匯入小時資料哦
|
||||
// 1.src_day to master inv_day
|
||||
ss = @" delete from solar_master.inverter_history_hour where powerStationID = 22;
|
||||
|
||||
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, DC1KW, DC1WH, DC2V, DC2A, DC2W, DC2KW, DC2WH, DC3V, DC3A, DC3W, DC3KW, DC3WH, DC4V, DC4A, DC4W, DC4KW, DC4WH, DC5V, DC5A, DC5W, DC5KW, DC5WH,
|
||||
PR, RA1, RA2, RA3, RA4, RA5, DCKW, ACKW, KWH, TODAYKWH, TOTALKWH, KWHKWP)
|
||||
|
||||
select 22 as PowerStationId, invId, reportdate, irr,
|
||||
AC1V, AC1A, 0, 0, 0,
|
||||
AC2V, AC2A, 0, 0, 0,
|
||||
AC3V, AC3A, 0, 0, 0,
|
||||
DC1V, DC1A, DC1W, 0, 0,
|
||||
DC2V, DC2A, DC2W, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0 as PR, RA as RA1, 0, 0, 0, 0,
|
||||
0 as DCKW, 0 as ACKW, wh as 'KWH', wh as TODAYKWH, wh as TOTALKWH, 0 as KWHKWP
|
||||
from solar_import.v_inv_hour_hj ;";
|
||||
conn.Execute(ss);
|
||||
}
|
||||
else
|
||||
{//匯入 day 資料
|
||||
// 1.src_day to master inv_day
|
||||
ss = @" delete from solar_master.inverter_history_day where powerStationID = 22;
|
||||
|
||||
insert into solar_master.inverter_history_day(powerStationID, inverterID, `TIMESTAMP`, irradiance, PR, kwh, todayKWH, totalKWh, kwhkwp)
|
||||
select '22' as powerStationID, CONCAT('0802500010100', right(a.inv, 2) ) invID, concat(a.reportDate,' 00:00:00') ts, round(a.irr, 8) irr,
|
||||
round(a.pr, 8) pr, round(a.kwh, 8)kwh, round((a.totalkWh - b.totalkWh), 8) as todaykWh, round(a.totalkWh, 8) totalkWh, round(a.kwhkwp, 8)kwhkwp
|
||||
from solar_import.v_inv_day_huijing a join
|
||||
( # 把今天的值 放到明天
|
||||
select reportDate, DATE(DATE_ADD(reportDate, INTERVAL +1 DAY)) day_1, totalkWh, inv
|
||||
from solar_import.v_inv_day_huijing
|
||||
)b on a.inv = b.inv and a.reportDate = b.day_1;";
|
||||
conn.Execute(ss);
|
||||
|
||||
// 2.month
|
||||
ss = @" delete from solar_master.inverter_history_month where powerStationID = 22;
|
||||
|
||||
insert into solar_master.inverter_history_month(powerstationid, inverterid, `TIMESTAMP`, irradiance, PR, kwh, todayKWH, totalKWh, kwhkwp)
|
||||
select 22 powerstationid, inverterid, concat(left(`TIMESTAMP`, 7), '-01 00:00:00') , avg(irradiance) irr,
|
||||
avg(PR) PR, SUM(kwh) kwh, max(todaykwh)todaykwh, max(totalkwh)totalkwh, avg(kwhkwp) kwhkwp
|
||||
from solar_master.inverter_history_day
|
||||
where powerStationID = 22
|
||||
group by left(`TIMESTAMP`, 7) , inverterid;";
|
||||
conn.Execute(ss);
|
||||
|
||||
// 3.station day
|
||||
ss = @" delete from solar_master.power_station_history_day where powerstationID = 22;
|
||||
INSERT INTO solar_master.power_station_history_day( PowerStationId, `TIMESTAMP`, SITEID, SITETYPE, TODAYKWH, TOTALKWH, KWHKWP,
|
||||
PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON)
|
||||
select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.TODAYKWH, a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR,
|
||||
(KWH * PowerRate) MONEY, (a.TOTALKWH * PowerRate) TOTALMONEY,
|
||||
(KWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON
|
||||
from
|
||||
(
|
||||
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00:00') reportdate, '080250001' siteid, 0 siteType, round((sum(KWH)), 6) KWH,
|
||||
round((sum(TODAYKWH)), 6) TODAYKWH, round((max(TOTALKWH)), 6) TOTALKWH, round((avg(KWHKWP)), 6) KWHKWP,
|
||||
round((avg(PR)), 6) PR, 0 as MP, 0 SOLARHOUR
|
||||
from solar_master.inverter_history_day a
|
||||
where powerstationID = 22 and DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') between '2020-01-01' and '2021-08-31'
|
||||
group by powerstationID, DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
|
||||
)a join
|
||||
(
|
||||
select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType
|
||||
from solar_master.power_station
|
||||
where `code` = '080250001'
|
||||
) b on a.siteID = b.siteID ;";
|
||||
conn.Execute(ss);
|
||||
|
||||
|
||||
// 4.station month
|
||||
ss = @" delete from solar_master.power_station_history_month where powerstationID = 22;
|
||||
INSERT INTO solar_master.power_station_history_month( PowerStationId, `TIMESTAMP`, SITEID, SITETYPE, MonthKWH, TOTALKWH, KWHKWP,
|
||||
PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON)
|
||||
|
||||
select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.MonthKWH, a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR,
|
||||
(MonthKWH * PowerRate) MONEY, (a.TOTALKWH * PowerRate) TOTALMONEY,
|
||||
(MonthKWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON
|
||||
from
|
||||
(
|
||||
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00:00') reportdate, '080250001' siteid, 0 siteType,
|
||||
round((sum(TODAYKWH)), 6) MonthKWH, round((max(TOTALKWH)), 6) TOTALKWH, round((avg(KWHKWP)), 6) KWHKWP,
|
||||
round((avg(PR)), 6) PR, 0 as MP, 0 SOLARHOUR
|
||||
from solar_master.power_station_history_day a
|
||||
where powerstationID = 22 and DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m') between '2020-01' and '2021-08'
|
||||
group by powerstationID, DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m')
|
||||
)a join
|
||||
(
|
||||
select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType
|
||||
from solar_master.power_station
|
||||
where `code` = '080250001'
|
||||
) b on a.siteID = b.siteID ;";
|
||||
conn.Execute(ss);
|
||||
|
||||
// 5. sensor day
|
||||
ss = @" delete from solar_master.sensor_history_day where powerstationID = 22;
|
||||
insert solar_master.sensor_history_day(powerStationID, `TIMESTAMP`, irradiance, Temperature)
|
||||
select 22 powerstationid, concat(left(`TIMESTAMP`, 10), ' 00:00:00') , round(avg(irradiance), 6) irradiance , 0 Temperature
|
||||
from solar_master.inverter_history_day
|
||||
where powerStationID = 22
|
||||
group by left(`TIMESTAMP`, 10) ;";
|
||||
conn.Execute(ss);
|
||||
|
||||
// 6. sensor month
|
||||
ss = @" delete from solar_master.sensor_history_month where powerstationID = 22;
|
||||
insert solar_master.sensor_history_month(powerStationID, `TIMESTAMP`, irradiance, Temperature)
|
||||
select 22 powerstationid, concat(left(`TIMESTAMP`, 7), '-01 00:00:00') , round(avg(irradiance), 6) irradiance , 0 Temperature
|
||||
from solar_master.inverter_history_day
|
||||
where powerStationID = 22
|
||||
group by left(`TIMESTAMP`, 7);";
|
||||
conn.Execute(ss);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 建立 view, 已建立 目前用不到
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool create_view()
|
||||
{
|
||||
bool result = false;
|
||||
string ss;
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
int i = 0;
|
||||
// 1.src_day to master inv_day
|
||||
ss = @" create view v_inv_hour_hj as
|
||||
select
|
||||
c1 as reportdate
|
||||
,round(c2 , 6) as DC2A
|
||||
,round(c3 , 6) as DC1A
|
||||
,round(c4 , 6) as wh
|
||||
,round(c5 , 6) as DC2W
|
||||
,round(c6 , 6) as DC1W
|
||||
,round(c7 , 6) as DC1V
|
||||
,round(c8 , 6) as DC2V
|
||||
,round(c9 , 6) as irr
|
||||
,round(c10, 6) as RA
|
||||
#,c11 as (c6 + c5) / 1000
|
||||
,round(c12, 6) as AC1A
|
||||
,round(c13, 6) as AC2A
|
||||
,round(c14, 6) as AC3A
|
||||
,round(c15, 6) as AC1V
|
||||
,round(c16, 6) as AC2V
|
||||
,round(c17, 6) as AC3V
|
||||
-- ,c18 機內溫度(°C)
|
||||
-- ,c19 裝置容量(kWp)
|
||||
,CONCAT('0802500010100', right(inv, 2) ) as invID
|
||||
from src_inv
|
||||
where c1 <> '欄位名稱';";
|
||||
conn.Execute(ss);
|
||||
|
||||
ss = @"create view v_inv_day_huijing
|
||||
as
|
||||
select
|
||||
c1 reportDate,
|
||||
round(c2 , 6) as kWp,
|
||||
round(c3 , 6) as kWh,
|
||||
round(c4 , 6) as irr,
|
||||
round(c5 , 6) as kwhkwp,
|
||||
round(c6 , 6) as totalkWh,
|
||||
round(c7 , 6) as PR,
|
||||
(select inv1 from v_invID_day_huijing) inv
|
||||
from src_inv_day
|
||||
where c1 not in ('裝置名稱', '欄位名稱')
|
||||
union
|
||||
select
|
||||
c1 reportDate,
|
||||
round(c8 , 6) as kWp,
|
||||
round(c9 , 6) as kWh,
|
||||
round(c10, 6) as irr,
|
||||
round(c11, 6) as kwhkwp,
|
||||
round(c12, 6) as totalkWh,
|
||||
round(c13, 6) as PR,
|
||||
(select inv2 from v_invID_day_huijing) inv
|
||||
from src_inv_day
|
||||
where c1 not in ('裝置名稱', '欄位名稱')
|
||||
union
|
||||
select
|
||||
c1 reportDate,
|
||||
round(c14, 6) as kWp,
|
||||
round(c15, 6) as kWh,
|
||||
round(c16, 6) as irr,
|
||||
round(c17, 6) as kwhkwp,
|
||||
round(c18, 6) as totalkWh,
|
||||
round(c19, 6) as PR,
|
||||
(select inv3 from v_invID_day_huijing) inv
|
||||
from src_inv_day
|
||||
where c1 not in ('裝置名稱', '欄位名稱')
|
||||
union
|
||||
select
|
||||
c1 reportDate,
|
||||
round(c20, 6) as kWp,
|
||||
round(c21, 6) as kWh,
|
||||
round(c22, 6) as irr,
|
||||
round(c23, 6) as kwhkwp,
|
||||
round(c24, 6) as totalkWh,
|
||||
round(c25, 6) as PR,
|
||||
(select inv4 from v_invID_day_huijing) inv
|
||||
from src_inv_day
|
||||
where c1 not in ('裝置名稱', '欄位名稱')
|
||||
union
|
||||
select
|
||||
c1 reportDate,
|
||||
round(c26, 6) as kWp,
|
||||
round(c27, 6) as kWh,
|
||||
round(c28, 6) as irr,
|
||||
round(c29, 6) as kwhkwp,
|
||||
round(c30, 6) as totalkWh,
|
||||
round(c31, 6) as PR,
|
||||
(select inv5 from v_invID_day_huijing) inv
|
||||
from src_inv_day
|
||||
where c1 not in ('裝置名稱', '欄位名稱')
|
||||
union
|
||||
select
|
||||
c1 reportDate,
|
||||
round(c32, 6) as kWp,
|
||||
round(c33, 6) as kWh,
|
||||
round(c34, 6) as irr,
|
||||
round(c35, 6) as kwhkwp,
|
||||
round(c36, 6) as totalkWh,
|
||||
round(c37, 6) as PR,
|
||||
(select inv6 from v_invID_day_huijing) inv
|
||||
from src_inv_day
|
||||
where c1 not in ('裝置名稱', '欄位名稱')
|
||||
union
|
||||
select
|
||||
c1 reportDate,
|
||||
round(c38, 6) as kWp,
|
||||
round(c39, 6) as kWh,
|
||||
round(c40, 6) as irr,
|
||||
round(c41, 6) as kwhkwp,
|
||||
round(c42, 6) as totalkWh,
|
||||
round(c43, 6) as PR,
|
||||
(select inv7 from v_invID_day_huijing) inv
|
||||
from src_inv_day
|
||||
where c1 not in ('裝置名稱', '欄位名稱')
|
||||
union
|
||||
select
|
||||
c1 reportDate,
|
||||
round(c44, 6) as kWp,
|
||||
round(c45, 6) as kWh,
|
||||
round(c46, 6) as irr,
|
||||
round(c47, 6) as kwhkwp,
|
||||
round(c48, 6) as totalkWh,
|
||||
round(c49, 6) as PR,
|
||||
(select inv8 from v_invID_day_huijing) inv
|
||||
from src_inv_day
|
||||
where c1 not in ('裝置名稱', '欄位名稱')
|
||||
union
|
||||
select
|
||||
c1 reportDate,
|
||||
round(c50, 6) as kWp,
|
||||
round(c51, 6) as kWh,
|
||||
round(c52, 6) as irr,
|
||||
round(c53, 6) as kwhkwp,
|
||||
round(c54, 6) as totalkWh,
|
||||
round(c55, 6) as PR,
|
||||
(select inv9 from v_invID_day_huijing) inv
|
||||
from src_inv_day
|
||||
where c1 not in ('裝置名稱', '欄位名稱');
|
||||
|
||||
create view v_invID_day_huijing as
|
||||
select c2 as inv1, c8 as inv2, c14 as inv3, c20 as inv4, c26 as inv5, c32 as inv6, c38 as inv7, c44 as inv8, c50 as inv9
|
||||
from src_inv_day where c1 = '裝置名稱';";
|
||||
conn.Execute(ss);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
80
solarApp/fmExcel.Designer.cs
generated
80
solarApp/fmExcel.Designer.cs
generated
@ -33,15 +33,17 @@ namespace solarApp
|
||||
this.lbSiteDB_sensor = new System.Windows.Forms.Label();
|
||||
this.lbSiteID_sensor = new System.Windows.Forms.Label();
|
||||
this.bt_archive = new System.Windows.Forms.Button();
|
||||
this.bt_openFile = new System.Windows.Forms.Button();
|
||||
this.bt_inv_hour_hj = new System.Windows.Forms.Button();
|
||||
this.bt_clear_station = new System.Windows.Forms.Button();
|
||||
this.bt_clear_inv = new System.Windows.Forms.Button();
|
||||
this.bt_inv_day_hj = new System.Windows.Forms.Button();
|
||||
this.fp_site = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.btVerifyData = new System.Windows.Forms.Button();
|
||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.lbSiteName_sensor = new System.Windows.Forms.Label();
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.bt_hour_archive_hj = new System.Windows.Forms.Button();
|
||||
this.bt_day_archive_hj = new System.Windows.Forms.Button();
|
||||
this.tb1 = new System.Windows.Forms.TabPage();
|
||||
this.tabControl = new System.Windows.Forms.TabControl();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||
@ -97,16 +99,16 @@ namespace solarApp
|
||||
this.bt_archive.UseVisualStyleBackColor = true;
|
||||
this.bt_archive.Visible = false;
|
||||
//
|
||||
// bt_openFile
|
||||
// bt_inv_hour_hj
|
||||
//
|
||||
this.bt_openFile.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.bt_openFile.Location = new System.Drawing.Point(5, 251);
|
||||
this.bt_openFile.Name = "bt_openFile";
|
||||
this.bt_openFile.Size = new System.Drawing.Size(172, 44);
|
||||
this.bt_openFile.TabIndex = 7;
|
||||
this.bt_openFile.Text = "慧景 - inv hour";
|
||||
this.bt_openFile.UseVisualStyleBackColor = true;
|
||||
this.bt_openFile.Click += new System.EventHandler(this.bt_openFile_Click);
|
||||
this.bt_inv_hour_hj.Font = new System.Drawing.Font("Microsoft JhengHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.bt_inv_hour_hj.Location = new System.Drawing.Point(5, 251);
|
||||
this.bt_inv_hour_hj.Name = "bt_inv_hour_hj";
|
||||
this.bt_inv_hour_hj.Size = new System.Drawing.Size(143, 44);
|
||||
this.bt_inv_hour_hj.TabIndex = 7;
|
||||
this.bt_inv_hour_hj.Text = "慧景 - inv hour";
|
||||
this.bt_inv_hour_hj.UseVisualStyleBackColor = true;
|
||||
this.bt_inv_hour_hj.Click += new System.EventHandler(this.bt_inv_hour_hj_Click);
|
||||
//
|
||||
// bt_clear_station
|
||||
//
|
||||
@ -119,16 +121,16 @@ namespace solarApp
|
||||
this.bt_clear_station.UseVisualStyleBackColor = true;
|
||||
this.bt_clear_station.Visible = false;
|
||||
//
|
||||
// bt_clear_inv
|
||||
// bt_inv_day_hj
|
||||
//
|
||||
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(5, 335);
|
||||
this.bt_clear_inv.Name = "bt_clear_inv";
|
||||
this.bt_clear_inv.Size = new System.Drawing.Size(172, 44);
|
||||
this.bt_clear_inv.TabIndex = 5;
|
||||
this.bt_clear_inv.Text = "慧景 - inv day";
|
||||
this.bt_clear_inv.UseVisualStyleBackColor = true;
|
||||
this.bt_clear_inv.Click += new System.EventHandler(this.bt_clear_inv_Click);
|
||||
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(5, 335);
|
||||
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;
|
||||
this.bt_inv_day_hj.Text = "慧景 - inv day";
|
||||
this.bt_inv_day_hj.UseVisualStyleBackColor = true;
|
||||
this.bt_inv_day_hj.Click += new System.EventHandler(this.bt_inv_day_hj_Click);
|
||||
//
|
||||
// fp_site
|
||||
//
|
||||
@ -193,10 +195,12 @@ namespace solarApp
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
this.splitContainer1.Panel1.BackColor = System.Drawing.Color.PaleGoldenrod;
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_hour_archive_hj);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_day_archive_hj);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_archive);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_openFile);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_inv_hour_hj);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_clear_station);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_clear_inv);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_inv_day_hj);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.fp_site);
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
@ -208,6 +212,28 @@ namespace solarApp
|
||||
this.splitContainer1.SplitterWidth = 10;
|
||||
this.splitContainer1.TabIndex = 0;
|
||||
//
|
||||
// bt_hour_archive_hj
|
||||
//
|
||||
this.bt_hour_archive_hj.Font = new System.Drawing.Font("Microsoft JhengHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.bt_hour_archive_hj.Location = new System.Drawing.Point(154, 251);
|
||||
this.bt_hour_archive_hj.Name = "bt_hour_archive_hj";
|
||||
this.bt_hour_archive_hj.Size = new System.Drawing.Size(146, 44);
|
||||
this.bt_hour_archive_hj.TabIndex = 10;
|
||||
this.bt_hour_archive_hj.Text = "hour archive";
|
||||
this.bt_hour_archive_hj.UseVisualStyleBackColor = true;
|
||||
this.bt_hour_archive_hj.Click += new System.EventHandler(this.bt_hour_archive_hj_Click);
|
||||
//
|
||||
// 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(154, 335);
|
||||
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;
|
||||
this.bt_day_archive_hj.Text = "day archive";
|
||||
this.bt_day_archive_hj.UseVisualStyleBackColor = true;
|
||||
this.bt_day_archive_hj.Click += new System.EventHandler(this.bt_day_archive_hj_Click);
|
||||
//
|
||||
// tb1
|
||||
//
|
||||
this.tb1.Controls.Add(this.splitContainer1);
|
||||
@ -231,13 +257,13 @@ namespace solarApp
|
||||
this.tabControl.Size = new System.Drawing.Size(1782, 853);
|
||||
this.tabControl.TabIndex = 1;
|
||||
//
|
||||
// fmExcel
|
||||
// bt_day_achive_hj
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1782, 853);
|
||||
this.Controls.Add(this.tabControl);
|
||||
this.Name = "fmExcel";
|
||||
this.Name = "bt_day_achive_hj";
|
||||
this.Text = "fmExcel";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||
this.panel1.ResumeLayout(false);
|
||||
@ -258,7 +284,7 @@ namespace solarApp
|
||||
private System.Windows.Forms.Label lbSiteDB_sensor;
|
||||
private System.Windows.Forms.Label lbSiteID_sensor;
|
||||
private System.Windows.Forms.Button bt_archive;
|
||||
private System.Windows.Forms.Button bt_openFile;
|
||||
private System.Windows.Forms.Button bt_inv_hour_hj;
|
||||
private System.Windows.Forms.Button bt_clear_station;
|
||||
private System.Windows.Forms.Button bt_clear_inv;
|
||||
private System.Windows.Forms.FlowLayoutPanel fp_site;
|
||||
@ -269,5 +295,9 @@ namespace solarApp
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private System.Windows.Forms.TabPage tb1;
|
||||
private System.Windows.Forms.TabControl tabControl;
|
||||
private System.Windows.Forms.Button bt_inv_day_hj;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button bt_hour_archive_hj;
|
||||
private System.Windows.Forms.Button bt_day_archive_hj;
|
||||
}
|
||||
}
|
||||
@ -21,7 +21,7 @@ namespace solarApp
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void bt_openFile_Click(object sender, EventArgs e)
|
||||
private void bt_inv_hour_hj_Click(object sender, EventArgs e)
|
||||
{
|
||||
string fname = "";
|
||||
OpenFileDialog fdlg = new OpenFileDialog();
|
||||
@ -53,7 +53,8 @@ namespace solarApp
|
||||
|
||||
if (isFirst)
|
||||
{
|
||||
csvSvc.createColumnDay(ref dt, fileName);
|
||||
csvSvc.clear_inv("hour");
|
||||
csvSvc.createColumnHour(ref dt, fileName);
|
||||
csvSvc.readCsvFile(ref dt, fileName, InvID, dt.Columns.Count, isFirst);
|
||||
isFirst = false;
|
||||
}
|
||||
@ -63,8 +64,7 @@ namespace solarApp
|
||||
MessageBox.Show(" 共 "+ dt.Rows.Count.ToString());
|
||||
|
||||
//System.Data.DataTable dt = solarApp.Service.csvHelper.OpenCSV(fname);
|
||||
dataGridView1.DataSource = dt;
|
||||
csvSvc.insertDay2DB(ref dt);
|
||||
dataGridView1.DataSource = csvSvc.insertHour2DB(ref dt);
|
||||
MessageBox.Show("OK");
|
||||
}
|
||||
protected void ImportFile()
|
||||
@ -130,7 +130,7 @@ namespace solarApp
|
||||
|
||||
}
|
||||
|
||||
private void bt_clear_inv_Click(object sender, EventArgs e)
|
||||
private void bt_inv_day_hj_Click(object sender, EventArgs e)
|
||||
{
|
||||
string fname = "";
|
||||
OpenFileDialog fdlg = new OpenFileDialog();
|
||||
@ -162,6 +162,7 @@ namespace solarApp
|
||||
|
||||
if (isFirst)
|
||||
{
|
||||
csvSvc.clear_inv("day");
|
||||
csvSvc.createColumnDay(ref dt, fileName);
|
||||
csvSvc.readCsvFile(ref dt, fileName, "", dt.Columns.Count, isFirst);
|
||||
isFirst = false;
|
||||
@ -176,5 +177,19 @@ namespace solarApp
|
||||
csvSvc.insertDay2DB(ref dt);
|
||||
MessageBox.Show("OK");
|
||||
}
|
||||
|
||||
private void bt_day_archive_hj_Click(object sender, EventArgs e)
|
||||
{
|
||||
Service.operateCSV csvSvc = new Service.operateCSV(); // readCsvTxt
|
||||
csvSvc.archive_data("day");
|
||||
MessageBox.Show("ok");
|
||||
}
|
||||
|
||||
private void bt_hour_archive_hj_Click(object sender, EventArgs e)
|
||||
{
|
||||
Service.operateCSV csvSvc = new Service.operateCSV(); // readCsvTxt
|
||||
csvSvc.archive_data("hour");
|
||||
MessageBox.Show("ok");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user