首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Ektron到EpiServer的内容迁移错误

从Ektron到EpiServer的内容迁移错误
EN

Stack Overflow用户
提问于 2015-11-08 04:53:56
回答 3查看 385关注 0票数 0

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

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

下面是我的代码片段:

代码语言:javascript
复制
   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
            {

            }

但是我得到了这个错误:

EN

回答 3

Stack Overflow用户

发布于 2015-11-25 03:00:17

这就是我最终要做的:由于有许多方法可以执行迁移,因此我选择了一种方法,即主要关注EpiServer API来创建新的内容、块和资产;并使用SQL语句从Ektron获取所需的所有内容。

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

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

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

代码语言:javascript
复制
select folder_id from content  where content_id = 2147485807

有了这个文件夹id,你就可以获取该特定文件夹下列出的所有页面;例如,你需要获取“文章”下的所有页面。

然后我在这个查询中使用了这个folderID:

代码语言:javascript
复制
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’)

它为我创建了一个可以在我的EpiServer代码中使用的XML。

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

代码语言:javascript
复制
[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)。

代码语言:javascript
复制
     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”类型的新页面,并添加了来自先前生成的包含Ektron’s信息的XML的内容。

票数 1
EN

Stack Overflow用户

发布于 2015-11-09 05:44:02

仅将一个dll从一个Ektron站点复制到另一个站点将不起作用。

Web服务是一个更好的想法。存在通过id获取内容的web服务调用。

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

票数 0
EN

Stack Overflow用户

发布于 2015-11-13 05:29:10

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33587665

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档