Skip to content

Instantly share code, notes, and snippets.

@AndyButland
Created November 10, 2022 12:05
Show Gist options
  • Save AndyButland/d01fc45813f6217a180c7f0deaf9d6cc to your computer and use it in GitHub Desktop.
Save AndyButland/d01fc45813f6217a180c7f0deaf9d6cc to your computer and use it in GitHub Desktop.
@using Umbraco.Core.Services
@using Umbraco.Core
@using Umbraco.Core.Deploy
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@using Umbraco.Web.Models
@{
Layout = "Master.cshtml";
var scf = DependencyResolver.Current.GetService<Umbraco.Deploy.Connectors.ServiceConnectors.IServiceConnectorFactory>();
var cs = DependencyResolver.Current.GetService<IContentService>();
var cts = DependencyResolver.Current.GetService<IContentTypeService>();
var contentTypes = cts.GetAll();
var count = 0;
long totalCount = 0;
var errorMessage = string.Empty;
foreach (var ct in contentTypes)
{
var contentOfContentType = cs.GetPagedOfType(ct.Id, 0, 1000, out long totalRecords, null);
foreach (var content in contentOfContentType)
{
var udi = content.GetUdi();
var connector = scf.GetConnector(udi.EntityType);
try
{
var artifact = connector.GetArtifact(content);
}
catch (JsonReaderException ex)
{
errorMessage += $"Failed with {ex.Message} on content with ID {content.Id}.<br/>";
}
}
count += contentOfContentType.Count();
totalCount += totalRecords;
}
}
<div>Content types: @contentTypes.Count()</div>
<div>Content: @count, @totalCount</div>
<div>Error: @Html.Raw(errorMessage)</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment