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;
            }
        }
예제 #2
0
        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();
            }
        }