프로젝트를 만들고 RDL 스키마에서 클래스를 생성한 후에는 보고서 서버에서 보고서 정의를 로드할 준비가 된 것입니다.
보고서 정의를 로드하려면
Report클래스의ReportUpdater맨 위에 프라이빗 필드를 추가합니다. (Visual Basic을 사용하는 경우 모듈을 사용합니다.) 이 필드는 애플리케이션의 수명 동안 보고서 서버에서 로드되는 보고서에 대한 참조를 유지하는 데 사용됩니다.private Report _report;Private m_report As ReportLoadReportDefinition()Program.cs 파일(Visual Basic용 Module1.vb)의 메서드 코드를 다음 코드로 바꿉니다.private void LoadReportDefinition() { System.Console.WriteLine("Loading Report Definition"); string reportPath = "/AdventureWorks 2012 Sample Reports/Company Sales 2012"; // Retrieve the report definition // from the report server byte[] bytes = _reportService.GetItemDefinition(reportPath); if (bytes != null) { XmlSerializer serializer = new XmlSerializer(typeof(Report)); // Load the report bytes into a memory stream using (MemoryStream stream = new MemoryStream(bytes)) { // Deserialize the report stream to an // instance of the Report class _report = (Report)serializer.Deserialize(stream); } } }Private Sub LoadReportDefinition() System.Console.WriteLine("Loading Report Definition") Dim reportPath As String = _ "/AdventureWorks 2012 Sample Reports/Company Sales 2012" 'Retrieve the report definition 'from the report server Dim bytes As Byte() = _ m_reportService.GetItemDefinition(reportPath) If Not (bytes Is Nothing) Then Dim serializer As XmlSerializer = _ New XmlSerializer(GetType(Report)) 'Load the report bytes into a memory stream Using stream As MemoryStream = New MemoryStream(bytes) 'Deserialize the report stream to an 'instance of the Report class m_report = CType(serializer.Deserialize(stream), _ Report) End Using End If End Sub
다음 단원:
다음 단원에서는 보고서 서버에서 로드된 보고서 정의를 업데이트하는 코드를 작성합니다. 4단원: 프로그래밍 방식으로 보고서 정의를 업데이트합니다.