public override void Execute(CommandContext context) { if (!Verify(context)) { return; } LighthouseLog.Debug("Open chart command was triggered"); var item = context.Items[0]; var lighthouseItem = new _Lighthouse(item); if (!string.IsNullOrEmpty(lighthouseItem?.Data.RawValue)) { //Do not disclose internal server configuration to user var url = $"{HttpContext.Current.Request.Url.Scheme}://{HttpContext.Current.Request.Url.Host}/api/sitecore/lighthouse/Chart?database={item.Database}&itemId={item.ID}"; SheerResponse.ShowModalDialog(new ModalDialogOptions(url) { Response = false, MinWidth = "920", MinHeight = "220", Width = "1000" }); } else { LighthouseLog.Error($"Not enough data to display chart for {item.Paths.FullPath}"); SheerResponse.ShowError("Not enough data to display chart.", "Please, try to run report creation before trying to open it."); } }
public ActionResult Chart(string itemId, string database) { try { var item = Sitecore.Data.Database.GetDatabase(database).GetItem(itemId); var lighthouseItem = new _Lighthouse(item); var chart = new Chart { Json = lighthouseItem.Data.RawValue }; return(View("~/Views/Lighthouse/Chart.cshtml", chart)); } catch (Exception ex) { Sitecore.Diagnostics.Log.Error($"Lighthouse: was not able render chart', itemId:{itemId}, database:{database}", ex, this); return(new ContentResult() { Content = "Sorry, exception happened. Please check Sitecore logs." }); } }
public bool AddCheckPoint(Item item, Checkpoint checkpoint) { var itemTemplate = TemplateManager.GetTemplate(item); if (itemTemplate.GetBaseTemplates().Any(x => x.ID == Constants.LighthouseTemplate)) { var lighthouseItem = new _Lighthouse(item); lighthouseItem.Editing.BeginEdit(); lighthouseItem.Accessibility.RawValue = checkpoint.Accessibility.ToString(); lighthouseItem.BestPractices.RawValue = checkpoint.BestPractices.ToString(); lighthouseItem.Perfomance.RawValue = checkpoint.Performance.ToString(); lighthouseItem.SEO.RawValue = checkpoint.SEO.ToString(); lighthouseItem.Data.RawValue = AddDataCheckpoint(lighthouseItem.Data.RawValue, checkpoint); lighthouseItem.Editing.EndEdit(); } else { Sitecore.Diagnostics.Log.Error($"Lighthouse: could not save data, item is not inherited from _Lighthouse template {Constants.LighthouseTemplate}", this); } return(false); }