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();
        }
Beispiel #2
0
        public static ContentWorkflow CreateDraftVersion(
            Guid siteGuid,
            string contentText,
            string customData,
            int customReferenceNumber,
            Guid customReferenceGuid,
            Guid moduleGuid,
            Guid userGuid)
        {
            ContentWorkflow draftVersion = new ContentWorkflow();

            draftVersion.moduleGuid            = moduleGuid;
            draftVersion.contentText           = contentText;
            draftVersion.customData            = customData;
            draftVersion.customReferenceNumber = customReferenceNumber;
            draftVersion.customReferenceGuid   = customReferenceGuid;
            draftVersion.siteGuid        = siteGuid;
            draftVersion.userGuid        = userGuid;
            draftVersion.lastModUserGuid = userGuid;
            draftVersion.createdDateUtc  = DateTime.UtcNow;
            draftVersion.status          = ContentWorkflowStatus.Draft;
            draftVersion.Save();

            return(draftVersion);
        }
Beispiel #3
0
        public static ContentWorkflow GetWorkInProgress(Guid moduleGuid, string status)
        {
            using (IDataReader reader = DBContentWorkflow.GetWorkInProgress(moduleGuid, status))
            {
                ContentWorkflow wip = new ContentWorkflow();

                if (wip.PopulateFromReader(reader))
                {
                    return(wip);
                }
                else
                {
                    return(null);
                }
            }
        }
Beispiel #4
0
        //public bool IsValid
        //{
        //    get { return (GetRuleViolations().Count() == 0); }
        //}

        #endregion

        private static List <ContentWorkflow> LoadListFromReader(IDataReader reader)
        {
            List <ContentWorkflow> contentWorkflowList = new List <ContentWorkflow>();

            try
            {
                while (reader.Read())
                {
                    ContentWorkflow contentWorkflow = new ContentWorkflow();

                    contentWorkflow.guid        = new Guid(reader["Guid"].ToString());
                    contentWorkflow.siteGuid    = new Guid(reader["SiteGuid"].ToString());
                    contentWorkflow.userGuid    = new Guid(reader["UserGuid"].ToString());
                    contentWorkflow.moduleGuid  = new Guid(reader["ModuleGuid"].ToString());
                    contentWorkflow.contentText = reader["ContentText"].ToString();
                    contentWorkflow.customData  = reader["CustomData"].ToString();

                    object val = reader["CustomReferenceNumber"];
                    contentWorkflow.customReferenceNumber = val == DBNull.Value ? -1 : Convert.ToInt32(val);

                    val = reader["CustomReferenceGuid"];
                    contentWorkflow.customReferenceGuid = val == DBNull.Value ? Guid.Empty : new Guid(val.ToString());

                    contentWorkflow.createdDateUtc = Convert.ToDateTime(reader["CreatedDateUtc"]);

                    //val = reader["LastModUserGuid"];
                    //contentWorkflow.lastModUserGuid = val == DBNull.Value ? null : (Guid?)new Guid(val.ToString());
                    contentWorkflow.lastModUserGuid = new Guid(reader["LastModUserGuid"].ToString());

                    //val = reader["LastModUtc"];
                    //contentWorkflow.lastModUtc = val == DBNull.Value ? null : (DateTime?)DateTime.Parse(val.ToString());

                    contentWorkflow.lastModUtc = Convert.ToDateTime(reader["LastModUtc"]);

                    contentWorkflow.createdByUserLogin = reader["CreatedByUserLogin"].ToString();
                    contentWorkflow.createdByUserName  = reader["CreatedByUserName"].ToString();

                    contentWorkflow.recentActionByUserLogin = reader["RecentActionByUserLogin"].ToString();
                    contentWorkflow.recentActionByUserName  = reader["RecentActionByUserName"].ToString();
                    contentWorkflow.recentActionByUserEmail = reader["RecentActionByUserEmail"].ToString();

                    string statusVal = reader["Status"].ToString();
                    contentWorkflow.status = String.IsNullOrEmpty(statusVal)
                        ? ContentWorkflowStatus.None
                        : (ContentWorkflowStatus)Enum.Parse(typeof(ContentWorkflowStatus), statusVal);

                    contentWorkflow.originalStatus = contentWorkflow.status;

                    contentWorkflow.notes = reader["Notes"].ToString();

                    //val = reader["RecentActionOn"];
                    //contentWorkflow.recentActionOn = val == null ? null : (DateTime?)DateTime.Parse(val.ToString());
                    if (reader["RecentActionOn"] != DBNull.Value)
                    {
                        contentWorkflow.recentActionOn = Convert.ToDateTime(reader["RecentActionOn"]);
                    }

                    contentWorkflow.moduleTitle = reader["ModuleTitle"].ToString();
                    contentWorkflow.moduleId    = Convert.ToInt32(reader["ModuleID"]);

                    contentWorkflowList.Add(contentWorkflow);
                }
            }
            finally
            {
                reader.Close();
            }

            return(contentWorkflowList);
        }
        public bool ContainsModuleInProgress()
        {
            int count = ContentWorkflow.GetWorkInProgressCountByPage(this.pageGuid);

            return(count > 0);
        }