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."); } }
protected bool Verify(CommandContext context) { var item = context.Items[0]; var itemTemplate = TemplateManager.GetTemplate(item); if (!itemTemplate.InheritsFrom(_Lighthouse.ItemTemplateId)) { LighthouseLog.Error($"Error during attempt to execute {this.Name}. Item {item.Paths.FullPath} is not inherited from _Lighthouse item"); var lighthouseTemplate = Sitecore.Data.Database.GetDatabase("master").GetItem(_Lighthouse.ItemTemplateId); SheerResponse.ShowError("Could not run this command", $"You want to run Lighthouse command on item that is not inherited from Lighthouse template. Please inherit item from _Lighthouse({lighthouseTemplate.Paths.FullPath}) template and try again."); return(false); } return(true); }