Copied to clipboard

Flag this post as spam?

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


  • MuirisOG 382 posts 1284 karma points
    May 22, 2015 @ 14:59
    MuirisOG
    1

    ContentService 'move' vs Set new parent ID and 'save'

    I'm looking for more info on how the ContentService works, in particular, Move, Save, SaveAndPublishWithStatus.

    I'd also be grateful for information on the purpose of umbraco.library.RefreshContent() and umbraco.library.UpdatedocumentCache(doc.Id), and whether they should be used within my loop below (which process about 5000 records), or outside.

    I've imported our existing site into Umbraco and have looped through all the new pages in order to recreate the structure of the old site.

    However, I found that using 'move' was taking a lot longer than assigning a new parent ID and saving.

    Can anyone shed any light on why, or maybe if I'm missing an important step?

    (I'm on v7.2.5 / SQL Server Express / Windows Server 2012)

    Here's the code snippet that works :

        For Each doc As IContent In d
          //'...some code to get various page id's
    
          //'set the new parent id
          doc.ParentId = newParentId
    
          //'Save and publish
          cs.Save(doc, 0, False)
    
        Next
    
        //' Tell the published XML content that the document has been moved.
        umbraco.library.RefreshContent()
    

    And here's the code that takes forever, and eventually fails (including dragging the backoffice to a crawl)

    For Each doc As IContent In d
      //'...some code to get various page id's
    
      //'set the new parent id
      cs.Move(doc, newParentId)
    
      //'Save and publish
      cs.SaveAndPublishWithStatus(doc)
    
    Next
    //' Tell the published XML content that the document has been moved.
    umbraco.library.RefreshContent()
    
  • MuirisOG 382 posts 1284 karma points
    Jun 01, 2015 @ 12:06
    MuirisOG
    0

    ...or any working examples would be appreciated (Note that I'm coding in VB)

Please Sign in or register to post replies

Write your reply to:

Draft