Added a new dashboard to rebuild xml structures for content, members, media. I haven't put it in the release dashboard config for now. Also added methods to the examine controller to check the index integrity which we can use for th 7.3 task.

This commit is contained in:
Shannon
2014-10-23 18:52:11 +10:00
parent 44a39e7ca6
commit b4be203b2a
12 changed files with 252 additions and 27 deletions

View File

@@ -0,0 +1,82 @@
using System;
using System.Web.Http;
using Umbraco.Core;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Web.WebApi;
namespace Umbraco.Web.WebServices
{
public class XmlDataIntegrityController : UmbracoAuthorizedApiController
{
[HttpPost]
public bool FixContentXmlTable()
{
Services.ContentService.RebuildXmlStructures();
return CheckContentXmlTable();
}
[HttpPost]
public bool FixMediaXmlTable()
{
Services.MediaService.RebuildXmlStructures();
return CheckMediaXmlTable();
}
[HttpPost]
public bool FixMembersXmlTable()
{
Services.MemberService.RebuildXmlStructures();
return CheckMembersXmlTable();
}
[HttpGet]
public bool CheckContentXmlTable()
{
var totalPublished = Services.ContentService.CountPublished();
var subQuery = new Sql()
.Select("Count(DISTINCT cmsContentXml.nodeId)")
.From<ContentXmlDto>()
.InnerJoin<DocumentDto>()
.On<DocumentDto, ContentXmlDto>(left => left.NodeId, right => right.NodeId);
var totalXml = ApplicationContext.DatabaseContext.Database.ExecuteScalar<int>(subQuery);
return totalXml == totalPublished;
}
[HttpGet]
public bool CheckMediaXmlTable()
{
var total = Services.MediaService.Count();
var mediaObjectType = Guid.Parse(Constants.ObjectTypes.Media);
var subQuery = new Sql()
.Select("Count(*)")
.From<ContentXmlDto>()
.InnerJoin<NodeDto>()
.On<ContentXmlDto, NodeDto>(left => left.NodeId, right => right.NodeId)
.Where<NodeDto>(dto => dto.NodeObjectType == mediaObjectType);
var totalXml = ApplicationContext.DatabaseContext.Database.ExecuteScalar<int>(subQuery);
return totalXml == total;
}
[HttpGet]
public bool CheckMembersXmlTable()
{
var total = Services.MemberService.Count();
var memberObjectType = Guid.Parse(Constants.ObjectTypes.Member);
var subQuery = new Sql()
.Select("Count(*)")
.From<ContentXmlDto>()
.InnerJoin<NodeDto>()
.On<ContentXmlDto, NodeDto>(left => left.NodeId, right => right.NodeId)
.Where<NodeDto>(dto => dto.NodeObjectType == memberObjectType);
var totalXml = ApplicationContext.DatabaseContext.Database.ExecuteScalar<int>(subQuery);
return totalXml == total;
}
}
}