FIC_Solar/solarApp/Service/procArchiveLog.cs

33 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
namespace solarApp.Service
{
public class procArchiveLog
{
/// <summary>
/// insert Log
/// </summary>
/// <param name="action_name">動作名稱</param>
/// <param name="duration_sec">運行時間</param>
/// <param name="src_table">來源Table</param>
/// <param name="dest_table">目的地table</param>
/// <param name="errMessage">異常資訊</param>
/// <param name="myCon">連線資訊</param>
/// <param name="cmd">command物件</param>
public void insert_log(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
src_table + "', '"+ dest_table + "', b'"+ procResult + "', '" + // src_table, dest_table, result
errMessage + "');"; // err_txt
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
}
}
}