Logger.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Text;
  3. using System.Runtime.InteropServices;
  4. using Wayne.Lib;
  5. using Wayne.Lib.Log;
  6. namespace Wayne.ForecourtControl.Fusion
  7. {
  8. public static class Trace
  9. {
  10. public static DebugLogger debugLogger = null;
  11. public static void Add(IIdentifiableEntity logclass)
  12. {
  13. try
  14. {
  15. if (debugLogger == null)
  16. debugLogger = new DebugLogger(logclass, true);
  17. }
  18. catch (Exception ex)
  19. {
  20. }
  21. }
  22. public static void WriteLine(string msg)
  23. {
  24. try
  25. {
  26. if (debugLogger != null && debugLogger.IsActive())
  27. {
  28. debugLogger.Add(msg);
  29. }
  30. }
  31. catch (Exception ex)
  32. {
  33. }
  34. }
  35. public static void WriteLineIf(bool condition, string msg)
  36. {
  37. try
  38. {
  39. if (debugLogger != null && debugLogger.IsActive() && (condition || debugLogger.GetDebugLevel() == DebugLogLevel.Detailed))
  40. {
  41. debugLogger.Add(msg);
  42. }
  43. }
  44. catch (Exception ex)
  45. {
  46. }
  47. }
  48. public static bool CheckTraceLevel(int iLevel)
  49. {
  50. return true;
  51. }
  52. }
  53. public static class IniFile
  54. {
  55. [DllImport("kernel32")]
  56. private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
  57. public static string IniReadValue(string Path, string Section, string Key)
  58. {
  59. StringBuilder temp = new StringBuilder(255);
  60. int i = GetPrivateProfileString(Section, Key, "", temp, 255, Path);
  61. return temp.ToString();
  62. }
  63. }
  64. }