Beispiel #1
0
 internal static void AddOrUpdate(string tableName, int fileId, string savePath, DateTime lastUpdate, bool isComplete)
 {
     // Open database (or create if not exits)
     using (var db = new LiteDatabase(DataBaseFilePath))
     {
         var files    = db.GetCollection <FileCachInfo>(tableName);
         var fileInfo = files.FindOne(x => x.FileId == fileId);
         if (fileInfo == null)
         {
             fileInfo = new FileCachInfo
             {
                 FileId             = fileId,
                 LastUpdateDateTime = lastUpdate,
                 SavePath           = savePath,
                 IsComplete         = isComplete
             };
             files.EnsureIndex(x => x.FileId);
             files.Insert(fileInfo);
         }
         else
         {
             fileInfo.LastUpdateDateTime = lastUpdate;
             fileInfo.SavePath           = savePath;
             fileInfo.IsComplete         = isComplete;
             files.Update(fileInfo);
         }
     }
 }
Beispiel #2
0
 internal static void Add(string tableName, int fileId, string savePath, DateTime lastUpdate)
 {
     // Open database (or create if not exits)
     using (var db = new LiteDatabase(DataBaseFilePath))
     {
         var files    = db.GetCollection <FileCachInfo>(tableName);
         var fileInfo = new FileCachInfo
         {
             FileId             = fileId,
             LastUpdateDateTime = lastUpdate,
             SavePath           = savePath
         };
         files.EnsureIndex(x => x.FileId);
         files.Insert(fileInfo);
     }
 }