private static void DoOnDemandSyncReport(HttpContext context) { var syncStatus = SynthesisHelper.CheckSyncAll(); var results = new StringBuilder(); foreach (var syncResult in syncStatus) { var configuration = syncResult.Key; var configName = configuration.Name.IsNullOrEmpty() ? "Unnamed Configuration" : configuration.Name; var result = syncResult.Value; 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(); results.AppendFormat("<h2>{0}</h2>", configName); 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("</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 static void Regenerate(object obj) { Log.Info("[AutomaticModelRebuilder] Regenerating Synthesis models due to change in template items.", typeof(AutomaticModelRebuilder)); try { SynthesisHelper.RegenerateAll(); } catch (Exception ex) { Log.Error("[AutomaticModelRebuilder] An error occurred rebuilding the model.", ex, typeof(AutomaticModelRebuilder)); } }
private static string CreateSyncSummary() { var sb = new StringBuilder(); var syncStatus = SynthesisHelper.CheckSyncAll().ToArray(); if (syncStatus.Any()) { foreach (var syncResult in syncStatus) { var configuration = syncResult.Key; var result = syncResult.Value; var configName = configuration.Name.IsNullOrEmpty() ? "Unnamed Configuration" : configuration.Name; var count = result.Count(x => !x.IsSynchronized); if (result.AreTemplatesSynchronized) { sb.AppendFormat("<p><strong>{0}</strong>: Templates and model are currently synchronized.</p>", configName); } else { sb.AppendFormat("<p><strong>{0}</strong>: {1} template{2} not synchronized. ", configName, count, count == 1 ? " is" : "s are"); sb.Append("<a href=\"?synthesis-syncstatus=1\">Details</a>"); } } sb.Append("<p>Note: if Synthesis configuration file changes are made you should force a regenerate</p>"); if (DebugUtility.IsDynamicDebugEnabled) { sb.Append("<p><a href=\"?synthesis-regenerate=1\">Regenerate Now</a></p>"); } else { sb.Append("<p>(enable debug compilation if you want to regenerate)</p>"); } } else { sb.Append(@"<p><em>Synthesis currently has no model configurations registered.</em></p> <p>This probably means you need to enable the <code>RegisterDefaultConfiguration</code> processor in the <code>initialize</code> pipeline, or that you need to register your own configurations in separate initialize pipeline processors.</p> <p>Synthesis cannot run any generation or syncing until a configuration is registered</p>."); } return(sb.ToString()); }
private static void DoOnDemandRegenerate(HttpContext context) { var timer = new Stopwatch(); timer.Start(); SynthesisHelper.RegenerateAll(); timer.Stop(); var result = $"<p>Generation complete in {timer.ElapsedMilliseconds} ms. You will want to rebuild to pick up the changes.</p>"; context.Response.Write(WrapReport("Regenerating Model", result)); context.Response.End(); }
private void DoRegenerateSync() { var syncStatus = SynthesisHelper.CheckSyncAllAndRegenerate(); foreach (var configuration in syncStatus) { var syncResult = configuration.Value; if (syncResult.AreTemplatesSynchronized) { return; } foreach (var template in syncResult) { if (!template.IsSynchronized) { Log.Warn("Synthesis template desynchronization ({0}): {1}".FormatWith(configuration.Key.Name, template), this); } } } }