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

  1. using Newtonsoft.Json;
  2. using OT.COM.ArsenalDB;
  3. using OT.COM.SignalerMessage;
  4. using SoldierData.EnterprizeV4;
  5. using System.Collections.Generic;
  6. namespace CounsellorBL.Helper
  7. {
  8. public class LogHelper : DBService
  9. {
  10. public override string MainTable => GetMainTableName(typeof(tb_sys_exceptionlog));
  11. public static int DBLog(string i_sDetail,
  12. [System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
  13. [System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
  14. [System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
  15. {
  16. return new LogHelper().WriteDB(i_sDetail, null, null, i_nCodeLine, i_sMemberName, i_sSourcePath);
  17. }
  18. public static int DBLog(
  19. string i_sDetail, Dictionary<string, object> i_oParameter, string i_sProgramUid = null,
  20. [System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
  21. [System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
  22. [System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
  23. {
  24. return new LogHelper().WriteDB(i_sDetail, i_sProgramUid, i_oParameter, i_nCodeLine, i_sMemberName, i_sSourcePath);
  25. }
  26. public static int DBLog(string i_sDetail, CRequestMessage i_crq,
  27. [System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
  28. [System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
  29. [System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
  30. {
  31. string sProgramUid = GetRequestProgramID(i_crq);
  32. Dictionary<string, object> oParameter = i_crq?.param;
  33. return new LogHelper().WriteDB(i_sDetail, sProgramUid, oParameter, i_nCodeLine, i_sMemberName, i_sSourcePath);
  34. }
  35. public int WriteDB(string i_sDetail, string i_sProgramUid, Dictionary<string, object> i_oParameter = null,
  36. [System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
  37. [System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
  38. [System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
  39. {
  40. int nRes = 0;
  41. try
  42. {
  43. do
  44. {
  45. tb_sys_exceptionlog el = new tb_sys_exceptionlog
  46. {
  47. detail = i_sDetail
  48. };
  49. if (i_sProgramUid != null)
  50. {
  51. el.program_uid = i_sProgramUid;
  52. }
  53. if (i_oParameter != null)
  54. {
  55. el.parameters = JsonConvert.SerializeObject(i_oParameter);
  56. }
  57. el.member_name = i_sMemberName;
  58. el.file_path = i_sSourcePath;
  59. el.line_number = i_nCodeLine;
  60. Command cInsert = Command.SetupInsertCmd(el);
  61. ArsenalInterface ai = ArsenalDBMgr.GetInst(cInsert, GetDefaultSystemColumnInfo());
  62. nRes = ai.RunEditSingleCmd(cInsert);
  63. }
  64. while (false);
  65. }
  66. catch
  67. {
  68. // If comes here no place to put log anymore, just ignore. e.g. DB Fail
  69. }
  70. return nRes;
  71. }
  72. }
  73. }