You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
3.5 KiB
85 lines
3.5 KiB
using Newtonsoft.Json;
|
|
using OT.COM.ArsenalDB;
|
|
using OT.COM.SignalerMessage;
|
|
using SoldierData.EnterprizeV4;
|
|
using System.Collections.Generic;
|
|
|
|
namespace CounsellorBL.Helper
|
|
{
|
|
public class LogHelper : DBService
|
|
{
|
|
public override string MainTable => GetMainTableName(typeof(tb_sys_exceptionlog));
|
|
|
|
public static int DBLog(string i_sDetail,
|
|
[System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
|
|
[System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
|
|
[System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
|
|
{
|
|
return new LogHelper().WriteDB(i_sDetail, null, null, i_nCodeLine, i_sMemberName, i_sSourcePath);
|
|
}
|
|
public static int DBLog(
|
|
string i_sDetail, Dictionary<string, object> i_oParameter, string i_sProgramUid = null,
|
|
[System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
|
|
[System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
|
|
[System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
|
|
{
|
|
return new LogHelper().WriteDB(i_sDetail, i_sProgramUid, i_oParameter, i_nCodeLine, i_sMemberName, i_sSourcePath);
|
|
}
|
|
|
|
public static int DBLog(string i_sDetail, CRequestMessage i_crq,
|
|
[System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
|
|
[System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
|
|
[System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
|
|
{
|
|
string sProgramUid = GetRequestProgramID(i_crq);
|
|
Dictionary<string, object> oParameter = i_crq?.param;
|
|
|
|
return new LogHelper().WriteDB(i_sDetail, sProgramUid, oParameter, i_nCodeLine, i_sMemberName, i_sSourcePath);
|
|
}
|
|
|
|
public int WriteDB(string i_sDetail, string i_sProgramUid, Dictionary<string, object> i_oParameter = null,
|
|
[System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
|
|
[System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
|
|
[System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
|
|
{
|
|
int nRes = 0;
|
|
try
|
|
{
|
|
do
|
|
{
|
|
tb_sys_exceptionlog el = new tb_sys_exceptionlog
|
|
{
|
|
detail = i_sDetail
|
|
};
|
|
|
|
if (i_sProgramUid != null)
|
|
{
|
|
el.program_uid = i_sProgramUid;
|
|
}
|
|
|
|
if (i_oParameter != null)
|
|
{
|
|
el.parameters = JsonConvert.SerializeObject(i_oParameter);
|
|
}
|
|
|
|
el.member_name = i_sMemberName;
|
|
el.file_path = i_sSourcePath;
|
|
el.line_number = i_nCodeLine;
|
|
|
|
Command cInsert = Command.SetupInsertCmd(el);
|
|
ArsenalInterface ai = ArsenalDBMgr.GetInst(cInsert, GetDefaultSystemColumnInfo());
|
|
|
|
nRes = ai.RunEditSingleCmd(cInsert);
|
|
}
|
|
while (false);
|
|
}
|
|
catch
|
|
{
|
|
// If comes here no place to put log anymore, just ignore. e.g. DB Fail
|
|
}
|
|
|
|
return nRes;
|
|
}
|
|
|
|
}
|
|
}
|