Exemple #1
0
        ///<summary>Creates historical entry of deletion into wikiPageHist, and deletes current non-draft page from WikiPage.
        ///For middle tier purposes we need to have the currently logged in user passed into this method.</summary>
        public static void Archive(string pageTitle, long userNumCur)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), pageTitle, userNumCur);
                return;
            }
            WikiPage wikiPage = GetByTitle(pageTitle);

            if (wikiPage == null)
            {
                return;                //The wiki page could not be found by the page title, nothing to do.
            }
            WikiPageHist wikiPageHist = PageToHist(wikiPage);

            //preserve the existing page with user credentials
            WikiPageHists.Insert(wikiPageHist);
            //make entry to show who deleted the page
            wikiPageHist.IsDeleted     = true;
            wikiPageHist.UserNum       = userNumCur;
            wikiPageHist.DateTimeSaved = MiscData.GetNowDateTime();
            WikiPageHists.Insert(wikiPageHist);
            //Now mark the wikipage as IsDeleted
            wikiPage.IsDeleted     = true;
            wikiPage.DateTimeSaved = MiscData.GetNowDateTime();
            Crud.WikiPageCrud.Update(wikiPage);
            //Remove all associated home pages for all users.
            UserOdPrefs.DeleteForValueString(0, UserOdFkeyType.WikiHomePage, pageTitle);
        }
Exemple #2
0
 ///<summary></summary>
 public static long Insert(WikiPageHist wikiPageHist)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         wikiPageHist.WikiPageNum = Meth.GetLong(MethodBase.GetCurrentMethod(), wikiPageHist);
         return(wikiPageHist.WikiPageNum);
     }
     return(Crud.WikiPageHistCrud.Insert(wikiPageHist));
 }
Exemple #3
0
		private void LoadWikiPage(WikiPageHist WikiPageCur) {
			try {
				webBrowserWiki.DocumentText=WikiPages.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);
			}
			textContent.Text=WikiPageCur.PageContent;
		}
Exemple #4
0
        public static WikiPageHist PageToHist(WikiPage wikiPage)
        {
            //No need to check RemotingRole; no call to db.
            WikiPageHist wikiPageHist = new WikiPageHist();

            wikiPageHist.UserNum       = wikiPage.UserNum;
            wikiPageHist.PageTitle     = wikiPage.PageTitle;
            wikiPageHist.PageContent   = wikiPage.PageContent;
            wikiPageHist.DateTimeSaved = wikiPage.DateTimeSaved;          //This gets set to NOW if this page is then inserted
            wikiPageHist.IsDeleted     = false;
            return(wikiPageHist);
        }
Exemple #5
0
        public static WikiPageHist PageToHist(WikiPage wikiPage)
        {
            //No need to check RemotingRole; no call to db.
            WikiPageHist wikiPageHist = new WikiPageHist();

            wikiPageHist.WikiPageNum   = -1;        //todo:handle this -1, shouldn't be a problem since we always get pages by Title.
            wikiPageHist.UserNum       = wikiPage.UserNum;
            wikiPageHist.PageTitle     = wikiPage.PageTitle;
            wikiPageHist.PageContent   = wikiPage.PageContent;
            wikiPageHist.DateTimeSaved = wikiPage.DateTimeSaved;          //This gets set to NOW if this page is then inserted
            wikiPageHist.IsDeleted     = false;
            return(wikiPageHist);
        }
Exemple #6
0
        ///<summary>Archives first by moving to WikiPageHist if it already exists.  Then, in either case, it inserts the new page.</summary>
        public static long InsertAndArchive(WikiPage wikiPage)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                wikiPage.WikiPageNum = Meth.GetLong(MethodBase.GetCurrentMethod(), wikiPage);
                return(wikiPage.WikiPageNum);
            }
            WikiPage wpExisting = GetByTitle(wikiPage.PageTitle);

            if (wpExisting != null)
            {
                WikiPageHist wpHist = PageToHist(wpExisting);
                WikiPageHists.Insert(wpHist);
                string command = "DELETE FROM wikipage WHERE PageTitle = '" + POut.String(wikiPage.PageTitle) + "'";
                Db.NonQ(command);
            }
            return(Crud.WikiPageCrud.Insert(wikiPage));
        }
Exemple #7
0
        public static WikiPage RevertFrom(WikiPageHist wikiPageHist)
        {
            WikiPage retVal = new WikiPage();

            //retVal.WikiPageNum
            //retVal.UserNum
            retVal.PageTitle   = wikiPageHist.PageTitle;
            retVal.PageContent = wikiPageHist.PageContent;
            retVal.KeyWords    = "";
            Match m = Regex.Match(wikiPageHist.PageContent, @"\[\[(keywords:).*?\]\]");

            if (m.Length > 0)
            {
                retVal.KeyWords = m.Value.Substring(11).TrimEnd(']');
            }
            //retVal.DateTimeSaved=DateTime.Now;//gets set when inserted.
            return(retVal);
        }
Exemple #8
0
        ///<summary>Creates historical entry of deletion into wikiPageHist, and deletes current page from WikiPage.</summary>
        public static void Delete(string pageTitle)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), pageTitle);
                return;
            }
            WikiPage     wikiPage     = GetByTitle(pageTitle);
            WikiPageHist wikiPageHist = PageToHist(wikiPage);

            //preserve the existing page with user credentials
            WikiPageHists.Insert(wikiPageHist);
            //make entry to show who deleted the page
            wikiPageHist.IsDeleted = true;
            wikiPageHist.UserNum   = Security.CurUser.UserNum;
            WikiPageHists.Insert(wikiPageHist);
            string command = "DELETE FROM wikipage WHERE PageTitle = '" + POut.String(pageTitle) + "'";

            Db.NonQ(command);
        }
Exemple #9
0
        public static WikiPage RevertFrom(WikiPageHist wikiPageHist)
        {
            //Get the existing WikiPage to ensure the WikiPageNum is preserved for links.
            //See JobNum 4429 for the job that made this necessary.
            WikiPage retVal = WikiPages.GetByTitle(wikiPageHist.PageTitle);

            if (retVal == null)
            {
                retVal = new WikiPage();
            }
            //retVal.WikiPageNum
            //retVal.UserNum
            retVal.PageTitle   = wikiPageHist.PageTitle;
            retVal.PageContent = wikiPageHist.PageContent;
            retVal.KeyWords    = "";
            Match m = Regex.Match(wikiPageHist.PageContent, @"\[\[(keywords:).*?\]\]");

            if (m.Length > 0)
            {
                retVal.KeyWords = m.Value.Substring(11).TrimEnd(']');
            }
            //retVal.DateTimeSaved=DateTime.Now;//gets set when inserted.
            return(retVal);
        }
Exemple #10
0
        ///<summary>Archives first by moving to WikiPageHist if it already exists.  Then, in either case, it inserts the new page.
        ///Does not delete drafts.</summary>
        public static long InsertAndArchive(WikiPage wikiPage)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                wikiPage.WikiPageNum = Meth.GetLong(MethodBase.GetCurrentMethod(), wikiPage);
                return(wikiPage.WikiPageNum);
            }
            wikiPage.PageContentPlainText = MarkupEdit.ConvertToPlainText(wikiPage.PageContent);
            wikiPage.IsDraft = false;
            WikiPage wpExisting = GetByTitle(wikiPage.PageTitle);

            if (wpExisting != null)
            {
                WikiPageHist wpHist = PageToHist(wpExisting);
                WikiPageHists.Insert(wpHist);
                wikiPage.DateTimeSaved = MiscData.GetNowDateTime();
                //Old behavior was to delete the wiki page and then always insert.
                //It was changed to Update here for storing wiki page references by WikiPageNum instead of PageTitle
                //See JobNum 4429 for additional information.
                Crud.WikiPageCrud.Update(wikiPage);
                return(wikiPage.WikiPageNum);
            }
            //Deleted(archived) wp with the same page title should be updated with new page content. No need to create a new wp if the wikipage exist already.
            WikiPage wpDeleted = GetByTitle(wikiPage.PageTitle, isDeleted: true);

            if (wpDeleted != null)
            {
                //No need to add history since we already added the history when we archived it.
                wikiPage.WikiPageNum   = wpDeleted.WikiPageNum;
                wikiPage.DateTimeSaved = wpDeleted.DateTimeSaved;
                Crud.WikiPageCrud.Update(wikiPage);
                return(wikiPage.WikiPageNum);
            }
            //At this point the wp does not exist. Insert new a new wikipage.
            return(Crud.WikiPageCrud.Insert(wikiPage));
        }
Exemple #11
0
		public static WikiPage RevertFrom(WikiPageHist wikiPageHist) {
			WikiPage retVal=new WikiPage();
			//retVal.WikiPageNum
			//retVal.UserNum
			retVal.PageTitle=wikiPageHist.PageTitle;
			retVal.PageContent=wikiPageHist.PageContent;
			retVal.KeyWords="";
			Match m=Regex.Match(wikiPageHist.PageContent,@"\[\[(keywords:).*?\]\]");
			if(m.Length>0) {
				retVal.KeyWords=m.Value.Substring(11).TrimEnd(']');
			}
			//retVal.DateTimeSaved=DateTime.Now;//gets set when inserted.
			return retVal;
		}
Exemple #12
0
		///<summary></summary>
		public static long Insert(WikiPageHist wikiPageHist){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){
				wikiPageHist.WikiPageNum=Meth.GetLong(MethodBase.GetCurrentMethod(),wikiPageHist);
				return wikiPageHist.WikiPageNum;
			}
			return Crud.WikiPageHistCrud.Insert(wikiPageHist);
		}
Exemple #13
0
		public static WikiPageHist PageToHist(WikiPage wikiPage) {
			//No need to check RemotingRole; no call to db.
			WikiPageHist wikiPageHist=new WikiPageHist();
			wikiPageHist.WikiPageNum=-1;//todo:handle this -1, shouldn't be a problem since we always get pages by Title.
			wikiPageHist.UserNum=wikiPage.UserNum;
			wikiPageHist.PageTitle=wikiPage.PageTitle;
			wikiPageHist.PageContent=wikiPage.PageContent;
			wikiPageHist.DateTimeSaved=wikiPage.DateTimeSaved;//This gets set to NOW if this page is then inserted
			wikiPageHist.IsDeleted=false;
			return wikiPageHist;
		}
		private void LoadWikiPage(WikiPageHist WikiPageCur) {
			webBrowserWiki.DocumentText=WikiPages.TranslateToXhtml(WikiPageCur.PageContent,false);
			textContent.Text=WikiPageCur.PageContent;
		}