Beispiel #1
0
        public bool editPost(string postid, string username, string password, Post post, bool publish)
        {
            int uid = ValidateUser(username, password);
            if (uid < 1)
                throw new XmlRpcFaultException(0, "用户不存在");
            Entity.SpacePostInfo spacepostinfo = Discuz.Space.Provider.BlogProvider.GetSpacepostsInfo(DbProvider.GetInstance().GetSpacePost(int.Parse(postid)));

            spacepostinfo.Title = ForumUtils.BanWordFilter(post.title);
            spacepostinfo.Content = ForumUtils.BanWordFilter(post.description);
            spacepostinfo.Category = Space.Spaces.GetCategoryIds(post.categories, uid);
            spacepostinfo.PostUpDateTime = DateTime.Now;

            bool success;
            try
            {
                success = DbProvider.GetInstance().SaveSpacePost(spacepostinfo);
            }
            catch (Exception ex)
            {
                throw new XmlRpcFaultException(0, ex.ToString());
            }
            return success;

        } 
Beispiel #2
0
        public string newPost(string blogid, string username, string password, Post post, bool publish)
        {
            int uid = ValidateUser(username, password);
            if (uid < 1)
                throw new XmlRpcFaultException(0, "用户不存在");
            Entity.SpaceConfigInfo spaceconfig = Space.Spaces.GetSpaceConfigByUserId(uid);

            Discuz.Entity.SpacePostInfo spacepostsinfo = new Discuz.Entity.SpacePostInfo();
            spacepostsinfo.Title = Discuz.Forum.ForumUtils.BanWordFilter(post.title);
            spacepostsinfo.Content = Utils.RemoveUnsafeHtml(ForumUtils.BanWordFilter(post.description));
            spacepostsinfo.Category = Space.Spaces.GetCategoryIds(post.categories, uid);
            spacepostsinfo.PostStatus = publish ? 1 : 0;
            spacepostsinfo.CommentStatus = spaceconfig.Commentpref;
            spacepostsinfo.Postdatetime = DateTime.Now;
            spacepostsinfo.Author = username;
            spacepostsinfo.Uid = uid;
            spacepostsinfo.PostUpDateTime = DateTime.Now;
            spacepostsinfo.Commentcount = 0;

            int postid = DbProvider.GetInstance().AddSpacePost(spacepostsinfo);
            if (postid < 1)
                throw new XmlRpcFaultException(0, "发表文章不成功");
            return postid.ToString();
        } 
Beispiel #3
0
 /// <summary>
 /// 转换日志
 /// </summary>
 /// <param name="postinfo"></param>
 /// <param name="uid"></param>
 /// <returns></returns>
 private Post ConvertPost(Entity.SpacePostInfo postinfo, int uid)
 {
     Post post = new Post();
     post.postid = postinfo.Postid;
     post.title = postinfo.Title;
     post.description = postinfo.Content;
     post.categories = Space.Spaces.GetCategories(postinfo.Category, uid);
     return post;
 }
Beispiel #4
0
        public Post[] getRecentPosts(string blogid, string username, string password, int numberOfPosts)
        {
            int uid = ValidateUser(username, password);
            if (uid < 1)
                throw new XmlRpcFaultException(0, "用户不存在");
            int blogId = int.Parse(blogid);

            DataTable dt = DbProvider.GetInstance().SpacePostsList(numberOfPosts, 1, uid);

            DataRowCollection drs = dt.Rows; 
#if NET1
            ArrayList list = new ArrayList(drs.Count); 
#else
            List<Post> list = new List<Post>(drs.Count);
#endif

            foreach (DataRow dr in drs)
            {
                Post post = new Post();
                post.postid = dr["postid"].ToString();
                post.title = dr["title"].ToString();
                post.description = dr["content"].ToString();
                post.categories = Space.Spaces.GetCategories(dr["category"].ToString(), uid);
                list.Add(post);
            } 
#if NET1
            return (Post[])list.ToArray(typeof(Post));
#else
            return list.ToArray();
#endif
        }