Copied to clipboard

Flag this post as spam?

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


  • lori ryan 239 posts 573 karma points
    May 01, 2020 @ 09:48
    lori ryan
    0

    Umbraco Heartcore Pulling information

    Hi

    I would like to pull content from Umbraco Heartcore into a self-hosted umbraco project.

    I have the below:

    However the code sometimes just hangs with no errors thrown, just waiting not getting a response. However, if I reset iis the content is actually there and displays. I would like to check for new notifications every 15-30 minutes.

    Would anybody please have suggestions on how I can improve the below.

      public async Task<PagedContent> GetNotificationsAsync()
        {
            var projectAlias = "xxxxxxxx";
            Guid notifications = new Guid("xxxxxxxxxxxxx");
            var contentDeliveryService = new ContentDeliveryService(projectAlias, "xxxxxxxxxxxxxxxxxxxxx");
            var response = await contentDeliveryService.Content.GetChildren(notifications, "en-GB", page: 1, pageSize: 25);
            return (response);
        }
    
    
    public List<notificationItem> GetNotificationsV2()
        {
    
                List<notificationItem> notificationsComplete = new List<notificationItem>();
    
                Task<PagedContent> response = null;
                var tNotifications = Task.Factory.StartNew(() =>
                {
                    try
                    {
                        response = GetNotificationsAsync();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("{0} Exception caught.", e);
                    }
    
                });
                tNotifications.Wait();
    
    
    
                var countItems = response.Result.TotalItems;
                if (countItems > 0)
                {
                    foreach (var item in response.Result.Content.Items)
                    {
                        var myProperties = item.Properties;
                        var pNotificationDetail = myProperties["notificationDetail"].ToString();
                        var pNotificationFor = myProperties["notificationFor"].ToString();                 
                            notificationsComplete.Add(new notificationItem()
                            {
                                Name = item.Name,
                                notificationDetail = pNotificationDetail,
                                notificationFor = pNotificationFor
                            });
    
                    }
                }
            return notificationsComplete;
        }
    
  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    May 01, 2020 @ 14:48
    Alex Skrypnyk
    0

    Hi Lori

    Can you show "GetNotificationsAsyncV2" method code?

    Thanks,

    Alex

  • lori ryan 239 posts 573 karma points
    May 01, 2020 @ 15:09
    lori ryan
    0

    Hi Alex Sorry should be GetNotificationsAsync - just calls up to my heartcore instance to get the "notifications"

    uses the Umbraco.Headless.Client.Net library

  • lori ryan 239 posts 573 karma points
    May 05, 2020 @ 07:44
    lori ryan
    0

    on the umbraco heartcore logs I see System.Data.SqlClient.SqlException (0x80131904): The connection is broken and recovery is not possible. The connection is marked by the server as unrecoverable. No attempt was made to restore the connection.

    Unsure if it's related or not.

Please Sign in or register to post replies

Write your reply to:

Draft