A client of mine needed help with converting a site from Escenic to EPiServer. I knew absolutely nothing about Escenic, but after some research on the Internet, I found out that Escenic can export articles and related information using XML files.
I asked the client to export a selection of articles with related files, and from that I was able to create an importer for the XML files. And once I had that, it was a relatively easy task to create pages in EPiServer and fill the properties with information from the article fields in Escenics export files.
It was decided that all pages should be created in EPiserver grouped after what type they were in Escenic. An article of type ”standard” will be created under a page with the name ”standard”, etc. After migration was completed, the editors would then move the pages to their final destination, after checking that the imported pages looked OK.
The migrator reads all information from the XML files, and then does some LINQ magic to connect the articles with their sections, references, relations, and authors. References are references to media files, such as images or documents. Relations contain information about related pages, such as links to other pages with related information. Sections are kind of like parent pages in EPiServer, it controls in what sections an article is shown (an article can belong to several sections). And finally, Author contains information about the author(s) of the article.
After reading the XML files, the migrator loops through all the imported articles, and based on the article type, a corresponding EPiServer page type is created using PageTypeResolver.GetDefaultPageData(). Before returning the new (unsaved) page, certain common information (such as PageName, StartPublish, and the page creation date) is set.
The next step in the migration process is to convert the fields of the article to EPiServer property values. The ”standard” article type had a lot of sequentially named BODY fields (BODY1, BODY2, etc), with images sometimes added between the fields (the reference tag holds information about which field it belongs to). The methods Article.ConstructHtmlForStandardSection() and Article.FormatPart() are responsible for assembling these fields, and then saving them to MainBody of the page. Article.FormatPart() is also responsible for saving the attached media files to the Unified File System.
After setting a couple of more properties on the EPiServer page, the page is finally saved to the database, and the process continues with the next article, until everything is migrated.
I’m not going to post any code in this post, but I am attaching a .7z file with a bunch of code you can use. There are some extensions methods and helper classes which are a bit useful, they are also included in the project.
I am using EPiServer CMS 6 R2, but it should be easy to modify the code for earlier or later versions. The project is using .Net Framework 4 and Visual Studio 2012.
BTW, if you just want to browse the information, the Parse button just reads the XML files from Escenic and displays their contents in a structured way on the page. If you click on the ”Fields” link on the rendered page, all fields will be shown.
And, as usual, I can not be held responsible for any bugs in the code, or damage caused by running it. You should adapt it to your own needs and test it thoroughly before running it on a production environment!! 🙂
If you find it useful or have any tips for changes, please let me know! Constructive feedback is always welcome.
I’ve created a repo on github with the code: https://github.com/PaddySe/EscenicMigrator