public ActionResult SWIGetDashboardResult(string guid, string itemguid, bool force) { WriteDebug("SWIGetDashboardResult"); try { checkSWIAuthentication(); if (!CheckAuthentication()) { return(Content(_loginContent)); } Report report = null; ReportExecution execution = null; Repository repository = null; var dashboard = WebUser.UserDashboards.FirstOrDefault(i => i.GUID == guid); if (dashboard == null) { throw new Exception("Error: The dashboard does not exist"); } var item = dashboard.Items.FirstOrDefault(i => i.GUID == itemguid); if (item == null) { throw new Exception("Error: The item does not exist"); } var widget = WebUser.Widgets.FirstOrDefault(i => i.GUID == item.WidgetGUID); if (widget == null) { throw new Exception("Error: the widget does not exist"); } if (!WebUser.CanSelectWidget(widget)) { throw new Exception("Error: no right to view this widget"); } /* No check on exec rights for widgets... * SWIFolder folder = getParentFolder(widget.ReportPath); * if (folder.right == 0) throw new Exception("Error: no right on this folder"); */ var filePath = Repository.ReportsFolder + widget.ReportPath; if (!System.IO.File.Exists(filePath)) { throw new Exception("Error: the report does not exist"); } var executions = DashboardExecutions; lock (executions) { //remove executions older than 2 hours executions.RemoveAll(i => i.Report.ExecutionEndDate < DateTime.Now.AddHours(-2)); execution = executions.FirstOrDefault(i => i.Report.FilePath == filePath); if (execution != null && execution.Report.LastModification != System.IO.File.GetLastWriteTime(filePath)) { executions.RemoveAll(i => i.Report.FilePath == filePath); execution = null; } } if (execution != null) { report = execution.Report; } else { repository = Repository.CreateFast(); report = Report.LoadFromFile(filePath, repository); report.ExecutionContext = ReportExecutionContext.WebReport; //Disable basics report.ExecutionView.InitParameters(false); report.ExecutionView.SetParameter(Parameter.DrillEnabledParameter, false); report.ExecutionView.SetParameter(Parameter.SubReportsEnabledParameter, false); report.ExecutionView.SetParameter(Parameter.ServerPaginationParameter, false); //Force load of all models report.ExecutionView.SetParameter(Parameter.ForceModelsLoad, true); } string content = ""; var view = report.GetWidgetViewToParse(report.Views, widget.GUID); var modelView = report.CurrentModelView; var rootAutoRefresh = 0; if (view != null) { //Init parmeters if the root view is different from the one executed... var rootView = report.GetRootView(view); if (rootView != null && rootView != report.ExecutionView) { string templateErrors = ""; rootView.InitTemplates(rootView, ref templateErrors); rootAutoRefresh = rootView.GetNumericValue("refresh_rate"); } else { rootAutoRefresh = report.ExecutionView.GetNumericValue("refresh_rate"); } if (execution != null) { if (!report.IsExecuting && (force || report.ExecutionEndDate < DateTime.Now.AddSeconds(-1 * report.WidgetCache))) { execution.Execute(); while (report.IsExecuting) { Thread.Sleep(100); } } } else { execution = new ReportExecution() { Report = report }; lock (executions) { executions.Add(execution); } execution.Execute(); while (report.IsExecuting) { Thread.Sleep(100); } } //Reset pointers and parse lock (report) { report.CurrentModelView = modelView; if (modelView.Model.Pages.Count > 0) { report.CurrentPage = modelView.Model.Pages[0]; report.CurrentPage.PageId = null; //Reset page id } content = view.Parse(); } } else { content = "<b>Invalid Widget definition</b>"; } var result = new { dashboardguid = guid, itemguid = itemguid, path = widget.Exec ? widget.ReportPath : "", lastexec = Translate("Last execution at") + " " + report.ExecutionEndDate.ToString("G", Repository.CultureInfo), description = widget.Description, dynamic = item.Dynamic, content = content, refresh = (item.Refresh == -1 ? rootAutoRefresh : item.Refresh) }; return(Json(result)); } catch (Exception ex) { return(HandleSWIException(ex)); } }