/// <summary> /// 写Log到DB中 /// </summary> /// <param name="eLevel"></param> /// <param name="curTime"></param> /// <param name="nLogID"></param> /// <param name="strMsg"></param> /// <param name="strFinalMsg"></param> /// <param name="nTaskID"></param> private void WriteToDB(ENUM_LogLevel eLevel, DateTime curTime, int nLogID, string strMsg, string strFinalMsg, int nTaskID) { try { if (((int)eLevel) < ((int)ENUM_LogLevel.eLogLevel_Warning)) { return; } if (m_DBLog == null) { return; } FKSQLiteLogNode node = new FKSQLiteLogNode(); node.LogId = m_nLogID; node.LogTime = curTime; node.LogLevel = (int)eLevel; node.LogInfo = strMsg; node.TaskID = nTaskID; m_DBLog.AddLogToDB(node); } catch (Exception e) { Console.WriteLine($"[Error] Write a log to DB failed. Error = {e.Message}, Msg = {strFinalMsg}, TaskID = {nTaskID}"); } }
/// <summary> /// 对外接口:添加一条DB Log记录 /// </summary> /// <param name="node"></param> public bool AddLogToDB(FKSQLiteLogNode node) { try { if (!IsDBFileExistByTime(node.LogTime)) { m_DBObject = CreateDBFileByTime(node.LogTime); } return(m_DBObject.Insert(node) > 0); } catch (Exception e) { Console.WriteLine($"[Error] Add log to Failed. Error = {e.ToString()}"); return(false); } }