Esempio n. 1
0
        public void WikiPages_ConvertToPlainText_PageLinks()
        {
            string PageLinks      = "This is a title: [[234]] that shouldn't be [There]";
            string pageLinkResult = "This is a title:  that shouldn't be [There]";

            Assert.AreEqual(pageLinkResult, MarkupEdit.ConvertToPlainText(PageLinks));
        }
Esempio n. 2
0
        public void WikiPages_ConvertToPlainText_HTML()
        {
            string htmltags   = "<h2>Ideas</h2> <h3>Common Passwords file</h3>A file would be &>included that would contain</br> the top 1000 or so";
            string htmlResult = "Ideas Common Passwords fileA file would be &>included that would contain the top 1000 or so";

            Assert.AreEqual(htmlResult, MarkupEdit.ConvertToPlainText(htmltags));
        }
Esempio n. 3
0
        public void WikiPages_ConvertToPlainText_HtmlWebChatEndSessionMessage()
        {
            string htmltags = "<b>The session has ended.  You can close this browser window.</b><br><br>You can save this conversation for future reference."
                              + "  <a href=\"chathistory.aspx\">Save the chat history</a>.";
            string htmlResult = "The session has ended.  You can close this browser window.You can save this conversation for future reference.  Save the chat history.";

            Assert.AreEqual(htmlResult, MarkupEdit.ConvertToPlainText(htmltags));
        }
Esempio n. 4
0
        private void FillMessageThread()
        {
            List <WebChatMessage>   listWebChatMessages = WebChatMessages.GetAllForSessions(_webChatSession.WebChatSessionNum);
            List <SmsThreadMessage> listThreadMessages  = new List <SmsThreadMessage>();

            foreach (WebChatMessage webChatMessage in listWebChatMessages)
            {
                string strMsg = webChatMessage.MessageText;
                if (webChatMessage.MessageType == WebChatMessageType.EndSession)
                {
                    strMsg = MarkupEdit.ConvertToPlainText(strMsg);
                }
                SmsThreadMessage msg = new SmsThreadMessage(webChatMessage.DateT,
                                                            strMsg,
                                                            (webChatMessage.MessageType == WebChatMessageType.Customer),
                                                            false,
                                                            false,
                                                            webChatMessage.UserName
                                                            );
                listThreadMessages.Add(msg);
            }
            webChatThread.ListSmsThreadMessages = listThreadMessages;
        }
Esempio n. 5
0
        ///<summary>Before calling this, make sure to increment/decrement the historyNavBack index to keep track of the position in history.  If loading a new page, decrement historyNavBack before calling this function.  </summary>
        private void LoadWikiPage(string pageTitle)
        {
            //This is called from 11 different places, any time the program needs to refresh a page from the db.
            //It's also called from the browser_Navigating event when a "wiki:" link is clicked.
            WikiPage wpage = WikiPages.GetByTitle(pageTitle);

            if (wpage == null)
            {
                string errorMsg = "";
                if (!WikiPages.IsWikiPageTitleValid(pageTitle, out errorMsg))
                {
                    MsgBox.Show(this, "That page does not exist and cannot be made because the page title contains invalid characters.");
                    return;
                }
                if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "That page does not exist. Would you like to create it?"))
                {
                    return;
                }
                Action <string> onWikiSaved = new Action <string>((pageTitleNew) => {
                    //Insert the pageTitleNew where the pageTitle exists in the existing WikiPageCur
                    //(guaranteed to be unique because all INVALID WIKIPAGE LINK's have an ID at the end)
                    string pageContent      = WikiPages.GetWikiPageContentWithWikiPageTitles(WikiPageCur.PageContent);
                    WikiPageCur.PageContent = pageContent.Replace(pageTitle, pageTitleNew);
                    WikiPageCur.PageContent = WikiPages.ConvertTitlesToPageNums(WikiPageCur.PageContent);
                    if (!WikiPageCur.IsDraft)
                    {
                        WikiPageCur.PageContentPlainText = MarkupEdit.ConvertToPlainText(WikiPageCur.PageContent);
                    }
                    WikiPages.Update(WikiPageCur);
                });
                AddWikiPage(onWikiSaved);
                return;
            }
            WikiPageCur = wpage;
            try {
                webBrowserWiki.DocumentText = MarkupEdit.TranslateToXhtml(WikiPageCur.PageContent, false);
            }
            catch (Exception ex) {
                webBrowserWiki.DocumentText = "";
                MessageBox.Show(this, Lan.g(this, "This page is broken and cannot be viewed.  Error message:") + " " + ex.Message);
            }
            Text = "Wiki - " + WikiPageCur.PageTitle;
            #region historyMaint
            //This region is duplicated in webBrowserWiki_Navigating() for external links.  Modifications here will need to be reflected there.
            int indexInHistory = historyNav.Count - (1 + historyNavBack); //historyNavBack number of pages before the last page in history.  This is the index of the page we are loading.
            if (historyNav.Count == 0)                                    //empty history
            {
                historyNavBack = 0;
                historyNav.Add("wiki:" + pageTitle);
            }
            else if (historyNavBack < 0)           //historyNavBack could be negative here.  This means before the action that caused this load, we were not navigating through history, simply set back to 0 and add to historyNav[] if necessary.
            {
                historyNavBack = 0;
                if (historyNav[historyNav.Count - 1] != "wiki:" + pageTitle)
                {
                    historyNav.Add("wiki:" + pageTitle);
                }
            }
            else if (historyNavBack >= 0 && historyNav[indexInHistory] != "wiki:" + pageTitle) //branching from page in history
            {
                historyNav.RemoveRange(indexInHistory, historyNavBack + 1);                    //remove "forward" history. branching off in a new direction
                historyNavBack = 0;
                historyNav.Add("wiki:" + pageTitle);
            }
            #endregion
        }