Try our conversational search powered by Generative AI!

Import script to create pages programmatically

Vote:
 

I have to programmatically create about 1,300 pages within our CMS.  The data for the pages is in an excel spreadsheet at the moment.  My question is, what is the easiest way to get the data into the CMS?

I have seen the code samples to create a page so I think that part is easy.  What I would like is some advice on where I should create this "import app".  Can I create a simple console app or should I add a module to the CMS?  Is there some fancy built in import button that I don't know about?  How do I authenticate with the CMS if I use a console app?  Some general guidance on the best way to go about this would be helpful.

Thanks!

#63040
Nov 07, 2012 17:33
Vote:
 

The only time i've done a console app we did some magic stuff directly against the database.

Creating a admin mode plugin with a button Import and all the rest hardcoded into the plugin is the way I would have done it.

Also there's the xml page provider (I've not tried it myself) that perhaps could be an alternative.

 

http://world.episerver.com/Documentation/Items/Tech-Notes/EPiServer-CMS-6/EPiServer-CMS-60/XmlPageProvider/

http://world.episerver.com/Articles/Items/Introducing-Page-Providers/

 

#63042
Nov 07, 2012 18:00
Vote:
 

I would write it as a Scheduled Job, so it runs in the EPiServer context.

Your bigger problem is going to be determining location/parentage.  Creating all the pages at the same level is easy.  It's putting them in the correct tree structure which is hard.  Does your Excel document give you any clue of what page is a child of what other page?

#63043
Nov 07, 2012 18:01
Vote:
 

Thanks for the quick replies.  The tree structure is sort of built into the data in that the new pages will be stored alphabetically based on the "name" column/field.  There will be "container" pages for each letter of the alphabet plus one for numerical entries.  The code will then just have to figure out the apropriate container for each item based on its name.

I will take a look at both the admin plugin (I have created one of those before) and a Scheduled Job.  Although this is pretty much a one shot deal so not sure if a Scheduled Job is appropriate but maybe it is.

Thanks again for the quick replies!

John

#63044
Nov 07, 2012 18:23
Vote:
 

A scheduled job is easy to implement so it shouldn't be any trouble if you haven't created one before.

#63046
Nov 07, 2012 18:55
Vote:
 

I do one-shot Scheduled Jobs all the time.  It's the main (only?) way I import data.  You never schedule them, you just start them manually to execute.

It's no more complicated than any other code, but it runs in-process and has access to the entire EPiServer API.  It runs as part of the app itself, instead of some external process tryng to work over web services or something.

When your done with your import, delete the class file and the job goes away.

#63047
Nov 07, 2012 19:05
Vote:
 

For one time shot you might also consider to use a simple ASP.NET page without codebehind and with server side code in markup in <script runat="server" >. Advantages: single file, no need to compile just drop it in the site root and load with browser.

#63261
Nov 13, 2012 14:05
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.