Copied to clipboard

Flag this post as spam?

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


  • Adriano Fabri 459 posts 1602 karma points
    Jun 28, 2019 @ 06:57
    Adriano Fabri
    0

    Some problems converting my package to umbraco v8

    Hi, I'm updating my projects for Umbraco v8 but I have some problems.

    I'm trying to update this code that work perfectly in v7:

    // Check existing "falmServiceFolder" node
    var contentTypeService = Current.Services.ContentTypeService;
    var contentService = Current.Services.ContentService;
    
    var listFalmServiceFolderNodes = contentService.GetContentOfContentType(contentTypeService.GetContentType("falmServiceFolder").Id);
    if ((listFalmServiceFolderNodes.Count() == 0) || (listFalmServiceFolderNodes.First(n => n.Name == "FALM - Service Folder") == null))
    {
        // Create Service Folder node
        falmServiceFolderNode = contentService.Create("FALM - Service Folder", -1, "falmServiceFolder");
        contentService.SaveAndPublishWithStatus(falmServiceFolderNode);
        contentService.RebuildXmlStructures(falmServiceFolderNode.Id);
    
        Logger.Info<string>("FALM Housekeeping - Content Node 'FALM - Service Folder' successfully created");
    }
    else
    {
        falmServiceFolderNode = listFalmServiceFolderNodes.First(n => n.Name == "FALM - Service Folder");
    
        Logger.Info<string>("FALM Housekeeping - Content Node 'FALM - Service Folder' already exist");
    }
    

    In Umbraco v8, in the VS2019 "Error List Panel" I receive 3 diffferent errors:

    Error on GetContentOfContentType

    'IContentService' does not contain a definition for 'GetContentOfContentType' and no accessible extension method 'GetContentOfContentType' accepting a first argument of type 'IContentService' could be found (are you missing a using directive or an assembly reference?)

    Error on SaveAndPublishWithStatus

    'IContentService' does not contain a definition for 'SaveAndPublishWithStatus' and no accessible extension method 'SaveAndPublishWithStatus' accepting a first argument of type 'IContentService' could be found (are you missing a using directive or an assembly reference?)

    Error on RebuildXmlStructures

    'IContentService' does not contain a definition for 'RebuildXmlStructures' and no accessible extension method 'RebuildXmlStructures' accepting a first argument of type 'IContentService' could be found (are you missing a using directive or an assembly reference?)

    I tried to search a solution but I didn't find it.

    Can anyone help me? Thank you very much

  • Doug Moore 48 posts 103 karma points c-trib
    Feb 19, 2021 @ 14:51
    Doug Moore
    0

    No luck with this one? I would love to see FALM on v8!

  • Bo Jacobsen 597 posts 2395 karma points
    Feb 19, 2021 @ 15:13
    Bo Jacobsen
    0

    Hi.

    I think this will do it (havent testet it).

    var contentTypeService = Current.Services.ContentTypeService;
    var contentService = Current.Services.ContentService;
    
    var contentTypeIds = contentTypeService.GetAllContentTypeIds(new string[] { "falmServiceFolder" });
    var listFalmServiceFolderNodes = contentService.GetPagedOfType(contentTypeIds.First(), 0, 1, out long totalRecords, null);
    if ((listFalmServiceFolderNodes.Count() == 0) || (listFalmServiceFolderNodes.First(n => n.Name == "FALM - Service Folder") == null))
    {
        // Create Service Folder node
        falmServiceFolderNode = contentService.Create("FALM - Service Folder", -1, "falmServiceFolder");
        contentService.SaveAndPublish(falmServiceFolderNode, culture: "*", userId: -1, raiseEvents: true);
        contentService.CheckDataIntegrity(new ContentDataIntegrityReportOptions() { FixIssues = true });
    
        Logger.Info<string>("FALM Housekeeping - Content Node 'FALM - Service Folder' successfully created");
    }
    else
    {
        falmServiceFolderNode = listFalmServiceFolderNodes.First(n => n.Name == "FALM - Service Folder");
    
        Logger.Info<string>("FALM Housekeeping - Content Node 'FALM - Service Folder' already exist");
    }
    
  • Adriano Fabri 459 posts 1602 karma points
    Feb 22, 2021 @ 11:42
    Adriano Fabri
    0

    Thank you, I'll try asap ;-)

Please Sign in or register to post replies

Write your reply to:

Draft