public void SaveFile(File file, FileStorages storage) { using (var context = new Data.CMSContext()) { file.Data.StoredData = EncryptFiles ? CryptUtil.EncryptBytes(file.Data.StoredData) : file.Data.StoredData; file.Data.StoredThumbData = EncryptFiles ? CryptUtil.EncryptBytes(file.Data.StoredThumbData) : file.Data.StoredThumbData; var oldfile = context.Files.SingleOrDefault(f => f.FileUId == file.FileUId); if (oldfile == null) { context.Files.Add(file); } else { context.Files.Remove(oldfile); context.Files.Add(file); } context.SaveChanges(); } }
public void SaveFile(File file, FileStorages storage) { var crypt = new CryptUtil(Settings); file.Data.StoredData = EncryptFiles ? crypt.EncryptBytes(file.Data.StoredData) : file.Data.StoredData; file.Data.StoredThumbData = EncryptFiles ? crypt.EncryptBytes(file.Data.StoredThumbData) : file.Data.StoredThumbData; file._CreateDate = DateTime.Now; var oldfile = _context.Files.SingleOrDefault(f => f.FileUId == file.FileUId); if (oldfile == null) { _context.Files.Add(file); } else { _context.Files.Remove(oldfile); _context.Files.Add(file); } _context.SaveChanges(); _log.Log($"File '{file.FileUId}' was uploaded to folder '{file.Folder}'.", saveParameters: false); }
public static ValueTask <DBTrieEngine> OpenFromFolder(string folderName) { var storages = new FileStorages(folderName); return(OpenFromStorages(storages)); }
public void SaveFile(File file, FileStorages storage) { using (var context = new Data.CMSContext()) { file.Data.StoredData = EncryptFiles ? CryptUtil.EncryptBytes(file.Data.StoredData) : file.Data.StoredData; file.Data.StoredThumbData = EncryptFiles ? CryptUtil.EncryptBytes(file.Data.StoredThumbData) : file.Data.StoredThumbData; var oldfile = context.Files.SingleOrDefault(f => f.FileUId == file.FileUId); if (oldfile == null) { context.Files.Add(file); } else { context.Files.Remove(oldfile); context.Files.Add(file); } context.SaveChanges(); } }