/// <summary> /// Load da pagina /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { if (string.IsNullOrEmpty(CFG_RelatorioBO.CurrentReportID)) { RedirecionarPagina("~/Documentos/DocumentoAluno/Busca.aspx"); } else { try { ucBoletim.Visible = false; //recebe valores da sessão e grava em variáveis var rlt_id = int.Parse(CFG_RelatorioBO.CurrentReportID); string parametrosRel = CFG_RelatorioBO.CurrentReportParameters; //Recebe os dados do relatório CFG_Relatorio rpt = new CFG_Relatorio { rlt_id = rlt_id }; CFG_RelatorioBO.GetEntity(rpt); if (rpt.IsNew) { lblMessage.Text = UtilBO.GetErroMessage("Relatório não encontrado.", UtilBO.TipoMensagem.Alerta); } else { string[] param = parametrosRel.ToLower().Split('&'); var tpc_id = Convert.ToInt32(param.First(p => p.StartsWith("periodoavaliacao=")).Split('=')[1]); var alu_ids = param.First(p => p.StartsWith("alu_id=")).Split('=')[1].Split(',').Where(a => !string.IsNullOrEmpty(a)).Select(a => Convert.ToInt64(a)).ToArray(); var mtu_ids = param.First(p => p.StartsWith("mtu_id=")).Split('=')[1].Split(',').Where(a => !string.IsNullOrEmpty(a)).Select(a => Convert.ToInt32(a)).ToArray(); ucBoletim.Carregar(tpc_id, alu_ids, mtu_ids, false); ucBoletim.Visible = true; } } catch (ValidationException ex) { lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta); } catch (Exception err) { ApplicationWEB._GravaErro(err); lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar o boletim do aluno.", UtilBO.TipoMensagem.Erro); } } } } catch (Exception ex) { ApplicationWEB._GravaErro(ex); lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar o relatório.", UtilBO.TipoMensagem.Erro); } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { //recebe valores da sessão e grava em variáveis string tipoRel = CFG_RelatorioBO.CurrentReportID; string parametrosRel = CFG_RelatorioBO.CurrentReportParameters; if (!String.IsNullOrEmpty(tipoRel)) { this.QueryStringUrlReports = "tipRel=" + HttpUtility.UrlEncode(tipoRel) + "¶ms=" + HttpUtility.UrlEncode(parametrosRel); //remove os valores da sessão CFG_RelatorioBO.ClearSessionReportParameters(); //Recebe os dados do relatório CFG_Relatorio rpt = new CFG_Relatorio() { rlt_id = int.Parse(tipoRel) }; CFG_RelatorioBO.GetEntity(rpt); if (rpt.IsNew) { throw new ValidationException("Relatório não encontrado."); } //Configurações do Relatório CFG_ServidorRelatorio rptServer = CFG_ServidorRelatorioBO.CarregarServidorRelatorioPorEntidade( this.__SessionWEB.__UsuarioWEB.Usuario.ent_id , ApplicationWEB.AppMinutosCacheLongo ); if (rptServer.IsNew) { throw new ValidationException("O servidor de relatório não está configurado."); } VerificaAtributosReport(rpt.rlt_id); //Carrega os parâmetros do relatório MSReportServerParameters param = new MSReportServerParameters(parametrosRel); //Verifica se está Habilitada a impressão sem activeX bool bHabilitarImpressaoRel = ACA_ParametroAcademicoBO.ParametroValorBooleanoPorEntidade(eChaveAcademico.HABILITA_IMPRESSAO_RELATORIO , __SessionWEB.__UsuarioWEB.Usuario.ent_id); this.HabilitarImpressaoRel = bHabilitarImpressaoRel; divPdf.Visible = bHabilitarImpressaoRel; ReportViewerRel.ShowPrintButton = !bHabilitarImpressaoRel; //Verifica se usuário vizualizará algum relatório da aba 'DOCUMENTOS' if (_VS_TipoRelatorio == tipoRelatorio.Documento) { // Habilita ou desabilita, conforme configuração do parâmetro HABILITA_EXPORTACAO_IMPRESSAO_DOCUMENTOS, se vai ter botão de exportar documento no ReportView. ReportViewerRel.ShowExportControls = ACA_ParametroAcademicoBO.ParametroValorBooleanoPorEntidade(eChaveAcademico.HABILITA_EXPORTACAO_IMPRESSAO_DOCUMENTOS , __SessionWEB.__UsuarioWEB.Usuario.ent_id); } //Checa o modo de processamento do servidor if (rptServer.srr_remoteServer) { //Configura o reportviewer ReportViewerRel.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; Uri urlReport = new Uri(rptServer.srr_diretorioRelatorios); ReportViewerRel.ServerReport.ReportServerUrl = urlReport; ReportViewerRel.ServerReport.ReportServerCredentials = new MSReportServerCredentials(rptServer.srr_usuario, rptServer.srr_senha, rptServer.srr_dominio); ReportViewerRel.ServerReport.ReportPath = String.Concat(rptServer.srr_pastaRelatorios, rpt.rlt_nome); ReportViewerRel.ServerReport.SetParameters(param.getReportParameters()); //Recebe as configurações do delegate ConfigRemoteRerpotViewerEvent configRemoteRerpotViewer = Events[ConfigRemoteRerpotViewerKey] as ConfigRemoteRerpotViewerEvent; if (configRemoteRerpotViewer != null) { configRemoteRerpotViewer(ReportViewerRel); } //Carrega o relatório ReportViewerRel.ServerReport.Refresh(); } else { //Configura o reportviewer ReportViewerRel.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; ReportViewerRel.LocalReport.ReportPath = String.Concat(rptServer.srr_pastaRelatorios, rpt.rlt_nome); ReportViewerRel.LocalReport.SetParameters(param.getReportParameters()); //Recebe as configurações do delegate ConfigLocalRerpotViewerEvent configLocalRerpotViewer = Events[ConfigLocalRerpotViewerKey] as ConfigLocalRerpotViewerEvent; if (configLocalRerpotViewer != null) { configLocalRerpotViewer(ReportViewerRel); } //Carrega o relatório ReportViewerRel.LocalReport.Refresh(); } } else { string nome = _VS_TipoRelatorio == tipoRelatorio.Relatorio ? "relatório" : "documento"; _lblMensagem.Text = UtilBO.GetErroMessage("Não foi possível carregar o " + nome + ". Tipo de relatório indisponível.", UtilBO.TipoMensagem.Informacao); } } this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "reports", " var query= '" + this.QueryStringUrlReports + "';", true); } catch (ValidationException ex) { this._TrataErro(ex, ex.Message); } catch (Exception ex) { string nome = _VS_TipoRelatorio == tipoRelatorio.Relatorio ? "relatório" : "documento"; this._TrataErro(ex, "Recurso indisponível ao exibir o " + nome + "."); } }