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.

47 lines
1.3 KiB

  1. using System;
  2. using System.Configuration;
  3. using System.IO;
  4. using System.Text;
  5. namespace JMETxnPushScheduler.Business
  6. {
  7. public static class GetStatic
  8. {
  9. public static string ReadWebConfig(string key, string defValue)
  10. {
  11. return ConfigurationManager.AppSettings[key] ?? defValue;
  12. }
  13. public static void WriteLog(string Log)
  14. {
  15. string LogFile = GetStatic.ReadAppSetting("LogFile");
  16. StringBuilder LogText = new StringBuilder();
  17. LogText.AppendLine(Log + DateTime.Now.ToString());
  18. LogText.AppendLine("----------------------------------------------------------------------------");
  19. Write(LogText.ToString());
  20. using (StreamWriter writetext = new StreamWriter(LogFile, true))
  21. {
  22. writetext.WriteLine(LogText.ToString());
  23. }
  24. }
  25. static void Write(string data)
  26. {
  27. Console.WriteLine(data);
  28. }
  29. public static string ReadAppSetting(this string val)
  30. {
  31. try
  32. {
  33. return ConfigurationSettings.AppSettings[val].ToString();
  34. }
  35. catch (Exception)
  36. {
  37. return "";
  38. }
  39. }
  40. }
  41. }