public void DeleteHtmlText(HtmlTextInfo htmlText)
        {
            Requires.NotNull("htmlText", htmlText);
            Requires.PropertyNotNegative("htmlText", "ItemId", htmlText.ItemId);

            repository.Delete(htmlText);
        }
        public void UpdateHtmlText(HtmlTextInfo htmlText, bool blnCreateNewVersion, int maximumVersionHistory)
        {
            Requires.NotNull("htmlText", htmlText);
            //Requires.PropertyNotNegative("htmlText", "ItemId", htmlText.ItemId);
            Requires.PropertyNotNegative("htmlText", "ModuleId", htmlText.ModuleId);

            //flag create new version if ItemId is not valid
            if (htmlText.ItemId == -1)
            {
                blnCreateNewVersion = true;
            }

            if (blnCreateNewVersion)
            {
                //add new version content
                htmlText.CreatedByUserID      = UserController.Instance.GetCurrentUserInfo().UserID;
                htmlText.CreatedOnDate        = DateTime.Now;
                htmlText.LastModifiedByUserId = UserController.Instance.GetCurrentUserInfo().UserID;
                htmlText.LastModifiedOnDate   = DateTime.Now;
                repository.Add(htmlText, maximumVersionHistory);
            }
            else
            {
                //update existing content
                htmlText.LastModifiedByUserId = UserController.Instance.GetCurrentUserInfo().UserID;
                htmlText.LastModifiedOnDate   = DateTime.Now;
                repository.Update(htmlText);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface
        /// </summary>
        /// <param name="moduleId">The Id of the module to be imported</param>
        /// <param name="content">The content to be imported</param>
        /// <param name="version">The version of the module to be imported</param>
        /// <param name="userId">The Id of the user performing the import</param>
        /// -----------------------------------------------------------------------------
        public void ImportModule(int moduleId, string content, string version, int userId)
        {
            ModuleInfo module     = ModuleController.Instance.GetModule(moduleId, Null.NullInteger, true);
            var        controller = new HtmlTextController();
            XmlNode    item       = DotNetNuke.Common.Globals.GetContent(content, "htmlText");

            if (item == null)
            {
                return;
            }

            var newItem = new HtmlTextInfo()
            {
                ModuleId             = moduleId,
                Locale               = System.Threading.Thread.CurrentThread.CurrentCulture.Name,
                ModuleTitle          = item.SelectSingleNode("ModuleTitle").InnerText,
                Content              = item.SelectSingleNode("Content").InnerText,
                Summary              = item.SelectSingleNode("Summary").InnerText,
                Version              = -1,
                IsPublished          = true,
                CreatedByUserID      = userId,
                CreatedOnDate        = DateTime.Now,
                LastModifiedByUserId = userId,
                LastModifiedOnDate   = DateTime.Now
            };

            // NOTE: If moving from one installation to another, this user will not exist
            controller.UpdateHtmlText(newItem, true, controller.GetMaximumVersionHistory(module.PortalID));
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ExportModule implements the IPortable ExportModule Interface
        /// </summary>
        /// <param name="moduleId">The Id of the module to be exported</param>
        /// -----------------------------------------------------------------------------
        public string ExportModule(int moduleId)
        {
            var          controller = new HtmlTextController();
            HtmlTextInfo item       = controller.GetTopHtmlText(moduleId, System.Threading.Thread.CurrentThread.CurrentCulture.Name, true);
            var          sb         = new StringBuilder();

            if (item == null)
            {
                return(string.Empty);
            }

            sb.Append("<htmlText>");
            //sb.AppendFormat("<ItemId>{0}</ItemId>", item.ItemId);
            //sb.AppendFormat("<ModuleId>{0}</ModuleId>", item.ModuleId);
            //sb.AppendFormat("<Locale>{0}</Locale>", item.Locale);
            sb.AppendFormat("<ModuleTitle>{0}</ModuleTitle>", XmlUtils.XMLEncode(item.ModuleTitle));
            sb.AppendFormat("<Content>{0}</Content>", XmlUtils.XMLEncode(item.Content));
            sb.AppendFormat("<Summary>{0}</Summary>", XmlUtils.XMLEncode(item.Summary));
            //sb.AppendFormat("<Version>{0}</Version>", item.Version);
            //sb.AppendFormat("<IsPublished>{0}</IsPublished>", item.IsPublished);
            //sb.AppendFormat("<CreatedByUserID>{0}</CreatedByUserID>", item.CreatedByUserID);
            //sb.AppendFormat("<CreatedOnDate>{0}</CreatedOnDate>", item.CreatedOnDate);
            //sb.AppendFormat("<LastModifiedByUserId>{0}</LastModifiedByUserId>", item.LastModifiedByUserId);
            //sb.AppendFormat("<LastModifiedOnDate>{0}</LastModifiedOnDate>", item.LastModifiedOnDate);
            sb.Append("</htmlText>");

            return(sb.ToString());
        }
示例#5
0
        public void Delete(HtmlTextInfo htmlText)
        {
            Requires.NotNull("htmlText", htmlText);
            Requires.PropertyNotNegative("htmlText", "ItemId", htmlText.ItemId);

            using (IDataContext db = DataContext.Instance())
            {
                var rep = db.GetRepository <HtmlTextInfo>();
                rep.Delete(htmlText);
            }
        }
示例#6
0
        public int Add(HtmlTextInfo htmlText, int MaximumVersionHistory)
        {
            Requires.NotNull("htmlText", htmlText);
            Requires.PropertyNotNegative("htmlText", "ModuleId", htmlText.ModuleId);
            Requires.PropertyNotNullOrEmpty("htmlText", "Locale", htmlText.Locale);

            //set version
            var topVersion = GetAll(htmlText.ModuleId, htmlText.Locale).OrderByDescending(x => x.Version).FirstOrDefault();

            htmlText.Version = topVersion != null ? topVersion.Version + 1 : 1;

            //proceed
            using (IDataContext db = DataContext.Instance())
            {
                try
                {
                    db.BeginTransaction();

                    var rep = db.GetRepository <HtmlTextInfo>();

                    //insert
                    rep.Insert(htmlText);

                    //purge version history
                    rep.Delete("WHERE ModuleID = @0 AND Locale = @1 AND Version <= (@2 - @3)",
                               htmlText.ModuleId, htmlText.Locale, htmlText.Version, MaximumVersionHistory);

                    db.Commit();
                }
                catch (Exception)
                {
                    db.RollbackTransaction();
                    throw;
                }
            }

            return(htmlText.ItemId);
        }