ActiveReports 9 Server
Uploading a Code-Based Section Report

You can upload all types of developer-created ActiveReports to the server using the UploadResource method. This topic explains how to upload a code-based section report.

  1. From the Visual Studio File menu, select New Project.
  2. In the New Project dialog that appears, in the list of templates under Visual C#, then Windows, select Console Application.
  3. Rename the project to UploadReport and сlick OK.
    Note: The target framework of the project must be set to .NET Framework 4.0
  4. From the Visual Studio Project menu, select Add Service Reference.
  5. In the Add Service Reference dialog that appears, enter the service URL on a server in the Adress field and rename the namespace to ReportService.
  6. In Program.cs, add the following using statements to the list of using statements at the top of the code. 
    Add to the list of using statements at the top of the code.
    Copy Code
    using System.IO;
    
    using UploadReport.ReportService;                                       
    
  7. In Program.cs, add the following code into the Main method of the Program class declaration.
    Paste the following code into the Main method of the Program class declaration
    Copy Code
        var reportAssemblyName = "ReportLib, Version=1.0.0.0"; // the name of assembly containing the section report to upload
        var reportsAssemblyPath = @"D:\temp\ReportLib.dll"; // the path to assembly containing the section report to upload
        var reportClassName = "ReportLib.SectionReport"; // the fully qualified class name of the section report to upload
        var serverUserName = "admin"; 
        var serverUserPwd = "1";
        var uploadOptions = new UploadOptions {Overwrite = true};
        var reportAssemblyContent = Convert.ToBase64String(File.ReadAllBytes(reportsAssemblyPath));
        var reportService = new ReportServiceClient("WSHttpBinding_IReportService");
        var securityToken = reportService.Login(serverUserName, serverUserPwd, null, true);
        var result = reportService.UploadResource(securityToken, new AssemblyDescription {Name = reportAssemblyName},
                                              reportAssemblyContent, uploadOptions);
        var assemblyId = (result.ItemDescriptions[0] as AssemblyDescription).Id;
        var reportDescription = new ReportDescription()
                                    {
                                        Name = "Section Report",
                                        ReportType = ReportType.CodeBasedSectionReport,
                                        ClassName = reportClassName,
                                        AssemblyResourceId = assemblyId
                                    };
                
        reportService.UploadResource(securityToken, reportDescription , Convert.ToBase64String(new byte[0]), uploadOptions);                   
    
  8. Run the project.

 

 


Copyright © 2016 GrapeCity, inc. All rights reserved

Support Forum