private static string CreateSyncSummary() { var sb = new StringBuilder(); // force getting the latest templates from sitecore ProviderResolver.Current.TemplateInputProvider.Refresh(); var sync = ProviderResolver.CreateSyncEngine(); var result = sync.AreTemplatesSynchronized(); var count = result.Count(x => !x.IsSynchronized); if (result.AreTemplatesSynchronized) { sb.Append("<p>Templates and model are currently synchronized.</p>"); } else { sb.AppendFormat("<p>{0} template{1} not synchronized. ", count, count == 1 ? " is" : "s are"); sb.Append("<a href=\"?synthesis-syncstatus=1\">Details</a>"); if (DebugUtility.IsDynamicDebugEnabled) { sb.Append(" | <a href=\"?synthesis-regenerate=1\">Regenerate Now</a>"); } sb.Append("</p>"); } return(sb.ToString()); }
private static void DoOnDemandSyncReport(HttpContext context) { var timer = new Stopwatch(); timer.Start(); // force getting the latest templates from sitecore ProviderResolver.Current.TemplateInputProvider.Refresh(); var sync = ProviderResolver.CreateSyncEngine(); var result = sync.AreTemplatesSynchronized(); var sco = result.Where(x => x.Locations == SyncSource.Sitecore).ToList(); var mo = result.Where(x => x.Locations == SyncSource.Model).ToList(); var ma = result.Where(x => x.Locations == SyncSource.Both).ToList(); var nonsyn = result.Where(x => !x.IsSynchronized).ToList(); timer.Stop(); var results = new StringBuilder(); results.AppendLine("<ul>"); results.AppendLine("<li>Synchronized: <strong>" + result.AreTemplatesSynchronized.ToString() + "</strong></li>"); results.AppendLine("<li>Total Items: <strong>" + result.Count + "</strong></li>"); results.AppendLine("<li>Total Not Synchronized: <strong>" + nonsyn.Count + "</strong></li>"); results.AppendLine("<li>Total Sitecore Only: <strong>" + sco.Count + "</strong></li>"); results.AppendLine("<li>Total Model Only: <strong>" + mo.Count + "</strong></li>"); results.AppendLine("<li>Total in Both: <strong>" + ma.Count + "</strong></li>"); results.AppendLine("<li>Sync time taken: <strong>" + timer.ElapsedMilliseconds + " ms</strong></li>"); results.AppendLine("</ul>"); results.AppendLine("<table cellpadding=\"3\" cellspacing=\"1\">"); results.AppendLine("<thead><tr>"); results.AppendLine("<th>Template</th><th class=\"flag\">Sitecore</th><th class=\"flag\">Model</th><th class=\"flag\">Sync</th>"); results.AppendLine("</tr></thead>"); results.AppendLine("<tbody>"); foreach (var item in result.OrderBy(x => x.SitecoreTemplateName ?? x.ModelTypeName)) { results.AppendLine("<tr>"); results.AppendFormat("<td>{0}</td>", item.SitecoreTemplateName ?? item.ModelTypeName); results.AppendFormat("<td style=\"background-color: {0}\"> </td>", (item.Locations == SyncSource.Sitecore || item.Locations == SyncSource.Both) ? "green" : "red"); results.AppendFormat("<td style=\"background-color: {0}\"> </td>", (item.Locations == SyncSource.Model || item.Locations == SyncSource.Both) ? "green" : "red"); results.AppendFormat("<td style=\"background-color: {0}\"> </td>", (item.IsSynchronized) ? "green" : "red"); results.AppendLine("</tr>"); } results.AppendLine("</tbody></table>"); context.Response.Write(WrapReport("Synthesis Template Status", results.ToString())); context.Response.End(); }
private TemplateComparisonResultCollection GetSyncResult() { var sw = new Stopwatch(); sw.Start(); TemplateComparisonResultCollection syncResult = ProviderResolver.CreateSyncEngine().AreTemplatesSynchronized(); sw.Stop(); Log.Info("Synthesis Template synchronization check completed in " + sw.ElapsedMilliseconds + " ms", this); return(syncResult); }