public void UpdateContent(ImageProperty image) { image.NullCheck("image"); IMaterialContentPersistManager manager = MaterialContentSettings.GetConfig().PersistManager; image.EnsureMaterialContent(); using (TransactionScope scope = TransactionScopeFactory.Create()) { if (image.Content.IsEmpty()) { manager.DeleteMaterialContent(image.Content); } else { manager.DestFileInfo = GetPhysicalDestinationImagePath(image.Content.FileName); manager.SourceFileInfo = image.Content.PhysicalSourceFilePath; manager.SaveMaterialContent(image.Content); image.FilePath = string.Empty; image.Changed = false; } scope.Complete(); } }
public void DoModifyFileOperations(string rootPathName, MaterialFileOeprationInfo fileOp, MaterialContent content) { string uploadRootPath = AppPathConfigSettings.GetConfig().Paths[rootPathName].Dir; ExceptionHelper.CheckStringIsNullOrEmpty(uploadRootPath, "uploadRootPath"); IMaterialContentPersistManager persistManager = GetMaterialContentPersistManager(rootPathName, fileOp); if (content == null) { content = fileOp.Material.GenerateMaterialContent(); } switch (fileOp.Operation) { case FileOperation.Add: case FileOperation.Update: persistManager.SaveMaterialContent(content); break; case FileOperation.Delete: persistManager.DeleteMaterialContent(content); break; default: break; } }
public static void Save(MaterialContent content) { IMaterialContentPersistManager manager = MaterialContentSettings.GetConfig().PersistManager; string path = GetUploadRootPath("ImageUploadRootPath"); string fileName = Path.Combine(path + @"Temp\", content.FileName); if (manager is FileMaterialContentPersistManager) { manager.DestFileInfo = new System.IO.FileInfo(Path.Combine(path, content.FileName)); } manager.SourceFileInfo = new System.IO.FileInfo(fileName); manager.SaveMaterialContent(content); }