From 452f43aeafb43066ea27ef906e84184bb14e151f Mon Sep 17 00:00:00 2001 From: cesar liu Date: Mon, 22 Aug 2022 10:20:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=B0=E5=B8=B8=E5=90=8C=E6=AD=A5=20SQL=20?= =?UTF-8?q?=E8=AA=9E=E6=B3=95=E5=9F=B7=E8=A1=8C=E6=99=82=E9=96=93=E5=BB=B6?= =?UTF-8?q?=E9=95=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- solarApp/Service/procSyncError.cs | 22 +++++++++++----------- solarApp/fmArchive.Designer.cs | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/solarApp/Service/procSyncError.cs b/solarApp/Service/procSyncError.cs index cbc08bd..2c77194 100644 --- a/solarApp/Service/procSyncError.cs +++ b/solarApp/Service/procSyncError.cs @@ -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(sql).AsList(); + var ds_max = conn.Query(sql, commandTimeout: 600).AsList(); 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(sql).AsList(); + var ds = conn.Query(sql, commandTimeout: 600).AsList(); 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,11 +178,11 @@ 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); - #endregion + #endregion } conn.Close(); } diff --git a/solarApp/fmArchive.Designer.cs b/solarApp/fmArchive.Designer.cs index 1c81943..2fd4e06 100644 --- a/solarApp/fmArchive.Designer.cs +++ b/solarApp/fmArchive.Designer.cs @@ -753,7 +753,7 @@ namespace solarApp // // timer1 // - this.timer1.Interval = 1000; + this.timer1.Interval = 10000; // // fmArchive //