当前位置: 首页>>代码示例>>C#>>正文


C# Forum.PostToJournal方法代码示例

本文整理汇总了C#中Forum.PostToJournal方法的典型用法代码示例。如果您正苦于以下问题:C# Forum.PostToJournal方法的具体用法?C# Forum.PostToJournal怎么用?C# Forum.PostToJournal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Forum的用法示例。


在下文中一共展示了Forum.PostToJournal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryCreatePostJournalXML

        /// <summary>
        /// Functions generates the TryCreatePostJournal XML
        /// </summary>
        /// <param name="body"></param>
        /// <param name="subject"></param>
        /// <param name="preview"></param>
        /// <param name="post"></param>
        /// <param name="postStyle"></param>
        /// <param name="profanityTriggered"></param>
        /// <param name="nonAllowedURLsTriggered"></param>
        /// <param name="emailAddressTriggered"></param>
        private void TryCreatePostJournalXML(string body, string subject, bool preview, bool post, int postStyle, int profanityTriggered, int nonAllowedURLsTriggered, int emailAddressTriggered)
        {
            //Clean any existing XML.
            RootElement.RemoveAll();

            Forum forum = new Forum(InputContext);
                
            XmlElement previewBody = CreateElement("PREVIEWBODY");

            if (InputContext.ViewingUser.UserID == 0 || InputContext.ViewingUser.UserLoggedIn == false || InputContext.ViewingUser.IsBanned)
            {
                XmlElement postJournalFail = AddElementTag(RootElement, "POSTJOURNALUNREG");
                if (InputContext.ViewingUser.UserID != 0)
                {
                    AddAttribute(postJournalFail, "RESTRICTED", 1);
                    AddAttribute(postJournalFail, "REGISTERED", 1);
                }
                return;
            }
            else if ((post || preview) && (postStyle == 1))
            {
                XmlDocument previewDoc = new XmlDocument();
                try
                {
                    previewDoc.LoadXml(body);
                    XmlElement richPostText = AddElementTag(previewBody, "RICHPOST");
                    richPostText.AppendChild(ImportNode(previewDoc.FirstChild));
                }
                catch(System.Xml.XmlException ex)
                {
                    AddErrorXml("PARSE-ERROR", ex.Message, previewBody);
                    post = false;
                }               
            }
            XmlElement warning = null;

	        if ((post || preview) && (subject == String.Empty))
	        {
                //XmlElement warning = AddTextTag(addToJournal, "WARNING", "You must type a Subject for your Journal Entry");
                //AddAttribute(warning, "TYPE", "SUBJECT");

                warning = CreateElement("WARNING");
                AddAttribute(warning, "TYPE", "SUBJECT");
                warning.InnerText = "You must type a Subject for your Journal Entry.";
	        }
	        else if ((post || preview) && (body == String.Empty))
	        {
                warning = CreateElement("WARNING");
                AddAttribute(warning, "TYPE", "EMPTYBODY");
                warning.InnerText = "Your Journal Entry cannot be empty.";
	        }
	        else if ((post || preview) && (body.Length > 200*1024))
	        {
                warning = CreateElement("WARNING");
                AddAttribute(warning, "TYPE", "TOOLONG");
                warning.InnerText = "Your posting is too long.";
	        }
	        else if (postStyle != 1 && (post || preview)/* && /*(!StringUtils.ConvertPlainText(body, 200))*/)
	        {
                warning = CreateElement("WARNING");
                AddAttribute(warning, "TYPE", "TOOMANYSMILEYS");
                warning.InnerText = "Your posting contained too many smileys.";
	        }
            else if (post)
            {
                // TODO Actually post the page
                int userID = 0;
                int journalID = 0;
                string userName = String.Empty;

                userID = InputContext.ViewingUser.UserID;
                journalID = InputContext.ViewingUser.Journal;
                userName = InputContext.ViewingUser.UserName;

                bool profanityFound = false;
                bool nonAllowedURLsFound = false;
                bool emailAddressFound = false;

                //Try and post to the users journal
                forum.PostToJournal(userID, journalID, userName, subject,
                    body, InputContext.CurrentSite.SiteID, postStyle, ref profanityFound, ref nonAllowedURLsFound, ref emailAddressFound);

                if (profanityFound && profanityTriggered == 0)
                {
                    profanityTriggered = 1;
                }
                else if (nonAllowedURLsFound && nonAllowedURLsTriggered == 0)
                {
                    nonAllowedURLsTriggered = 1;
//.........这里部分代码省略.........
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:101,代码来源:PostJournal.cs


注:本文中的Forum.PostToJournal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。