[NonSerialized] IDbConnection _ParseConnection; // while parsing we sometimes need to connect public DataSourceDefn(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _Name=null; _Transaction=false; _ConnectionProperties=null; _DataSourceReference=null; // Run thru the attributes foreach(XmlAttribute xAttr in xNode.Attributes) { switch (xAttr.Name) { case "Name": _Name = new Name(xAttr.Value); break; } } // Loop thru all the child nodes foreach(XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "Transaction": _Transaction = XmlUtil.Boolean(xNodeLoop.InnerText, OwnerReport.rl); break; case "ConnectionProperties": _ConnectionProperties = new ConnectionProperties(r, this, xNodeLoop); break; case "DataSourceReference": _DataSourceReference = xNodeLoop.InnerText; break; default: // don't know this element - log it OwnerReport.rl.LogError(4, "Unknown DataSource element '" + xNodeLoop.Name + "' ignored."); break; } } if (_Name == null) OwnerReport.rl.LogError(8, "DataSource Name is required but not specified."); else if (_ConnectionProperties == null && _DataSourceReference == null) OwnerReport.rl.LogError(8, string.Format("Either ConnectionProperties or DataSourceReference must be specified for DataSource {0}.", this._Name.Nm)); else if (_ConnectionProperties != null && _DataSourceReference != null) OwnerReport.rl.LogError(8, string.Format("Either ConnectionProperties or DataSourceReference must be specified for DataSource {0} but not both.", this._Name.Nm)); }
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 = Oranikle.Report.Engine.DataSourceReference.Retrieve(_DataSourceReference);//Oranikle.Report.Engine.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; }