コード例 #1
0
 internal SupportingFileFactory(SupportingFileService supportingFileService, string fileId, string fileName, int nextVersion)
 {
     _fileService = supportingFileService;
     _fileId      = fileId;
     _fileName    = fileName;
     _nextVersion = nextVersion;
     _uploadInfos = new Hashtable();
 }
コード例 #2
0
 internal SupportingFileFactory(SupportingFileService supportingFileService, string fileId, string fileName, int nextVersion)
 {
     _fileService = supportingFileService;
     _fileId = fileId;
     _fileName = fileName;
     _nextVersion = nextVersion;
     _uploadInfos = new Hashtable();
 }
コード例 #3
0
        public IBlogPostEditingContext Load(bool addToRecentDocs)
        {
            try
            {
                if (!IsSaved)
                    throw new InvalidOperationException("Attempted to load a PostEditorFile that has never been saved!");

                // add to shell recent documents
                if (addToRecentDocs)
                    Shell32.SHAddToRecentDocs(SHARD.PATHW, TargetFile.FullName);

                using (Storage postStorage = new Storage(TargetFile.FullName, StorageMode.Open, false))
                {
                    // meta-data
                    string destinationBlogId = ReadString(postStorage, DESTINATION_BLOG_ID);
                    string serverSupportingFileDirectory = ReadString(postStorage, SERVER_SUPPORTING_FILE_DIR);

                    // blog post
                    BlogPost blogPost = new BlogPost();
                    blogPost.Id = ReadString(postStorage, POST_ID);
                    blogPost.IsPage = SafeReadBoolean(postStorage, POST_ISPAGE, false);
                    blogPost.Title = ReadString(postStorage, POST_TITLE);
                    blogPost.Categories = (BlogPostCategory[])ReadXml(postStorage, POST_CATEGORIES, new XmlReadHandler(ReadCategories));
                    blogPost.NewCategories = (BlogPostCategory[])SafeReadXml(postStorage, POST_NEW_CATEGORIES, new XmlReadHandler(ReadCategories), new BlogPostCategory[] { });
                    blogPost.DatePublished = ReadDateTime(postStorage, POST_DATEPUBLISHED);
                    blogPost.DatePublishedOverride = ReadDateTime(postStorage, POST_DATEPUBLISHED_OVERRIDE);
                    blogPost.CommentPolicy = ReadCommentPolicy(postStorage);
                    blogPost.TrackbackPolicy = ReadTrackbackPolicy(postStorage);
                    blogPost.Keywords = ReadString(postStorage, POST_KEYWORDS);
                    blogPost.Excerpt = ReadString(postStorage, POST_EXCERPT);
                    blogPost.Permalink = SafeReadString(postStorage, POST_PERMALINK, String.Empty);
                    blogPost.PingUrlsPending = (string[])ReadXml(postStorage, POST_PINGURLS_PENDING, new XmlReadHandler(ReadPingUrls));
                    blogPost.PingUrlsSent = (string[])SafeReadXml(postStorage, POST_PINGURLS_SENT, new XmlReadHandler(ReadPingUrls), new string[0]);
                    blogPost.Slug = SafeReadString(postStorage, POST_SLUG, String.Empty);
                    blogPost.Password = SafeReadString(postStorage, POST_PASSWORD, String.Empty);
                    string authorId = SafeReadString(postStorage, POST_AUTHOR_ID, String.Empty);
                    string authorName = SafeReadString(postStorage, POST_AUTHOR_NAME, String.Empty);
                    blogPost.Author = new PostIdAndNameField(authorId, authorName);
                    string pageParentId = SafeReadString(postStorage, POST_PAGE_PARENT_ID, String.Empty);
                    string pageParentName = SafeReadString(postStorage, POST_PAGE_PARENT_NAME, String.Empty);
                    blogPost.PageParent = new PostIdAndNameField(pageParentId, pageParentName);
                    blogPost.PageOrder = SafeReadString(postStorage, POST_PAGE_ORDER, String.Empty);
                    blogPost.ETag = SafeReadString(postStorage, POST_ETAG, String.Empty);
                    blogPost.AtomRemotePost = (XmlDocument)SafeReadXml(postStorage, POST_ATOM_REMOTE_POST, new XmlReadHandler(XmlDocReadHandler), null);

                    try
                    {
                        blogPost.ContentsVersionSignature = ReadString(postStorage, POST_CONTENTS_VERSION_SIGNATURE);
                    }
                    catch (StorageFileNotFoundException) { } //BACKWARDS_COMPATABILITY: occurs if this file was created before the introduction of content signatures (pre-Beta2)

                    // post contents (must extract supporting files -- protect against leakage with try/catch
                    BlogPostSupportingFileStorage supportingFileStorage = new BlogPostSupportingFileStorage();
                    using (Storage postSupportStorage = postStorage.OpenStorage(POST_SUPPORTING_FILES, StorageMode.Open, false))
                    {
                        SupportingFilePersister supportingFilePersister = new SupportingFilePersister(postSupportStorage, supportingFileStorage);

                        //read the attached files
                        SupportingFileService supportingFileService = new SupportingFileService(supportingFileStorage);
                        try
                        {
                            ReadXml(postStorage, POST_ATTACHED_FILES, new XmlReadHandler(new AttachedFileListReader(supportingFileService, supportingFilePersister).ReadAttachedFileList));
                        }
                        catch (StorageFileNotFoundException) { } //occurs if this file was created before the introduction of extension data

                        //read in the image data (note: this must happen before fixing the file references)
                        BlogPostImageDataList imageDataList = (BlogPostImageDataList)ReadXml(postStorage, POST_IMAGE_FILES, new XmlReadHandler(new ImageListReader(supportingFilePersister, supportingFileService).ReadImageFiles));

                        //read the extension data settings
                        BlogPostExtensionDataList extensionDataList = new BlogPostExtensionDataList(supportingFileService);
                        try
                        {
                            ReadXml(postStorage, POST_EXTENSION_DATA_LIST, new XmlReadHandler(new ExtensionDataListReader(extensionDataList, supportingFilePersister, supportingFileService).ReadExtensionDataList));
                        }
                        catch (StorageFileNotFoundException) { } //occurs if this file was created before the introduction of extension data

                        //fix up the HTML content to reference the extracted files
                        blogPost.Contents = supportingFilePersister.FixupHtmlReferences(ReadStringUtf8(postStorage, POST_CONTENTS));

                        string originalSourcePath = SafeReadString(postStorage, ORIGINAL_SOURCE_PATH, null);
                        PostEditorFile autoSaveFile;
                        PostEditorFile file = GetFileFromSourcePath(originalSourcePath, out autoSaveFile);

                        // return init params
                        return new BlogPostEditingContext(destinationBlogId, blogPost, file, autoSaveFile, serverSupportingFileDirectory, supportingFileStorage, imageDataList, extensionDataList, supportingFileService);
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.Fail("Unexpected exception type in PostEditorFile.Load. It is critical that only IO exceptions occur at this level of the system so please check the code which threw the exeption and see if there is a way to behave more robustly!\r\n"
                    + ex.ToString());
                throw PostEditorStorageException.Create(ex);
            }
        }
コード例 #4
0
 public AttachedFileListReader(SupportingFileService supportingFileService, SupportingFilePersister supportingFilePersister)
 {
     _fileService = supportingFileService;
     _supportingFilePersister = supportingFilePersister;
 }
コード例 #5
0
 public ExtensionDataListReader(BlogPostExtensionDataList extensionDataList, SupportingFilePersister supportingFilePersister, SupportingFileService fileService)
 {
     _extensionDataList = extensionDataList;
     _supportingFilePersister = supportingFilePersister;
     _fileService = fileService;
 }
コード例 #6
0
 public ImageListReader(SupportingFilePersister supportingFilePersister, SupportingFileService fileService)
 {
     _supportingFilePersister = supportingFilePersister;
     _fileService = fileService;
 }
コード例 #7
0
 private void _editingContext_BlogChanged(object sender, EventArgs e)
 {
     SupportingFileService = (SupportingFileService)(_editingContext as IBlogPostEditingContext).SupportingFileService;
 }
コード例 #8
0
 private void _editingContext_BlogChanged(object sender, EventArgs e)
 {
     SupportingFileService = (SupportingFileService)(_editingContext as IBlogPostEditingContext).SupportingFileService;
 }