Copied to clipboard

Flag this post as spam?

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


  • Laura 3 posts 71 karma points
    Dec 02, 2016 @ 03:06
    Laura
    0

    Calling import from code

    Hi all,

    I would need to call an import manually from code.

    The answer in this topic in unfortunately out of date as the ExecuteImport(Guid importId) method is not longer in ImportHelper class. https://our.umbraco.org/projects/developer-tools/cmsimport/using-cmsimport/28928-Calling-an-import-definition-manually-from-code

    Does anyone know if there another way to manually call an import function with the Id please?

    Thanks a lot in advance.

    Laura

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Dec 02, 2016 @ 08:18
    Richard Soeteman
    0

    Hi Laura,

    I replied to your email this morning.

    Hi Laura,

    I would not recommend calling an import from a public url. What you better can do is create a separate application for CMSImport in app.config and modify trees.config so that cmsimport can be used in the new section and you have nothing else there.

    And/or you can configure a Dashboard (see chapter 8 of the usermanual http://soetemansoftware.nl/cmsimport/downloads ) where people can only execute the imports you defined.Then people only see cmsimport but only after they logged in.

    That is what I would recommend but if you really need to you can use the following code snippet (this is an internal API so can be changed in future releases)

    Hope this answers your question for now.

    usings

    using CMSImportLibrary.Import;
    using CMSImportLibrary.Helpers;
    

    Code

    var importId = Guid.NewGuid().ToString();
    var state = Helpers.StateHelper.GetPersistedStateByWizardID(the id in the database here);
    var importOptions = new ImportOptions { UserId = scheduledTask.RunTaskAs };
    

    Best,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft