diff --git a/.vs2/slnSolarPower/DesignTimeBuild/.dtbcache.v2 b/.vs2/slnSolarPower/DesignTimeBuild/.dtbcache.v2 new file mode 100644 index 0000000..7deac22 Binary files /dev/null and b/.vs2/slnSolarPower/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs2/slnSolarPower/config/applicationhost.config b/.vs2/slnSolarPower/config/applicationhost.config new file mode 100644 index 0000000..3269632 --- /dev/null +++ b/.vs2/slnSolarPower/config/applicationhost.config @@ -0,0 +1,995 @@ + + + + + + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/solarApp/Model/errMain_model.cs b/solarApp/Model/errMain_model.cs index 35f1d60..548436a 100644 --- a/solarApp/Model/errMain_model.cs +++ b/solarApp/Model/errMain_model.cs @@ -8,21 +8,21 @@ namespace solarApp.Model { public int id { get; set; } public string site_id { get; set; } - public int timestamp { get; set; } + public Int64 timestamp { get; set; } public string datestamp { get; set; } public int uuidHash { get; set; } - public string uuid { get; set; } + public Byte[] uuid { get; set; } public string isOpen {get; set;} public string sourceState { get; set; } public string ackState { get; set; } public Int16 ackRequired { get; set; } public int alarmClass { get; set; } public int priority { get; set; } - public int normalTime { get; set; } - public int ackTime { get; set; } + public Int64 normalTime { get; set; } + public Int64 ackTime { get; set; } public string userAccount { get; set; } public int alarmTransition { get; set; } - public int lastUpdate { get; set; } + public Int64 lastUpdate { get; set; } public string errDevice { get; set; } public string err_valuekind { get; set; } public string errValue { get; set; } diff --git a/solarApp/Service/procSyncError.cs b/solarApp/Service/procSyncError.cs index b58b48b..6fabfba 100644 --- a/solarApp/Service/procSyncError.cs +++ b/solarApp/Service/procSyncError.cs @@ -43,7 +43,7 @@ namespace solarApp.Service a.`normaltime` = b.`normaltime`, a.`acktime` = b.`acktime`, a.`lastupdate` = b.`lastupdate` - where a.sourcestate =1 and and a.site_id is not null "; // b.datestamp >= '{ System.DateTime.Now.AddDays(-90).ToString("yyyy-mm-dd")}' ;"; + where a.sourcestate =1 and a.site_id is not null "; // b.datestamp >= '{ System.DateTime.Now.AddDays(-90).ToString("yyyy-mm-dd")}' ;"; int rowCount = conn.Execute(sql); TimeSpan durationSec = DateTime.Now - dt_start; arclog.insert_log("0", "syncError s2 normaltime", durationSec.TotalSeconds, "orionAlarmRecord", "err_main", "0", "", rowCount.ToString(), conn, null); @@ -51,9 +51,11 @@ namespace solarApp.Service #endregion #region 取得 昨天到今天的尚未同步的異常資料 - sql = $@" select * from alarmorion_orionalarmrecord - where id not in (select id from err_main ) - and datestamp >= '{System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}'"; + //sql = $@" select * from alarmorion_orionalarmrecord + // where id not in (select id from err_main ) + // 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(); StringBuilder sb = new StringBuilder(); bool isfirst = true; @@ -72,16 +74,16 @@ namespace solarApp.Service if (ds.Count > 0) { #region 新增異常值 err_main - string sql_header = "INSERT INTO `err_main`(`id`, `timestamp`, `datestamp`, `uuidHash`, `uuid`, `isOpen`, `sourceState`, `ackState`, `ackRequired`, `alarmClass`, `priority`, `normalTime`, `ackTime`, `userAccount`, `alarmTransition`, `lastUpdate`) "; - foreach (var item in ds) - { - sql = sql_header + $@" VALUES ({item.id}, {item.timestamp}, '{item.datestamp}', {item.uuidHash}, {item.uuid}, {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); - TimeSpan duration = DateTime.Now - dt_start; - arclog.insert_log("0", "syncError s1", duration.TotalSeconds, "orionAlarmRecord", "err_main", "0", "", rowCT.ToString(), conn, null); + //string sql_header = "INSERT INTO `err_main`(`id`, `timestamp`, `datestamp`, `uuidHash`, `uuid`, `isOpen`, `sourceState`, `ackState`, `ackRequired`, `alarmClass`, `priority`, `normalTime`, `ackTime`, `userAccount`, `alarmTransition`, `lastUpdate`) "; + //foreach (var item in ds) + //{ + // sql = sql_header + $@" VALUES ({item.id}, {item.timestamp}, '{item.datestamp}', {item.uuidHash}, {item.uuid}, {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); + //TimeSpan duration = DateTime.Now - dt_start; + //arclog.insert_log("0", "syncError s1", duration.TotalSeconds, "orionAlarmRecord", "err_main", "0", "", rowCT.ToString(), conn, null); #endregion #region update site_id, inverterID @@ -92,8 +94,8 @@ namespace solarApp.Service SUBSTRING_INDEX(`value`, '@', 1) # @前面所有string --> e:7 , ':', -1) where facetName = 4 and alarm in ({sb.ToString()});"; - rowCT = conn.Execute(sql); - duration = DateTime.Now - dt_start; + int rowCT = conn.Execute(sql); + TimeSpan duration = DateTime.Now - dt_start; arclog.insert_log("0", "syncError s3 errValue", duration.TotalSeconds, "facetvalue4", "err_main", "0", "", rowCT.ToString(), conn, null); #endregion @@ -102,7 +104,7 @@ namespace solarApp.Service dt_start = DateTime.Now; sql = $@"update err_main a join alarmorion_orionalarmfacetvalue b on a.id = b.alarm set err_valuekind = left(`value`, 1), - errDevice = SUBSTRING_INDEX(SUBSTRING_INDEX(new.`value`, ':', -1) # : 後面所有string + errDevice = SUBSTRING_INDEX(SUBSTRING_INDEX(`value`, ':', -1) # : 後面所有string ,'S', -1) where facetName = 8 and alarm in ({sb.ToString()});"; rowCT = conn.Execute(sql); @@ -125,7 +127,7 @@ namespace solarApp.Service #region 更新全部的燈號 dt_start = DateTime.Now; - sql = $@"drop table temp_healthStatus; + sql = $@"DROP TABLE IF EXISTS `temp_healthStatus`; create table temp_healthStatus select v.siteName, z.* from ( select ROW_NUMBER() OVER (PARTITION BY site_id ORDER BY HealthStatus desc) row_num, @@ -136,7 +138,7 @@ namespace solarApp.Service when alarmClass != 4 then 2 end HealthStatus # inv, sensor 異常 黃燈 from err_main where sourceState = 1 and left(site_id , 1) = '0' - and datestamp > '{ System.DateTime.Now.AddDays(-60).ToString("yyyy-mm-dd")}' + and datestamp > '{ System.DateTime.Now.AddDays(-60).ToString("yyyy-MM-dd")}' order by HealthStatus desc limit 100 ) x