SysConfig.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Entity;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Security.Policy;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using XdCxRhDW.Entity;
  10. namespace XdCxRhDW.Repostory
  11. {
  12. public static class SysConfig
  13. {
  14. public static SysSetings Config { get; set; }
  15. public static DateTime ToUtc(this DateTime time)
  16. {
  17. return time.AddHours(-Config.ZoneHours);
  18. }
  19. public static string GetBaseUrl()
  20. {
  21. if (Config == null) return null;
  22. return $"http://{IpHelper.GetLocalIp()}:{Config.HttpPort}/api/";
  23. }
  24. public static string GetUrl(string url)
  25. {
  26. if (Config == null) return null;
  27. if (url.StartsWith("/"))
  28. {
  29. return $"http://{IpHelper.GetLocalIp()}:{Config.HttpPort}/api{url}";
  30. }
  31. else
  32. {
  33. return $"http://{IpHelper.GetLocalIp()}:{Config.HttpPort}/api/{url}";
  34. }
  35. }
  36. }
  37. }