protected void btnReporte_Click(object sender, EventArgs e) { if (DDLFiltroEstado.SelectedValue == "0") { String vError = String.Empty; try { ReportExecutionService.ReportExecutionService vRSE = new ReportExecutionService.ReportExecutionService(); vRSE.Credentials = new NetworkCredential("report_user", "kEbn2HUzd$Fs2T", "adbancat.hn"); vRSE.Url = "http://10.128.0.52/reportserver/reportexecution2005.asmx"; vRSE.ExecutionHeaderValue = new ReportExecutionService.ExecutionHeader(); var vEInfo = new ReportExecutionService.ExecutionInfo(); vEInfo = vRSE.LoadReport("/STEI/reporteMantenimientoCorGlobal", null); //String vIDEstado = DDLFiltroEstado.SelectedValue; List <ReportExecutionService.ParameterValue> vParametros = new List <ReportExecutionService.ParameterValue>(); //vParametros.Add(new ReportExecutionService.ParameterValue { Name = "ID", Value = vIDEstado }); vRSE.SetExecutionParameters(vParametros.ToArray(), "en-US"); String deviceinfo = "<DeviceInfo><Toolbar>false</Toolbar></DeviceInfo>"; String mime; String encoding; string[] stream; ReportExecutionService.Warning[] warning; byte[] vResultado = vRSE.Render("EXCEL", deviceinfo, out mime, out encoding, out encoding, out warning, out stream); //byte[] vResultado = vRSE.Render("pdf", deviceinfo, out mime, out encoding, out encoding, out warning, out stream); //File.WriteAllBytes("c:\\files\\test.pdf", vResultado); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.AppendHeader("Content-Type", "application/vnd.ms-excel"); //Response.AppendHeader("Content-Type", "application/pdf"); byte[] bytFile = vResultado; Response.OutputStream.Write(bytFile, 0, bytFile.Length); Response.AddHeader("Content-disposition", "attachment;filename=EstadoMantenimientoCorGlobal.xls"); //Response.AddHeader("Content-disposition", "attachment;filename=DescargaPDFArea.pdf"); Response.End(); } catch (Exception Ex) { vError = Ex.Message; } DDLFiltroEstado.SelectedValue = "0"; } else { String vError = String.Empty; try { ReportExecutionService.ReportExecutionService vRSE = new ReportExecutionService.ReportExecutionService(); vRSE.Credentials = new NetworkCredential("report_user", "kEbn2HUzd$Fs2T", "adbancat.hn"); vRSE.Url = "http://10.128.0.52/reportserver/reportexecution2005.asmx"; vRSE.ExecutionHeaderValue = new ReportExecutionService.ExecutionHeader(); var vEInfo = new ReportExecutionService.ExecutionInfo(); vEInfo = vRSE.LoadReport("/STEI/reporteMantenimientoCorrectivo", null); String vIDEstado = DDLFiltroEstado.SelectedValue; List <ReportExecutionService.ParameterValue> vParametros = new List <ReportExecutionService.ParameterValue>(); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "ID", Value = vIDEstado }); vRSE.SetExecutionParameters(vParametros.ToArray(), "en-US"); String deviceinfo = "<DeviceInfo><Toolbar>false</Toolbar></DeviceInfo>"; String mime; String encoding; string[] stream; ReportExecutionService.Warning[] warning; byte[] vResultado = vRSE.Render("EXCEL", deviceinfo, out mime, out encoding, out encoding, out warning, out stream); //byte[] vResultado = vRSE.Render("pdf", deviceinfo, out mime, out encoding, out encoding, out warning, out stream); //File.WriteAllBytes("c:\\files\\test.pdf", vResultado); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.AppendHeader("Content-Type", "application/vnd.ms-excel"); //Response.AppendHeader("Content-Type", "application/pdf"); byte[] bytFile = vResultado; Response.OutputStream.Write(bytFile, 0, bytFile.Length); Response.AddHeader("Content-disposition", "attachment;filename=EstadoMantenimientoCor" + DDLFiltroEstado.SelectedItem.Text + ".xls"); //Response.AddHeader("Content-disposition", "attachment;filename=DescargaPDFArea.pdf"); Response.End(); } catch (Exception Ex) { vError = Ex.Message; } DDLFiltroEstado.SelectedValue = "0"; } }
protected void BtnConfirmar_Click(object sender, EventArgs e) { try{ if (DDLReporte.SelectedValue.Equals("1")) { DataTable vDatos = (DataTable)Session["DOCUMENTO_REPORTE"]; string Parametro1 = vDatos.Rows[0]["idCategoria"].ToString(); string Parametro2 = DDLDocumento.SelectedValue; ReportExecutionService.ReportExecutionService vRSE = new ReportExecutionService.ReportExecutionService(); vRSE.Credentials = new NetworkCredential("report_user", "kEbn2HUzd$Fs2T", "adbancat.hn"); vRSE.Url = "http://10.128.0.52/reportserver/reportexecution2005.asmx"; vRSE.ExecutionHeaderValue = new ReportExecutionService.ExecutionHeader(); var vEInfo = new ReportExecutionService.ExecutionInfo(); vEInfo = vRSE.LoadReport("/Recursos Humanos Interno/GestionDocumentalConsultas", null); List <ReportExecutionService.ParameterValue> vParametros = new List <ReportExecutionService.ParameterValue>(); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "D1", Value = Parametro1 }); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "D2", Value = Parametro2 }); vRSE.SetExecutionParameters(vParametros.ToArray(), "en-US"); String deviceinfo = "<DeviceInfo><Toolbar>false</Toolbar></DeviceInfo>"; String mime; String encoding; string[] stream; ReportExecutionService.Warning[] warning; byte[] vResultado = vRSE.Render("EXCEL", deviceinfo, out mime, out encoding, out encoding, out warning, out stream); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.AppendHeader("Content-Type", "application/vnd.ms-excel"); byte[] bytFile = vResultado; Response.OutputStream.Write(bytFile, 0, bytFile.Length); Response.AddHeader("Content-disposition", "attachment;filename=Reporte.xls"); Response.End(); } else if (DDLReporte.SelectedValue.Equals("2")) { string Parametro1 = DDLTipoPDoc.SelectedValue; ReportExecutionService.ReportExecutionService vRSE = new ReportExecutionService.ReportExecutionService(); vRSE.Credentials = new NetworkCredential("report_user", "kEbn2HUzd$Fs2T", "adbancat.hn"); vRSE.Url = "http://10.128.0.52/reportserver/reportexecution2005.asmx"; vRSE.ExecutionHeaderValue = new ReportExecutionService.ExecutionHeader(); var vEInfo = new ReportExecutionService.ExecutionInfo(); vEInfo = vRSE.LoadReport("/Recursos Humanos Interno/GestionDocumentalInventario", null); List <ReportExecutionService.ParameterValue> vParametros = new List <ReportExecutionService.ParameterValue>(); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "D1", Value = Parametro1 }); vRSE.SetExecutionParameters(vParametros.ToArray(), "en-US"); String deviceinfo = "<DeviceInfo><Toolbar>false</Toolbar></DeviceInfo>"; String mime; String encoding; string[] stream; ReportExecutionService.Warning[] warning; byte[] vResultado = vRSE.Render("EXCEL", deviceinfo, out mime, out encoding, out encoding, out warning, out stream); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.AppendHeader("Content-Type", "application/vnd.ms-excel"); byte[] bytFile = vResultado; Response.OutputStream.Write(bytFile, 0, bytFile.Length); string nombreExcel = "ReporteInventario" + DDLTipoPDoc.SelectedItem.Text + ".xls"; Response.AddHeader("Content-disposition", "attachment;filename=" + nombreExcel); Response.End(); } limpiarDatos(); } catch (Exception Ex) { Mensaje(Ex.Message, WarningType.Danger); } }
/// <summary> /// Returns a report from the SSRS server. /// </summary> /// <param name="serverName">Name of the report server. i.e. lfkbwtlabsql01</param> /// <param name="reportPath">Location of the report path. i.e. '/CRT/Reports/ContainerStatusReportByDate'</param> /// <param name="format">The format of the file. i.e. XML, NULL, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL, and HTMLOWC. The default is PDF.</param> /// <param name="fileName">Filename with extension. i.e. "\\server\c$\report.pdf"</param> /// <param name="parameterDictionary">Report parameters i.e. Key = "DateEnter", Value = "2015-10-11 00:00:00" or in JSON { DateEnter: '1/1/2016', Plant: 'Newtown Creek' } /// </param> public byte[] GenerateReport(string serverName, string reportPath, string format = null, string fileName = null, List <KeyValuePair <string, string> > parameterDictionary = null, string historyID = null) { byte[] result = null; using (ReportExecutionService.ReportExecutionService rs = new ReportExecutionService.ReportExecutionService()) { // Web service option setup. rs.Timeout = 300000; rs.Credentials = System.Net.CredentialCache.DefaultCredentials; rs.Url = "http://" + serverName + "/ReportServer/ReportExecution2005.asmx"; // Prepare report parameter. DataSourceCredentials[] credentials = null; string showHideToggle = null; string encoding; string mimeType; string extension; Warning[] warnings = null; ParameterValue[] reportHistoryParameters = null; string[] streamIDs = null; rs.ExecutionHeaderValue = new ExecutionHeader(); ExecutionInfo execInfo = rs.LoadReport(reportPath, historyID); var parameters_ = rs.GetExecutionInfo().Parameters; ParameterValue[] executionParameters = GetExecutionParameterArray(parameterDictionary); rs.SetExecutionParameters(executionParameters, "en-us"); String SessionId = rs.ExecutionHeaderValue.ExecutionID; Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID); try { string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"; result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); Extension = extension; Encoding = encoding; MimeType = mimeType; StreamIDs = streamIDs; execInfo = rs.GetExecutionInfo(); Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime); } catch (System.Web.Services.Protocols.SoapException e) { Console.WriteLine(e.Detail.OuterXml); } // Write the contents of the report to an MHTML file. try { if (fileName != null) { System.IO.FileStream stream = System.IO.File.Create(fileName, result.Length); Console.WriteLine("File created."); stream.Write(result, 0, result.Length); Console.WriteLine("Result written to the file."); stream.Close(); } } catch (Exception e) { Console.WriteLine(e.Message); } } return(result); }
protected void BtnDescargarModal_Click(object sender, EventArgs e) { try { if (Session["STEIDREPORTE"].Equals("1")) { string Parametro1 = Session["STEPARAMETRO1"].ToString(); string Parametro2 = Session["STEPARAMETRO2"].ToString(); string Parametro3 = Session["STEPARAMETRO3"].ToString(); string Parametro4 = Session["STEPARAMETRO4"].ToString(); ReportExecutionService.ReportExecutionService vRSE = new ReportExecutionService.ReportExecutionService(); vRSE.Credentials = new NetworkCredential("report_user", "kEbn2HUzd$Fs2T", "adbancat.hn"); vRSE.Url = "http://10.128.0.52/reportserver/reportexecution2005.asmx"; vRSE.ExecutionHeaderValue = new ReportExecutionService.ExecutionHeader(); var vEInfo = new ReportExecutionService.ExecutionInfo(); vEInfo = vRSE.LoadReport("/Recursos Humanos Interno/TiempoExtraordinarioCargaSap", null); List <ReportExecutionService.ParameterValue> vParametros = new List <ReportExecutionService.ParameterValue>(); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "D1", Value = Parametro1 }); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "D2", Value = Parametro2 }); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "D3", Value = Parametro3 }); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "D4", Value = Parametro4 }); vRSE.SetExecutionParameters(vParametros.ToArray(), "en-US"); String deviceinfo = "<DeviceInfo><Toolbar>false</Toolbar></DeviceInfo>"; String mime; String encoding; string[] stream; ReportExecutionService.Warning[] warning; byte[] vResultado = vRSE.Render("EXCEL", deviceinfo, out mime, out encoding, out encoding, out warning, out stream); //File.WriteAllBytes("c:\\files\\test.pdf", vResultado); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.AppendHeader("Content-Type", "application/vnd.ms-excel"); byte[] bytFile = vResultado; Response.OutputStream.Write(bytFile, 0, bytFile.Length); Response.AddHeader("Content-disposition", "attachment;filename=CargaSap.xls"); Response.End(); } else if (Session["STEIDREPORTE"].Equals("2")) { string Parametro1 = Session["STEPARAMETRO1"].ToString(); string Parametro2 = Session["STEPARAMETRO2"].ToString(); string Parametro3 = Session["STEPARAMETRO3"].ToString(); string Parametro4 = Session["STEPARAMETRO4"].ToString(); ReportExecutionService.ReportExecutionService vRSE = new ReportExecutionService.ReportExecutionService(); vRSE.Credentials = new NetworkCredential("report_user", "kEbn2HUzd$Fs2T", "adbancat.hn"); vRSE.Url = "http://10.128.0.52/reportserver/reportexecution2005.asmx"; vRSE.ExecutionHeaderValue = new ReportExecutionService.ExecutionHeader(); var vEInfo = new ReportExecutionService.ExecutionInfo(); vEInfo = vRSE.LoadReport("/Recursos Humanos Interno/TiempoExtraordinarioFacturacionBanco", null); List <ReportExecutionService.ParameterValue> vParametros = new List <ReportExecutionService.ParameterValue>(); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "D1", Value = Parametro1 }); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "D2", Value = Parametro2 }); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "D3", Value = Parametro3 }); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "D4", Value = Parametro4 }); vRSE.SetExecutionParameters(vParametros.ToArray(), "en-US"); String deviceinfo = "<DeviceInfo><Toolbar>false</Toolbar></DeviceInfo>"; String mime; String encoding; string[] stream; ReportExecutionService.Warning[] warning; byte[] vResultado = vRSE.Render("EXCEL", deviceinfo, out mime, out encoding, out encoding, out warning, out stream); //File.WriteAllBytes("c:\\files\\test.pdf", vResultado); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.AppendHeader("Content-Type", "application/vnd.ms-excel"); byte[] bytFile = vResultado; Response.OutputStream.Write(bytFile, 0, bytFile.Length); Response.AddHeader("Content-disposition", "attachment;filename=FactBanco.xls"); Response.End(); } else if (Session["STEIDREPORTE"].Equals("3")) { SmtpService vService = new SmtpService(); string Parametro1 = Session["STEPARAMETRO1"].ToString(); string Parametro2 = Session["STEPARAMETRO2"].ToString(); string Parametro3 = Session["STEPARAMETRO3"].ToString(); string Parametro4 = Session["STEPARAMETRO4"].ToString(); DataTable vDatos = new DataTable(); String vQuery = "RSP_TiempoExtraordinarioConsolidado 1,'" + Parametro1 + "','" + Parametro2 + "','" + Parametro3 + "','" + Parametro4 + "'"; vDatos = vConexion.obtenerDataTable(vQuery); DataTable vDatosSolicitudes = new DataTable(); for (int i = 0; i < vDatos.Rows.Count; i++) { string vCodigoSAP = vDatos.Rows[i]["codigo"].ToString(); String vQuerySolicitudes = "RSP_TiempoExtraordinarioConsolidado 2,'" + Parametro1 + "','" + Parametro2 + "','" + Parametro3 + "','" + Parametro4 + "','" + vCodigoSAP + "'"; vDatosSolicitudes = vConexion.obtenerDataTable(vQuerySolicitudes); vService.EnviarMensaje( vDatos.Rows[i]["emailEmpresa"].ToString(), typeBody.Reporte, vDatos.Rows[i]["nombre"].ToString(), "REPORTE DE CONSOLIDADO DE TIEMPO EXTRAORDINARIO.", null, ConfigurationManager.AppSettings["RHMail"].ToString(), vDatosSolicitudes ); } } }catch (Exception Ex) { Mensaje(Ex.Message, WarningType.Danger); } }
protected void btnReporteMotivoViaje_Click(object sender, EventArgs e) { if (DDLMotivoViaje.SelectedValue == "0") { DDLMotivoViaje.SelectedValue = "0"; Mensaje("Debe seleccionar motivo de viaje al que generará reporte", WarningType.Warning); } else { String vError = String.Empty; try { ReportExecutionService.ReportExecutionService vRSE = new ReportExecutionService.ReportExecutionService(); vRSE.Credentials = new NetworkCredential("report_user", "kEbn2HUzd$Fs2T", "adbancat.hn"); vRSE.Url = "http://10.128.0.52/reportserver/reportexecution2005.asmx"; vRSE.ExecutionHeaderValue = new ReportExecutionService.ExecutionHeader(); var vEInfo = new ReportExecutionService.ExecutionInfo(); vEInfo = vRSE.LoadReport("/Recursos Humanos/viaticosMotivoViaje", null); String vMotivo = DDLMotivoViaje.SelectedValue; List <ReportExecutionService.ParameterValue> vParametros = new List <ReportExecutionService.ParameterValue>(); vParametros.Add(new ReportExecutionService.ParameterValue { Name = "Motivo", Value = vMotivo }); vRSE.SetExecutionParameters(vParametros.ToArray(), "en-US"); String deviceinfo = "<DeviceInfo><Toolbar>false</Toolbar></DeviceInfo>"; String mime; String encoding; string[] stream; ReportExecutionService.Warning[] warning; //byte[] vResultado = vRSE.Render("EXCEL", deviceinfo, out mime, out encoding, out encoding, out warning, out stream); byte[] vResultado = vRSE.Render("pdf", deviceinfo, out mime, out encoding, out encoding, out warning, out stream); //File.WriteAllBytes("c:\\files\\test.pdf", vResultado); Response.Cache.SetCacheability(HttpCacheability.NoCache); //Response.AppendHeader("Content-Type", "application/vnd.ms-excel"); Response.AppendHeader("Content-Type", "application/pdf"); byte[] bytFile = vResultado; Response.OutputStream.Write(bytFile, 0, bytFile.Length); //Response.AddHeader("Content-disposition", "attachment;filename=DescargaPDFTest.xls"); Response.AddHeader("Content-disposition", "attachment;filename=DescargaPDFMotivoViaje.pdf"); Response.End(); } catch (Exception Ex) { vError = Ex.Message; } DDLMotivoViaje.SelectedValue = "0"; } }