From 3f34f8a052d5cc4d58f661abdd8e00072544088c Mon Sep 17 00:00:00 2001 From: cesar liu Date: Mon, 28 Mar 2022 01:06:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=A0=B1=E8=A1=A8Log=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20=E9=9B=BB=E7=AB=99ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- solarApp/Service/procArchiveLog.cs | 6 +++--- solarApp/Service/procInvSvc.cs | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/solarApp/Service/procArchiveLog.cs b/solarApp/Service/procArchiveLog.cs index 2dbef06..98c9ac2 100644 --- a/solarApp/Service/procArchiveLog.cs +++ b/solarApp/Service/procArchiveLog.cs @@ -17,12 +17,12 @@ namespace solarApp.Service /// 異常資訊 /// 連線資訊 /// command物件 - public void insert_log(string action_name, double duration_sec, string src_table, string dest_table, string errMessage, MySqlConnection myCon , MySqlCommand cmd) { + public void insert_log(string power_stationID, string action_name, double duration_sec, string src_table, string dest_table, string errMessage, MySqlConnection myCon , MySqlCommand cmd) { string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string procResult = (string.IsNullOrEmpty(errMessage)) ? "0" : "1"; - string sql = @"INSERT INTO `solar_master`.`log_archive`(`action_name`, `action_time`, `duration_sec`, `src_table`, `dest_table`, `result`, `err_txt`) - VALUES ('" + action_name + "', '" + nowTime + "', " + duration_sec + ", '" + // action_time, duration_sec + string sql = @"INSERT INTO `solar_master`.`log_archive`(power_stationID, `action_name`, `action_time`, `duration_sec`, `src_table`, `dest_table`, `result`, `err_txt`) + VALUES ("+ power_stationID + ", '" + action_name + "', '" + nowTime + "', " + duration_sec + ", '" + // action_time, duration_sec src_table + "', '"+ dest_table + "', b'"+ procResult + "', '" + // src_table, dest_table, result errMessage + "');"; // err_txt cmd.CommandText = sql; diff --git a/solarApp/Service/procInvSvc.cs b/solarApp/Service/procInvSvc.cs index 5f050c7..fab9952 100644 --- a/solarApp/Service/procInvSvc.cs +++ b/solarApp/Service/procInvSvc.cs @@ -607,13 +607,13 @@ ALTER TABLE `temp_invDay{_powerStationID}_s1` ADD INDEX `temp_indexs1` (report_d //select LAST_INSERT_ID() TimeSpan duration = DateTime.Now - dt_start; - arclog.insert_log("report_day step1", duration.TotalSeconds, "inverter_history_hour", "temp_invDay", "", conn, cmd); + arclog.insert_log(_powerStationID, "report_day step1", duration.TotalSeconds, "inverter_history_hour", "temp_invDay", "", conn, cmd); } catch (Exception ex) { TimeSpan duration = DateTime.Now - dt_start; - arclog.insert_log("report_day step1", duration.TotalSeconds, "inverter_history_hour", "temp_invDay", ex.Message, conn, cmd); + arclog.insert_log(_powerStationID, "report_day step1", duration.TotalSeconds, "inverter_history_hour", "temp_invDay", ex.Message, conn, cmd); } #endregion @@ -650,12 +650,12 @@ from temp_invDay{_powerStationID}_s1 a join cmd.ExecuteNonQuery(); TimeSpan duration = DateTime.Now - dt_start2 ; - arclog.insert_log("report_day step2 inv_no01", duration.TotalSeconds, "inverter_history_hour", "report_invday", "", conn, cmd); + arclog.insert_log(_powerStationID, "report_day step2 inv_no01", duration.TotalSeconds, "inverter_history_hour", "report_invday", "", conn, cmd); } catch (Exception ex) { TimeSpan duration = DateTime.Now - dt_start2 ; - arclog.insert_log("report_day step2 inv_no01", duration.TotalSeconds, "inverter_history_hour", "report_invday", ex.Message, conn, cmd); + arclog.insert_log(_powerStationID, "report_day step2 inv_no01", duration.TotalSeconds, "inverter_history_hour", "report_invday", ex.Message, conn, cmd); } // conn.Execute(sql); @@ -729,13 +729,13 @@ set a.inv_02 = b.inv_02 "); if (_logger != null) _logger.LogInformation("【Proc_inv_日報 table 】執行完成[{0}]在{1} inv_get_SQLStatement", _siteID, _date1); - TimeSpan duration = DateTime.Now - dt_start3; - arclog.insert_log("report_day step3 update inv02", duration.TotalSeconds, "inverter_history_hour", "report_invday", "", conn, cmd); + TimeSpan duration = DateTime.Now - dt_start3; + arclog.insert_log(_powerStationID, "report_day step3 update inv02", duration.TotalSeconds, "inverter_history_hour", "report_invday", "", conn, cmd); } catch (Exception ex) { TimeSpan duration = DateTime.Now - dt_start3 ; - arclog.insert_log("report_day step3 update inv02", duration.TotalSeconds, "inverter_history_hour", "report_invday", ex.Message, conn, cmd); + arclog.insert_log(_powerStationID, "report_day step3 update inv02", duration.TotalSeconds, "inverter_history_hour", "report_invday", ex.Message, conn, cmd); if (_logger != null) { _logger.LogError("【Proc_inv_日報 table】執行失敗[{0}]在{1}inv_get_SQLStatement", _siteID, _date1);