Esempio n. 1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   GetTopHtmlText gets the most recent HtmlTextInfo object for the Module, Workflow, and State
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name = "moduleId">The ID of the Module</param>
        /// <param name = "isPublished">Whether the content has been published or not</param>
        /// <param name="workflowId">The Workflow ID</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        public HtmlTextInfo GetTopHtmlText(int moduleId, bool isPublished, int workflowId)
        {
            var htmlText = CBO.FillObject <HtmlTextInfo>(DataProvider.Instance().GetTopHtmlText(moduleId, isPublished));

            if (htmlText != null)
            {
                // check if workflow has changed
                if (isPublished == false && htmlText.WorkflowID != workflowId)
                {
                    // get proper state for workflow
                    htmlText.WorkflowID   = workflowId;
                    htmlText.WorkflowName = "[REPAIR_WORKFLOW]";

                    var workflowStateController = new WorkflowStateController();
                    htmlText.StateID = htmlText.IsPublished
                                        ? workflowStateController.GetLastWorkflowStateID(workflowId)
                                        : workflowStateController.GetFirstWorkflowStateID(workflowId);
                    // update object
                    UpdateHtmlText(htmlText, GetMaximumVersionHistory(htmlText.PortalID));

                    // get object again
                    htmlText = CBO.FillObject <HtmlTextInfo>(DataProvider.Instance().GetTopHtmlText(moduleId, false));
                }
            }
            return(htmlText);
        }
Esempio n. 2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   GetTopHtmlText gets the most recent HtmlTextInfo object for the Module, Workflow, and State
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name = "ModuleID">The ID of the Module</param>
        /// <param name = "IsPublished">Whether the content has been published or not</param>
        /// <param name="WorkflowID">The Workflow ID</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        public HtmlTextInfo GetTopHtmlText(int ModuleID, bool IsPublished, int WorkflowID)
        {
            var objHtmlText = (HtmlTextInfo)(CBO.FillObject(DataProvider.Instance().GetTopHtmlText(ModuleID, IsPublished), typeof(HtmlTextInfo)));

            if (objHtmlText != null)
            {
                // check if workflow has changed
                if (IsPublished == false && objHtmlText.WorkflowID != WorkflowID)
                {
                    // get proper state for workflow
                    var objWorkflow = new WorkflowStateController();
                    objHtmlText.WorkflowID   = WorkflowID;
                    objHtmlText.WorkflowName = "[REPAIR_WORKFLOW]";
                    if (objHtmlText.IsPublished)
                    {
                        objHtmlText.StateID = objWorkflow.GetLastWorkflowStateID(WorkflowID);
                    }
                    else
                    {
                        objHtmlText.StateID = objWorkflow.GetFirstWorkflowStateID(WorkflowID);
                    }
                    // update object
                    UpdateHtmlText(objHtmlText, GetMaximumVersionHistory(objHtmlText.PortalID));
                    // get object again
                    objHtmlText = (HtmlTextInfo)(CBO.FillObject(DataProvider.Instance().GetTopHtmlText(ModuleID, IsPublished), typeof(HtmlTextInfo)));
                }
            }
            return(objHtmlText);
        }
Esempio n. 3
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   UpdateHtmlText creates a new HtmlTextInfo object or updates an existing HtmlTextInfo object
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name = "htmlContent">An HtmlTextInfo object</param>
        /// <param name = "MaximumVersionHistory">The maximum number of versions to retain</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        public void UpdateHtmlText(HtmlTextInfo htmlContent, int MaximumVersionHistory)
        {
            var _workflowStateController = new WorkflowStateController();
            bool blnCreateNewVersion = false;

            // determine if we are creating a new version of content or updating an existing version
            if (htmlContent.ItemID != -1)
            {
                if (htmlContent.WorkflowName != "[REPAIR_WORKFLOW]")
                {
                    HtmlTextInfo objContent = GetTopHtmlText(htmlContent.ModuleID, false, htmlContent.WorkflowID);
                    if (objContent != null)
                    {
                        if (objContent.StateID == _workflowStateController.GetLastWorkflowStateID(htmlContent.WorkflowID))
                        {
                            blnCreateNewVersion = true;
                        }
                    }
                }
            }
            else
            {
                blnCreateNewVersion = true;
            }

            // determine if content is published
            if (htmlContent.StateID == _workflowStateController.GetLastWorkflowStateID(htmlContent.WorkflowID))
            {
                htmlContent.IsPublished = true;
            }
            else
            {
                htmlContent.IsPublished = false;
            }

            if (blnCreateNewVersion)
            {
                // add content
                htmlContent.ItemID = DataProvider.Instance().AddHtmlText(htmlContent.ModuleID,
                                                                         htmlContent.Content,
																		 htmlContent.Summary,
                                                                         htmlContent.StateID,
                                                                         htmlContent.IsPublished,
                                                                         UserController.GetCurrentUserInfo().UserID,
                                                                         MaximumVersionHistory);
            }
            else
            {
                // update content
				DataProvider.Instance().UpdateHtmlText(htmlContent.ItemID, htmlContent.Content, htmlContent.Summary, htmlContent.StateID, htmlContent.IsPublished, UserController.GetCurrentUserInfo().UserID);
            }

            // add log history
            var logInfo = new HtmlTextLogInfo();
            logInfo.ItemID = htmlContent.ItemID;
            logInfo.StateID = htmlContent.StateID;
            logInfo.Approved = htmlContent.Approved;
            logInfo.Comment = htmlContent.Comment;
            var objLogs = new HtmlTextLogController();
            objLogs.AddHtmlTextLog(logInfo);

            // create user notifications
            CreateUserNotifications(htmlContent);

            // refresh output cache
            ModuleController.SynchronizeModule(htmlContent.ModuleID);
        }
Esempio n. 4
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 ///   GetTopHtmlText gets the most recent HtmlTextInfo object for the Module, Workflow, and State
 /// </summary>
 /// <remarks>
 /// </remarks>
 /// <param name = "ModuleID">The ID of the Module</param>
 /// <param name = "IsPublished">Whether the content has been published or not</param>
 /// <param name="WorkflowID">The Workflow ID</param>
 /// <history>
 /// </history>
 /// -----------------------------------------------------------------------------
 public HtmlTextInfo GetTopHtmlText(int ModuleID, bool IsPublished, int WorkflowID)
 {
     var objHtmlText = (HtmlTextInfo) (CBO.FillObject(DataProvider.Instance().GetTopHtmlText(ModuleID, IsPublished), typeof (HtmlTextInfo)));
     if (objHtmlText != null)
     {
         // check if workflow has changed
         if (IsPublished == false && objHtmlText.WorkflowID != WorkflowID)
         {
             // get proper state for workflow
             var objWorkflow = new WorkflowStateController();
             objHtmlText.WorkflowID = WorkflowID;
             objHtmlText.WorkflowName = "[REPAIR_WORKFLOW]";
             if (objHtmlText.IsPublished)
             {
                 objHtmlText.StateID = objWorkflow.GetLastWorkflowStateID(WorkflowID);
             }
             else
             {
                 objHtmlText.StateID = objWorkflow.GetFirstWorkflowStateID(WorkflowID);
             }
             // update object
             UpdateHtmlText(objHtmlText, GetMaximumVersionHistory(objHtmlText.PortalID));
             // get object again
             objHtmlText = (HtmlTextInfo) (CBO.FillObject(DataProvider.Instance().GetTopHtmlText(ModuleID, IsPublished), typeof (HtmlTextInfo)));
         }
     }
     return objHtmlText;
 }
Esempio n. 5
0
        protected void OnSaveClick(object sender, EventArgs e)
        {
            const bool redirect = true;

            try
            {
                // get content
                var htmlContent = GetLatestHTMLContent();

                var aliases = from PortalAliasInfo pa in PortalAliasController.Instance.GetPortalAliasesByPortalId(PortalSettings.PortalId)
                              select pa.HTTPAlias;
                string content;
                if (phEdit.Visible)
                {
                    content = txtContent.Text;
                }
                else
                {
                    content = hfEditor.Value;
                }


                if (Request.QueryString["nuru"] == null)
                {
                    content = HtmlUtils.AbsoluteToRelativeUrls(content, aliases);
                }
                htmlContent.Content = content;

                var draftStateID     = _workflowStateController.GetFirstWorkflowStateID(WorkflowID);
                var publishedStateID = _workflowStateController.GetLastWorkflowStateID(WorkflowID);

                switch (CurrentWorkflowType)
                {
                case WorkflowType.DirectPublish:
                    _htmlTextController.UpdateHtmlText(htmlContent, _htmlTextController.GetMaximumVersionHistory(PortalId));

                    break;

                case WorkflowType.ContentStaging:
                    if (chkPublish.Checked)
                    {
                        //if it's already published set it to draft
                        if (htmlContent.StateID == publishedStateID)
                        {
                            htmlContent.StateID = draftStateID;
                        }
                        else
                        {
                            htmlContent.StateID = publishedStateID;
                            //here it's in published mode
                        }
                    }
                    else
                    {
                        //if it's already published set it back to draft
                        if ((htmlContent.StateID != draftStateID))
                        {
                            htmlContent.StateID = draftStateID;
                        }
                    }

                    _htmlTextController.UpdateHtmlText(htmlContent, _htmlTextController.GetMaximumVersionHistory(PortalId));
                    break;
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
                UI.Skins.Skin.AddModuleMessage(Page, "Error occurred: ", exc.Message, ModuleMessage.ModuleMessageType.RedError);
                return;
            }

            // redirect back to portal
            if (redirect)
            {
                Response.Redirect(Globals.NavigateURL(), true);
            }
        }
Esempio n. 6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   UpdateHtmlText creates a new HtmlTextInfo object or updates an existing HtmlTextInfo object
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name = "htmlContent">An HtmlTextInfo object</param>
        /// <param name = "MaximumVersionHistory">The maximum number of versions to retain</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        public void UpdateHtmlText(HtmlTextInfo htmlContent, int MaximumVersionHistory)
        {
            var  _workflowStateController = new WorkflowStateController();
            bool blnCreateNewVersion      = false;

            // determine if we are creating a new version of content or updating an existing version
            if (htmlContent.ItemID != -1)
            {
                if (htmlContent.WorkflowName != "[REPAIR_WORKFLOW]")
                {
                    HtmlTextInfo objContent = GetTopHtmlText(htmlContent.ModuleID, false, htmlContent.WorkflowID);
                    if (objContent != null)
                    {
                        if (objContent.StateID == _workflowStateController.GetLastWorkflowStateID(htmlContent.WorkflowID))
                        {
                            blnCreateNewVersion = true;
                        }
                    }
                }
            }
            else
            {
                blnCreateNewVersion = true;
            }

            // determine if content is published
            if (htmlContent.StateID == _workflowStateController.GetLastWorkflowStateID(htmlContent.WorkflowID))
            {
                htmlContent.IsPublished = true;
            }
            else
            {
                htmlContent.IsPublished = false;
            }

            if (blnCreateNewVersion)
            {
                // add content
                htmlContent.ItemID = DataProvider.Instance().AddHtmlText(htmlContent.ModuleID,
                                                                         htmlContent.Content,
                                                                         htmlContent.Summary,
                                                                         htmlContent.StateID,
                                                                         htmlContent.IsPublished,
                                                                         UserController.Instance.GetCurrentUserInfo().UserID,
                                                                         MaximumVersionHistory);
            }
            else
            {
                // update content
                DataProvider.Instance().UpdateHtmlText(htmlContent.ItemID, htmlContent.Content, htmlContent.Summary, htmlContent.StateID, htmlContent.IsPublished, UserController.Instance.GetCurrentUserInfo().UserID);
            }

            // add log history
            var logInfo = new HtmlTextLogInfo();

            logInfo.ItemID   = htmlContent.ItemID;
            logInfo.StateID  = htmlContent.StateID;
            logInfo.Approved = htmlContent.Approved;
            logInfo.Comment  = htmlContent.Comment;
            var objLogs = new HtmlTextLogController();

            objLogs.AddHtmlTextLog(logInfo);

            // create user notifications
            CreateUserNotifications(htmlContent);

            // refresh output cache
            ModuleController.SynchronizeModule(htmlContent.ModuleID);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   GetTopHtmlText gets the most recent HtmlTextInfo object for the Module, Workflow, and State
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name = "moduleId">The ID of the Module</param>
        /// <param name = "isPublished">Whether the content has been published or not</param>
        /// <param name="workflowId">The Workflow ID</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        public HtmlTextInfo GetTopHtmlText(int moduleId, bool isPublished, int workflowId)
        {
            var htmlText = CBO.FillObject<HtmlTextInfo>(DataProvider.Instance().GetTopHtmlText(moduleId, isPublished));
            if (htmlText != null)
            {
                // check if workflow has changed
                if (isPublished == false && htmlText.WorkflowID != workflowId)
                {
                    // get proper state for workflow
                    htmlText.WorkflowID = workflowId;
                    htmlText.WorkflowName = "[REPAIR_WORKFLOW]";

                    var workflowStateController = new WorkflowStateController();
                    htmlText.StateID = htmlText.IsPublished 
                                        ? workflowStateController.GetLastWorkflowStateID(workflowId) 
                                        : workflowStateController.GetFirstWorkflowStateID(workflowId);
                    // update object
                    UpdateHtmlText(htmlText, GetMaximumVersionHistory(htmlText.PortalID));

                    // get object again
                    htmlText = CBO.FillObject<HtmlTextInfo>(DataProvider.Instance().GetTopHtmlText(moduleId, false));
                }
            }
            return htmlText;
        }