Copied to clipboard

Flag this post as spam?

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


  • Mike 10 posts 72 karma points
    Mar 04, 2015 @ 22:41
    Mike
    0

    Automate Import

    I have two environments A and B. I'm trying to write a script that is triggered by our continious integration servers that will uSync all content from B into A.

    So far my script copys everything in B's uSync\content folder to A's uSync\content folder but I have to manually log into A and click "import" in uSync to have it import all the content.

     

    Is there a way I could automate this? Even if there is a url I could have my script send a request to that would work.

  • Kevin Jump 1673 posts 10586 karma points MVP 3x c-trib
    Mar 04, 2015 @ 23:32
    Kevin Jump
    0

    Hi,

    there isn't a built in remote command, but you could write an api controller that calls ImportDiskContent on the ContentImporter Class, then uSync would kick off a fill import of what is on the disk, then you could just call the URL of the APIController and that would be able to start the import ? 

    probibly along the lines of (and i am typing this here, so this is just psudo code).

    public SomeApiContoller : UmbracoAPIController 
    {
      public bool DoUsyncImport()
      {
        var usync = new jumoo.usync.content.ContentImporter();
        uSync.ImportDiskContent(); 
      }
    }
    

    then 

    http://site/umbraco/api/SomeApi/DoUsyncImport - would kick pff the import (i think)

  • Kevin Jump 1673 posts 10586 karma points MVP 3x c-trib
    Mar 04, 2015 @ 23:39
    Kevin Jump
    100

    HI just realised it's slightly more involved, you also need to import media, and then map id's - it's actually the code in the ui class that is behind the import button. (here https://github.com/KevinJump/jumoo.usync/blob/master/jumoo.usync.usyncui/uSyncTab.ascx.cs)

    but that just means it's three calls in the controller.

    ContentImporter ci = new ContentImporter(); 
    int contentCount = ci.ImportDiskContent();
    
    MediaImporter mi = new MediaImporter();
    int mediaCount = mi.ImportMedia();
    
    // we map ids at the end..
    ci.MapContentIds();
    
  • keilo 560 posts 1015 karma points
    Nov 08, 2015 @ 17:00
    keilo
    0

    I have to say this is brilliant! being able to sync two environments on demand with three calls...

Please Sign in or register to post replies

Write your reply to:

Draft