Partager via


Leçon 5 : Publier la définition du rapport sur le serveur de rapports

La dernière étape de la mise à jour de la définition du rapport consiste à la republier sur le serveur de rapports.

Pour publier le rapport sur le catalogue de rapports

  1. Remplacez le code de la PublishReportDefinition() méthode dans votre fichier Program.cs (Module1.vb pour Visual Basic) par le code suivant :

    private void PublishReportDefinition()  
    {  
        System.Console.WriteLine("Publishing Report Definition");  
    
        string reportPath =  
            "/AdventureWorks 2012 Sample Reports/Company Sales 2012";  
    
        XmlSerializer serializer =  
            new XmlSerializer(typeof(Report));  
    
        using (MemoryStream stream = new MemoryStream())  
        {  
            // Serialize the report into the MemoryStream  
            serializer.Serialize(stream, _report);  
            stream.Position = 0;  
    
            byte[] bytes = stream.ToArray();  
    
            // Update the report on the report server  
            Warning[] warnings =   
                _reportService.SetItemDefinition(reportPath, bytes, null);  
        }  
    }  
    
    Private Sub PublishReportDefinition()  
    
        System.Console.WriteLine("Publishing Report Definition")  
    
        Dim reportPath As String = _  
            "/AdventureWorks 2012 Sample Reports/Company Sales 2012"  
        Dim serializer As XmlSerializer = _  
            New XmlSerializer(GetType(Report))  
    
        Using stream As MemoryStream = New MemoryStream  
    
            'Serialize the report into the MemoryStream  
            serializer.Serialize(stream, m_report)  
            stream.Position = 0  
    
            'Update the report on the report server  
            Dim bytes As Byte() = stream.ToArray  
            Dim warnings As Warning() = _  
                m_reportService.SetItemDefinition(reportPath, bytes, Nothing)  
    
        End Using  
    
    End Sub  
    

Leçon suivante

Dans la leçon suivante, vous allez compiler et exécuter l’application SampleRDLSchema . Consultez Leçon 6 : Exécuter l’application de schéma RDL (VB-C#).

Voir aussi

Mise à jour des rapports à l'aide des classes générées à partir du schéma RDL (didacticiel SSRS)
Langage de définition de rapport (SSRS, Report Definition Language)