Quellcode durchsuchen

增加只查3天内数据

master
fyf vor 2 Jahren
Ursprung
Commit
ed0a9a172a
1 geänderte Dateien mit 3 neuen und 3 gelöschten Zeilen
  1. +3
    -3
      DataVAPI.ServerDB/MongoDB/MongodbHelper.cs

+ 3
- 3
DataVAPI.ServerDB/MongoDB/MongodbHelper.cs Datei anzeigen

@@ -211,7 +211,7 @@ namespace DataVAPI.ServerDB.MongoDB

public List<T> QueryClientIdName(string clientId,string name)
{
return collection.Find(a => a.ClientId == clientId && a.devicename==name)?.ToList().OrderByDescending(a => a.CreateTime)?.ToList();
return collection.Find(a => a.ClientId == clientId && a.devicename==name && a.CreateTime >= DateTime.Now.Date)?.ToList().OrderByDescending(a => a.CreateTime)?.ToList();
}

public T QueryClientIdMax(string clientId)
@@ -222,13 +222,13 @@ namespace DataVAPI.ServerDB.MongoDB

public T QueryClientIdMaxName(string clientId,string name)
{
List<T> clo = collection.Find(a => a.ClientId == clientId && a.devicename==name && a.State == "y")?.ToList().OrderByDescending(a => a.CreateTime)?.ToList();
List<T> clo = collection.Find(a => a.ClientId == clientId && a.devicename==name && a.CreateTime >= DateTime.Now.AddDays(-3).Date && a.State == "y")?.ToList().OrderByDescending(a => a.CreateTime)?.ToList();
return clo.Count > 0 ? clo[0] : null;
}

public List<T> QueryDeviceId(string clientId, string deviceId)
{
return collection.Find(a => a.DeviceId == deviceId && a.ClientId == clientId && a.CreateTime >= DateTime.Now.Date && a.State == "y")?.ToList().OrderByDescending(a => a.CreateTime)?.ToList();
return collection.Find(a => a.DeviceId == deviceId && a.ClientId == clientId && a.CreateTime >= DateTime.Now.AddDays(-3).Date && a.State == "y")?.ToList().OrderByDescending(a => a.CreateTime)?.ToList();
}

public List<T> QueryAll()


Laden…
Abbrechen
Speichern