| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | 
							- using DxHelper;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Data.Entity;
 
- using System.IO;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using XdCxRhDW.Repostory.EFContext;
 
- using XdCxRhDW.Repostory.Model;
 
- namespace XdCxRhDW.App
 
- {
 
-     public static class XlCache
 
-     {
 
-         public static  List<XlInfo> GetAll()
 
-         {
 
-             try
 
-             {
 
-                 DateTime now = DateTime.Now;
 
-                 List<XlInfo> xlInfos = new List<XlInfo>();
 
-                 for (int i = 0; i < 30; i++)
 
-                 {
 
-                     using (RHDWPartContext db = RHDWPartContext.GetContext(now.AddDays(-i)))
 
-                     {
 
-                         var items =  db.XlInfos.OrderBy(p => p.SatName).OrderByDescending(p => p.TimeBJ).ToList();
 
-                         xlInfos.AddRange(items);
 
-                     }
 
-                 }
 
-                 return xlInfos;
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 Serilog.Log.Error(ex, "加载星历信息异常");
 
-                 return null;
 
-             }
 
-         }
 
-         public static async Task<List<XlInfo>> GetAllAsync()
 
-         {
 
-             try
 
-             {
 
-                 List<XlInfo> list = new List<XlInfo>();
 
-                 if (!Directory.Exists("DbPart")) return list;
 
-                 var yearDirs = Directory.EnumerateDirectories("DbPart").OrderByDescending(p => Convert.ToInt32(new DirectoryInfo(p).Name));//年目录,倒叙排列
 
-                 foreach (var yearDir in yearDirs)
 
-                 {
 
-                     //每一天的db文件,倒序排列
 
-                     var dayFiles = Directory.EnumerateFiles(yearDir, "*.db").OrderByDescending(p => Convert.ToInt32(new DirectoryInfo(p).Name.Substring(0, 4)));
 
-                     foreach (var dayFile in dayFiles)
 
-                     {
 
-                         using (RHDWPartContext db = RHDWPartContext.GetContext(dayFile))
 
-                         {
 
-                             list.AddRange(await db.XlInfos.ToListAsync());
 
-                             if (list.Count > 2000)
 
-                                 return list;
 
-                         }
 
-                     }
 
-                 }
 
-                 return list;
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 Serilog.Log.Error(ex, "加载星历信息异常");
 
-                 return null;
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |