XlCache.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using XdCxRhDW.Repostory.EFContext;
  7. using XdCxRhDW.Repostory.Model;
  8. namespace XdCxRhDW.App
  9. {
  10. public static class XlCache
  11. {
  12. public static IEnumerable<XlInfo> GetAll()
  13. {
  14. try
  15. {
  16. DateTime now = DateTime.Now;
  17. IEnumerable<XlInfo> xlInfos = null;
  18. for (int i = 0; i < 30; i++)
  19. {
  20. using (RHDWPartContext db = new RHDWPartContext(now.AddDays(-i)))
  21. {
  22. if (xlInfos == null)
  23. xlInfos = db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ);
  24. else
  25. xlInfos = xlInfos.Concat(db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ));
  26. }
  27. }
  28. return xlInfos;
  29. }
  30. catch (Exception ex)
  31. {
  32. Serilog.Log.Error(ex, "加载星历信息异常");
  33. return null;
  34. }
  35. }
  36. }
  37. }