예제 #1
0
        /// <summary>
        /// 添加或修改文章
        /// </summary>
        /// <param name="blogID"></param>
        /// <param name="postID"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="sentPost"></param>
        /// <param name="publish"></param>
        /// <param name="operate"></param>
        /// <returns></returns>
        private int NewOrUpdatePost(string blogID, string postID, string userName, string password, MWAPost sentPost, bool publish, OperateType operate)
        {
            ValidateRequest(userName, password);

            PostInfo post = new PostInfo();
            PostService _postService = new PostService();

            if (operate == OperateType.Update)
            {
                post = new PostService().GetPost(Jqpress.Framework.Utils.TypeConverter.StrToInt(postID, 0));

            }
            else
            {
                post.CommentCount = 0;
                post.ViewCount = 0;
                post.PostTime = DateTime.Now;

                UserInfo user = (new UserService()).GetUser(userName);
                if (user != null)
                {
                    post.UserId = user.UserId;
                }
            }

            post.Title = Jqpress.Framework.Web.HttpHelper.HtmlEncode(sentPost.title);
            post.PostContent = sentPost.description;
            post.Status = publish == true ? 1 : 0;
            post.PageName = Jqpress.Framework.Utils.StringHelper.FilterPageName(sentPost.pagename, "post", true);
            post.Summary = sentPost.excerpt;

            post.UrlFormat = (int)PostUrlFormat.Default;
            post.Template = string.Empty;
            post.Recommend = 0;
            post.TopStatus = 0;
            post.PostStatus = 0;
            post.UpdateTime = DateTime.Now;

            if (sentPost.commentPolicy != "")
            {
                if (sentPost.commentPolicy == "1")
                    post.CommentStatus = 1;
                else
                    post.CommentStatus = 0;
            }

            foreach (string item in sentPost.categories)
            {
                CategoryInfo cat;
                if (LookupCategoryGuidByName(item, out cat))
                {
                    post.CategoryId = cat.CategoryId;
                }
                else
                {
                    CategoryInfo newcat = new CategoryInfo();
                    newcat.PostCount = 0;
                    newcat.CreateTime = DateTime.Now;
                    newcat.Description = "由离线工具创建";
                    newcat.SortNum = 1000;
                    newcat.CateName = Jqpress.Framework.Web.HttpHelper.HtmlEncode(item);
                    newcat.PageName = Jqpress.Framework.Utils.StringHelper.FilterPageName(item, "cate", false);

                    newcat.CategoryId = new CategoryService().InsertCategory(newcat);
                    post.CategoryId = newcat.CategoryId;
                }
            }
            post.Tag = GetTagIdList(sentPost.tags);

            if (operate == OperateType.Update)
            {
                new PostService().UpdatePost(post);
            }
            else
            {
                post.PostId = new PostService().InsertPost(post);

                //    SendEmail(p);
            }

            return post.PostId;
        }
예제 #2
0
        /// <summary>
        /// metaWeblog.getPost
        /// </summary>
        /// <param name="postID">post guid in string format</param>
        /// <param name="userName">login username</param>
        /// <param name="password">login password</param>
        /// <returns>struct with post details</returns>
        internal MWAPost GetPost(string postID, string userName, string password)
        {
            ValidateRequest(userName, password);

            MWAPost sendPost = new MWAPost();
            PostService _postService = new PostService();

            PostInfo post = new PostService().GetPost(Jqpress.Framework.Utils.TypeConverter.StrToInt(postID, 0));

            sendPost.postID = post.PostId.ToString();
            sendPost.postDate = post.PostTime;
            sendPost.title = Jqpress.Framework.Web.HttpHelper.HtmlDecode(post.Title);
            sendPost.description = post.PostContent;
            sendPost.link = post.Url;
            sendPost.pagename = Jqpress.Framework.Web.HttpHelper.HtmlDecode(post.PageName);
            sendPost.excerpt = post.Summary;
            if (post.CommentStatus == 1)
            {
                sendPost.commentPolicy = "1";
            }
            else
            {
                sendPost.commentPolicy = "0";
            }

            sendPost.publish = post.Status == 1 ? true : false;

            List<string> cats = new List<string>();
            cats.Add(Jqpress.Framework.Web.HttpHelper.HtmlDecode(post.Category.CateName));
            sendPost.categories = cats;

            //List<string> tags = new List<string>();
            //for (int i = 0; i < post.Tags.Count; i++)
            //{
            //    tags.Add(Jqpress.Framework.Web.HttpHelper.HtmlDecode(post.Tags[i].CateName));
            //}
            //sendPost.tags = tags;

            return sendPost;
        }
예제 #3
0
        /// <summary>
        /// metaWeblog.getRecentPosts
        /// </summary>
        /// <param name="blogID">always 1000 in BlogEngine since it is a singlar blog instance</param>
        /// <param name="userName">login username</param>
        /// <param name="password">login password</param>
        /// <param name="numberOfPosts">number of posts to return</param>
        /// <returns>array of post structs</returns>
        internal List<MWAPost> GetRecentPosts(string blogID, string userName, string password, int numberOfPosts)
        {
            ValidateRequest(userName, password);

            List<MWAPost> sendPosts = new List<MWAPost>();

            int userid = 0;
            UserInfo user = (new UserService()).GetUser(userName);
            if (user != null)
            {
                userid = user.UserId;
            }
            PostService _postService = new PostService();

            List<PostInfo> posts = new PostService().GetPostList(numberOfPosts, "", userid, -1, -1, -1, -1);

            foreach (PostInfo post in posts)
            {
                MWAPost tempPost = new MWAPost();
                List<string> tempCats = new List<string>();
                List<string> tempTags = new List<string>();

                tempPost.postID = post.PostId.ToString();
                tempPost.postDate = post.PostTime;
                tempPost.title = Jqpress.Framework.Web.HttpHelper.HtmlDecode(post.Title);
                tempPost.description = post.PostContent;
                tempPost.link = post.Url;
                tempPost.pagename = Jqpress.Framework.Web.HttpHelper.HtmlDecode(post.PageName);
                tempPost.excerpt = post.Summary;
                if (post.CommentStatus == 1)
                    tempPost.commentPolicy = "";
                else
                    tempPost.commentPolicy = "0";
                tempPost.publish = post.Status == 1 ? true : false;

                tempCats.Add(Jqpress.Framework.Web.HttpHelper.HtmlDecode(post.Category.CateName));
                tempPost.categories = tempCats;

                //for (int i = 0; i < post.Tags.Count; i++)
                //{
                //    tempTags.Add(Jqpress.Framework.Web.HttpHelper.HtmlDecode(post.Tags[i].CateName));
                //}
                //tempPost.tags = tempTags;

                sendPosts.Add(tempPost);
            }
            return sendPosts;
        }
예제 #4
0
 /// <summary>
 /// blogger.deletePost
 /// </summary>
 /// <param name="appKey">Key from application.  Outdated methodology that has no use here.</param>
 /// <param name="postID">post guid in string format</param>
 /// <param name="userName">login username</param>
 /// <param name="password">login password</param>
 /// <param name="publish">mark as published?</param>
 /// <returns></returns>
 internal bool DeletePost(string appKey, string postID, string userName, string password, bool publish)
 {
     ValidateRequest(userName, password);
     var _postService = new PostService();
     new PostService().DeletePost(Jqpress.Framework.Utils.TypeConverter.StrToInt(postID, 0));
     return true;
 }