Example #1
0
            public Stream UpgradeToCurrent(Stream stream, ref Stream outStream)
            {
                XmlDocument xmlDocument     = this.LoadDefinition(stream);
                XmlElement  documentElement = xmlDocument.DocumentElement;

                this.ScanRdlNamespace(documentElement);
                if (this.NeedsUpgrade)
                {
                    switch (this.OldRdlNamespace)
                    {
                    case "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition":
                        this.UpdateNamespaceURI("http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition", "http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition");
                        break;

                    default:
                        throw new RDLUpgradeException(RDLUpgradeStrings.rdlInvalidTargetNamespace(this.OldRdlNamespace));

                    case "http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition":
                        break;
                    }
                }
                return(this.SaveDefinition(ref outStream));
            }
            private Stream UpgradeUnified(Stream stream, XmlReader xmlReader, string namespaceURI, bool throwUpgradeException, bool upgradeDundasCRIToNative, bool renameInvalidDataSources, out RDLUpgradeResult upgradeResults)
            {
                if (stream == null && xmlReader == null)
                {
                    throw new ArgumentNullException("Stream or XmlReader must be non-null");
                }
                if (xmlReader != null && namespaceURI == null)
                {
                    throw new ArgumentException("namespaceURI must not be null if xmlReader is specified");
                }
                if (namespaceURI == null)
                {
                    xmlReader = this.CreateXmlReader(stream);
                    xmlReader.MoveToContent();
                    namespaceURI = xmlReader.NamespaceURI;
                    xmlReader.Close();
                    xmlReader = null;
                    stream.Seek(0L, SeekOrigin.Begin);
                }
                upgradeResults = null;
                switch (namespaceURI)
                {
                case "http://schemas.microsoft.com/SQLServer/reporting/reportdefinition-1":
                case "http://schemas.microsoft.com/SQLServer/reporting/reportdefinition-2":
                case "http://schemas.microsoft.com/sqlserver/reporting/2003/04/reportdefinition":
                case "http://schemas.microsoft.com/sqlserver/reporting/2003/04/reportdefinition-1":
                case "http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition":
                    this.LoadDefinitionXml(ref xmlReader, stream, false);
                    stream = this.SaveDefinitionXml();
                    goto case "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition";

                case "http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition":
                    stream = this.UpgradeFrom200501(this.EnsureReaderSetup(xmlReader, stream), throwUpgradeException, upgradeDundasCRIToNative, renameInvalidDataSources, out upgradeResults);
                    goto case "http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition";

                case "http://schemas.microsoft.com/sqlserver/reporting/2007/01/reportdefinition":
                    this.LoadDefinitionXml(ref xmlReader, stream, true);
                    this.UpgradeFrom200701();
                    stream = this.SaveDefinitionXml();
                    goto case "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition";

                case "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition":
                    stream = this.UpgradeFrom200801(this.EnsureReaderSetup(xmlReader, stream), out upgradeResults);
                    goto case "http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition";

                case "http://schemas.microsoft.com/sqlserver/reporting/2009/01/reportdefinition":
                    this.LoadDefinitionXml(ref xmlReader, stream, true);
                    this.UpgradeFrom200901();
                    stream = this.SaveDefinitionXml();
                    goto case "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition";

                case "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition":
                    stream = this.UpgradeFrom201001(this.EnsureReaderSetup(xmlReader, stream), out upgradeResults);
                    goto case "http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition";

                case "http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition":
                    if (upgradeResults == null)
                    {
                        upgradeResults = new RDLUpgradeResult();
                    }
                    if (stream == null)
                    {
                        this.LoadDefinitionXml(ref xmlReader, stream, true);
                        stream = this.SaveDefinitionXml();
                    }
                    return(stream);

                default:
                    throw new RDLUpgradeException(RDLUpgradeStrings.rdlInvalidTargetNamespace(namespaceURI));
                }
            }