Пример #1
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);
        }