Пример #1
0
        private void EnsureNotChangedMaterial()
        {
            if (this._Content.ContentData == null)
            {
                if (this.TempPhysicalFilePath.IsNotEmpty())
                {
                    FileInfo tempFile = new FileInfo(this.TempPhysicalFilePath);

                    if (tempFile.Exists)
                    {
                        this._Content.ContentData = tempFile.OpenRead().ToBytes();
                    }
                }

                if (this._Content.ContentData == null)
                {
                    IMaterialContentPersistManager manager = MaterialContentSettings.GetConfig().PersistManager;

                    //在数据库存储附件的模式下,这个参数其实没用
                    manager.DestFileInfo = new FileInfo(GetTempPhysicalFilePath(string.Empty));

                    this._Content.ContentData = manager.GetMaterialContent(this._Content.ContentID).ToBytes();
                }
            }
        }
Пример #2
0
        private void EnsureChangedImage()
        {
            if (this.SourceImageID.IsNullOrEmpty())
            {
                this._Content.PhysicalSourceFilePath =
                    ImagePropertyAdapter.Instance.GetPhysicalUploadImagePath(this._Content.FileName);
            }
            else
            {
                IMaterialContentPersistManager manager = MaterialContentSettings.GetConfig().PersistManager;

                manager.DestFileInfo = ImagePropertyAdapter.Instance.GetPhysicalUploadImagePath(this._Content.FileName);
                if (!File.Exists(manager.DestFileInfo.DirectoryName))
                {
                    Directory.CreateDirectory(manager.DestFileInfo.DirectoryName);
                }
                using (Stream srcContent = manager.GetMaterialContent(this.SourceImageID))
                {
                    using (FileStream fs = new FileStream(manager.DestFileInfo.ToString(), FileMode.Create, FileAccess.Write))
                    {
                        srcContent.CopyTo(fs);
                    }

                    this._Content.PhysicalSourceFilePath = manager.DestFileInfo;
                }
            }
        }
Пример #3
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();
            }
        }
        public static MaterialContentSettings GetConfig()
        {
            MaterialContentSettings settings = (MaterialContentSettings)ConfigurationBroker.GetSection("materialContentSettings");

            if (settings == null)
            {
                settings = new MaterialContentSettings();
            }

            return(settings);
        }
Пример #5
0
        private void EnsureNotChangedImage()
        {
            if (this._Content.ContentData == null)
            {
                IMaterialContentPersistManager manager = MaterialContentSettings.GetConfig().PersistManager;

                manager.DestFileInfo = ImagePropertyAdapter.Instance.GetPhysicalDestinationImagePath(this._Content.FileName);

                this._Content.ContentData = manager.GetMaterialContent(this._Content.ContentID).ToBytes();
            }
        }
        protected override string GetConnectionName()
        {
            string connectionName = MaterialContentSettings.GetConfig().ConnectionName;

            if (connectionName.IsNullOrEmpty())
            {
                connectionName = WorkflowSettings.GetConfig().ConnectionName;
            }

            return(connectionName);
        }
        private static IMaterialContentPersistManager GetMaterialContentPersistManager(string rootPathName, MaterialFileOeprationInfo fileOp)
        {
            string uploadRootPath = AppPathConfigSettings.GetConfig().Paths[rootPathName].Dir;

            FileInfo sourceFile = new FileInfo(uploadRootPath + @"Temp\" + Path.GetFileName(fileOp.Material.RelativeFilePath));
            FileInfo destFile   = new FileInfo(uploadRootPath + fileOp.Material.RelativeFilePath);

            IMaterialContentPersistManager persistManager = MaterialContentSettings.GetConfig().PersistManager;

            persistManager.SourceFileInfo = sourceFile;
            persistManager.DestFileInfo   = destFile;

            if (fileOp.Operation == FileOperation.Update)
            {
                persistManager.CheckSourceFileExists = false;
            }

            return(persistManager);
        }