/// <summary> /// Обновление данных по загрузке в кэше /// </summary> /// <param name="fileCashes"></param> public void UpdateCasheFiles(FileCashes fileCashes) { using (var db = _govDb.GetContext()) { db.FileCashes.Update(fileCashes); db.SaveChanges(); } }
/// <summary> /// Удаление из кэша несуществующего/недоступного на ftp файла /// </summary> /// <param name="fileCashes"></param> public void DeleteCasheFiles(FileCashes fileCashes) { using (var db = _govDb.GetContext()) { db.FileCashes.Remove(fileCashes); db.SaveChanges(); } }
private void SavePath(FileCashes item) { try { using (var db = _govDb.GetContext()) { db.FileCashes.Add(item); db.SaveChanges(); } } catch (Exception ex) { _logger.LogError(ex, ex.Message); } }
private void SaveFTPPath(List <FtpListItem> ListFile, string ftpDir, string baseDir, Status status, FLType fz) { foreach (FtpListItem item in ListFile) { if (!_dataServices.CheckCasheFiles(item.FullName)) { var filesave = new FileCashes(); filesave.Date = item.Modified; filesave.Size = item.Size; filesave.Full_path = item.FullName; filesave.Zip_file = item.Name; filesave.BaseDir = baseDir; filesave.Dirtype = ftpDir; filesave.Fz_type = fz; filesave.Status = status; filesave.Modifid_date = DateTime.Now; SavePath(filesave); } } }
/// <summary> /// Проверка на наличие имеющейся записи о файле /// </summary> /// <param name="FullPath"></param> /// <returns></returns> public bool CheckCasheFiles(string FullPath) { FileCashes find = null; using (var db = _govDb.GetContext()) { find = db.FileCashes .AsNoTracking() .Where(x => x.Full_path == FullPath) .OrderByDescending(x => x.Date) .FirstOrDefault(); } if (find == null) { return(false); } else { return(true); } }