Copy DNN HTML Pro module in content to another module

蓝咒 提交于 2019-12-25 08:49:38

问题


Below code is working fine for HTML module but not working for HTML PRO module.

HtmlTextController htmlTextController = new HtmlTextController();
WorkflowStateController workflowStateController = new WorkflowStateController();
int workflowId = htmlTextController.GetWorkflow(ModuleId, TabId, PortalId).Value;

List<HtmlTextInfo> htmlContents = htmlTextController.GetAllHtmlText(ModuleModId);
htmlContents = htmlContents.OrderBy(c => c.Version).ToList();

foreach (var content in htmlContents)
{
    HtmlTextInfo htmlContent = new HtmlTextInfo();
    htmlContent.ItemID = -1;
    htmlContent.StateID = workflowStateController.GetFirstWorkflowStateID(workflowId);
    htmlContent.WorkflowID = workflowId;
    htmlContent.ModuleID = ModuleId;
    htmlContent.IsPublished = content.IsPublished;
    htmlContent.Approved = content.Approved;
    htmlContent.IsActive = content.IsActive;
    htmlContent.Content = content.Content;
    htmlContent.Summary = content.Summary;
    htmlContent.Version = content.Version;
}
htmlTextController.UpdateHtmlText(htmlContent, htmlTextController.GetMaximumVersionHistory(PortalId));

回答1:


This is occurred due to HTML Pro module has different methods. That is partially different from DNN HTML Module. below is the code.

            HtmlTextController htmlTextController = new HtmlTextController();
            WorkflowStateController workflowStateController = new WorkflowStateController();
            WorkflowStateInfo wsinfo = new WorkflowStateInfo();

            int workflowId = wsinfo.WorkflowID;

            HtmlTextInfo htmlContents = htmlTextController.GetLatestHTMLContent(ModuleModId);

                HtmlTextInfo htmlContent = new HtmlTextInfo();
                htmlContent.ItemID = -1;
                htmlContent.StateID = workflowStateController.GetFirstWorkflowStateID(workflowId);
                htmlContent.WorkflowID = workflowId;
                htmlContent.ModuleID = ModuleId;
                htmlContent.IsPublished = htmlContents.IsPublished;
                htmlContent.Approved = htmlContents.Approved;
                htmlContent.IsActive = htmlContents.IsActive;
                htmlContent.Content = htmlContents.Content;
                htmlContent.Summary = htmlContents.Summary;
                htmlContent.Version = htmlContents.Version;

                if (Tags != null && Tags.Count > 0)
                {
                    foreach (KeyValuePair<string, string> tag in Tags)
                    {
                        if (htmlContent.Content.Contains(tag.Key))
                        {
                            htmlContent.Content = htmlContent.Content.Replace(tag.Key, tag.Value);
                        }
                    }
                }

                htmlTextController.SaveHtmlContent(htmlContent, newModule);

And please add below reference to the code to refer the methods.

using DotNetNuke.Modules.HtmlPro;
using DotNetNuke.Professional.HtmlPro;
using DotNetNuke.Professional.HtmlPro.Components;
using DotNetNuke.Professional.HtmlPro.Services;



回答2:


If you are looking to simply "copy" the content from one to the other, you might investigate the usage of the "Import" and "Export" functions that are part of these modules.

I recommend using this route to help you ensure better compatibility as time progresses. Should they update fields or other data elements you will not have to investigate and then update your code as part of this.

You can simply look at the .dnn manifest for each of these modules and find the BusinessControllerClass which will have two methods "ImportModule" and "ExportModule" that you could use.



来源:https://stackoverflow.com/questions/39835302/copy-dnn-html-pro-module-in-content-to-another-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!