【问题标题】:Content migration error from Ektron to EpiServer从 Ektron 到 EpiServer 的内容迁移错误
【发布时间】:2015-11-07 20:53:56
【问题描述】:

我正在做一个内容迁移项目,从Ektron 9EpiServer 8,第一个任务是迁移特定页面的内容,为了实现这一点,我正在遵循Ektron's API指导Ektron Developer API

1- 我正在以正确的方式处理此迁移?现在我刚刚在我的应用程序中添加了 Ektron Dll 作为参考。我尝试使用他们的网络服务,但它没有我需要的数据(特定页面的内容)。Ektron Web Services

这是我的代码的 sn-p:

   GetAllTemplatesRequest cc = new GetAllTemplatesRequest();
            //var UserCRUD = new Ektron.Cms.Framework.User.UserManager();
            var UserCRUD = new UserManager();
            string Token = UserCRUD.Authenticate("admin", "password");
            if (!string.IsNullOrEmpty(Token)) // Success
            {
             try
            {
                //Create the Content Object set to observe permissions
                Ektron.Cms.Framework.Content.ContentManager ContentAPI
                  = new      Ektron.Cms.Framework.Content.ContentManager(ApiAccessMode.Admin);
                //Retrieve the content
                Ektron.Cms.ContentData contentData;
                contentData = ContentAPI.GetItem(30);
                //Output the retrieved item's content
                var cs = contentData.Html;
            }
            catch (Exception _e)
            {
                throw _e;
            }
            }
            else // Fail
            {

            }

但我收到此错误:

【问题讨论】:

    标签: episerver ektron


    【解决方案1】:

    这就是我最终做的: 由于迁移的方式很多,我选择了以EpiServer API 为主的方式来创建新的内容、区块和资产;并使用SQL 语句从Ektron 获取我需要的所有内容。

    Ektron 将所有内容保存在名为 content 的表中。

    页面以“文件夹结构”的方式组织,所以每个页面都在一个“文件夹”中

    要获取特定页面的文件夹 ID,您可以使用以下查询:

    select folder_id from content  where content_id = 2147485807
    

    使用该文件夹 ID,您可以获得该特定文件夹下列出的所有页面;例如,您需要获取“文章”下的所有页面。

    然后我在此查询中使用了该文件夹 ID:

    SELECT [content_id]
    ,[content_title]
    ,[content_html]
    ,[date_created]
    ,folder_id
    ,[content_teaser]
    ,[content_text]
    ,[end_date]
    ,[content_type]
    ,[template_id]
    , content_status
    FROM content
    where folder_id=(select folder_id from content  where content_id = 2147485807)
    order by content_title
    FOR XML PATH(‘Article’), ROOT (‘Articles’)
    

    它为我创建了一个 XML,准备在我的 EpiServer 代码中使用。

    我在 EPI 服务器中做的第一件事是在 SitePageBase 模型中添加一个新属性,以添加一个“LegacyContentID”作为映射条目,以防我需要访问/修改新创建页面的内容。它充当从 Ektron 导入的数据和我在 EPI 服务器上创建的新数据之间的链接。

    [Display(
    Name = “Legacy Content ID”,
    Description = “Content ID from Ektron imported data , for migration purposes”,
    GroupName = GroupNames.PageSettings,
    Order = 37)]
    [ScaffoldColumn(false)]
    [Editable(false)]
    public virtual string LegacyContentID { get; set; }
    

    然后我创建了一个创建文章页面的方法,它唯一需要的参数是IP服务器的parentID(你可以在EpiServer中创建一个新页面,然后在该页面的属性下你可以得到页面ID)。

         public void CreateArticlesPages(int parentID)
    {
    
    IContentRepository contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
    
    var parentlink = new ContentReference(parentID);
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(File.ReadAllText(@”Articles.xml”));
    string jsonText = JsonConvert.SerializeXmlNode(doc);
    dynamic data = JsonConvert.DeserializeObject(jsonText);
    
    for (int i = 0; i < data.Articles.Article.Count; i++)
    {
    var PageImportedObject = data.Articles.Article[i];
    ArticlePage page = contentRepository.GetDefault<ArticlePage>(parentlink);
    
    page = contentRepository.GetDefault<ArticlePage>(parentlink);
    page.LegacyContentID = PageImportedObject.content_id;
    page.Name = PageImportedObject.content_title;
    page.PageTitle = PageImportedObject.content_title;
    
    if (PageImportedObject.content_teaser == null)
    page.Summary = “No Summary from the Ektron DB”;
    else
    page.Summary = PageImportedObject.content_teaser;
    page.Description = PageImportedObject.content_html.root.Description;
    
    contentRepository.Save(page, EPiServer.DataAccess.SaveAction.Save, EPiServer.Security.AccessLevel.NoAccess);
    contentRepository.Save(page, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);
    
    }
    }
    

    上面的代码创建了一个“ArticlePage”类型的新页面,并从之前生成的XML 中添加内容,并持有Ektron’s 信息。

    【讨论】:

      【解决方案2】:

      仅仅将一个 dll 从 Ektron 站点复制到另一个站点是行不通的。

      Web 服务理念更好。有通过 id 获取内容的 Web 服务调用。

      或者,您可以编写自己的 Web 服务,在 ektron 站点内运行并使用 Ektron API 公开您想要的数据。然后从另一个站点调用该服务。

      【讨论】:

        【解决方案3】:

        您需要查看内容迁移入门工具包。 https://github.com/egandalf/ContentTransferStarterKit

        【讨论】:

        • 感谢分享,其实我已经开始了自己的迁移过程,并将创建一个关于它的博客,但该项目看起来正在推广,我会检查它甚至贡献
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-12-27
        • 2021-09-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多