|
|
@@ -304,27 +304,59 @@ namespace XdCxRhDW.App.Controllers
|
|
|
foreach (var item in list)
|
|
|
{
|
|
|
var dayFile = Path.Combine(dir, item);
|
|
|
- using (RHDWPartContext db = RHDWPartContext.GetContext(dayFile))
|
|
|
+ try
|
|
|
{
|
|
|
- if (db == null) continue;
|
|
|
- var query = db.PosRes.Where(p => p.SigTime >= start && p.SigTime <= end && p.TaskInfoID == dto.TaskInfoID);
|
|
|
- if (!dto.IncludeInvalidate)
|
|
|
- query = query.Where(p => p.PosLon != 999);
|
|
|
- if (dto.TarFrequpHz != null && dto.TarFrequpHz > 0)
|
|
|
- query = query.Where(p => p.FreqUpHz == dto.TarFrequpHz.Value);
|
|
|
- var posRes = await query.Include(p => p.CheckRes).OrderByDescending(p => p.SigTime).ToListAsync();
|
|
|
+ using (RHDWPartContext db = RHDWPartContext.GetContext(dayFile))
|
|
|
+ {
|
|
|
+ if (db == null) continue;
|
|
|
+ var query = db.PosRes.Where(p => p.SigTime >= start && p.SigTime <= end && p.TaskInfoID == dto.TaskInfoID);
|
|
|
+ if (!dto.IncludeInvalidate)
|
|
|
+ query = query.Where(p => p.PosLon != 999);
|
|
|
+ if (dto.TarFrequpHz != null && dto.TarFrequpHz > 0)
|
|
|
+ query = query.Where(p => p.FreqUpHz == dto.TarFrequpHz.Value);
|
|
|
+ var posRes = await query.Include(p => p.CheckRes).OrderByDescending(p => p.SigTime).ToListAsync();
|
|
|
|
|
|
- foreach (var itemPos in posRes)
|
|
|
+ foreach (var itemPos in posRes)
|
|
|
+ {
|
|
|
+ if (itemPos.TargetInfoID > 0)
|
|
|
+ {
|
|
|
+ itemPos.TargetInfo = targets.FirstOrDefault(p => p.ID == itemPos.TargetInfoID);
|
|
|
+ if (itemPos.TargetInfo != null && !string.IsNullOrWhiteSpace(itemPos.TargetInfo.TargeColor))
|
|
|
+ itemPos.ColorKey = itemPos.TargetInfo.TargeColor;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ posList.AddRange(posRes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ using (RHDWPartContext db = RHDWPartContext.GetContext(dayFile))
|
|
|
{
|
|
|
- if (itemPos.TargetInfoID > 0)
|
|
|
+ db.SyncDb();
|
|
|
+ }
|
|
|
+ using (RHDWPartContext db = RHDWPartContext.GetContext(dayFile))
|
|
|
+ {
|
|
|
+ if (db == null) continue;
|
|
|
+ var query = db.PosRes.Where(p => p.SigTime >= start && p.SigTime <= end && p.TaskInfoID == dto.TaskInfoID);
|
|
|
+ if (!dto.IncludeInvalidate)
|
|
|
+ query = query.Where(p => p.PosLon != 999);
|
|
|
+ if (dto.TarFrequpHz != null && dto.TarFrequpHz > 0)
|
|
|
+ query = query.Where(p => p.FreqUpHz == dto.TarFrequpHz.Value);
|
|
|
+ var posRes = await query.Include(p => p.CheckRes).OrderByDescending(p => p.SigTime).ToListAsync();
|
|
|
+
|
|
|
+ foreach (var itemPos in posRes)
|
|
|
{
|
|
|
- itemPos.TargetInfo = targets.FirstOrDefault(p => p.ID == itemPos.TargetInfoID);
|
|
|
- if (itemPos.TargetInfo != null && !string.IsNullOrWhiteSpace(itemPos.TargetInfo.TargeColor))
|
|
|
- itemPos.ColorKey = itemPos.TargetInfo.TargeColor;
|
|
|
+ if (itemPos.TargetInfoID > 0)
|
|
|
+ {
|
|
|
+ itemPos.TargetInfo = targets.FirstOrDefault(p => p.ID == itemPos.TargetInfoID);
|
|
|
+ if (itemPos.TargetInfo != null && !string.IsNullOrWhiteSpace(itemPos.TargetInfo.TargeColor))
|
|
|
+ itemPos.ColorKey = itemPos.TargetInfo.TargeColor;
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
+ posList.AddRange(posRes);
|
|
|
}
|
|
|
- posList.AddRange(posRes);
|
|
|
}
|
|
|
}
|
|
|
return Success(posList);
|
|
|
@@ -445,22 +477,49 @@ namespace XdCxRhDW.App.Controllers
|
|
|
var dayFiles = Directory.EnumerateFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, yearDir), "*.db").OrderByDescending(p => Convert.ToInt32(new DirectoryInfo(p).Name.Substring(0, 4)));
|
|
|
foreach (var dayFile in dayFiles)
|
|
|
{
|
|
|
- using (RHDWPartContext db = RHDWPartContext.GetContext(dayFile))
|
|
|
+ try
|
|
|
{
|
|
|
- if (db == null) continue;
|
|
|
- var query = db.PosRes.Where(p => p.TaskInfoID == dto.TaskInfoID);
|
|
|
- if (!dto.IncludeInvalidate)
|
|
|
+ using (RHDWPartContext db = RHDWPartContext.GetContext(dayFile))
|
|
|
{
|
|
|
- query = query.Where(p => p.PosLon != 999);
|
|
|
+ if (db == null) continue;
|
|
|
+ var query = db.PosRes.Where(p => p.TaskInfoID == dto.TaskInfoID);
|
|
|
+ if (!dto.IncludeInvalidate)
|
|
|
+ {
|
|
|
+ query = query.Where(p => p.PosLon != 999);
|
|
|
|
|
|
+ }
|
|
|
+ if (dto.TarFrequpHz != null && dto.TarFrequpHz > 0)
|
|
|
+ {
|
|
|
+ query = query.Where(p => p.FreqUpHz == dto.TarFrequpHz);
|
|
|
+ }
|
|
|
+ bool any = await query.AnyAsync();
|
|
|
+ if (any)
|
|
|
+ max = await query.MaxAsync(p => p.SigTime);
|
|
|
}
|
|
|
- if (dto.TarFrequpHz != null && dto.TarFrequpHz > 0)
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ using (RHDWPartContext db = RHDWPartContext.GetContext(dayFile))
|
|
|
+ {
|
|
|
+ db.SyncDb();
|
|
|
+ }
|
|
|
+ using (RHDWPartContext db = RHDWPartContext.GetContext(dayFile))
|
|
|
{
|
|
|
- query = query.Where(p => p.FreqUpHz == dto.TarFrequpHz);
|
|
|
+ if (db == null) continue;
|
|
|
+ var query = db.PosRes.Where(p => p.TaskInfoID == dto.TaskInfoID);
|
|
|
+ if (!dto.IncludeInvalidate)
|
|
|
+ {
|
|
|
+ query = query.Where(p => p.PosLon != 999);
|
|
|
+
|
|
|
+ }
|
|
|
+ if (dto.TarFrequpHz != null && dto.TarFrequpHz > 0)
|
|
|
+ {
|
|
|
+ query = query.Where(p => p.FreqUpHz == dto.TarFrequpHz);
|
|
|
+ }
|
|
|
+ bool any = await query.AnyAsync();
|
|
|
+ if (any)
|
|
|
+ max = await query.MaxAsync(p => p.SigTime);
|
|
|
}
|
|
|
- bool any = await query.AnyAsync();
|
|
|
- if (any)
|
|
|
- max = await query.MaxAsync(p => p.SigTime);
|
|
|
}
|
|
|
if (max != DateTime.MinValue)
|
|
|
{
|