Exemple #1
0
        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.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);
        }
Exemple #2
0
        void ConnectDataSourceReference(Report rpt)
        {
            if (_ConnectionProperties != null)
            {
                return;
            }

            try
            {
                string file;
                string folder = rpt == null? OwnerReport.ParseFolder: rpt.Folder;
                if (folder == null)
                {   // didn't specify folder; check to see if we have a fully formed name
                    if (!_DataSourceReference.EndsWith(".dsr", StringComparison.InvariantCultureIgnoreCase))
                    {
                        file = _DataSourceReference + ".dsr";
                    }
                    else
                    {
                        file = _DataSourceReference;
                    }
                }
                else if (_DataSourceReference[0] != Path.DirectorySeparatorChar)
                {
                    file = folder + Path.DirectorySeparatorChar + _DataSourceReference + ".dsr";
                }
                else
                {
                    file = folder + _DataSourceReference + ".dsr";
                }

                string pswd = OwnerReport.GetDataSourceReferencePassword == null?
                              null: OwnerReport.GetDataSourceReferencePassword();
                if (pswd == null)
                {
                    throw new Exception("No password provided for shared DataSource reference");
                }

                string      xml  = RDL.DataSourceReference.Retrieve(file, pswd);
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(xml);
                XmlNode xNodeLoop = xDoc.FirstChild;

                _ConnectionProperties = new ConnectionProperties(OwnerReport, this, xNodeLoop);
                _ConnectionProperties.FinalPass();
            }
            catch (Exception e)
            {
                OwnerReport.rl.LogError(4, e.Message);
                _ConnectionProperties = null;
            }
            return;
        }
Exemple #3
0
        void ConnectDataSourceReference(Report rpt)
        {
            if (_ConnectionProperties != null)
            {
                return;
            }

            try
            {
                string file;
                string folder = rpt == null? OwnerReport.ParseFolder: rpt.Folder;
                if (_DataSourceReference[0] != Path.DirectorySeparatorChar)
                {
                    file = folder + Path.DirectorySeparatorChar + _DataSourceReference + ".dsr";
                }
                else
                {
                    file = folder + _DataSourceReference + ".dsr";
                }

                string pswd = OwnerReport.GetDataSourceReferencePassword == null?
                              null: OwnerReport.GetDataSourceReferencePassword();
                if (pswd == null)
                {
                    throw new Exception("No password provided for shared DataSource reference");
                }

                string      xml  = RDL.DataSourceReference.Retrieve(file, pswd);
                XmlDocument xDoc = new XmlDocument();
                xDoc.LoadXml(xml);
                XmlNode xNodeLoop = xDoc.FirstChild;

                _ConnectionProperties = new ConnectionProperties(OwnerReport, this, xNodeLoop);
                _ConnectionProperties.FinalPass();
            }
            catch (Exception e)
            {
                OwnerReport.rl.LogError(4, e.Message);
                _ConnectionProperties = null;
            }
            return;
        }