ielcoro
2/9/2015 - 10:27 AM

Reporting Services Examples

Reporting Services Examples

###Todos los ejemplos parten de añadir las siguientes referencias a los servicios de Reporting Services:

  • http:///ReportServer/ReportService2010.asmx
  • http:///ReportServer/ReportExecution2005.asmx
using (var rs = new ReportingService2010())
{
    rs.Url = reportingURL;
    rs.Credentials = new NetworkCredential(reportingUsuario, reportingPassword, reportingDominio);
    
    return rs.ListItemHistory("/ruta/informe");
}

using (var rs = new ReportingService2010())
{
    rs.Url = reportingURL;
    rs.Credentials = new NetworkCredential("usuario", "password", "reportingDominio");

    CatalogItem[] items = rs.ListChildren("ruta", true);

    return items.Where(x => x.TypeName == ItemTypeEnum.Report.ToString()).ToList();
}
using (var rs = new ReportExecutionService.ReportExecutionService())
{
  string extension = null;
  string encoding = null;
  string mimeType = null;
  string[] streamIDs = null;
  Warning[] warnings = null;
  
  rs.Url = "http://<reportserverurl>/ReportServer/ReportExecution2005.asmx";
  rs.Credentials = new NetworkCredential("usuario", "contraseña", "dominio");
  
  string historyId = null;
  ExecutionHeader execHeader = new ExecutionHeader();
  
  rs.Timeout = 300000;
  rs.ExecutionHeaderValue = execHeader;
  ExecutionInfo2 execInfo2 = rs.LoadReport2(reportPath, historyId);
  
  if ((parameters != null))
  {
      rs.SetExecutionParameters(parameters, "es_es");
  }
  
  string deviceInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
  
  return rs.Render2("PDF", deviceInfo, PageCountMode.Actual, out extension, out encoding, out mimeType, out warnings, out streamIDs);
}