Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nic Wise 51 posts 85 karma points
    Mar 27, 2010 @ 16:25
    Nic Wise
    0

    Command line tools?

    Hi there

    Long time listener, first time caller.

    Anyone know if it's possible to write commandline tools which use the Umbraco api (current version - 4.0?). We want to import (once) a load of data, as well as export content, doctypes and other stuff so we can version it in subversion.

    Anyone done this, or better yet, tried and failed? Any examples (happy to publish our tools once written)?

    Thanks

    N

  • Nic Wise 51 posts 85 karma points
    Mar 27, 2010 @ 17:28
    Nic Wise
    0

    To expand, I'd like to do (on the command line, and hence can be scheduled)

    • Export document type
    • Create a document (page?) (ok, not scheduled, but we have around 400 articles, all in marked up XML, to import _once_) and save it (not publish, tho I doubt it matters)
    • Export a document (page) to an XML file (ie, back up all our content in XML - versioned - not in SQL databases (not at all versioned)
    • possibly reverse the previous one, tho really, thats just what #2 is with a different XML format :)
    Thats most of it. But to start, this would do:
    List<DocumentType> docs = DocumentType.GetAllAsList();
                foreach (var doc in docs)
                {
                    Console.WriteLine(doc.Id);
                }
                Console.WriteLine("done");

  • Jamie Howarth 306 posts 773 karma points c-trib
    Mar 27, 2010 @ 17:48
    Jamie Howarth
    0

    Hi Nic,

    For exporting doctypes you may want to look at the packages section of the API, as this allows the automatic packaging of doctypes which are then portable as ZIP files for you to then install automatically (again, using the packaging part of the API).

    For some pseudo-logic:

    • Export doctypes, import to new installation;
    • Create documents based on XML-stored data and your new doctypes, and save;
    • Export newly-created document to XML for versioning in source control.
    1 and 2 are simple, 3 can be done using a post-publish hook in Umbraco that you can then use to call a Subversion commit action on the umbraco.config file, which then means it's automatically stored in Subversion for you.
    Hope this helps.
    Best,
    Benjamin

  • Nic Wise 51 posts 85 karma points
    Mar 27, 2010 @ 17:55
    Nic Wise
    0

    Thanks Benjamin

    are 1 and 2 simple in an app which is not part of Umbraco? ie external? while I could embed it in, it MUST be able to run as a scheduled job.

    BTW, these are all seperate tasks / apps. 1 and 3 might be the same app (run once a day), and 2 is a once-off app, run once it's all tested etc. After the content is in, it'll most likely never be used again.

    I guess the other option is to put it into the umbraco interface, and somehow hit a URL every so often...... but then I also have to login..... 

    Thanks for the help.

  • Nic Wise 51 posts 85 karma points
    Mar 27, 2010 @ 18:43
    Nic Wise
    0

    Bother, after an afternoon of playing around, it appears to need a full ASP.NET stack running to work, so I guess commandline tools are out

    Oh, well. Thanks for the help.

Please Sign in or register to post replies

Write your reply to:

Draft