/// <summary> /// Returns report graph. /// </summary> private void GetReportGraph(ReportGraphInfo reportGraph) { Visible = true; ucChart.Visible = true; int correctWidth = 0; if (ComputedWidth != 0) { correctWidth = ModifyGraphInfo(); } if (Width != String.Empty) { int graphWidth = ValidationHelper.GetInteger(Width, 0); if (graphWidth != 0) { reportGraph.GraphWidth = graphWidth; } } if (Height != 0) { reportGraph.GraphHeight = Height; } ReportGraph graph = new ReportGraph(); graph.ChartControl = ucChart; ReportInfo report = ReportInfoProvider.GetReportInfo(reportGraph.GraphReportID); if (report == null) { return; } // Check graph security settings if (report.ReportAccess != ReportAccessEnum.All) { if (!CMSContext.CurrentUser.IsAuthenticated()) { Visible = false; return; } } // Set default parametrs directly if not set if (ReportParameters == null) { // Load ReportInfo if (report != null) { FormInfo fi = new FormInfo(report.ReportParameters); // Get datarow with required columns ReportParameters = fi.GetDataRow(); fi.LoadDefaultValues(ReportParameters, true); } } // If used via widget - this function ensure showing specific interval from actual time (f.e. last 6 weeks) ApplyTimeParameters(); // Only use base parameters in case of stored procedure if (QueryIsStoredProcedure) { AllParameters = SpecialFunctions.ConvertDataRowToParams(ReportParameters, null); } ContextResolver resolver = CMSContext.CurrentResolver.CreateContextChild(); // Indicaates whether exception was throw during data loading bool errorOccurred = false; // Create graph image try { // Resolve parameters in query resolver.SourceParameters = AllParameters.ToArray(); // Resolve dynamic data macros if (DynamicMacros != null) { for (int i = 0; i <= DynamicMacros.GetUpperBound(0); i++) { resolver.AddDynamicParameter(DynamicMacros[i, 0], DynamicMacros[i, 1]); } } // Prepare query attributes QueryText = resolver.ResolveMacros(reportGraph.GraphQuery); QueryIsStoredProcedure = reportGraph.GraphQueryIsStoredProcedure; // LoadData DataSet dsGraphData = LoadData(); // Test if dataset is empty if (DataHelper.DataSourceIsEmpty(dsGraphData)) { string noRecordText = ValidationHelper.GetString(reportGraph.GraphSettings["QueryNoRecordText"], String.Empty); if (noRecordText != String.Empty) { lblInfo.Text = noRecordText; lblInfo.Visible = true; ucChart.Visible = false; menuCont.MenuID = String.Empty; return; } Visible = false; } else { // Create Chart graph.CorrectWidth = correctWidth; graph.CreateChart(reportGraph, dsGraphData, resolver); } } catch (Exception ex) { EventLogProvider ev = new EventLogProvider(); ev.LogEvent("Get report graph", "E", ex); graph.CorrectWidth = correctWidth; graph.CreateInvalidDataGraph(reportGraph, "Reporting.Graph.InvalidDataGraph", false); errorOccurred = true; } // Export data if ((report != null) && (!errorOccurred)) { ProcessExport(ValidationHelper.GetCodeName(report.ReportDisplayName)); } }
/// <summary> /// Returns report graph. /// </summary> private void GetReportGraph(ReportGraphInfo reportGraph) { // Check whether report graph is defined if (reportGraph == null) { return; } report = ReportInfoProvider.GetReportInfo(reportGraph.GraphReportID); //check graph security settings if (report.ReportAccess != ReportAccessEnum.All) { if (!CMSContext.CurrentUser.IsAuthenticated()) { Visible = false; return; } } EnableSubscription = (EnableSubscription && ValidationHelper.GetBoolean(ReportGraphInfo.GraphSettings["SubscriptionEnabled"], true) && report.ReportEnableSubscription); if (EmailMode && !EnableSubscription) { this.Visible = false; return; } //Set default parametrs directly if not set if (ReportParameters == null) { //Load ReportInfo if (report != null) { FormInfo fi = new FormInfo(report.ReportParameters); // Get datarow with required columns ReportParameters = fi.GetDataRow(false); fi.LoadDefaultValues(ReportParameters, true); } } // Only use base parameters in case of stored procedure if (QueryIsStoredProcedure) { AllParameters = SpecialFunctions.ConvertDataRowToParams(ReportParameters, null); } // Indicaates whether exception was throw during data loading errorOccurred = false; // Create graph data try { ContextResolver resolver = CMSContext.CurrentResolver.CreateContextChild(); //Resolve parameters in query resolver.SourceParameters = AllParameters.ToArray(); // Resolve dynamic data macros if (DynamicMacros != null) { for (int i = 0; i <= DynamicMacros.GetUpperBound(0); i++) { resolver.AddDynamicParameter(DynamicMacros[i, 0], DynamicMacros[i, 1]); } } //Prepare query attributes QueryText = resolver.ResolveMacros(reportGraph.GraphQuery); QueryIsStoredProcedure = reportGraph.GraphQueryIsStoredProcedure; // Load data DataSource = LoadData(); if (DataHelper.DataSourceIsEmpty(DataSource) && EmailMode && SendOnlyNonEmptyDataSource) { Visible = false; return; } } catch (Exception ex) { EventLogProvider ev = new EventLogProvider(); ev.LogEvent("Get report graph", "E", ex); lblError.Text = ex.Message; lblError.Visible = true; errorOccurred = true; } }
/// <summary> /// Returns report graph. /// </summary> private void GetReportGraph(ReportGraphInfo reportGraph) { Visible = true; ucChart.Visible = true; int correctWidth = 0; if (ComputedWidth != 0) { correctWidth = ModifyGraphInfo(); } if (Width != String.Empty) { int graphWidth = ValidationHelper.GetInteger(Width, 0); if (graphWidth != 0) { reportGraph.GraphWidth = graphWidth; } } if (Height != 0) { reportGraph.GraphHeight = Height; } ReportGraph graph = new ReportGraph(); graph.ChartControl = ucChart; report = ReportInfoProvider.GetReportInfo(reportGraph.GraphReportID); if (report == null) { return; } // Check graph security settings if (report.ReportAccess != ReportAccessEnum.All) { if (!CMSContext.CurrentUser.IsAuthenticated()) { Visible = false; return; } } // Set default parametrs directly if not set if (ReportParameters == null) { // Load ReportInfo if (report != null) { FormInfo fi = new FormInfo(report.ReportParameters); // Get datarow with required columns ReportParameters = fi.GetDataRow(false); fi.LoadDefaultValues(ReportParameters, true); } } // If used via widget - this function ensure showing specific interval from actual time (f.e. last 6 weeks) ApplyTimeParameters(); // Only use base parameters in case of stored procedure if (QueryIsStoredProcedure) { AllParameters = SpecialFunctions.ConvertDataRowToParams(ReportParameters, null); } ContextResolver resolver = CMSContext.CurrentResolver.CreateContextChild(); errorOccurred = false; // Create graph image try { // Resolve parameters in query resolver.SourceParameters = AllParameters.ToArray(); // Resolve dynamic data macros if (DynamicMacros != null) { for (int i = 0; i <= DynamicMacros.GetUpperBound(0); i++) { resolver.AddDynamicParameter(DynamicMacros[i, 0], DynamicMacros[i, 1]); } } // Prepare query attributes QueryText = resolver.ResolveMacros(reportGraph.GraphQuery); QueryIsStoredProcedure = reportGraph.GraphQueryIsStoredProcedure; // LoadData DataSet dsGraphData = LoadData(); // Empty dataset, and flag not send empty dataset is set if (SendOnlyNonEmptyDataSource && EmailMode && DataHelper.DataSourceIsEmpty(dsGraphData)) { Visible = false; return; } // Test if dataset is empty if (DataHelper.DataSourceIsEmpty(dsGraphData)) { string noRecordText = CMSContext.ResolveMacros(ValidationHelper.GetString(reportGraph.GraphSettings["QueryNoRecordText"], String.Empty)); if (noRecordText != String.Empty) { ltlEmail.Text = noRecordText; lblInfo.Text = noRecordText; ucChart.Visible = false; menuCont.MenuID = String.Empty; EnableExport = false; plcInfo.Visible = true; } else { Visible = false; } } else { // Create Chart graph.CorrectWidth = correctWidth; if (EmailMode) { byte[] data = graph.CreateChart(reportGraph, dsGraphData, resolver, true); ltlEmail.Text = "##InlineImage##" + reportGraph.GraphName + "##InlineImage##"; ReportSubscriptionSender.AddToRequest(report.ReportName, "g" + reportGraph.GraphName, data); } else { graph.CreateChart(reportGraph, dsGraphData, resolver); } } // Check if subscription is allowed EnableSubscription = (EnableSubscription && ValidationHelper.GetBoolean(ReportGraphInfo.GraphSettings["SubscriptionEnabled"], true) && report.ReportEnableSubscription); if (EmailMode && !EnableSubscription) { this.Visible = false; return; } } catch (Exception ex) { EventLogProvider ev = new EventLogProvider(); ev.LogEvent("Get report graph", "E", ex); graph.CorrectWidth = correctWidth; graph.CreateInvalidDataGraph(reportGraph, "Reporting.Graph.InvalidDataGraph", false); errorOccurred = true; } }