public ReportsContainer RenderReports(ReportsContainer reportsContainer)
        {
            if (string.IsNullOrEmpty(reportsContainer.ReportServiceUrl) || string.IsNullOrEmpty(reportsContainer.ReportExecutionUrl))
            {
                throw new Exception("Atributos ReportServicesUrl e ReportExecutionUrl devem ser definidos");
            }

            //Instancia as classes do ReportingService
            _rsService = new ReportingService2005();
            _rsExecution = new ReportExecutionService();

            if (reportsContainer.CredentialType == CredentialType.DefaultCredential )
            {
                _rsService.Credentials = CredentialCache.DefaultCredentials;
                _rsExecution.Credentials = CredentialCache.DefaultCredentials;
            }
            else if(reportsContainer.CredentialType == CredentialType.NetworkCredential)
            {
                _rsService.Credentials = CredentialCache.DefaultNetworkCredentials;
                _rsExecution.Credentials = CredentialCache.DefaultNetworkCredentials;
            }
            else
            {
                _credential = new NetworkCredential
                                    {
                                        UserName = reportsContainer.ReportUserLogin,
                                        Password = reportsContainer.ReportUserPassword,
                                        Domain = reportsContainer.NetworkDomain
                                    };
                _rsService.Credentials = _credential;
                _rsExecution.Credentials = _credential;
            }

            //Define a URL do Servidor que vai gerar o relatório
            _rsService.Url = reportsContainer.ReportServiceUrl;
            _rsExecution.Url = reportsContainer.ReportExecutionUrl;

            if (reportsContainer.LogReports)
            {
                SaveReportsContainerInformation(reportsContainer);
                reportsContainer.Reports.ForEach(r => r.ReportsContainerGuid = reportsContainer.ReportsContainerGuid);
            }

            for (int i = 0; i < reportsContainer.Reports.Count; i++ )
            {
                Report report = reportsContainer.Reports[i];

                try
                {
                    report = RenderReportItem(reportsContainer, report);
                }
                catch (Exception ex)
                {
                    report.ReportGenerationStatus = false;
                    report.ReportErrorDescription = ex.ToString();
                    UpdateReportStatus(report);
                }
            }
             return reportsContainer;
        }
        private byte[] RenderReport(ReportsContainer reportsContainer, Report report)
        {
            byte[] reportFile = null;
            string ReportDbFilestreamPathName = string.Empty;

            if (string.IsNullOrEmpty(reportsContainer.ReportServiceUrl) || string.IsNullOrEmpty(reportsContainer.ReportExecutionUrl))
            {
                throw new Exception("Atributos ReportServicesUrl e ReportExecutionUrl devem ser definidos");
            }

            //Instancia as classes do ReportingService
            _rsService = new ReportingService2005();
            _rsExecution = new ReportExecutionService();

            if (reportsContainer.CredentialType == CredentialType.DefaultCredential)
            {
                _rsService.Credentials = CredentialCache.DefaultCredentials;
                _rsExecution.Credentials = CredentialCache.DefaultCredentials;
            }
            else if (reportsContainer.CredentialType == CredentialType.NetworkCredential)
            {
                _rsService.Credentials = CredentialCache.DefaultNetworkCredentials;
                _rsExecution.Credentials = CredentialCache.DefaultNetworkCredentials;
            }
            else
            {
                _credential = new NetworkCredential
                {
                    UserName = reportsContainer.ReportUserLogin,
                    Password = reportsContainer.ReportUserPassword,
                    Domain = reportsContainer.NetworkDomain
                };
                _rsService.Credentials = _credential;
                _rsExecution.Credentials = _credential;
            }

            //Define a URL do Servidor que vai gerar o relatório
            _rsService.Url = reportsContainer.ReportServiceUrl;
            _rsExecution.Url = reportsContainer.ReportExecutionUrl;

            _reportName = @"/" + report.ReportName;
            _historyID = null;
            _forRendering = false;

            //Carrega a session para o relatorio selecionado
            ReportExecution2005.ExecutionInfo _executionInfo = _rsExecution.LoadReport(_reportName, _historyID);

            //Prepara os parametros do relatório.
            ReportExecution2005.ParameterValue[] reportExecutionParameters = new ReportExecution2005.ParameterValue[report.Parameters.Count];

            //lista todos os parametros do objeto Report e carrega nos parametros do relatório
            int contador = 0;
            foreach (KeyValuePair<string, object> parametro in report.Parameters)
            {
                reportExecutionParameters[contador++] = new ReportExecution2005.ParameterValue
                {
                    Name = parametro.Key,
                    Value = parametro.Value.ToString()
                };
            }

            //definindo os valores dos parametros do relatório
            _rsExecution.SetExecutionParameters(reportExecutionParameters, "en-us");

            //o relatorio é armazenado como um array de bytes
            if (report.ReportFormat == ReportFormat.HTML4)
                reportFile = _rsExecution.Render("HTML4.0", _deviceInfo, out _extension, out _encoding, out _mimeType, out _warnings, out _streamIDs);
            else
                reportFile = _rsExecution.Render(report.ReportFormat.ToString(), _deviceInfo, out _extension, out _encoding, out _mimeType, out _warnings, out _streamIDs);

            return reportFile;
        }