bool _Transaction; // Indicates the data sets that use this data

        #endregion Fields

        #region Constructors

        internal 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(Strings.DataSourceDefn_Error_NoPasswordForDSR);

				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()
		{
			if (_ConnectionProperties != null)
				return;

			try
			{
				string file;
				if (_DataSourceReference[0] != Path.DirectorySeparatorChar)
					file = OwnerReport.Folder + Path.DirectorySeparatorChar + _DataSourceReference + ".dsr";
				else
					file = OwnerReport.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);
			}
			catch (Exception e)
			{
				OwnerReport.rl.LogError(4, e.Message);
				_ConnectionProperties = null;
			}
			return;
		}