Esempio n. 1
0
        public override async Task<PostingResult> TryToPostWithoutCaptcha(PostInfo postInfo, string boardId, long parent = 0) {
            if (ApiKeys.PrivateKey == null)
                return await PostAsync(postInfo, boardId, parent);

            var checkUrl = ((UrlService) UrlService).GetKeyCheckingUrl();
            try
            {
                var checkResultString = await Get(checkUrl);
                var checkResult = JsonConvert.DeserializeAnonymousType(checkResultString, new
                {
                    Id = "",
                    Result = 0,
                    Type = "",
                    Error = 0,
                    Description = ""
                });
                if (checkResult.Error != 0)
                    throw new Exception(checkResult.Description);

                if (checkResult.Result != 1 || checkResult.Type != "app")
                    return await PostAsync(postInfo, boardId, parent);

                return await PostWithoutCaptcha(checkResult.Id, postInfo, boardId, parent);
            }
            catch (Exception)
            {
                return await PostAsync(postInfo, boardId, parent);
            }
        }
Esempio n. 2
0
 public override async Task<PostingResult> PostAsync(PostInfo postInfo, string boardId, long parent = 0) {
     var uri = UrlService.GetPostingUrl();
     var content = await Mapper.MapPostInfo(postInfo, boardId, parent);
     var result = await PostAndConvertJsonResponse<PostingResultEntity, PostingResult>(uri, content, Mapper.MapPostingResult);
     if (!result.IsSuccessful && result.Error == "Капча невалидна.")
         throw await CreateCaptchaNeededException(result);
     return result;
 }
 public ExtendedPostingViewModel(IShell shell, IBoard board, PostInfo postInfo, ThreadLink threadLink) {
     PostInfo = postInfo;
     Shell = shell;
     Board = board;
     BoardId = threadLink.BoardId;
     Parent = threadLink.ThreadNumber;
     SetupProperties();
 }
 public ExtendedPostingViewModel(IShell shell, IBoard board, PostInfo postInfo, string boardId) {
     PostInfo = postInfo;
     Shell = shell;
     Board = board;
     BoardId = boardId;
     Parent = 0;
     IsNewThread = true;
     SetupProperties();
 }
Esempio n. 5
0
 public BloggerManager.PostInfo GetPost(string blogId, string postId)
 {
     Post p = BloggerHelper.getPost(_bsBlogger, blogId, postId);
     PostInfo pi = new PostInfo();
     pi.AuthorName = p.Author.DisplayName;
     pi.Content = p.Content;
     pi.Published = p.Published;
     pi.Title = p.Title;
     pi.Url = p.Url;
     pi.Tags = p.Labels == null ? new List<string>() : p.Labels.ToList();
     return pi;
 }
Esempio n. 6
0
        //private void GetAjaxForumsJsonList()
        //{
        //    StringBuilder sb = new StringBuilder();
        //    List<ForumInfo> forumlist = Forums.GetSubForumList(DNTRequest.GetInt("fid", 0));
        //    sb.Append("[");
        //    if (forumlist != null && forumlist.Count > 0)
        //    {
        //        foreach (ForumInfo info in forumlist)
        //        {
        //            if (config.Hideprivate == 1 && info.Viewperm != "" && !Utils.InArray(usergroupid.ToString(), info.Viewperm))
        //                continue;
        //            sb.Append(string.Format("{{'forumname':'{0}','fid':{1},'parentid':{2},'applytopictype':{3},'topictypeselectoptions':'{4}','postbytopictype':{5}}},", info.Name.Trim(), info.Fid.ToString(), info.Parentid.ToString(), info.Applytopictype.ToString(), Forums.GetCurrentTopicTypesOption(info.Fid, info.Topictypes), info.Postbytopictype.ToString()));
        //        }
        //        if (sb.ToString() != "")
        //            ResponseJSON(sb.ToString().Remove(sb.ToString().Length - 1) + "]");
        //    }
        //    ResponseJSON(sb.Append("]").ToString());
        //}

        private void GetPostInfo()
        {
            PostInfo      info    = Posts.GetPostInfo(DNTRequest.GetInt("tid", 0), Posts.GetTopicPostInfo(DNTRequest.GetInt("tid", 0)).Pid);
            StringBuilder xmlnode = IsValidGetPostInfo(info);

            if (!xmlnode.ToString().Contains("<error>"))
            {
                xmlnode.Append("<post>\r\n\t");
                xmlnode.AppendFormat("<message>{0}</message>\r\n", info.Message);
                xmlnode.AppendFormat("<tid>{0}</tid>\r\n", info.Tid);
                xmlnode.Append("</post>\r\n\t");
            }
            ResponseXML(xmlnode);
        }
Esempio n. 7
0
        public static PostInfo GetPostInfo(string postTableId, int pid)
        {
            PostInfo    postInfo = new PostInfo();
            IDataReader reader   = DatabaseProvider.GetInstance().GetPostInfo(postTableId, pid);

            if (reader.Read())
            {
                postInfo = LoadSinglePostInfo(reader);
                reader.Close();
                return(postInfo);
            }
            reader.Close();
            return(null);
        }
Esempio n. 8
0
        public void OpprettForsendelseMedUtvidelse()
        {
            var raw = "<?xml version=\"1.0\" encoding=\"utf-8\"?><lenke xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://begrep.difi.no/sdp/utvidelser/lenke\"><url>https://www.test.no</url><beskrivelse lang=\"nb\">This was raw string</beskrivelse></lenke>";

            MetadataDocument metadataDocument = new MetadataDocument("lenke.xml", "application/vnd.difi.dpi.lenke", raw);

            Avsender      avsender      = null; //Som initiert tidligere
            PostInfo      postInfo      = null; //Som initiert tidligere
            Dokumentpakke dokumentpakke = null; //Som initiert tidligere
            var           forsendelse   = new Forsendelse(avsender, postInfo, dokumentpakke)
            {
                MetadataDocument = metadataDocument
            };
        }
Esempio n. 9
0
        private PostInfo GetPost(IElement element)
        {
            PostInfo post = new PostInfo();

            post.Title         = GetTitle(ref element);
            post.Author        = GetAuthor(ref element);
            post.Url           = GetUrl(ref element);
            post.Description   = GetDescription(ref element);
            post.Date          = GetDate(ref element);
            post.Type          = GetType(ref element);
            post.Topics        = GetTopics(ref element);
            post.NumberOfViews = GetNumberOfViews(ref element);
            return(post);
        }
Esempio n. 10
0
        /// <summary>
        /// Executes the current extension.
        /// </summary>
        /// <param name="shell">The <see cref="IShell" /> object on which the current extension will be executed.</param>
        protected async override void DoExecute(IShell shell)
        {
            if (shell.HasActiveDocument)
            {
                await SafeExecutionContext.ExecuteAsync((Form)shell.Owner, async() =>
                {
                    var blogSetting = this.SettingProvider.GetExtensionSetting <BlogSetting>();
                    if (string.IsNullOrEmpty(blogSetting.MetaWeblogAddress) ||
                        string.IsNullOrEmpty(blogSetting.UserName) ||
                        string.IsNullOrEmpty(blogSetting.Password))
                    {
                        MessageBox.Show(Resources.MissingBlogConfigurationMsg, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    var gateway = new BlogGateway(blogSetting.MetaWeblogAddress, blogSetting.UserName,
                                                  blogSetting.Password);
                    if (await gateway.TestConnectionAsync())
                    {
                        var blogPublishDialog = new FrmBlogPublish(gateway);
                        if (blogPublishDialog.ShowDialog() == DialogResult.OK)
                        {
                            var selectedCategories = blogPublishDialog.SelectedCategories.Select(s => s.Title).ToList();
                            var postInfo           = new PostInfo
                            {
                                Categories  = selectedCategories,
                                DateCreated = DateTime.Now,
                                Description =
                                    HtmlUtilities.Tidy(HtmlUtilities.ReplaceFileSystemImages(shell.Note.Content)),
                                Title = shell.Note.Title
                            };
                            await gateway.PublishBlog(postInfo, selectedCategories);
                            shell.StatusText = Resources.PublishSucceeded;
                        }
                    }
                    else
                    {
                        MessageBox.Show(Resources.BlogExtensionCannotConnectToBlogService, Resources.Error,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                });
            }
            else
            {
                MessageBox.Show(Resources.NoActiveNoteOpened, Resources.Error, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Esempio n. 11
0
        public HttpResponseMessage ListPost(int top = 50)
        {
            ListPostResult  result = new ListPostResult();
            List <PostInfo> posts  = new List <PostInfo>();

            try
            {
                using (SqlConnection connection = new SqlConnection(Constants.ConnectionStr))
                {
                    connection.Open();
                    string listQuery = "SELECT TOP (@limit) p.*, u.PhotoUrl FROM posts AS p " +
                                       "LEFT JOIN users AS u " +
                                       "ON p.UserName = u.userName " +
                                       "ORDER BY Timestamp desc";
                    using (SqlCommand cmd = new SqlCommand(listQuery, connection))
                    {
                        cmd.Parameters.Add("@limit", SqlDbType.Int).Value = top;
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                var post = new PostInfo()
                                {
                                    postId       = reader.GetInt32(0),
                                    userName     = reader.IsDBNull(1) ? null : reader.GetString(1),
                                    imageUrl     = reader.IsDBNull(2) ? null : reader.GetString(2),
                                    description  = reader.IsDBNull(3) ? null : reader.GetString(3),
                                    longitude    = reader.GetSqlSingle(4).Value,
                                    latitude     = reader.GetSqlSingle(5).Value,
                                    timestamp    = (long)reader.GetDateTime(6).Subtract(StartTime).TotalMilliseconds,
                                    userPhotoUrl = reader.IsDBNull(7) ? null : reader.GetString(7)
                                };
                                posts.Add(post);
                            }
                        }
                    }

                    result.success = true;
                    result.message = $"List post succeeded";
                    result.posts   = posts.ToArray();
                    return(Utilities.CreateJsonReponse(Request, result));
                }
            }
            catch (Exception e)
            {
                result.message = $"Failed to list posts: {e.Message}";
                return(Utilities.CreateJsonReponse(Request, result));
            }
        }
        private static Forsendelse GenererForsendelse(Avsender avsender, PostInfo postInfo)
        {
            ResourceUtility resourceUtility = new ResourceUtility("Difi.SikkerDigitalPost.Klient.Testklient.Resources");

            var hoveddokument = resourceUtility.ReadAllBytes(true, "Hoveddokument.pdf");
            var vedlegg       = resourceUtility.ReadAllBytes(true, "Vedlegg.txt");

            //Forsendelse
            var dokumentpakke =
                new Dokumentpakke(new Dokument("Sendt" + DateTime.Now, hoveddokument, "application/pdf", "NO",
                                               "OWASP TOP 10.pdf"));

            dokumentpakke.LeggTilVedlegg(new Dokument("Vedlegg", vedlegg, "text/plain", "NO", "Vedlegg.txt"));
            return(new Forsendelse(avsender, postInfo, dokumentpakke, Prioritet.Prioritert, MpcId, "NO"));
        }
Esempio n. 13
0
        //Get all posts on a page and return a list containing them
        public List <PostInfo> GetAllPostsOnPage()
        {
            List <PostInfo> allPosts = new List <PostInfo>();
            dynamic         result   = client.Get(version + pageId + "posts?fields=message");

            for (int i = 0; i < result.data.Count; i++)
            {
                PostInfo posts = new PostInfo();

                posts.PostId  = result.data[i].id;
                posts.Message = result.data[i].message;
                allPosts.Add(posts);
            }
            return(allPosts);
        }
Esempio n. 14
0
 public void PrepareCondition(MssqlCondition mssqlCondition, PostInfo Model)
 {
     mssqlCondition.Add("[PostName]", Model.PostName, ConditionType.Like);
     //mssqlCondition.Add("[PostPlan]", Model.PostPlan, ConditionType.In);
     mssqlCondition.Add("[Locked]", Model.Locked, ConditionType.Equal);
     mssqlCondition.Add("[ParentId]", Model.ParentId, ConditionType.Equal);
     mssqlCondition.Add("[PostId]", Model.PostId, ConditionType.NoEqual);
     mssqlCondition.Add("[IsPost]", Model.IsPost, ConditionType.Equal);
     mssqlCondition.Add("[CompanyID]", Model.CompanyID, ConditionType.Equal);
     mssqlCondition.Add("[CompanyID]", Model.InCompanyID, ConditionType.In);
     if (!string.IsNullOrEmpty(Model.PostPlan))
     {
         mssqlCondition.Add(" [dbo].[" + ShopMssqlHelper.TablePrefix + "CompareSTR](PostPlan,'" + Model.PostPlan + "',',')=1 ");
     }
 }
Esempio n. 15
0
 public int RecoveryPostStatus(PostInfo postInfo)
 {
     try
     {
         var pst = _dataContext.PostInfos.FirstOrDefault(p => p.PostId == postInfo.PostId);
         pst.Status = 1;
         _dataContext.Update(pst);
         return(_dataContext.SaveChanges());
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         throw ex;
     }
 }
Esempio n. 16
0
        public async Task <Post> UpdatePost(int postId, PostInfo info)
        {
            var post = _dbContext.Posts.Find(postId);

            if (post == null)
            {
                throw new BreadException(BreadExceptionCode.PostIdIsUnknown, $"Invalid Post Id: {postId}");
            }

            post.SetInfo(info);

            await _dbContext.SaveChangesAsync();

            return(post);
        }
Esempio n. 17
0
        /// <summary>
        /// 获取海报信息
        /// </summary>
        /// <param name="postName"></param>
        /// <returns></returns>
        public PostInfo GetPostInfo(string postName)
        {
            PostInfo postInfo = new PostInfo();
            var      t008     = operateContext.BLLSession.IT008海报信息表BLL.GetListBy(m => m.PostName == postName)[0];

            postInfo.postName            = t008.PostName;
            postInfo.postPhotoURL        = t008.PhotosURL;
            postInfo.postBeginTime       = t008.PostBeginTime;
            postInfo.postEndTime         = t008.PostEndTime;
            postInfo.postTicketNumber    = t008.TicketNumber;
            postInfo.postTicketBeginTime = t008.TicketBeginTime;
            postInfo.postTicketEndTime   = t008.TicketEndTime;
            postInfo.postPartyName       = t008.PartyName;
            return(postInfo);
        }
Esempio n. 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int tid = DNTRequest.GetInt("tid", 0);

        if (tid > 0)
        {
            try
            {
                //ShowtopicPagePostInfo info = Posts.GetSinglePost(tid);
                PostInfo postInfo = Posts.GetPostInfo(tid, Posts.GetFirstPostId(tid));
                if (postInfo != null)
                {
                    //处理帖子内容
                    PostpramsInfo postpramsinfo = new PostpramsInfo();
                    postpramsinfo.Smileyoff   = postInfo.Smileyoff;
                    postpramsinfo.Bbcodeoff   = postInfo.Bbcodeoff;
                    postpramsinfo.Parseurloff = postInfo.Parseurloff;
                    postpramsinfo.Allowhtml   = postInfo.Htmlon;
                    postpramsinfo.Sdetail     = postInfo.Message;
                    postpramsinfo.Pid         = postInfo.Pid;
                    postpramsinfo.Showimages  = 1;

                    //Discuz.Web.News.News

                    //显示内容
                    //lblTitle.Text = postInfo.Title;
                    //lblAuthor.Text = postInfo.Poster;
                    //lblDatetime.Text = postInfo.Postdatetime.ToString();
                    //content.InnerHtml = UBB.UBBToHTML(postpramsinfo);
                    string postInfos = "0|" + postInfo.Title + "|" + postInfo.Postdatetime + "|" + postInfo.Poster + "$$$$";
                    string test      = UBB.UBBToHTML(postpramsinfo);
                    Response.Write(postInfos + UBB.UBBToHTML(postpramsinfo));
                }
                else
                {
                    Response.Write("1|不存在相关内容");
                }
            }
            catch (Exception ex)
            {
                Response.Write("2|获取信息出错:" + ex);
            }
        }
        else
        {
            Response.Write("3|帖子不存在");
        }
    }
Esempio n. 19
0
        /// <summary>
        /// 创建主题帖信息
        /// </summary>
        /// <param name="topicinfo"></param>
        /// <returns></returns>
        public PostInfo CreatePost(TopicInfo topicinfo)
        {
            PostInfo postinfo = new PostInfo();

            postinfo.Fid      = forumid;
            postinfo.Tid      = topicinfo.Tid;
            postinfo.Poster   = username;
            postinfo.Posterid = userid;
            postinfo.Title    = useradminid == 1 ? Utils.HtmlEncode(posttitle) :
                                postinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(posttitle));
            postinfo.Postdatetime              = curdatetime;
            postinfo.Message     = message;
            postinfo.Ip          = DNTRequest.GetIP();
            postinfo.Invisible   = UserAuthority.GetTopicPostInvisible(forum, useradminid, userid, usergroupinfo, postinfo);
            postinfo.Usesig      = TypeConverter.StrToInt(DNTRequest.GetString("usesig"));
            postinfo.Htmlon      = (usergroupinfo.Allowhtml == 1 && (TypeConverter.StrToInt(DNTRequest.GetString("htmlon")) == 1)) ? 1 : 0;
            postinfo.Smileyoff   = (smileyoff == 0 && forum.Allowsmilies == 1) ? TypeConverter.StrToInt(DNTRequest.GetString("smileyoff")) : smileyoff;
            postinfo.Bbcodeoff   = (usergroupinfo.Allowcusbbcode == 1 && forum.Allowbbcode == 1) ? postinfo.Bbcodeoff = TypeConverter.StrToInt(DNTRequest.GetString("bbcodeoff")) : 1;
            postinfo.Parseurloff = TypeConverter.StrToInt(DNTRequest.GetString("parseurloff"));
            postinfo.Topictitle  = topicinfo.Title;

            //if (Utils.GetCookie("lasttopictitle") == Utils.MD5(postinfo.Title) || Utils.GetCookie("lasttopicmessage") == Utils.MD5(postinfo.Message))
            //{
            //    AddErrLine("请勿重复发帖");
            //    return postinfo;
            //}

            try
            {
                postinfo.Pid = Posts.CreatePost(postinfo);
                Utils.WriteCookie("lasttopictitle", Utils.MD5(postinfo.Title));
                Utils.WriteCookie("lasttopicmessage", Utils.MD5(postinfo.Message));
            }
            catch
            {
                TopicAdmins.DeleteTopics(topicinfo.Tid.ToString(), false);
                AddErrLine("帖子保存出现异常");
            }

            //创建投票
            if (createpoll)
            {
                msg = Polls.CreatePoll(DNTRequest.GetFormString("PollItemname"), DNTRequest.GetString("multiple") == "on" ? 1 : 0,
                                       DNTRequest.GetInt("maxchoices", 1), DNTRequest.GetString("visiblepoll") == "on" ? 1 : 0, DNTRequest.GetString("allowview") == "on" ? 1 : 0,
                                       enddatetime, topicinfo.Tid, pollitem, userid);
            }
            return(postinfo);
        }
Esempio n. 20
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            int queryString = RequestHelper.GetQueryString <int>("ID");

            int      ParentId  = RequestHelper.GetForm <int>(ShopConfig.ReadConfigInfo().NamePrefix + "CateId");
            PostInfo PostModel = new PostInfo();

            PostModel.PostName   = this.PostName.Text;
            PostModel.PostId     = queryString;
            PostModel.ParentId   = ParentId;
            PostModel.OrderIndex = int.Parse(OrderIndex.Text);
            PostModel.CompanyID  = RequestHelper.GetForm <int>("CompanyId");
            if (IsPost.Checked)
            {
                PostModel.IsPost = 1;
            }
            else
            {
                PostModel.IsPost = 0;
            }

            //PostModel.PostPlan = RequestHelper.GetIntsForm("SelectId");
            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (PostModel.PostId == -2147483648)
            {
                base.CheckAdminPower("AddPost", PowerCheckType.Single);
                int id = PostBLL.AddPost(PostModel);

                //自动把客户公司专属的岗位添加到对应的公司信息里
                if (PostModel.CompanyID > 0 && PostModel.IsPost == 1)
                {
                    CompanyInfo company = CompanyBLL.ReadCompany(PostModel.CompanyID);
                    company.Post = string.IsNullOrEmpty(company.Post) ? id.ToString() : company.Post + "," + id.ToString();
                    CompanyBLL.UpdateCompany(company);
                }
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Post"), id);
            }
            else
            {
                base.CheckAdminPower("UpdatePost", PowerCheckType.Single);
                PostModel.PostPlan = PostBLL.ReadPost(queryString).PostPlan;
                PostBLL.UpdatePost(PostModel);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Post"), queryString);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl);
        }
        internal static PMode FromPostInfo(PostInfo postInfo)
        {
            var type = postInfo.GetType();

            if (type == typeof(FysiskPostInfo))
            {
                return(PMode.FormidleFysiskPost);
            }

            if (type == typeof(DigitalPostInfo))
            {
                return(PMode.FormidleDigitalPost);
            }

            throw new ArgumentOutOfRangeException(nameof(postInfo), type, "PostInfo har feil type.");
        }
Esempio n. 22
0
    /// <summary>
    /// Approve post and all child posts.
    /// </summary>
    protected void btnApproveSubTree_Click(object sender, EventArgs e)
    {
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        if ((PostInfo != null) && (MembershipContext.AuthenticatedUser != null))
        {
            // Approve with subtree
            PostInfo.Approve(MembershipContext.AuthenticatedUser.UserID, true);

            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_tree'].location.href = 'ForumPost_Tree.aspx?postid=" + PostInfo.PostId + "&forumid=" + PostInfo.PostForumID + "';");
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_edit'].location.href = 'ForumPost_View.aspx?postid=" + PostID + mListingParameter + "';");
        }
    }
Esempio n. 23
0
        /// <summary>
        /// 增加活动
        /// </summary>
        /// <param name="postInfo"></param>
        /// <returns></returns>
        public bool AddActivities(PostInfo postInfo)
        {
            T008海报信息表 t008 = new T008海报信息表();

            t008.PostName        = postInfo.postName;
            t008.PhotosURL       = postInfo.postPhotoURL;
            t008.PostBeginTime   = postInfo.postBeginTime;
            t008.PostEndTime     = postInfo.postEndTime;
            t008.TicketNumber    = postInfo.postTicketNumber;
            t008.TicketBeginTime = postInfo.postTicketBeginTime;
            t008.TicketEndTime   = postInfo.postTicketEndTime;
            t008.PartyName       = postInfo.postPartyName;

            operateContext.BLLSession.IT008海报信息表BLL.Add(t008);
            return(true);
        }
Esempio n. 24
0
    /// <summary>
    /// Reject post and all child posts.
    /// </summary>
    protected void btnRejectSubTree_Click(object sender, EventArgs e)
    {
        if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
        {
            return;
        }

        if (PostInfo != null)
        {
            // Reject with sub-posts
            PostInfo.Reject(true);

            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_tree'].location.href = 'ForumPost_Tree.aspx?postid=" + PostInfo.PostId + "&forumid=" + PostInfo.PostForumID + "';");
            ltlScript.Text += ScriptHelper.GetScript("parent.frames['posts_edit'].location.href = 'ForumPost_View.aspx?postid=" + PostID + mListingParameter + "';");
        }
    }
Esempio n. 25
0
        /// <summary>
        /// 删除文章
        /// </summary>
        /// <param name="post"></param>
        public virtual int Delete(PostInfo post)
        {
            PostInfo oldPost = GetById(post.PostId);

            if (oldPost == null)
            {
                throw new Exception("文章不存在");
            }

            string cmdText = string.Format("delete from [{0}posts] where [PostId] = @PostId", ConfigHelper.Tableprefix);

            using (var conn = new DapperHelper().OpenConnection())
            {
                return(conn.Execute(cmdText, new { PostId = post.PostId }));
            }
        }
Esempio n. 26
0
        /// <summary>
        /// 用当前的评分值通过一定兑换比例换算成积分后,更新相应帖子中的rate字段.
        /// </summary>
        /// <param name="postid">帖子ID</param>
        /// <param name="extid">扩展积分ID</param>
        /// <param name="score">分数</param>
        /// <param name="israte">true为评分,false为撤消评分</param>
        public static void SetPostRate(string posttableid, int postid, int extid, float score, bool israte)
        {
            if (score == 0)
            {
                return;
            }
            float rate = israte ? score : -1 * score;

            Discuz.Data.Posts.UpdatePostRate(postid, rate, posttableid);
            PostInfo postInfo = Discuz.Data.Posts.GetPostInfo(posttableid, postid);

            if (postInfo != null && postInfo.Layer == 0)
            {
                Discuz.Data.TopicAdmins.SetTopicStatus(postInfo.Tid.ToString(), "rate", postInfo.Rate.ToString());
            }
        }
Esempio n. 27
0
    void ParseJson()
    {
        TextAsset itemText = Resources.Load <TextAsset>("Post");

        json     = JsonMapper.ToObject(itemText.text);
        jsonData = JsonMapper.ToJson(json);
        foreach (JsonData tmp in json)
        {
            string   id    = "h" + tmp["id"].ToString();
            string   name  = tmp["Name"].ToString();
            string   image = tmp["image"].ToString();
            string   text  = tmp["text"].ToString();
            PostInfo Info  = new PostInfo(id, name, text, image);
            postList.Add(Info);
        }
    }
Esempio n. 28
0
 public int DeletePostInfo(PostInfo postInfo)
 {
     try
     {
         _dataContext.Entry(postInfo.SecondCategory).State = EntityState.Unchanged;
         _dataContext.Entry(postInfo.Author).State         = EntityState.Unchanged;
         _dataContext.Entry(postInfo.SecondCategory.FirstCategory).State = EntityState.Unchanged;
         _dataContext.Update(postInfo);
         return(_dataContext.SaveChanges());
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         throw ex;
     }
 }
Esempio n. 29
0
        /// <summary>
        /// 处理新增岗位的方法
        /// </summary>
        /// <returns></returns>
        public ActionResult ExeAddPost()
        {
            PostInfo p          = new PostInfo();
            int      DeptID     = Convert.ToInt16(Request["DeptID"]);
            string   PostName   = Request["PostName"];
            string   PostDuties = Request["PostDuties"];

            p.DeptID         = DeptID;
            p.JobDescription = PostDuties;
            p.JobTitle       = PostName;

            bool isAdd = dal.AddPost(p);

            ViewBag.isAdd = isAdd;
            return(RedirectToAction("AddPost"));
        }
Esempio n. 30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int queryString = RequestHelper.GetQueryString <int>("ID");

                base.CheckAdminPower("ReadPost", PowerCheckType.Single);

                if (queryString != -2147483648)
                {
                    PostInfo postModel = PostBLL.ReadPost(queryString);
                    if (postModel.CompanyID != companyID)
                    {
                        companyID   = postModel.CompanyID;
                        companyName = CompanyBLL.ReadCompany(companyID).CompanyName;
                    }

                    //string parentCompanyID = CompanyBLL.ReadParentCompanyId(postModel.CompanyID);
                    //parentCompanyID = string.IsNullOrEmpty(parentCompanyID) ? CompanyBLL.SystemCompanyId.ToString() : CompanyBLL.SystemCompanyId.ToString() + "," + parentCompanyID;

                    this.CateId.DataSource     = PostBLL.FilterPostListByCompanyID(PostBLL.ReadPostCateNamedList(), postModel.CompanyID.ToString());
                    this.CateId.DataTextField  = "PostName";
                    this.CateId.DataValueField = "PostId";
                    this.CateId.DataBind();
                    this.CateId.Items.Insert(0, new ListItem("设置为新部门", "0"));

                    this.PostName.Text   = postModel.PostName;
                    this.OrderIndex.Text = postModel.OrderIndex.ToString();
                    if (postModel.IsPost == 1)
                    {
                        this.IsPost.Checked = true;
                    }
                    if (CateId.Items.Contains(CateId.Items.FindByValue(postModel.ParentId.ToString())))
                    {
                        CateId.Items.FindByValue(postModel.ParentId.ToString()).Selected = true;
                    }
                }
                else
                {
                    this.CateId.DataSource     = PostBLL.FilterPostListByCompanyID(PostBLL.ReadPostCateNamedList(), CompanyBLL.SystemCompanyId.ToString());
                    this.CateId.DataTextField  = "PostName";
                    this.CateId.DataValueField = "PostId";
                    this.CateId.DataBind();
                    this.CateId.Items.Insert(0, new ListItem("设置为新部门", "0"));
                }
            }
        }
Esempio n. 31
0
        protected override void OnTopicCreated(TopicInfo topic, PostInfo post, AttachmentInfo[] attachs)
        {
            SpacePostInfo spacepost = new SpacePostInfo();

            spacepost.Author = post.Poster;
            string content = Posts.GetPostMessageHTML(post, attachs);

            spacepost.Category       = "";
            spacepost.Content        = content;
            spacepost.Postdatetime   = DateTime.Now;
            spacepost.PostStatus     = 1;
            spacepost.PostUpDateTime = DateTime.Now;
            spacepost.Title          = post.Title;
            spacepost.Uid            = post.Posterid;

            DbProvider.GetInstance().AddSpacePost(spacepost);
        }
Esempio n. 32
0
        protected void Delete()
        {
            PostInfo post = PostManager.GetPost(postId);

            if (post == null)
            {
                return;
            }
            if (PageUtils.CurrentUser.Type != (int)UserType.Administrator && PageUtils.CurrentUser.UserId != post.UserId)
            {
                Response.Redirect("postlist.aspx?result=444");
            }

            PostManager.DeletePost(postId);

            Response.Redirect("postlist.aspx?result=3");
        }
Esempio n. 33
0
        /// <summary>
        /// 更新父版块最后发帖信息
        /// </summary>
        /// <param name="foruminfo"></param>
        /// <param name="postinfo"></param>
        private static void UpdateParentForumLastPost(ForumInfo foruminfo, PostInfo postinfo)
        {
            int parentFid = Utils.StrToInt(foruminfo.Parentidlist.Split(',')[1], 0);//去parentidlist属性split后的第一个数组元素,因为第0个是分类

            if (parentFid > 0)
            {
                string fidList = "";

                //获取到游客可以访问到的版块fidlist
                foreach (string fid in AdminForums.FindChildNode(parentFid.ToString()).Split(','))
                {
                    if (fid == "0")
                    {
                        continue;
                    }
                    foreach (DataRow dr in Forums.GetOpenForumList().Rows)
                    {
                        if (dr["fid"].ToString().Trim() == fid.Trim())
                        {
                            fidList += fid + ",";
                            break;
                        }
                    }
                }
                if (string.IsNullOrEmpty(fidList))
                {
                    return;
                }

                int forumsTid = Data.Forums.GetForumsLastPostTid(fidList.TrimEnd(','));

                if (forumsTid > 0)
                {
                    postinfo = Discuz.Data.Posts.GetLastPostByTid(forumsTid, PostTables.GetPostTableName(forumsTid));
                }
                else
                {
                    postinfo.Pid          = postinfo.Tid = 0;
                    postinfo.Title        = postinfo.Topictitle = "从未";
                    postinfo.Postdatetime = "1900-1-1";
                    postinfo.Poster       = "";
                    postinfo.Posterid     = 0;
                }
                Discuz.Data.Forums.UpdateForumLastPost(GetForumInfo(parentFid), postinfo);
            }
        }
Esempio n. 34
0
 /// <summary>
 /// 检查别名是否重复
 /// </summary>
 /// <returns></returns>
 private static void CheckSlug(PostInfo post)
 {
     if (string.IsNullOrEmpty(post.Slug))
     {
         return;
     }
     while (true)
     {
         string cmdText = post.PostId == 0 ? string.Format("select count(1) from [{1}posts] where [slug]='{0}'  ", post.Slug, ConfigHelper.Tableprefix) : string.Format("select count(1) from [{2}posts] where [slug]='{0}'   and [postid]<>{1}", post.Slug, post.PostId, ConfigHelper.Tableprefix);
         int    r       = Convert.ToInt32(OleDbHelper.ExecuteScalar(cmdText));
         if (r == 0)
         {
             return;
         }
         post.Slug += "-2";
     }
 }
Esempio n. 35
0
        private StringBuilder IsValidGetPostInfo(PostInfo info)
        {
            StringBuilder xmlnode = new StringBuilder();

            xmlnode.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
            if (!DNTRequest.IsPost() || ForumUtils.IsCrossSitePost())
            {
                xmlnode.Append("<error>您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。</error>");
                return(xmlnode);
            }
            if (info == null)
            {
                xmlnode.Append("<error>读取帖子失败</error>");
                return(xmlnode);
            }
            return(xmlnode);
        }
Esempio n. 36
0
 /// <summary>
 /// 检查别名是否重复
 /// </summary>
 /// <returns></returns>
 private static void CheckSlug(PostInfo post)
 {
     if (string.IsNullOrEmpty(post.Slug))
     {
         return;
     }
     while (true)
     {
         string cmdText = post.PostId == 0 ? string.Format("select count(1) from [{1}posts] where [slug]='{0}'  ", post.Slug,ConfigHelper.Tableprefix) : string.Format("select count(1) from [{2}posts] where [slug]='{0}'   and [postid]<>{1}", post.Slug, post.PostId, ConfigHelper.Tableprefix);
         int r = Convert.ToInt32(OleDbHelper.ExecuteScalar(cmdText));
         if (r == 0)
         {
             return;
         }
         post.Slug += "-2";
     }
 }
        /// <summary>
        /// This completes the things necessary for creating a content item in the data store. 
        /// </summary>
        /// <param name="objPost">The PostInfo entity we just created in the data store.</param>
        /// <param name="tabId">The page we will associate with our content item.</param>
        /// <returns>The ContentItemId primary key created in the Core ContentItems table.</returns>
        private static int CompleteQuestionCreation(PostInfo objPost, int tabId)
        {
            var cntTaxonomy = new Content();
            var objContentItem = cntTaxonomy.CreateContentItem(objPost, tabId);

            return objContentItem.ContentItemId;
        }
            public PostInfoItem(PostInfo postInfo, BlogPostListBox listBox)
            {
                _postInfo = postInfo;
                _listbox = listBox;

                SearchIndex = HTMLDocumentHelper.HTMLToPlainText(postInfo.Title.ToLower(CultureInfo.CurrentUICulture) + " " + postInfo.Contents.ToLower(CultureInfo.CurrentUICulture), true);
            }
Esempio n. 39
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="postinfo">实体</param>
        /// <returns>修改的行数</returns>
        public int UpdatePost(PostInfo postinfo)
        {
            CheckSlug(postinfo);

            string cmdText = string.Format(@"update [{0}posts] set
                                       [CategoryId]=@CategoryId,
                                       [Title]=@Title,[Summary]=@Summary,
                                       [PostContent]=@PostContent,
                                       [Slug]=@Slug,
                                       [UserId]=@UserId,
                                       [CommentStatus]=@CommentStatus,
                                       [CommentCount]=@CommentCount,
                                       [ViewCount]=@ViewCount,
                                       [Tag]=@Tag,
                                       [UrlFormat]=@UrlFormat,
                                       [Template]=@Template,
                                       [Recommend]=@Recommend,
                                       [Status]=@Status,
                                       [TopStatus]=@TopStatus,
                                       [HomeStatus]=@HomeStatus,
                                       [HideStatus]=@HideStatus,
                                       [PostTime]=@PostTime,
                                       [UpdateTime]=@UpdateTime
                                   where [PostId]=@PostId", ConfigHelper.Tableprefix);
            using (var conn = dapper.OpenConnection())
            {
                return conn.Execute(cmdText, postinfo);
            }
        }
Esempio n. 40
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="post">实体</param>
        /// <returns>修改的行数</returns>
        public int UpdatePost(PostInfo post)
        {
            CheckSlug(post);

            string cmdText = string.Format(@"update [{0}posts] set
                                       [CategoryId]=@CategoryId,
                                       [Title]=@Title,
                                       [Summary]=@Summary,
                                       [PostContent]=@PostContent,
                                       [Slug]=@Slug,
                                       [UserId]=@UserId,
                                       [CommentStatus]=@CommentStatus,
                                       [CommentCount]=@CommentCount,
                                       [ViewCount]=@ViewCount,
                                       [Tag]=@Tag,
                                       [UrlFormat]=@UrlFormat,
                                       [Template]=@Template,
                                       [Recommend]=@Recommend,
                                       [Status]=@Status,
                                       [TopStatus]=@TopStatus,
                                       [HomeStatus]=@HomeStatus,
                                       [PostTime]=@PostTime,
                                       [UpdateTime]=@UpdateTime
                                   where [PostId]=@PostId", ConfigHelper.Tableprefix);

              using (var conn=dapper.OpenConnection())
              {
                  return conn.Execute(cmdText, new
                  {
                      CategoryId = post.CategoryId,
                      Title = post.Title,
                      Summary = post.Summary,
                      PostContent = post.PostContent,
                      Slug = post.Slug,
                      UserId = post.UserId,
                      CommentStatus = post.CommentStatus,
                      CommentCount = post.CommentCount,
                      ViewCount = post.ViewCount,
                      Tag = post.Tag,
                      UrlFormat = post.UrlFormat,
                      Template = post.Template,
                      Recommend = post.Recommend,
                      Status = post.Status,
                      TopStatus = post.TopStatus,
                      HomeStatus = post.HomeStatus,
                      PostTime = post.PostTime.ToString(),
                      UpdateTime = post.UpdateTime.ToString(),
                      PostId = post.PostId
                  });
              }
        }
 private void RemoveItem(PostInfo item)
 {
     for (int i = 0; i < Items.Count; i++)
     {
         PostInfoItem postInfoItem = Items[i] as PostInfoItem;
         if (postInfoItem.PostInfo == item)
             Items.Remove(postInfoItem);
     }
     Invalidate();
 }
Esempio n. 42
0
        /// <summary>
        /// Called while an item is being processed. If this function is called,
        /// NewsGator is processing an item that appears to be "new", and the 
        /// process of adding it to Outlook has been started.
        /// 
        /// This function will be called on one of the NewsGator retrieval threads.
        /// There are 1-5 of these threads, controlled by the "performance" setting
        /// in NewsGator/Options, Options tab.  You MUST NOT access the Outlook
        /// object model during this function.
        /// 
        /// Instance management is subject to change.  This means that NewsGator
        /// may call PreProcessItem 3 times, then PostProcessItem 3 times, or it
        /// may interleave the calls.  Use the reference object returned by 
        /// PreProcessItem to correlate Pre- and Post- calls. 
        /// </summary>
        /// <param name="postInfo">
        /// This is the normalized information NewsGator has parsed from the RSS item.
        /// This information will be sent to the code that actually creates the 
        /// PostItem in Outlook; any changes you make to this object will be 
        /// carried forward and will affect the Outlook PostItem.
        /// </param>
        /// <param name="originalItem">
        /// This is the actual RSS item XML for the item being processed.  If your
        /// extension will process custom extensions, for example, you will find
        /// them here.  The node element will be named originalItem, and the actual
        /// RSS item will be the first child of this element.
        /// </param>
        /// <param name="createPost">
        /// Output parameter, defines whether or not the post should be created in
        /// Outlook.  If you return with this parameter set to true, PostProcessItem
        /// will still be called, but its postItem parameter will be null.
        /// </param>
        /// <returns>
        /// Returns a reference object which will be passed to PostProcessItem as the
        /// reference parameter.
        /// </returns>
        public object PreProcessItem(PostInfo postInfo, XmlNode originalItem, out bool createPost)
        {
            using (log4net.NDC.Push("PreProcessItem"))
            {
                // only do anything if the stylesheet contains the placeholder
                if (postInfo.Description.IndexOf(contentPlaceholder) >= 0)
                {
                    string content = string.Empty;

                    // need a link otherwise we don't know whatto retrieve!
                    if (postInfo.PostLink != string.Empty && postInfo.PostLink != null)
                    {
                        try
                        {
                            content = GetContent(postInfo.FromAddr, postInfo.PostLink);
                        }
                        // I know we should *never* catch all exceptions, but we really don't want to take Outlook out
                        catch (Exception ex)
                        {
                            log.Error("Failed to get content from " + postInfo.PostLink, ex);
                        }
                    }

                    // replace the placeholder in the post with the content
                    postInfo.Description = postInfo.Description.Replace(contentPlaceholder, content);
                }

                // all is well
                createPost = true;
                return postInfo;
            }
        }
Esempio n. 43
0
        /// <summary>
        /// 修改文章
        /// </summary>
        /// <param name="_postinfo"></param>
        /// <returns></returns>
        public static int UpdatePost(PostInfo _postinfo)
        {
            //   PostInfo oldPost = GetPost(_postinfo.PostId);   //好像有问题,不能缓存

            PostInfo oldPost = GetPostByDatabase(_postinfo.PostId);

            int result = DatabaseProvider.Instance.UpdatePost(_postinfo);

            if (oldPost != null && oldPost.CategoryId != _postinfo.CategoryId)
            {
                //分类
                CategoryService.UpdateCategoryCount(oldPost.CategoryId, -1);
                CategoryService.UpdateCategoryCount(_postinfo.CategoryId, 1);
            }

            //     CacheHelper.Remove(CacheKey);

            //标签
            TagService.UpdateTagUseCount(oldPost.Tag, -1);
            TagService.UpdateTagUseCount(_postinfo.Tag, 1);

            //   RemovePostsCache();

            return result;
        }
        void SetPostList(PostInfo[] posts)
        {
            // Remove all the past searchs as they are no longer valid
            _filterCache.Clear();

            // Add all the posts/pages to the cache for the empty string search
            List<PostInfoItem> allPosts = new List<PostInfoItem>();
            foreach (PostInfo blogPostInfo in posts)
            {
                allPosts.Add(new PostInfoItem(blogPostInfo, this));
            }
            _filterCache.Add(String.Empty, allPosts.ToArray());

            // Update the listbox
            UpdateListBox();

            OnPostsRefreshed(EventArgs.Empty);
        }
Esempio n. 45
0
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        //老标签
        string oldTag = string.Empty;

        PostInfo p = new PostInfo();

        if (Operate == OperateType.Update)
        {
            p = PostManager.GetPost(postId);
            oldTag = p.Tag;
        }
        else
        {
            p.CommentCount = 0;
            p.ViewCount = 0;
            p.CreateDate = DateTime.Now;
            p.UserId = PageUtils.CurrentUserId;
        }

        p.CategoryId = StringHelper.StrToInt(ddlCategory.SelectedValue, 0);
        p.CommentStatus = chkCommentStatus.Checked ? 1 : 0;
        p.Content = txtContents.Text;
        p.Slug = PageUtils.FilterSlug(txtCustomUrl.Text, "post", true);
        p.Status = chkStatus.Checked ? 1 : 0;
        p.TopStatus = chkTopStatus.Checked ? 1 : 0;
        p.HideStatus = chkHideStatus.Checked ? 1 : 0;
        p.Summary = txtSummary.Text;
        p.Tag = GetTagIdList(txtTags.Text.Trim());
        p.Title = StringHelper.HtmlEncode(txtTitle.Text);
        //  p.TopStatus = chkTopStatus.Checked ? 1 : 0;

        p.UrlFormat = StringHelper.StrToInt(ddlUrlType.SelectedValue, 1);
        p.Template = ddlTemplate.SelectedValue;
        p.Recommend = chkRecommend.Checked ? 1 : 0;

        //  p.Type = 0;// (int)PostType.Article;
        p.UpdateDate = DateTime.Now;

        if (chkSaveImage.Checked)
        {
            p.Content = SaveRemoteImage(p.Content);
        }

        if (Operate == OperateType.Update)
        {
            PostManager.UpdatePost(p);
            //  TagManager.ResetTag(oldTag + p.Tag);
            Response.Redirect("postedit.aspx?operate=update&postid=" + postId + "&message=2");
        }
        else
        {
            p.PostId = PostManager.InsertPost(p);

            SendEmail(p);

            // TagManager.ResetTag(p.Tag);

            Response.Redirect("postedit.aspx?operate=update&postid=" + p.PostId + "&message=1");
        }
    }
Esempio n. 46
0
        public void SendMail(int postid, string email, PostInfo post, string content, string author, string siteurl, CommentInfo c,int parentid)
        {
            #region 发邮件
            try
            {

                if (BlogConfig.GetSetting().SendMailNotifyByComment == 1) //给订阅者发邮件
                {
                    //先不考虑审核的问题
                    List<CommentInfo> list = CommentService.GetCommentList(int.MaxValue, 1, -1, postid, 0, -1, 1, string.Empty);

                    List<string> emailList = new List<string>();

                    foreach (CommentInfo cmt in list)
                    {
                        if (!Jqpress.Framework.Utils.Validate.IsValidEmail(cmt.Email))
                        {
                            continue;
                        }
                        //自己不用发
                        if (email == cmt.Email)
                        {
                            continue;
                        }
                        //不重复发送
                        if (emailList.Contains(cmt.Email))
                        {
                            continue;
                        }
                        emailList.Add(cmt.Email);

                        string subject = string.Empty;
                        string body = string.Empty;

                        subject = string.Format("[评论订阅通知]{0}", post.Title);
                        body += string.Format("您订阅的{0}有新评论了:<br/>", post.Title);
                        body += "<hr/>";
                        body += content;
                        body += "<hr/>";
                        body += "<br />评论作者: " + author;

                        if (!string.IsNullOrEmpty(siteurl))
                        {
                            body += string.Format(" (<a href=\"{0}\">{0}</a>)", siteurl);
                        }

                        body += "<br />评论时间: " + DateTime.Now;
                        body += string.Format("<br />原文连接: <a href=\"{0}\" title=\"{1}\" >{1}</a>", post.Url, post.Title);

                        body += "<br />注:系统自动通知邮件,不要回复。";

                        EmailHelper.SendAsync(cmt.Email, subject, body);
                    }
                }

                if (BlogConfig.GetSetting().SendMailAuthorByComment == 1 && c.ParentId <= 0)       //给文章作者发邮件 回复时不发邮件
                {
                    string subject = string.Empty;
                    string body = string.Empty;

                    subject = string.Format("[新评论通知]{0}", post.Title);
                    body += string.Format("您发表的{0}有新评论了:<br/>", post.Title);
                    body += "<hr/>";
                    body += content;
                    body += "<hr/>";
                    body += "<br />评论作者: " + author;

                    if (!string.IsNullOrEmpty(siteurl))
                    {
                        body += string.Format(" (<a href=\"{0}\">{0}</a>)", siteurl);
                    }

                    body += "<br />评论时间: " + DateTime.Now;
                    body += string.Format("<br />原文连接: <a href=\"{0}\" title=\"{1}\" >{1}</a>", post.Url, post.Title);

                    body += "<br />注:系统自动通知邮件,不要回复。";

                    UserInfo user = UserService.GetUser(post.UserId);
                    if (user != null && Jqpress.Framework.Utils.Validate.IsValidEmail(user.Email))
                    {
                        EmailHelper.SendAsync(user.Email, subject, body);
                    }
                }
                if (BlogConfig.GetSetting().SendMailNotifyByComment == 1)//回复时发邮件
                {
                    //获取原品论者的邮箱
                    string replyemail = CommentService.GetComment(parentid).Email;
                    string subject = string.Empty;
                    string body = string.Empty;

                    subject = string.Format("[评论回复通知]{0}", post.Title);
                    body += string.Format("您对 {0} 发表的评论有回复了:<br/>", post.Title);
                    body += "<hr/>";
                    body += content;
                    body += "<hr/>";
                    body += "<br />评论作者: " + author;

                    if (!string.IsNullOrEmpty(siteurl))
                    {
                        body += string.Format(" (<a href=\"{0}\">{0}</a>)", siteurl);
                    }

                    body += "<br />回复时间: " + DateTime.Now;
                    body += string.Format("<br />原文连接: <a href=\"{0}\" title=\"{1}\" >{1}</a>", post.Url, post.Title);

                    body += "<br />注:系统自动通知邮件,不要回复。";

                    if (email != "" && Jqpress.Framework.Utils.Validate.IsValidEmail(replyemail))
                    {
                        EmailHelper.SendAsync(email, subject, body);
                    }
                }

            }catch(Exception e){

            }
            #endregion
        }
Esempio n. 47
0
 private async Task<PostingResult> PostWithoutCaptcha(string id, PostInfo postInfo, string boardId, long parent) {
     var uri = UrlService.GetPostingUrl();
     var content = (await Mapper
         .MapPostInfo(postInfo, boardId, parent))
         .AddString("captcha_type", "app")
         .AddString("app_response_id", id)
         .AddString("app_response", ApiKeys.Encrypt(id));
     var result = await PostAndConvertJsonResponse<PostingResultEntity, PostingResult>(uri, content, Mapper.MapPostingResult);
     if (!result.IsSuccessful && result.Error == "Капча невалидна.")
         throw await CreateCaptchaNeededException(result);
     return result;
 }
Esempio n. 48
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="postinfo">实体</param>
        /// <returns>成功返回新记录的ID,失败返回 0</returns>
        public int InsertPost(PostInfo postinfo)
        {
            CheckSlug(postinfo);
            string cmdText = @"insert into [loachs_posts]
                                (
                               [CategoryId],[Title],[Summary],[Content],[Slug],[UserId],[CommentStatus],[CommentCount],[ViewCount],[Tag],[UrlFormat],[Template],[Recommend],[Status],[TopStatus],[HideStatus],[CreateDate],[UpdateDate]
                                )
                                values
                                (
                                @CategoryId,@Title,@Summary,@Content,@Slug,@UserId,@CommentStatus,@CommentCount,@ViewCount,@Tag,@UrlFormat,@Template,@Recommend,@Status,@TopStatus,@HideStatus,@CreateDate,@UpdateDate
                                )";
               SqliteParameter[] prams = {

                                SqliteDbHelper.MakeInParam("@CategoryId",DbType.Int32,4,postinfo.CategoryId),
                                SqliteDbHelper.MakeInParam("@Title",DbType.String,255,postinfo.Title),
                                SqliteDbHelper.MakeInParam("@Summary",DbType.String,0,postinfo.Summary),
                                SqliteDbHelper.MakeInParam("@Content",DbType.String,0,postinfo.Content),
                                SqliteDbHelper.MakeInParam("@Slug",DbType.String,255,postinfo.Slug),
                                SqliteDbHelper.MakeInParam("@UserId",DbType.Int32,4,postinfo.UserId),
                                SqliteDbHelper.MakeInParam("@CommentStatus",DbType.Int32,1,postinfo.CommentStatus),
                                SqliteDbHelper.MakeInParam("@CommentCount",DbType.Int32,4,postinfo.CommentCount),
                                SqliteDbHelper.MakeInParam("@ViewCount",DbType.Int32,4,postinfo.ViewCount),
                                SqliteDbHelper.MakeInParam("@Tag",DbType.String,255,postinfo.Tag),
                                SqliteDbHelper.MakeInParam("@UrlFormat",DbType.Int32,1,postinfo.UrlFormat),
                                SqliteDbHelper.MakeInParam("@Template",DbType.String,50,postinfo.Template ),
                                SqliteDbHelper.MakeInParam("@Recommend",DbType.Int32,1,postinfo.Recommend),
                                SqliteDbHelper.MakeInParam("@Status",DbType.Int32,1,postinfo.Status),
                                SqliteDbHelper.MakeInParam("@TopStatus",DbType.Int32,1,postinfo.TopStatus),
                                SqliteDbHelper.MakeInParam("@HideStatus",DbType.Int32,1,postinfo.HideStatus),
                                SqliteDbHelper.MakeInParam("@CreateDate",DbType.Date,8,postinfo.CreateDate),
                                SqliteDbHelper.MakeInParam("@UpdateDate",DbType.Date,8,postinfo.UpdateDate)
                            };
            SqliteDbHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);
            int newId = StringHelper.ObjectToInt(SqliteDbHelper.ExecuteScalar("select   [PostId] from [Loachs_Posts] order by [PostId] desc limit 1"));
            //if (newId > 0)
            //{
            //    SqliteDbHelper.ExecuteNonQuery(string.Format("update [loachs_users] set [postcount]=[postcount]+1 where [userid]={0}", postinfo.UserId));
            //    SqliteDbHelper.ExecuteNonQuery("update [loachs_sites] set [postcount]=[postcount]+1");
            //    SqliteDbHelper.ExecuteNonQuery(string.Format("update [loachs_terms] set [count]=[count]+1 where [termid]={0}", postinfo.CategoryId));
            //}
            return newId;
        }
Esempio n. 49
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="postinfo">实体</param>
        /// <returns>成功返回新记录的ID,失败返回 0</returns>
        public int InsertPost(PostInfo postinfo)
        {
            CheckSlug(postinfo);
            string cmdText = string.Format(@"insert into [{0}posts]
                                (
                               [CategoryId],[Title],[Summary],[PostContent],[Slug],[UserId],[CommentStatus],[CommentCount],[ViewCount],[Tag],[UrlFormat],[Template],[Recommend],[Status],[TopStatus],[HomeStatus],[HideStatus],[PostTime],[UpdateTime]
                                )
                                values
                                (
                                @CategoryId,@Title,@Summary,@PostContent,@Slug,@UserId,@CommentStatus,@CommentCount,@ViewCount,@Tag,@UrlFormat,@Template,@Recommend,@Status,@TopStatus,@HomeStatus,@HideStatus,@PostTime,@UpdateTime
                                )", ConfigHelper.Tableprefix);
            OleDbParameter[] prams = {

                                OleDbHelper.MakeInParam("@CategoryId",OleDbType.Integer,4,postinfo.CategoryId),
                                OleDbHelper.MakeInParam("@Title",OleDbType.VarWChar,255,postinfo.Title),
                                OleDbHelper.MakeInParam("@Summary",OleDbType.VarWChar,0,postinfo.Summary),
                                OleDbHelper.MakeInParam("@PostContent",OleDbType.VarWChar,0,postinfo.PostContent),
                                OleDbHelper.MakeInParam("@Slug",OleDbType.VarWChar,255,postinfo.Slug),
                                OleDbHelper.MakeInParam("@UserId",OleDbType.Integer,4,postinfo.UserId),
                                OleDbHelper.MakeInParam("@CommentStatus",OleDbType.Integer,1,postinfo.CommentStatus),
                                OleDbHelper.MakeInParam("@CommentCount",OleDbType.Integer,4,postinfo.CommentCount),
                                OleDbHelper.MakeInParam("@ViewCount",OleDbType.Integer,4,postinfo.ViewCount),
                                OleDbHelper.MakeInParam("@Tag",OleDbType.VarWChar,255,postinfo.Tag),
                                OleDbHelper.MakeInParam("@UrlFormat",OleDbType.Integer,1,postinfo.UrlFormat),
                                OleDbHelper.MakeInParam("@Template",OleDbType.VarChar,50,postinfo.Template ),
                                OleDbHelper.MakeInParam("@Recommend",OleDbType.Integer,1,postinfo.Recommend),
                                OleDbHelper.MakeInParam("@Status",OleDbType.Integer,1,postinfo.Status),
                                OleDbHelper.MakeInParam("@TopStatus",OleDbType.Integer,1,postinfo.TopStatus),
                                OleDbHelper.MakeInParam("@HomeStatus",OleDbType.Integer,1,postinfo.HomeStatus),
                                OleDbHelper.MakeInParam("@HideStatus",OleDbType.Integer,1,postinfo.PostStatus),
                                OleDbHelper.MakeInParam("@PostTime",OleDbType.Date,8,postinfo.PostTime),
                                OleDbHelper.MakeInParam("@UpdateTime",OleDbType.Date,8,postinfo.UpdateTime)
                            };
            OleDbHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);
            int newId = TypeConverter.ObjectToInt(OleDbHelper.ExecuteScalar(string.Format("select top 1 [PostId] from [{0}Posts] order by [PostId] desc",ConfigHelper.Tableprefix)));
            //if (newId > 0)
            //{
            //    OleDbHelper.ExecuteNonQuery(string.Format("update [{0}users] set [postcount]=[postcount]+1 where [userid]={0}", postinfo.UserId));
            //    OleDbHelper.ExecuteNonQuery("update [{0}sites] set [postcount]=[postcount]+1");
            //    OleDbHelper.ExecuteNonQuery(string.Format("update [{0}terms] set [count]=[count]+1 where [termid]={0}", postinfo.CategoryId));
            //}
            return newId;
        }
Esempio n. 50
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="postinfo">实体</param>
        /// <returns>修改的行数</returns>
        public int UpdatePost(PostInfo postinfo)
        {
            CheckSlug(postinfo);

            //PostInfo oldPost = GetPost(postinfo.PostId);        //修改前

            //if (oldPost.CategoryId != postinfo.CategoryId)
            //{

            //    SqliteDbHelper.ExecuteNonQuery(string.Format("update [loachs_terms] set [count]=[count]-1 where [termid]={0}", oldPost.CategoryId));

            //    SqliteDbHelper.ExecuteNonQuery(string.Format("update [loachs_terms] set [count]=[count]+1 where [termid]={0}", postinfo.CategoryId));

            //}

            string cmdText = "update [loachs_posts] set  [CategoryId]=@CategoryId,[Title]=@Title,[Summary]=@Summary,[Content]=@Content,[Slug]=@Slug,[UserId]=@UserId,[CommentStatus]=@CommentStatus,[CommentCount]=@CommentCount,[ViewCount]=@ViewCount,[Tag]=@Tag,[UrlFormat]=@UrlFormat,[Template]=@Template,[Recommend]=@Recommend,[Status]=@Status,[TopStatus]=@TopStatus,[HideStatus]=@HideStatus,[CreateDate]=@CreateDate,[UpdateDate]=@UpdateDate where [PostId]=@PostId";
            SqliteParameter[] prams = {

                                SqliteDbHelper.MakeInParam("@CategoryId",DbType.Int32,4,postinfo.CategoryId),
                                SqliteDbHelper.MakeInParam("@Title",DbType.String,255,postinfo.Title),
                                SqliteDbHelper.MakeInParam("@Summary",DbType.String,0,postinfo.Summary),
                                SqliteDbHelper.MakeInParam("@Content",DbType.String,0,postinfo.Content),
                                SqliteDbHelper.MakeInParam("@Slug",DbType.String,255,postinfo.Slug),
                                SqliteDbHelper.MakeInParam("@UserId",DbType.Int32,4,postinfo.UserId),
                                SqliteDbHelper.MakeInParam("@CommentStatus",DbType.Int32,1,postinfo.CommentStatus),
                                SqliteDbHelper.MakeInParam("@CommentCount",DbType.Int32,4,postinfo.CommentCount),
                                SqliteDbHelper.MakeInParam("@ViewCount",DbType.Int32,4,postinfo.ViewCount),
                                SqliteDbHelper.MakeInParam("@Tag",DbType.String,255,postinfo.Tag),
                                SqliteDbHelper.MakeInParam("@UrlFormat",DbType.Int32,1,postinfo.UrlFormat),
                                SqliteDbHelper.MakeInParam("@Template",DbType.String,50,postinfo.Template ),
                                SqliteDbHelper.MakeInParam("@Recommend",DbType.Int32,1,postinfo.Recommend),
                                SqliteDbHelper.MakeInParam("@Status",DbType.Int32,1,postinfo.Status),
                                SqliteDbHelper.MakeInParam("@TopStatus",DbType.Int32,1,postinfo.TopStatus),
                                SqliteDbHelper.MakeInParam("@HideStatus",DbType.Int32,1,postinfo.HideStatus),
                                SqliteDbHelper.MakeInParam("@CreateDate",DbType.Date,8,postinfo.CreateDate),
                                SqliteDbHelper.MakeInParam("@UpdateDate",DbType.Date,8,postinfo.UpdateDate),
                                SqliteDbHelper.MakeInParam("@PostId",DbType.Int32,4,postinfo.PostId),
                            };
            return SqliteDbHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);
        }
Esempio n. 51
0
 /// <summary>
 /// 检查别名是否重复
 /// </summary>
 /// <param name="term"></param>
 /// <returns></returns>
 private bool CheckSlug(PostInfo post)
 {
     if (string.IsNullOrEmpty(post.Slug))
     {
         return true;
     }
     while (true)
     {
         string cmdText = string.Empty;
         if (post.PostId == 0)
         {
             cmdText = string.Format("select count(1) from [loachs_posts] where [slug]='{0}'  ", post.Slug);
         }
         else
         {
             cmdText = string.Format("select count(1) from [loachs_posts] where [slug]='{0}'   and [postid]<>{1}", post.Slug, post.PostId);
         }
         int r = Convert.ToInt32(SqliteDbHelper.ExecuteScalar(cmdText));
         if (r == 0)
         {
             return true;
         }
         post.Slug += "-2";
     }
 }
Esempio n. 52
0
        /// <summary>
        /// 数据转换
        /// </summary>
        /// <param name="read"></param>
        /// <returns></returns>
        private List<PostInfo> DataReaderToCommentList(SqliteDataReader read)
        {
            List<PostInfo> list = new List<PostInfo>();
            while (read.Read())
            {
                PostInfo postinfo = new PostInfo();
                postinfo.PostId = StringHelper.ObjectToInt(read["PostId"]);

                postinfo.CategoryId = StringHelper.ObjectToInt(read["CategoryId"]);
                postinfo.Title = Convert.ToString(read["Title"]);
                postinfo.Summary = Convert.ToString(read["Summary"]);
                postinfo.Content = Convert.ToString(read["Content"]);
                postinfo.Slug = Convert.ToString(read["Slug"]);
                postinfo.UserId = StringHelper.ObjectToInt(read["UserId"]);
                postinfo.CommentStatus = StringHelper.ObjectToInt(read["CommentStatus"]);
                postinfo.CommentCount = StringHelper.ObjectToInt(read["CommentCount"]);
                postinfo.ViewCount = StringHelper.ObjectToInt(read["ViewCount"]);
                postinfo.Tag = Convert.ToString(read["Tag"]);

                postinfo.UrlFormat = StringHelper.ObjectToInt((read["UrlFormat"]));
                postinfo.Template = Convert.ToString(read["Template"]);

                postinfo.Recommend = StringHelper.ObjectToInt(read["Recommend"]);
                postinfo.Status = StringHelper.ObjectToInt(read["Status"]);
                postinfo.TopStatus = StringHelper.ObjectToInt(read["TopStatus"]);
                postinfo.HideStatus = StringHelper.ObjectToInt(read["HideStatus"]);

                postinfo.CreateDate = Convert.ToDateTime(read["CreateDate"]);
                postinfo.UpdateDate = Convert.ToDateTime(read["UpdateDate"]);
                list.Add(postinfo);
            }
            read.Close();
            return list;
        }
Esempio n. 53
0
        private bool IsPostRestricted(Status status)
        {
            var currentPost = new PostInfo(status.CreatedAt, status.IdStr, status.Text ?? string.Empty, status.User.IdStr);

            if (currentPost.Equals(_prevPostInfo))
            {
                return true;
            }

            _prevPostInfo.CreatedAt = currentPost.CreatedAt;
            _prevPostInfo.Id = currentPost.Id;
            _prevPostInfo.Text = currentPost.Text;
            _prevPostInfo.UserId = currentPost.UserId;

            return false;
        }
Esempio n. 54
0
 public PostInfoChangedEventArgs(PostInfo postInfo) {
     PostInfo = postInfo;
 }
Esempio n. 55
0
    /// <summary>
    /// 发邮件
    /// </summary>
    /// <param name="post"></param>
    private void SendEmail(PostInfo post)
    {
        if (SettingManager.GetSetting().SendMailAuthorByPost == 1)
        {
            List<UserInfo> list = UserManager.GetUserList();
            List<string> emailList = new List<string>();

            foreach (UserInfo user in list)
            {
                if (!StringHelper.IsEmail(user.Email))
                {
                    continue;
                }
                //自己不用发
                if (PageUtils.CurrentUser.Email == user.Email)
                {
                    continue;
                }
                //不重复发送
                if (emailList.Contains(user.Email))
                {
                    continue;
                }
                emailList.Add(user.Email);

                string subject = string.Empty;
                string body = string.Empty;

                subject = string.Format("[新文章通知]{0}", post.Title);
                body += string.Format("{0}有新文章了:<br/>", SettingManager.GetSetting().SiteName);
                body += "<hr/>";
                body += "<br />标题: " + post.Link;
                body += post.Detail;
                body += "<hr/>";
                body += "<br />作者: " + PageUtils.CurrentUser.Link;
                body += "<br />时间: " + post.CreateDate;
                body += "<br />文章连接: " + post.Link;
                body += "<br />注:系统自动通知邮件,不要回复。";

                EmailHelper.SendAsync(user.Email, subject, body);
            }
        }
    }
Esempio n. 56
0
        private bool IsPostRestricted(TwitterDataModel.Status status)
        {
            var _current = new PostInfo(string.Empty, string.Empty, string.Empty, string.Empty);

            _current.CreatedAt = status.CreatedAt;
            _current.Id = status.IdStr;
            if (status.Text == null)
            {
                _current.Text = string.Empty;
            }
            else
            {
                _current.Text = status.Text;
            }
            _current.UserId = status.User.IdStr;

            if (_current.Equals(_prev))
            {
                return true;
            }
            _prev.CreatedAt = _current.CreatedAt;
            _prev.Id = _current.Id;
            _prev.Text = _current.Text;
            _prev.UserId = _current.UserId;

            return false;
        }
Esempio n. 57
0
 public bool Equals(PostInfo dst)
 {
     return CreatedAt == dst.CreatedAt && Id == dst.Id && Text == dst.Text && UserId == dst.UserId;
 }
Esempio n. 58
0
        ///// <summary>
        ///// 移动所有文章缓存
        ///// </summary>
        ///// <returns></returns>
        //private static bool RemovePostsCache()
        //{
        ////    Caches.Remove("/posts");
        //    return true;
        //}
        /// <summary>
        /// 添加文章
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        public static int InsertPost(PostInfo post)
        {
            post.PostId = dao.InsertPost(post);

            _posts.Add(post);
            _posts.Sort();

            //统计
            StatisticsManager.UpdateStatisticsPostCount(1);
            //用户
            UserManager.UpdateUserPostCount(post.UserId, 1);
            //分类
            CategoryManager.UpdateCategoryCount(post.CategoryId, 1);
            //标签
            TagManager.UpdateTagUseCount(post.Tag, 1);

            //   RemovePostsCache();

            return post.PostId;
        }
Esempio n. 59
0
 public bool Equals(PostInfo dst)
 {
     if (this.CreatedAt == dst.CreatedAt && this.Id == dst.Id && this.Text == dst.Text && this.UserId == dst.UserId)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Esempio n. 60
0
        /// <summary>
        /// 添加文章
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        public static int InsertPost(PostInfo post)
        {
            post.PostId = DatabaseProvider.Instance.InsertPost(post);

            _posts.Add(post);
            _posts.Sort();

            //统计
            StatisticsService.UpdateStatisticsPostCount(1);
            //用户
            UserService.UpdateUserPostCount(post.UserId, 1);
            //分类
            CategoryService.UpdateCategoryCount(post.CategoryId, 1);
            //标签
            TagService.UpdateTagUseCount(post.Tag, 1);

            //   RemovePostsCache();

            return post.PostId;
        }