/// <summary> /// Gets a list of content items of the provided page type /// </summary> /// <param name="contentTypeId"></param> /// <param name="includeReferences"></param> /// <param name="includeParentDetail"></param> /// <returns></returns> public ContentTypeAudit GetPageTypeAudit(int contentTypeId) { var use = PageTypeUsagesData.Get(contentTypeId); if (use != null) { return(JsonConvert.DeserializeObject <ContentTypeAudit>(use.AuditJson)); } return(new ContentTypeAudit()); }
/// <summary> /// Called when a scheduled job executes /// </summary> /// <returns>A status message to be stored in the database log and visible from admin mode</returns> public override string Execute() { //Call OnStatusChanged to periodically notify progress of job for manually started jobs OnStatusChanged(String.Format("Investigating usage of Page Types")); //Add implementation var cmsAuditor = ServiceLocator.Current.GetInstance <ICmsAuditor>(); var pageTypes = cmsAuditor.GetContentTypesOfType <PageType>(); int usagesFound = 0; PageTypeUsagesData.CleanUp(); foreach (var pageType in pageTypes) { var audit = cmsAuditor.GenerateContentTypeAudit(pageType.ContentTypeId, false, true); var pageTypeUsage = new PageTypeUsagesData { ContentTypeId = audit.ContentTypeId, AuditJson = JsonConvert.SerializeObject(audit) }; PageTypeUsagesData.Save(pageTypeUsage); usagesFound += audit.Usages.Count(); OnStatusChanged(String.Format("Done with {0}", audit.Name)); if (_stopSignaled) { return("Job was cancelled"); } } return(string.Format("Done looking through content. Found {0} page types used {1} time(s)", pageTypes.Count(), usagesFound)); }