MarkItUp.SingleUserBlog/UI/SUBBlogMLReader.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Text;
using System.Xml;
using System.Web;
using MarkItUp.SingleUserBlog.Common;
using MarkItUp.SingleUserBlog.Services;
using BlogML;
using BlogML.Xml;

namespace MarkItUp.SingleUserBlog.UI {

    public sealed class SUBBlogMLReader {

		public void LoadBlog(string xml) {

			BlogMLBlog blog = BlogMLSerializer.Deserialize(new StringReader(xml));

			// mapping between categories ID and actual ids
			Hashtable categories = new System.Collections.Hashtable();

			// add categories
			foreach (BlogMLCategory category in blog.Categories) {
				Services.Category cat = new Services.Category();
				cat.Id = category.ID;
				cat.DateCreated = category.DateCreated;
				cat.DateModified = category.DateModified;
				cat.Description = category.Description;
				cat.DisplayName = category.Title;
				cat.IsApproved = category.Approved;
				if (category.ParentRef != null)
					cat.ParentId = category.ParentRef;
				cat.CategoryType = CategoryType.Content;

				cat = DataLayer.Instance.SaveCategory(cat);
				if (category.ID != null && category.ID.Length > 0)
					categories.Add(category.ID, cat.Id);
			}

			// add posts
			foreach (BlogMLPost post in blog.Posts) {

				string postContent = post.Content.UncodedText;

				if (post.Attachments.Count > 0) {

					string dirPath = HttpContext.Current.Server.MapPath("~/Data/Images");
					if (!Directory.Exists(dirPath))
						Directory.CreateDirectory(dirPath);

					for (int i = 0; i < post.Attachments.Count; ++i) {
						BlogMLAttachment attachment = post.Attachments[i];

						string fileName = Path.GetFileName(attachment.Url);
						string filePath = HttpContext.Current.Server.MapPath("~/Data/Images/" + fileName);
						string httpPath = Globals.UrlStartPath + "Data/Images/" + fileName;

后面还有 51 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。