public WikiArticleHisotryItem[] GetWikiHistory(int wikiID)
        {
            LoginUser loggedinUser = TSAuthentication.GetLoginUser();
            List <WikiArticleHisotryItem> wikiHistory = new List <WikiArticleHisotryItem>();
            WikiHistoryCollection         history     = WikiHistoryCollection.GetWikiHistoryByArticleID(loggedinUser, wikiID);

            if (history != null)
            {
                foreach (WikiHistory wiki in history)
                {
                    WikiArticleHisotryItem item = new WikiArticleHisotryItem();
                    item.HistoryID      = wiki.HistoryID;
                    item.RevisionNumber = wiki.Version;
                    if (wiki.ModifiedBy != null)
                    {
                        User user = Users.GetUser(loggedinUser, (int)wiki.ModifiedBy);

                        if (user != null)
                        {
                            item.RevisedBy = user.DisplayName;
                        }
                    }
                    item.RevisedDate = wiki.ModifiedDate;
                    item.Comment     = (wiki.Comment != null) ? wiki.Comment : "";

                    wikiHistory.Add(item);
                }

                return(wikiHistory.ToArray());
            }
            else
            {
                return(null);
            }
        }
        public WikiHistoryProxy GetWikiRevision(int historyID)
        {
            WikiHistory article = WikiHistoryCollection.GetWikiHistory(TSAuthentication.GetLoginUser(), historyID);

            if (article != null)
            {
                return(article.GetProxy());
            }
            return(null);
        }
        public static string GetWikiHistory(RestCommand command, int historyID)
        {
            WikiHistory wikiHistory = WikiHistoryCollection.GetWikiHistory(command.LoginUser, historyID);

            if (wikiHistory.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(wikiHistory.GetXml("WikiHistory", true));
        }
        public static string GetWikiHistoryCollection(RestCommand command)
        {
            WikiHistoryCollection wikiHistoryCollection = new WikiHistoryCollection(command.LoginUser);

            wikiHistoryCollection.LoadByOrganizationID(command.Organization.OrganizationID);

            if (command.Format == RestFormat.XML)
            {
                return(wikiHistoryCollection.GetXml("WikiHistoryCollection", "WikiHistory", true, command.Filters));
            }
            else
            {
                throw new RestException(HttpStatusCode.BadRequest, "Invalid data format");
            }
        }
        public void LogHistory(LoginUser loggedInUser, WikiArticle wiki, string comment)
        {
            WikiHistoryCollection history        = new WikiHistoryCollection(loggedInUser);
            WikiHistory           newWikiHistory = history.AddNewWikiHistory();

            newWikiHistory.ModifiedBy     = loggedInUser.UserID;
            newWikiHistory.CreatedBy      = loggedInUser.UserID;
            newWikiHistory.Version        = wiki.Version;
            newWikiHistory.Body           = wiki.Body;
            newWikiHistory.ArticleName    = wiki.ArticleName;
            newWikiHistory.OrganizationID = wiki.OrganizationID;
            newWikiHistory.ArticleID      = wiki.ArticleID;
            newWikiHistory.ModifiedDate   = DateTime.UtcNow;
            newWikiHistory.CreatedDate    = DateTime.UtcNow;
            newWikiHistory.Comment        = comment;

            newWikiHistory.Collection.Save();
        }