private ReportDefn GetReport(string folder) { string prog; string name; if (_ReportName[0] == Path.DirectorySeparatorChar || _ReportName[0] == Path.AltDirectorySeparatorChar) { name = _ReportName; } else { name = folder + Path.DirectorySeparatorChar + _ReportName; } name = name + ".rdl"; // TODO: shouldn't necessarily require this extension // Load and Compile the report RDLParser rdlp; Report r; ReportDefn rdefn = null; try { prog = GetRdlSource(name); rdlp = new RDLParser(prog); rdlp.Folder = folder; r = rdlp.Parse(OwnerReport.GetObjectNumber(), OwnerReport.SourceLoader); OwnerReport.SetObjectNumber(r.ReportDefinition.GetObjectNumber()); if (r.ErrorMaxSeverity > 0) { string err; if (r.ErrorMaxSeverity > 4) { err = string.Format("Subreport {0} failed to compile with the following errors.", this._ReportName); } else { err = string.Format("Subreport {0} compiled with the following warnings.", this._ReportName); } OwnerReport.rl.LogError(r.ErrorMaxSeverity, err); OwnerReport.rl.LogError(r.rl); // log all these errors OwnerReport.rl.LogError(0, "End of Subreport errors"); } // If we've loaded the report; we should tell it where it got loaded from if (r.ErrorMaxSeverity <= 4) { rdefn = r.ReportDefinition; } } catch (Exception ex) { OwnerReport.rl.LogError(8, string.Format("Subreport {0} failed with exception. {1}", this._ReportName, ex.Message)); } return(rdefn); }
private Report GetReport(string prog, string file) { // Now parse the file RDLParser rdlp; Report r; try { rdlp = new RDLParser(prog); string folder = Path.GetDirectoryName(file); if (folder == "") { folder = Environment.CurrentDirectory; } rdlp.Folder = folder; r = rdlp.Parse(new RdlSourceLoader()); if (r.ErrorMaxSeverity > 4) { MessageBox.Show(string.Format("Report {0} has errors and cannot be processed.", "Report")); r = null; // don't return when severe errors } } catch(Exception e) { r = null; MessageBox.Show(e.Message, "Report load failed"); } return r; }
// Obtain the Pages by running the report private Report GetReport() { string prog; // Obtain the source if (_loadFailed) prog = GetReportErrorMsg(); else if (_SourceRdl != null) prog = _SourceRdl; else if (_SourceFileName != null) prog = GetRdlSource(); else prog = GetReportEmptyMsg(); // Compile the report // Now parse the file RDLParser rdlp; Report r; try { _errorMsgs = null; rdlp = new RDLParser(prog); rdlp.DataSourceReferencePassword = GetDataSourceReferencePassword; if (_SourceFileName != null) rdlp.Folder = Path.GetDirectoryName(_SourceFileName); else rdlp.Folder = this.Folder; r = rdlp.Parse(new RdlSourceLoader()); if (r.ErrorMaxSeverity > 0) { _errorMsgs = r.ErrorItems; // keep a copy of the errors int severity = r.ErrorMaxSeverity; r.ErrorReset(); if (severity > 4) { r = null; // don't return when severe errors _loadFailed=true; } } // If we've loaded the report; we should tell it where it got loaded from if (r != null && !_loadFailed) { // Don't care much if this fails; and don't want to null out report if it does try { if (_SourceFileName != null) { r.Name = Path.GetFileNameWithoutExtension(_SourceFileName); r.Folder = Path.GetDirectoryName(_SourceFileName); } else { r.Folder = this.Folder; r.Name = this.ReportName; } } catch {} } } catch (Exception ex) { _loadFailed=true; _errorMsgs = new List<string>(); // create new error list _errorMsgs.Add(ex.Message); // put the message in it _errorMsgs.Add(ex.StackTrace); // and the stack trace r = null; } if (r != null) { _PageWidth = r.PageWidthPoints; _PageHeight = r.PageHeightPoints; _ReportDescription = r.Description; _ReportAuthor = r.Author; r.SubreportDataRetrieval += new EventHandler<SubreportDataRetrievalEventArgs>(r_SubreportDataRetrieval); ParametersBuild(r); } else { _PageWidth = 0; _PageHeight = 0; _ReportDescription = null; _ReportAuthor = null; _ReportName = null; } return r; }
private ReportDefn GetReport(string folder) { string prog; string name; if (_ReportName[0] == Path.DirectorySeparatorChar || _ReportName[0] == Path.AltDirectorySeparatorChar) name = _ReportName; else name = folder + Path.DirectorySeparatorChar + _ReportName; name = name + ".rdl"; // TODO: shouldn't necessarily require this extension // Load and Compile the report RDLParser rdlp; Report r; ReportDefn rdefn=null; try { prog = GetRdlSource(name); rdlp = new RDLParser(prog); rdlp.Folder = folder; r = rdlp.Parse(OwnerReport.GetObjectNumber(), OwnerReport.SourceLoader); OwnerReport.SetObjectNumber(r.ReportDefinition.GetObjectNumber()); if (r.ErrorMaxSeverity > 0) { string err; if (r.ErrorMaxSeverity > 4) err = string.Format("Subreport {0} failed to compile with the following errors.", this._ReportName); else err = string.Format("Subreport {0} compiled with the following warnings.", this._ReportName); OwnerReport.rl.LogError(r.ErrorMaxSeverity, err); OwnerReport.rl.LogError(r.rl); // log all these errors OwnerReport.rl.LogError(0, "End of Subreport errors"); } // If we've loaded the report; we should tell it where it got loaded from if (r.ErrorMaxSeverity <= 4) { rdefn = r.ReportDefinition; } } catch (Exception ex) { OwnerReport.rl.LogError(8, string.Format("Subreport {0} failed with exception. {1}", this._ReportName, ex.Message)); } return rdefn; }