異常同步 SQL 語法執行時間延長

This commit is contained in:
cesar liu 2022-08-22 10:20:24 +08:00
parent c5b18933c4
commit 452f43aeaf
2 changed files with 12 additions and 12 deletions

View File

@ -44,7 +44,7 @@ namespace solarApp.Service
a.`acktime` = b.`acktime`,
a.`lastupdate` = b.`lastupdate`
where a.sourcestate = 1 and b.datestamp >= '{ System.DateTime.Now.AddDays(-60).ToString("yyyy-MM-dd")}'";// and a.site_id is not null "; // ;";
int rowCount = conn.Execute(sql);
int rowCount = conn.Execute(sql, commandTimeout: 600);
TimeSpan durationSec = DateTime.Now - dt_start;
arclog.insert_log("0", "syncError s0 normaltime", durationSec.TotalSeconds, "orionAlarmRecord", "err_main", "0", "", rowCount.ToString(), conn, null);
@ -53,7 +53,7 @@ namespace solarApp.Service
#region
sql = $@" select max(id) new_id, (select max(id) old_id from err_main ) old_id
from alarmorion_orionalarmrecord ";
var ds_max = conn.Query<max_id>(sql).AsList<max_id>();
var ds_max = conn.Query<max_id>(sql, commandTimeout: 600).AsList<max_id>();
if (ds_max.Count == 0 ) return false; // 查無資料
if (ds_max[0].new_id == ds_max[0].old_id) return true; // 無新資料
@ -63,7 +63,7 @@ namespace solarApp.Service
// and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}'";
//sql = $@"select * from err_main
// where site_id is null and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}'";
var ds = conn.Query<errMain_model>(sql).AsList<errMain_model>();
var ds = conn.Query<errMain_model>(sql, commandTimeout: 600).AsList<errMain_model>();
StringBuilder sb = new StringBuilder();
bool isfirst = true;
foreach (var item in ds)
@ -89,7 +89,7 @@ namespace solarApp.Service
, {item.isOpen}, {item.sourceState}, {item.ackState}, {item.ackRequired}, {item.alarmClass}, {item.priority}, {item.normalTime}, {item.ackTime}
, '{item.userAccount}', {item.alarmTransition}, {item.lastUpdate}); ";
}
int rowCT = conn.Execute(sql);
int rowCT = conn.Execute(sql, commandTimeout: 600);
TimeSpan duration = DateTime.Now - dt_start;
arclog.insert_log("0", "syncError s1", duration.TotalSeconds, "orionAlarmRecord", "err_main", "0", "", rowCT.ToString(), conn, null);
#endregion
@ -102,7 +102,7 @@ namespace solarApp.Service
SUBSTRING_INDEX(`value`, '@', 1) # @string --> e:7
, ':', -1)
where facetName = 4 and alarm in ({sb.ToString()});";
rowCT = conn.Execute(sql);
rowCT = conn.Execute(sql, commandTimeout: 600);
duration = DateTime.Now - dt_start;
arclog.insert_log("0", "syncError s2 errValue", duration.TotalSeconds, "facetvalue4", "err_main", "0", "", rowCT.ToString(), conn, null);
#endregion
@ -119,7 +119,7 @@ namespace solarApp.Service
,'S', -1)
, 1, 9)
where facetName = 8 and a.site_id is null and a.datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}';";
rowCT = conn.Execute(sql);
rowCT = conn.Execute(sql, commandTimeout: 600);
duration = DateTime.Now - dt_start;
arclog.insert_log("0", "syncError s3 errDevice", duration.TotalSeconds, "facetValue8", "err_main", "0", "", rowCT.ToString(), conn, null);
@ -131,7 +131,7 @@ namespace solarApp.Service
errDeviceBrand = b.brand,
errDeviceModel = b.Model
where errDevice is not null and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}';";
rowCT = conn.Execute(sql);
rowCT = conn.Execute(sql, commandTimeout: 600);
duration = DateTime.Now - dt_start;
arclog.insert_log("0", "syncError s4 site_id", duration.TotalSeconds, "v_company_inv", "err_main", "0", "", rowCT.ToString(), conn, null);
#endregion
@ -155,13 +155,13 @@ namespace solarApp.Service
) x
)z join v_station v on z.site_id = v.siteid
where row_num = 1;";
conn.Execute(sql);
conn.Execute(sql, commandTimeout: 600);
sql = $@"update power_station set healthstatus = 1;
update power_station a join temp_healthstatus b on a.code = b.site_id
set a.healthstatus = b.healthstatus;";
rowCT = conn.Execute(sql);
rowCT = conn.Execute(sql, commandTimeout: 600);
duration = DateTime.Now - dt_start;
arclog.insert_log("0", "syncError s5 site health", duration.TotalSeconds, "temp_healthstatus", "err_main", "0", "", rowCT.ToString(), conn, null);
@ -178,7 +178,7 @@ namespace solarApp.Service
group by errDevice
)b on a.inverterid = b.errDevice
set status = errStatus;";
rowCT = conn.Execute(sql);
rowCT = conn.Execute(sql, commandTimeout: 600);
duration = DateTime.Now - dt_start;
arclog.insert_log("0", "syncError s6 inv health", duration.TotalSeconds, "", "err_main", "0", "", rowCT.ToString(), conn, null);

View File

@ -753,7 +753,7 @@ namespace solarApp
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Interval = 10000;
//
// fmArchive
//