public void ApproveContent(Guid siteGuid, Guid approvalUserGuid)
        {
            // get latest workflow record waiting for approval
            ContentWorkflow submittedContent = ContentWorkflow.GetWorkInProgress(this.moduleGuid, ContentWorkflowStatus.AwaitingApproval.ToString());

            if (submittedContent == null)
            {
                return;
            }

            // create a new content history record of the existing live content
            ContentHistory history = new ContentHistory();

            history.ContentGuid = ModuleGuid;
            history.ContentText = Body;
            history.SiteGuid    = siteGuid;
            history.UserGuid    = LastModUserGuid;
            history.CreatedUtc  = LastModUtc;
            history.Save();

            //update the html with the approved content
            this.body            = submittedContent.ContentText;
            this.lastModUserGuid = submittedContent.LastModUserGuid;
            this.lastModUtc      = DateTime.UtcNow;
            this.Save();

            //update content workflow to show record is now approved
            submittedContent.Status          = ContentWorkflowStatus.Approved;
            submittedContent.LastModUserGuid = approvalUserGuid;
            submittedContent.LastModUtc      = DateTime.UtcNow;
            submittedContent.Save();
        }
        private static List <ContentHistory> LoadListFromReader(IDataReader reader)
        {
            List <ContentHistory> contentHistoryList = new List <ContentHistory>();

            try
            {
                while (reader.Read())
                {
                    ContentHistory contentHistory = new ContentHistory();
                    contentHistory.guid        = new Guid(reader["Guid"].ToString());
                    contentHistory.siteGuid    = new Guid(reader["SiteGuid"].ToString());
                    contentHistory.userGuid    = new Guid(reader["UserGuid"].ToString());
                    contentHistory.contentGuid = new Guid(reader["ContentGuid"].ToString());
                    contentHistory.title       = reader["Title"].ToString();
                    contentHistory.contentText = reader["ContentText"].ToString();
                    contentHistory.customData  = reader["CustomData"].ToString();
                    contentHistory.createdUtc  = Convert.ToDateTime(reader["CreatedUtc"]);
                    contentHistory.historyUtc  = Convert.ToDateTime(reader["HistoryUtc"]);
                    contentHistory.userLogin   = reader["LoginName"].ToString();
                    contentHistory.userName    = reader["Name"].ToString();
                    contentHistoryList.Add(contentHistory);
                }
            }
            finally
            {
                reader.Close();
            }

            return(contentHistoryList);
        }
        public void CreateHistory(Guid siteGuid)
        {
            if (this.itemGuid == Guid.Empty)
            {
                return;
            }

            HtmlContent currentVersion = new HtmlContent(moduleID);

            if (currentVersion.Body == this.Body)
            {
                return;
            }

            ContentHistory history = new ContentHistory();

            history.ContentGuid = currentVersion.ModuleGuid;
            history.ContentText = currentVersion.Body;
            history.SiteGuid    = siteGuid;
            history.UserGuid    = currentVersion.LastModUserGuid;
            history.CreatedUtc  = currentVersion.LastModUtc;
            history.Save();
        }
Exemple #4
0
        public void CreateHistory(Guid siteGuid)
        {
            if (this.blogGuid == Guid.Empty)
            {
                return;
            }

            Blog currentVersion = new Blog(this.itemID);

            if (currentVersion.Description == this.Description)
            {
                return;
            }

            ContentHistory history = new ContentHistory();

            history.ContentGuid = currentVersion.BlogGuid;
            history.Title       = currentVersion.Title;
            history.ContentText = currentVersion.Description;
            history.SiteGuid    = siteGuid;
            history.UserGuid    = currentVersion.LastModUserGuid;
            history.CreatedUtc  = currentVersion.LastModUtc;
            history.Save();
        }
 /// <summary>
 /// Compares 2 instances of ContentHistory.
 /// </summary>
 public static int CompareByHistoryUtc(ContentHistory contentHistory1, ContentHistory contentHistory2)
 {
     return(contentHistory1.HistoryUtc.CompareTo(contentHistory2.HistoryUtc));
 }
 /// <summary>
 /// Compares 2 instances of ContentHistory.
 /// </summary>
 public static int CompareByCreatedUtc(ContentHistory contentHistory1, ContentHistory contentHistory2)
 {
     return(contentHistory1.CreatedUtc.CompareTo(contentHistory2.CreatedUtc));
 }
 /// <summary>
 /// Compares 2 instances of ContentHistory.
 /// </summary>
 public static int CompareByCustomData(ContentHistory contentHistory1, ContentHistory contentHistory2)
 {
     return(contentHistory1.CustomData.CompareTo(contentHistory2.CustomData));
 }
 /// <summary>
 /// Compares 2 instances of ContentHistory.
 /// </summary>
 public static int CompareByContentText(ContentHistory contentHistory1, ContentHistory contentHistory2)
 {
     return(contentHistory1.ContentText.CompareTo(contentHistory2.ContentText));
 }
 /// <summary>
 /// Compares 2 instances of ContentHistory.
 /// </summary>
 public static int CompareByTitle(ContentHistory contentHistory1, ContentHistory contentHistory2)
 {
     return(contentHistory1.Title.CompareTo(contentHistory2.Title));
 }