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;
}
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.
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.
Hi Lori
Can you show "GetNotificationsAsyncV2" method code?
Thanks,
Alex
Hi Alex Sorry should be GetNotificationsAsync - just calls up to my heartcore instance to get the "notifications"
uses the Umbraco.Headless.Client.Net library
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.
is working on a reply...