private void button2_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "PDF 文件 (*.pdf)|*.pdf"; sfd.FileName = this.outfilename; if (sfd.ShowDialog() == DialogResult.OK) { //this.crystalReportViewer1.ExportReport(); DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat; exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; diskOpts.DiskFileName = sfd.FileName; exportOpts.ExportDestinationOptions = diskOpts; printCrystalReport.Export(exportOpts); MessageBox.Show("PDF导出完成", "注意"); } }
public void ExportReport(ReportDocument oReport, string cFileName, ExportTypes oExportTypes, int nFirstPage, int nLastPage) { ExportOptions oExportOptions = new ExportOptions(); PdfRtfWordFormatOptions oFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions(); DiskFileDestinationOptions oDestinationOptions = ExportOptions.CreateDiskFileDestinationOptions(); switch (oExportTypes) { case ExportTypes.PDF: case ExportTypes.MSWord: oExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; PdfRtfWordFormatOptions oPDFFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions(); if (nFirstPage > 0 && nLastPage > 0) { oPDFFormatOptions.FirstPageNumber = nFirstPage; oPDFFormatOptions.LastPageNumber = nLastPage; oPDFFormatOptions.UsePageRange = true; } oExportOptions.ExportFormatOptions = oPDFFormatOptions; break; case ExportTypes.MSExcel: oExportOptions.ExportFormatType = ExportFormatType.Excel; ExcelFormatOptions oExcelFormatOptions = ExportOptions.CreateExcelFormatOptions(); if (nFirstPage > 0 && nLastPage > 0) { oExcelFormatOptions.FirstPageNumber = nFirstPage; oExcelFormatOptions.LastPageNumber = nLastPage; oExcelFormatOptions.UsePageRange = true; } oExcelFormatOptions.ExcelUseConstantColumnWidth = false; oExportOptions.ExportFormatOptions = oExcelFormatOptions; break; case ExportTypes.HTML: oExportOptions.ExportFormatType = ExportFormatType.HTML40; HTMLFormatOptions oHTMLFormatOptions = ExportOptions.CreateHTMLFormatOptions(); if (nFirstPage > 0 && nLastPage > 0) { oHTMLFormatOptions.FirstPageNumber = nFirstPage; oHTMLFormatOptions.LastPageNumber = nLastPage; oHTMLFormatOptions.UsePageRange = true; } // can set additional HTML export options here oExportOptions.ExportFormatOptions = oHTMLFormatOptions; break; } oDestinationOptions.DiskFileName = cFileName; oExportOptions.ExportDestinationOptions = oDestinationOptions; oExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; oReport.Export(oExportOptions); }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { bool bMostrar = true; int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; string pf = "ctl00$CPHC$"; // pf = ""; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = Utilidades.CadenaConexion; int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdProyecto = new ReportDocument(); try { rdProyecto.Load(Server.MapPath(".") + @"\Prueba_PAs_encadenados.rpt"); } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdProyecto.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon . CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdProyecto.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } string strTipoFormato = Request.Form[pf + "FORMATO"]; // ESTO LO RECOGERE COMO PARAMETRO strControl = strTipoFormato; DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); try { rdProyecto.SetParameterValue("@nConcepto", 1); rdProyecto.SetParameterValue("@nIDItem", null); rdProyecto.SetParameterValue("@sDenominacion", ""); } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdProyecto.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC": oStream = rdProyecto.ExportToStream(ExportFormatType.Excel); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC2": // rdProyecto.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Exportacion"); bMostrar = false; break; } // FIN if (bMostrar) { Response.Clear(); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "EXC": // EXCEL Response.ContentType = "application/vnd.ms-excel"; //Response.ContentType = "Application/x-msexcel"; break; } Response.BinaryWrite(byteArray); Response.Flush(); Response.Close(); //HttpContext.Current.Response.End(); Response.End(); } } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; string pf = "ctl00$CPHC$"; pf = ""; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = Utilidades.CadenaConexion; int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdProyecto = new ReportDocument(); try { //if (Request.Form["CONSUMOS"] == "T") // if (Request.Form["DESGLOSADO"] == "S") // rdProyecto.Load(Server.MapPath(".") + @"\proyectos_desg_todos.rpt"); // else // rdProyecto.Load(Server.MapPath(".") + @"\proyectos_sin_desg_todos.rpt"); //else // if (Request.Form["DESGLOSADO"] == "S") // rdProyecto.Load(Server.MapPath(".") + @"\proyectos_desg_conconsumos.rpt"); // else // rdProyecto.Load(Server.MapPath(".") + @"\proyectos_sin_desg_conconsumos.rpt"); if (Request.QueryString[pf + "DESGLOSADO"] == "S") { rdProyecto.Load(Server.MapPath(".") + @"\sup_proyectos_desglosados.rpt"); } else { rdProyecto.Load(Server.MapPath(".") + @"\sup_proyectos_agregados.rpt"); } } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdProyecto.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon . CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdProyecto.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } string strTipoFormato = Request.QueryString[pf + "FORMATO"]; // ESTO LO RECOGERE COMO PARAMETRO strControl = strTipoFormato; DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); try { //rdProyecto.SetParameterValue("@Concepto", Request.QueryString[pf + "hdnConcepto"]); //rdProyecto.SetParameterValue("Cpto", Request.QueryString[pf + "hdnConcepto"]); rdProyecto.SetParameterValue("@Concepto", Request.QueryString[pf + "CONCEPTO"]); rdProyecto.SetParameterValue("Cpto", Request.QueryString[pf + "CONCEPTO"]); rdProyecto.SetParameterValue("@NivEstruc", Request.QueryString[pf + "NESTRUCTURA"]); rdProyecto.SetParameterValue("Estruc", Request.QueryString[pf + "NESTRUCTURA"]); rdProyecto.SetParameterValue("@Codigo", Request.QueryString[pf + "CODIGO"]); rdProyecto.SetParameterValue("@Tecnicos", Request.QueryString[pf + "TECNICOS"]); /* string[] aFecha = Regex.Split(Request.Form["FECHADESDE"], @"/"); * string mes = aFecha[0]; * if (mes.Length==1) mes = "0" + mes; * string strFecha = "01" + "/" + mes +"/"+ aFecha[1]; * rdProyecto.SetParameterValue("@FechaDesde", strFecha); * rdProyecto.SetParameterValue("FechaDesde", strFecha); * * aFecha = Regex.Split(Request.Form["FECHAHASTA"], @"/"); * * DateTime dtFechaHasta = DateTime.Parse("01/" + aFecha[0] + "/" + aFecha[1]); * dtFechaHasta = dtFechaHasta.AddMonths(1); * dtFechaHasta = dtFechaHasta.AddDays(-1); * * mes = dtFechaHasta.Month.ToString(); * string dia = dtFechaHasta.Day.ToString(); * * if (dia.Length == 1) dia = "0" + dia; * if (mes.Length == 1) mes = "0" + mes; * * strFecha = dia + "/" + mes + "/" + dtFechaHasta.Year.ToString(); * * rdProyecto.SetParameterValue("@FechaHasta", strFecha); * rdProyecto.SetParameterValue("FechaHasta", strFecha); */ rdProyecto.SetParameterValue("@FechaDesde", Request.QueryString[pf + "FECHADESDE"]); rdProyecto.SetParameterValue("FechaDesde", Request.QueryString[pf + "FECHADESDE"]); rdProyecto.SetParameterValue("@FechaHasta", Request.QueryString[pf + "FECHAHASTA"]); rdProyecto.SetParameterValue("FechaHasta", Request.QueryString[pf + "FECHAHASTA"]); if (Session["ADMINISTRADOR_PC_ACTUAL"].ToString() == "") { rdProyecto.SetParameterValue("@nUsuario", Request.QueryString[pf + "NUM_EMPLEADO"]); } else { rdProyecto.SetParameterValue("@nUsuario", 0); } rdProyecto.SetParameterValue("path", Server.MapPath(".") + "//"); rdProyecto.SetParameterValue("formato", strTipoFormato); } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdProyecto.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC": oStream = rdProyecto.ExportToStream(ExportFormatType.Excel); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; //case "EXC": // // //rdProyecto.ExportToHttpResponse(ExportFormatType.Excel, Response, false, "Exportacion"); //return; //break; } // FIN //Response.Buffer = false; Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); //String nav = HttpContext.Current.Request.Browser.Browser.ToString(); //if (nav.IndexOf("IE") == -1) //{ switch (strTipoFormato) { case "PDF": Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.pdf")); break; case "EXC": Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.xls")); break; } //} switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "EXC": // EXCEL Response.ContentType = "application/xls"; //Response.ContentType = "Application/vnd.ms-excel"; break; } Response.BinaryWrite(byteArray); //Response.Flush(); //Response.Close(); //HttpContext.Current.Response.End(); Response.End(); } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { bool bMostrar = true; int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; string pf = "ctl00$CPHC$"; // pf = ""; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = Utilidades.CadenaConexion; int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdProyecto = new ReportDocument(); try { rdProyecto.Load(Server.MapPath(".") + @"\sup_consumosproyecto.rpt"); } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdProyecto.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon . CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdProyecto.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } string strTipoFormato = "PDF"; // Request.Form[pf + "FORMATO"]; ESTO LO RECOGERE COMO PARAMETRO strControl = strTipoFormato; DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); try { if (Session["ADMINISTRADOR_PC_ACTUAL"].ToString() == "") { rdProyecto.SetParameterValue("@t314_idusuario", Session["UsuarioActual"].ToString()); } else { rdProyecto.SetParameterValue("@t314_idusuario", 0); } rdProyecto.SetParameterValue("@nPSN", Request.Form[pf + "hdnT305IdProy"]); rdProyecto.SetParameterValue("@dtFechaDesde", Request.Form[pf + "txtValIni"]); rdProyecto.SetParameterValue("@dtFechaHasta", Request.Form[pf + "txtValFin"]); rdProyecto.SetParameterValue("FechaDesde", Request.Form[pf + "txtValIni"]); rdProyecto.SetParameterValue("FechaHasta", Request.Form[pf + "txtValFin"]); rdProyecto.SetParameterValue("estado", Request.Form[pf + "hdnEstadoProy"]); rdProyecto.SetParameterValue("num_proyecto", Request.Form[pf + "txtCodProy"]); rdProyecto.SetParameterValue("nom_proyecto", Request.Form["txtNomProy"]); rdProyecto.SetParameterValue("path", Server.MapPath(".") + "//"); //if (Request.Form[pf + "hdnEsSoloRtpt"]=="S") // rdProyecto.SetParameterValue("@bEsSoloRtpt",1); //else // rdProyecto.SetParameterValue("@bEsSoloRtpt", 0); } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdProyecto.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC": oStream = rdProyecto.ExportToStream(ExportFormatType.Excel); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC2": // rdProyecto.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Exportacion"); bMostrar = false; break; } // FIN if (bMostrar) { Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); //String nav = HttpContext.Current.Request.Browser.Browser.ToString(); //if (nav.IndexOf("IE") == -1) //{ switch (strTipoFormato) { case "PDF": Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.pdf")); break; case "EXC": Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.xls")); break; } //} switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "EXC": // EXCEL Response.ContentType = "application/xls"; //Response.ContentType = "Application/vnd.ms-excel"; break; } Response.BinaryWrite(byteArray); //Response.Flush(); //Response.Close(); //HttpContext.Current.Response.End(); Response.End(); } } catch (Exception ex) { rdProyecto.Close(); rdProyecto.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { bool bMostrar = true; int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; string pf = "ctl00$CPHC$"; // pf = ""; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = Utilidades.CadenaConexion; int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdInforme = new ReportDocument(); try { rdInforme.Load(Server.MapPath(".") + @"\sup_consuproveed.rpt"); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdInforme.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon . CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdInforme.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } string strTipoFormato = Request.Form[pf + "FORMATO"]; // ESTO LO RECOGERE COMO PARAMETRO strControl = strTipoFormato; DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); try { rdInforme.SetParameterValue("path", Server.MapPath(".") + "//"); rdInforme.SetParameterValue("CABECERA", "CONSUMOS POR PROVEEDOR"); rdInforme.SetParameterValue("NODO", Estructura.getDefCorta(Estructura.sTipoElem.NODO)); if (SUPER.Capa_Negocio.Utilidades.EsAdminProduccion()) { rdInforme.SetParameterValue("@t314_idusuario", 0); } else { rdInforme.SetParameterValue("@t314_idusuario", Session["UsuarioActual"].ToString()); } string strFecha = Request.Form[pf + "hdnDesde"].Substring(0, 4) + "-" + Request.Form[pf + "hdnDesde"].Substring(4, 2) + "-01 00:00:00"; rdInforme.SetParameterValue("@nDesde", strFecha); DateTime dtFechaHasta = DateTime.Parse("01/" + Request.Form[pf + "hdnHasta"].Substring(4, 2) + "/" + Request.Form[pf + "hdnHasta"].Substring(0, 4)); dtFechaHasta = dtFechaHasta.AddMonths(1); dtFechaHasta = dtFechaHasta.AddDays(-1); string mes = dtFechaHasta.Month.ToString(); string dia = dtFechaHasta.Day.ToString(); if (dia.Length == 1) { dia = "0" + dia; } if (mes.Length == 1) { mes = "0" + mes; } strFecha = dtFechaHasta.Year.ToString() + "-" + mes + "-" + dia + " 00:00:00"; rdInforme.SetParameterValue("@nHasta", strFecha); rdInforme.SetParameterValue("FechaDesde", Request.Form[pf + "txtDesde"]); rdInforme.SetParameterValue("FechaHasta", Request.Form[pf + "txtHasta"]); rdInforme.SetParameterValue("@nNivelEstructura", Request.Form[pf + "hdnNivelEstructura"]); rdInforme.SetParameterValue("@t301_categoria", Request.Form[pf + "cboCategoria"]); rdInforme.SetParameterValue("@t305_cualidad", Request.Form[pf + "cboCualidad"]); rdInforme.SetParameterValue("@sProyectos", Request.Form[pf + "hdnProyectos"]); rdInforme.SetParameterValue("@sClientes", Request.Form[pf + "hdnClientes"]); rdInforme.SetParameterValue("@sResponsables", Request.Form[pf + "hdnResponsables"]); rdInforme.SetParameterValue("@sNaturalezas", Request.Form[pf + "hdnNaturalezas"]); rdInforme.SetParameterValue("@sHorizontal", Request.Form[pf + "hdnHorizontales"]); rdInforme.SetParameterValue("@sModeloContrato", Request.Form[pf + "hdnModeloCons"]); rdInforme.SetParameterValue("@sContrato", Request.Form[pf + "hdnContratos"]); rdInforme.SetParameterValue("@sIDEstructura", Request.Form[pf + "hdnEstrucAmbitos"]); rdInforme.SetParameterValue("@sSectores", Request.Form[pf + "hdnSectores"]); rdInforme.SetParameterValue("@sSegmentos", Request.Form[pf + "hdnSegmentos"]); rdInforme.SetParameterValue("@sProveedores", Request.Form[pf + "hdnProveedores"]); rdInforme.SetParameterValue("@bComparacionLogica", Request.Form[pf + "rdbOperador"]); rdInforme.SetParameterValue("@sCNP", Request.Form[pf + "hdnCNP"]); rdInforme.SetParameterValue("@sCSN1P", Request.Form[pf + "hdnCSN1P"]); rdInforme.SetParameterValue("@sCSN2P", Request.Form[pf + "hdnCSN2P"]); rdInforme.SetParameterValue("@sCSN3P", Request.Form[pf + "hdnCSN3P"]); rdInforme.SetParameterValue("@sCSN4P", Request.Form[pf + "hdnCSN4P"]); rdInforme.SetParameterValue("@t422_idmoneda", Session["MONEDA_VDC"].ToString()); rdInforme.SetParameterValue("ImportesEn", "* Importes en " + Session["DENOMINACION_VDC"].ToString()); //rdInforme.SetParameterValue("path", Server.MapPath(".") + "\\..\\..\\Rpts//"); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdInforme.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC": oStream = rdInforme.ExportToStream(ExportFormatType.Excel); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC2": // rdInforme.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Exportacion"); bMostrar = false; break; } // FIN if (bMostrar) { Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); //String nav = HttpContext.Current.Request.Browser.Browser.ToString(); //if (nav.IndexOf("IE") == -1) //{ switch (strTipoFormato) { case "PDF": Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.pdf")); break; case "EXC": Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.xls")); break; } //} switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "EXC": // EXCEL Response.ContentType = "application/xls"; break; } Response.BinaryWrite(byteArray); //Response.Flush(); //Response.Close(); //HttpContext.Current.Response.End(); Response.End(); } } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = Utilidades.Conexion(); int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdFormulario = new ReportDocument(); try { rdFormulario.Load(Server.MapPath(".") + @"\detalle_tar.rpt"); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdFormulario.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdFormulario.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } //for (int i = 0; i < rdFormulario.ParameterFields.Count; i++) //{ // if (rdFormulario.ParameterFields[i].ReportParameterType == CrystalDecisions.Shared.ParameterType.ReportParameter) continue; // rdFormulario.SetParameterValue(rdFormulario.ParameterFields[i].Name, null); //} try { rdFormulario.SetParameterValue("@Codigo", Request.QueryString["ID"]); //rdFormulario.SetParameterValue("@IDDEFICIENCIA", "18", "TAREAS"); //if (Request.QueryString["ADMIN"] == null) //{ // if (Session["ADMIN"].ToString() == "A") // rdFormulario.SetParameterValue("@IDFICEPI", "0", "TAREAS"); // else // rdFormulario.SetParameterValue("@IDFICEPI", Session["IDFICEPI"].ToString(), "TAREAS"); //} //else //{ // if (Request.QueryString["ADMIN"] == "A") // rdFormulario.SetParameterValue("@IDFICEPI", "0", "TAREAS"); // else // rdFormulario.SetParameterValue("@IDFICEPI", Request.QueryString["IDFICEPI"].ToString(), "TAREAS"); //} //rdFormulario.SetParameterValue("@INTCOLUMNA", "2", "TAREAS"); //rdFormulario.SetParameterValue("@INTORDEN", "0", "TAREAS"); //rdFormulario.SetParameterValue("@t042_idarea","1" , "DOCUMENTOS_AREA"); //rdFormulario.SetParameterValue("@t044_iddeficiencia","1" , "DOCUMENTOS_DEFICIENCIA"); //rdFormulario.SetParameterValue("@T044_IDDEFICIENCIA","1" , "CRONOLOGIA"); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } //try //{ // string[] aID = Regex.Split(Request.QueryString["ID"], @","); // //filter the data by setting the .RecordSelectionFormula property // //of rdOrders to just return those orders that were shipped via UPS // string strFormula = ""; // for (int i = 0; i < aID.Length; i++) // { // strFormula += "{GESTAR_DEFICIENCIA_INF;1.T044_IDDEFICIENCIA} = " + aID[i] + " OR"; // } // strFormula = strFormula.Substring(0, strFormula.Length - 3); // rdFormulario.RecordSelectionFormula = strFormula; //} //catch (Exception ex) //{ // rdFormulario.Close(); // rdFormulario.Dispose(); // Response.Write("Error al actualizar los parámetros del report: " + ex.Message); //} DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); string strTipoFormato = "PDF"; // ESTO LO RECOGERE COMO PARAMETRO ExportOptions exportOpts = new ExportOptions(); try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdFormulario.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "RTF": // RTF rdFormulario.ExportToHttpResponse(ExportFormatType.EditableRTF, Response, false, "Exportacion"); return; break; } rdFormulario.Close(); rdFormulario.Dispose(); // FIN Response.ClearContent(); Response.ClearHeaders(); switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "RTF": // RTF Response.ContentType = "application/msword"; break; } String nav = HttpContext.Current.Request.Browser.Browser.ToString(); if (nav.IndexOf("IE") == -1) { switch (strTipoFormato) { case "PDF": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.pdf"); break; case "EXC": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.xls"); break; } } Response.Clear(); Response.BinaryWrite(byteArray); Response.Flush(); Response.Close(); Response.End(); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("Report could not be created: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { bool bMostrar = true; int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; string pf = "ctl00$CPHC$"; // pf = ""; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = Utilidades.CadenaConexion; int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdInforme = new ReportDocument(); try { rdInforme.Load(Server.MapPath(".") + @"\sup_contratos.rpt"); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdInforme.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon . CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdInforme.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } string strTipoFormato = Request.Form[pf + "FORMATO"]; // ESTO LO RECOGERE COMO PARAMETRO strControl = strTipoFormato; DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); try { rdInforme.SetParameterValue("path", Server.MapPath(".") + "//"); rdInforme.SetParameterValue("CABECERA", "CUADRE DE CONTRATOS"); string sConcepto = ""; if (Request.Form[pf + "cboConceptoEje"] == "1") { sConcepto = Estructura.getDefCorta(Estructura.sTipoElem.NODO); } else if (Request.Form[pf + "cboConceptoEje"] == "2") { sConcepto = "Cliente"; } else if (Request.Form[pf + "cboConceptoEje"] == "3") { sConcepto = "Responsable del contrato"; } rdInforme.SetParameterValue("CONCEPTO", sConcepto); if (Session["ADMINISTRADOR_PC_ACTUAL"].ToString() == "") { rdInforme.SetParameterValue("@t314_idusuario", Session["UsuarioActual"].ToString()); } else { rdInforme.SetParameterValue("@t314_idusuario", 0); } rdInforme.SetParameterValue("@nOpcion", Request.Form[pf + "cboConceptoEje"]); rdInforme.SetParameterValue("@nNivelEstructura", Request.Form[pf + "hdnNivelEstructura"]); rdInforme.SetParameterValue("@sProyectos", Request.Form[pf + "hdnProyectos"]); rdInforme.SetParameterValue("@sClientes", Request.Form[pf + "hdnClientes"]); rdInforme.SetParameterValue("@sResponsables", Request.Form[pf + "hdnResponsables"]); rdInforme.SetParameterValue("@sNaturalezas", Request.Form[pf + "hdnNaturalezas"]); rdInforme.SetParameterValue("@sHorizontal", Request.Form[pf + "hdnHorizontales"]); rdInforme.SetParameterValue("@sModeloContrato", Request.Form[pf + "hdnModeloCons"]); rdInforme.SetParameterValue("@sContrato", Request.Form[pf + "hdnContratos"]); rdInforme.SetParameterValue("@sIDEstructura", Request.Form[pf + "hdnEstrucAmbitos"]); rdInforme.SetParameterValue("@sSectores", Request.Form[pf + "hdnSectores"]); rdInforme.SetParameterValue("@sSegmentos", Request.Form[pf + "hdnSegmentos"]); rdInforme.SetParameterValue("@bComparacionLogica", Request.Form[pf + "rdbOperador"]); rdInforme.SetParameterValue("@sCNP", Request.Form[pf + "hdnCNP"]); rdInforme.SetParameterValue("@sCSN1P", Request.Form[pf + "hdnCSN1P"]); rdInforme.SetParameterValue("@sCSN2P", Request.Form[pf + "hdnCSN2P"]); rdInforme.SetParameterValue("@sCSN3P", Request.Form[pf + "hdnCSN3P"]); rdInforme.SetParameterValue("@sCSN4P", Request.Form[pf + "hdnCSN4P"]); rdInforme.SetParameterValue("@bCuadre", Request.Form[pf + "rdbContrato"]); rdInforme.SetParameterValue("@Tolerancia", Request.Form[pf + "txtTolerancia"]); //rdInforme.SetParameterValue("path", Server.MapPath(".") + "\\..\\..\\Rpts//"); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdInforme.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC": oStream = rdInforme.ExportToStream(ExportFormatType.Excel); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC2": // rdInforme.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Exportacion"); bMostrar = false; break; } // FIN if (bMostrar) { Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); //String nav = HttpContext.Current.Request.Browser.Browser.ToString(); //if (nav.IndexOf("IE") == -1) //{ switch (strTipoFormato) { case "PDF": Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.pdf")); break; case "EXC": Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.xls")); break; } //} switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "EXC": // EXCEL Response.ContentType = "application/xls"; //Response.ContentType = "Application/vnd.ms-excel"; break; } Response.BinaryWrite(byteArray); //Response.Flush(); //Response.Close(); //HttpContext.Current.Response.End(); Response.End(); } } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { ReportDocument rdEstadisticas = new ReportDocument(); try { rdEstadisticas.Load(Server.MapPath(".") + @"\estadisticas_valores_1.rpt"); } catch (Exception ex) { rdEstadisticas.Close(); rdEstadisticas.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); try { IB.Progress.Models.Estadisticas rf = (IB.Progress.Models.Estadisticas)Session["ValoresRPT"]; IB.Progress.Models.ParamsRPT rfParamsRpt = (IB.Progress.Models.ParamsRPT)Session["ParamsRPT"]; //Parámetros Modelo 1 string Origen = Request.QueryString["origen"].ToString(); rdEstadisticas.SetParameterValue("Origen", Origen); rdEstadisticas.SetParameterValue("FechaDesde", rfParamsRpt.fecDesde.ToString()); rdEstadisticas.SetParameterValue("FechaHasta", rfParamsRpt.fecHasta.ToString()); rdEstadisticas.SetParameterValue("Profundizacion", rfParamsRpt.txtProfundizacion.ToString()); rdEstadisticas.SetParameterValue("Sexo", (rfParamsRpt.sexo == null) ? "" : rfParamsRpt.sexo.ToString()); rdEstadisticas.SetParameterValue("Evaluador", rfParamsRpt.txtEvaluador.ToString()); rdEstadisticas.SetParameterValue("Profundizacion", rfParamsRpt.txtProfundizacion.ToString()); rdEstadisticas.SetParameterValue("AntiguedadReferencia", rf.t001_fecantigu.ToString()); rdEstadisticas.SetParameterValue("Colectivo", rfParamsRpt.txtColectivo.ToString()); rdEstadisticas.SetParameterValue("Situacion", rfParamsRpt.txtSituacion.ToString()); rdEstadisticas.SetParameterValue("profevh", rf.profevh.ToString()); rdEstadisticas.SetParameterValue("profevm", rf.profevm.ToString()); rdEstadisticas.SetParameterValue("profevt", rf.profevt.ToString()); rdEstadisticas.SetParameterValue("profevhant", rf.profevhant.ToString()); rdEstadisticas.SetParameterValue("profevmant", rf.profevmant.ToString()); rdEstadisticas.SetParameterValue("profevantt", rf.profevantt.ToString()); rdEstadisticas.SetParameterValue("profnoevh", rf.profnoevh.ToString()); rdEstadisticas.SetParameterValue("profnoevm", rf.profnoevm.ToString()); rdEstadisticas.SetParameterValue("profnoevt", rf.profnoevt.ToString()); rdEstadisticas.SetParameterValue("profnoevhant", rf.profnoevhant.ToString()); rdEstadisticas.SetParameterValue("profnoevmant", rf.profnoevmant.ToString()); rdEstadisticas.SetParameterValue("profnoevantt", rf.profnoevantt.ToString()); rdEstadisticas.SetParameterValue("profht", rf.profht.ToString()); rdEstadisticas.SetParameterValue("profmt", rf.profmt.ToString()); rdEstadisticas.SetParameterValue("proft", rf.proft.ToString()); rdEstadisticas.SetParameterValue("profhantt", rf.profhantt.ToString()); rdEstadisticas.SetParameterValue("profmantt", rf.profmantt.ToString()); rdEstadisticas.SetParameterValue("profantt", rf.profantt.ToString()); rdEstadisticas.SetParameterValue("evabiertah", rf.evabiertah.ToString()); rdEstadisticas.SetParameterValue("evabiertam", rf.evabiertam.ToString()); rdEstadisticas.SetParameterValue("evabiertat", rf.evabiertat.ToString()); rdEstadisticas.SetParameterValue("evabiertahant", rf.evabiertahant.ToString()); rdEstadisticas.SetParameterValue("evabiertamant", rf.evabiertamant.ToString()); rdEstadisticas.SetParameterValue("evabiertaantt", rf.evabiertaantt.ToString()); rdEstadisticas.SetParameterValue("evcursoh", rf.evcursoh.ToString()); rdEstadisticas.SetParameterValue("evcursom", rf.evcursom.ToString()); rdEstadisticas.SetParameterValue("evcursot", rf.evcursot.ToString()); rdEstadisticas.SetParameterValue("evcursohant", rf.evcursohant.ToString()); rdEstadisticas.SetParameterValue("evcursomant", rf.evcursomant.ToString()); rdEstadisticas.SetParameterValue("evcursoantt", rf.evcursoantt.ToString()); rdEstadisticas.SetParameterValue("evcerradah", rf.evcerradah.ToString()); rdEstadisticas.SetParameterValue("evcerradam", rf.evcerradam.ToString()); rdEstadisticas.SetParameterValue("evcerradat", rf.evcursot.ToString()); rdEstadisticas.SetParameterValue("evcerradahant", rf.evcerradahant.ToString()); rdEstadisticas.SetParameterValue("evcerradamant", rf.evcerradamant.ToString()); rdEstadisticas.SetParameterValue("evcerradaantt", rf.evcerradaantt.ToString()); rdEstadisticas.SetParameterValue("evfirmadah", rf.evfirmadah.ToString()); rdEstadisticas.SetParameterValue("evfirmadam", rf.evfirmadam.ToString()); rdEstadisticas.SetParameterValue("evfirmadat", rf.evfirmadat.ToString()); rdEstadisticas.SetParameterValue("evfirmadahant", rf.evfirmadahant.ToString()); rdEstadisticas.SetParameterValue("evfirmadamant", rf.evfirmadamant.ToString()); rdEstadisticas.SetParameterValue("evfirmadaantt", rf.evfirmadaantt.ToString()); rdEstadisticas.SetParameterValue("evautomaticah", rf.evautomaticah.ToString()); rdEstadisticas.SetParameterValue("evautomaticam", rf.evautomaticam.ToString()); rdEstadisticas.SetParameterValue("evautomaticat", rf.evautomaticat.ToString()); rdEstadisticas.SetParameterValue("evautomaticahant", rf.evautomaticahant.ToString()); rdEstadisticas.SetParameterValue("evautomaticamant", rf.evautomaticamant.ToString()); rdEstadisticas.SetParameterValue("evautomaticaantt", rf.evautomaticaantt.ToString()); rdEstadisticas.SetParameterValue("evht", rf.evht.ToString()); rdEstadisticas.SetParameterValue("evmt", rf.evmt.ToString()); rdEstadisticas.SetParameterValue("evt", rf.evt.ToString()); rdEstadisticas.SetParameterValue("evhantt", rf.evhantt.ToString()); rdEstadisticas.SetParameterValue("evmantt", rf.evmantt.ToString()); rdEstadisticas.SetParameterValue("evantt", rf.evantt.ToString()); } catch (Exception ex) { rdEstadisticas.Close(); rdEstadisticas.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } try { System.IO.Stream oStream; byte[] byteArray = null; oStream = rdEstadisticas.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); // FIN //Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.Clear(); Response.BinaryWrite(byteArray); Response.Flush(); Response.Close(); //HttpContext.Current.Response.End(); Response.End(); } catch (Exception ex) { rdEstadisticas.Close(); rdEstadisticas.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; string strOpcion; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = Utilidades.Conexion(); int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdFormulario = new ReportDocument(); strOpcion = Session["ORIGEN"].ToString(); try { if (strOpcion == "PANT_AVANZADO_TAR") { rdFormulario.Load(Server.MapPath(".") + @"\relacion_avan_tar.rpt"); } else if (strOpcion == "PANT_PROPIAS_TAR") { rdFormulario.Load(Server.MapPath(".") + @"\relacion_prop_tar.rpt"); } } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdFormulario.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdFormulario.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } string strIDFICEPI = Session["IDFICEPI"].ToString(); if (Session["ADMIN"].ToString() == "A") { strIDFICEPI = "0"; } if (strOpcion == "PANT_AVANZADO_TAR") { //Las opciones son 1-> fecha prevista, 2-> fecha realización y 3 -> sin fecha que lo tratamos como el caso 2 string sOpcion = "1"; if ((((Hashtable)Session["PANT_AVANZADO_TAR"])["rdlOpciones"]).ToString() != "1") { sOpcion = "2"; } rdFormulario.SetParameterValue("@OPCION", sOpcion); rdFormulario.SetParameterValue("@T001_IDFICEPI", strIDFICEPI); rdFormulario.SetParameterValue("@IDAREA", (((Hashtable)Session["PANT_AVANZADO_TAR"])["hdnIDArea"]).ToString()); rdFormulario.SetParameterValue("@IDDEFICIENCIA", (((Hashtable)Session["PANT_AVANZADO_TAR"])["hdnDeficiencia"]).ToString()); rdFormulario.SetParameterValue("@IDCOORDINADOR", (((Hashtable)Session["PANT_AVANZADO_TAR"])["hdnCoordinador"]).ToString()); rdFormulario.SetParameterValue("@IDESPECIALISTA", (((Hashtable)Session["PANT_AVANZADO_TAR"])["hdnEspecialista"]).ToString()); rdFormulario.SetParameterValue("@SITUACION", (((Hashtable)Session["PANT_AVANZADO_TAR"])["cboSituacion"]).ToString()); rdFormulario.SetParameterValue("@T072_RESULTADO", (((Hashtable)Session["PANT_AVANZADO_TAR"])["cboRtado"]).ToString()); rdFormulario.SetParameterValue("@FECHA_INI", (((Hashtable)Session["PANT_AVANZADO_TAR"])["txtFechaInicio"]).ToString()); rdFormulario.SetParameterValue("@FECHA_FIN", (((Hashtable)Session["PANT_AVANZADO_TAR"])["txtFechaFin"]).ToString()); } else if (strOpcion == "PANT_PROPIAS_TAR") { rdFormulario.SetParameterValue("@T001_IDFICEPI", strIDFICEPI); rdFormulario.SetParameterValue("@IDAREA", (((Hashtable)Session["PANT_PROPIAS_TAR"])["hdnIDArea"]).ToString()); rdFormulario.SetParameterValue("@SITUACION", (((Hashtable)Session["PANT_PROPIAS_TAR"])["cboSituacion"]).ToString()); rdFormulario.SetParameterValue("@T072_RESULTADO", (((Hashtable)Session["PANT_PROPIAS_TAR"])["cboRtado"]).ToString()); rdFormulario.SetParameterValue("@FECHA", (((Hashtable)Session["PANT_PROPIAS_TAR"])["txtFecha"]).ToString()); } DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); string strTipoFormato = "PDF"; // ESTO LO RECOGERE COMO PARAMETRO ExportOptions exportOpts = new ExportOptions(); try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdFormulario.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "RTF": // RTF rdFormulario.ExportToHttpResponse(ExportFormatType.EditableRTF, Response, false, "Exportacion"); return; break; } rdFormulario.Close(); rdFormulario.Dispose(); // FIN Response.ClearContent(); Response.ClearHeaders(); switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "RTF": // RTF Response.ContentType = "application/msword"; break; } String nav = HttpContext.Current.Request.Browser.Browser.ToString(); if (nav.IndexOf("IE") == -1) { switch (strTipoFormato) { case "PDF": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.pdf"); break; case "EXC": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.xls"); break; } } Response.Clear(); Response.BinaryWrite(byteArray); Response.Flush(); Response.Close(); Response.End(); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("Report could not be created: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { bool bMostrar = true; int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = Utilidades.CadenaConexion; int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdFormulario = new ReportDocument(); try { rdFormulario.Load(Server.MapPath(".") + @"\detalle.rpt"); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdFormulario.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdFormulario.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } rdFormulario.SetParameterValue("@nRef", Utilidades.decodpar(Request.QueryString["ing"].ToString())); //rdFormulario.SetParameterValue("@nRef", "39273"); DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); //string strTipoFormato = Request.QueryString["FORMATO"]; // ESTO LO RECOGERE COMO PARAMETRO string strTipoFormato = "PDF"; ExportOptions exportOpts = new ExportOptions(); try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdFormulario.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "RTF": // RTF rdFormulario.ExportToHttpResponse(ExportFormatType.EditableRTF, Response, false, "Exportacion"); bMostrar = false; break; } rdFormulario.Close(); rdFormulario.Dispose(); // FIN if (bMostrar) { Response.ClearContent(); Response.ClearHeaders(); Response.Buffer = true; switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "RTF": // RTF Response.ContentType = "application/msword"; break; } Response.Clear(); //String nav = HttpContext.Current.Request.Browser.Browser.ToString(); //if (nav.IndexOf("IE") == -1) //{ switch (strTipoFormato) { case "PDF": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.pdf"); break; case "RTF": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.doc"); break; } //} Response.BinaryWrite(byteArray); Response.Flush(); Response.Close(); Response.End(); } } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("Report could not be created: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; string strOpcion; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = Utilidades.Conexion(); int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdFormulario = new ReportDocument(); strOpcion = Session["ORIGEN"].ToString(); try { if (strOpcion == "PANT_AVANZADO") { if ((((Hashtable)Session["PANT_AVANZADO"])["hdnCaso"]).ToString() == "A") { rdFormulario.Load(Server.MapPath(".") + @"\relacion_avan_act.rpt"); } else { if (short.Parse((((Hashtable)Session["PANT_AVANZADO"])["rdlCasoCronologia"]).ToString()) == 0) { rdFormulario.Load(Server.MapPath(".") + @"\relacion_avan_cro_or.rpt"); } else { rdFormulario.Load(Server.MapPath(".") + @"\relacion_avan_cro_and.rpt"); } } } else if (strOpcion == "PANT_VENCIMIENTO") { rdFormulario.Load(Server.MapPath(".") + @"\relacion_vto.rpt"); } } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdFormulario.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdFormulario.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } string strIDFICEPI = Session["IDFICEPI"].ToString(); if (Session["ADMIN"].ToString() == "A") { strIDFICEPI = "0"; } if (strOpcion == "PANT_AVANZADO") { if ((((Hashtable)Session["PANT_AVANZADO"])["hdnCaso"]).ToString() == "C") { rdFormulario.SetParameterValue("@FECHA_INICIO", (((Hashtable)Session["PANT_AVANZADO"])["txtFechaInicio"]).ToString()); rdFormulario.SetParameterValue("@FECHA_FIN", (((Hashtable)Session["PANT_AVANZADO"])["txtFechaFin"]).ToString()); } rdFormulario.SetParameterValue("@T001_IDFICEPI", strIDFICEPI); rdFormulario.SetParameterValue("@IDAREA", (((Hashtable)Session["PANT_AVANZADO"])["hdnIDArea"]).ToString()); rdFormulario.SetParameterValue("@T044_IMPORTANCIA", (((Hashtable)Session["PANT_AVANZADO"])["cboImportancia"]).ToString()); rdFormulario.SetParameterValue("@T044_PRIORIDAD", (((Hashtable)Session["PANT_AVANZADO"])["cboPrioridad"]).ToString()); rdFormulario.SetParameterValue("@T044_RTDO", (((Hashtable)Session["PANT_AVANZADO"])["cboRtado"]).ToString()); rdFormulario.SetParameterValue("@T074_IDENTRADA", (((Hashtable)Session["PANT_AVANZADO"])["hdnEntrada"]).ToString()); rdFormulario.SetParameterValue("@T076_IDTIPO", (((Hashtable)Session["PANT_AVANZADO"])["hdnTipo"]).ToString()); rdFormulario.SetParameterValue("@T077_IDALCANCE", (((Hashtable)Session["PANT_AVANZADO"])["hdnAlcance"]).ToString()); rdFormulario.SetParameterValue("@T078_IDPROCESO", (((Hashtable)Session["PANT_AVANZADO"])["hdnProceso"]).ToString()); rdFormulario.SetParameterValue("@T079_IDPRODUCTO", (((Hashtable)Session["PANT_AVANZADO"])["hdnProducto"]).ToString()); rdFormulario.SetParameterValue("@T081_IDREQUISITO", (((Hashtable)Session["PANT_AVANZADO"])["hdnRequisito"]).ToString()); rdFormulario.SetParameterValue("@T082_CAUSA_CAT", (((Hashtable)Session["PANT_AVANZADO"])["hdnCausa"]).ToString()); rdFormulario.SetParameterValue("@T044_COORDINADOR", (((Hashtable)Session["PANT_AVANZADO"])["hdnCoordinador"]).ToString()); rdFormulario.SetParameterValue("@T044_SOLICITANTE", (((Hashtable)Session["PANT_AVANZADO"])["hdnSolicitante"]).ToString()); rdFormulario.SetParameterValue("@T044_PROVEEDOR", (((Hashtable)Session["PANT_AVANZADO"])["txtProveedor"]).ToString()); rdFormulario.SetParameterValue("@T044_CLIENTE", (((Hashtable)Session["PANT_AVANZADO"])["txtCliente"]).ToString()); rdFormulario.SetParameterValue("@T044_CR", (((Hashtable)Session["PANT_AVANZADO"])["txtCR"]).ToString()); rdFormulario.SetParameterValue("@COLUMNA", "1"); rdFormulario.SetParameterValue("@ORDEN", "0"); string strTramitadas; string strPdteAclara; string strAclaRta; string strAceptadas; string strRechazadas; string strEnEstudio; string strPdtesDeResolucion; string strPdtesDeAcepPpta; string strEnResolucion; string strResueltas; string strNoAprobadas; string strAprobadas; string strAnuladas; if ((((Hashtable)Session["PANT_AVANZADO"])["hdnCaso"]).ToString() == "A") { if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkTramitadas"]).ToString())) { strTramitadas = "1"; } else { strTramitadas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkPdteAclara"]).ToString())) { strPdteAclara = "1"; } else { strPdteAclara = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkAclaRta"]).ToString())) { strAclaRta = "1"; } else { strAclaRta = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkAceptadas"]).ToString())) { strAceptadas = "1"; } else { strAceptadas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkRechazadas"]).ToString())) { strRechazadas = "1"; } else { strRechazadas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkEnEstudio"]).ToString())) { strEnEstudio = "1"; } else { strEnEstudio = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkPdtesDeResolucion"]).ToString())) { strPdtesDeResolucion = "1"; } else { strPdtesDeResolucion = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkPdtesDeAcepPpta"]).ToString())) { strPdtesDeAcepPpta = "1"; } else { strPdtesDeAcepPpta = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkEnResolucion"]).ToString())) { strEnResolucion = "1"; } else { strEnResolucion = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkResueltas"]).ToString())) { strResueltas = "1"; } else { strResueltas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkNoAprobadas"]).ToString())) { strNoAprobadas = "1"; } else { strNoAprobadas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkAprobadas"]).ToString())) { strAprobadas = "1"; } else { strAprobadas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkAnuladas"]).ToString())) { strAnuladas = "1"; } else { strAnuladas = "0"; } } else { if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkTramitadas2"]).ToString())) { strTramitadas = "1"; } else { strTramitadas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkPdteAclara2"]).ToString())) { strPdteAclara = "1"; } else { strPdteAclara = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkAclaRta2"]).ToString())) { strAclaRta = "1"; } else { strAclaRta = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkAceptadas2"]).ToString())) { strAceptadas = "1"; } else { strAceptadas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkRechazadas2"]).ToString())) { strRechazadas = "1"; } else { strRechazadas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkEnEstudio2"]).ToString())) { strEnEstudio = "1"; } else { strEnEstudio = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkPdtesDeResolucion2"]).ToString())) { strPdtesDeResolucion = "1"; } else { strPdtesDeResolucion = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkPdtesDeAcepPpta2"]).ToString())) { strPdtesDeAcepPpta = "1"; } else { strPdtesDeAcepPpta = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkEnResolucion2"]).ToString())) { strEnResolucion = "1"; } else { strEnResolucion = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkResueltas2"]).ToString())) { strResueltas = "1"; } else { strResueltas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkNoAprobadas2"]).ToString())) { strNoAprobadas = "1"; } else { strNoAprobadas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkAprobadas2"]).ToString())) { strAprobadas = "1"; } else { strAprobadas = "0"; } if (bool.Parse((((Hashtable)Session["PANT_AVANZADO"])["chkAnuladas2"]).ToString())) { strAnuladas = "1"; } else { strAnuladas = "0"; } } rdFormulario.SetParameterValue("@TRAMITADAS", strTramitadas); rdFormulario.SetParameterValue("@PDTEACLARA", strPdteAclara); rdFormulario.SetParameterValue("@ACLARARTA", strAclaRta); rdFormulario.SetParameterValue("@ACEPTADAS", strAceptadas); rdFormulario.SetParameterValue("@RECHAZADAS", strRechazadas); rdFormulario.SetParameterValue("@ENESTUDIO", strEnEstudio); rdFormulario.SetParameterValue("@PENDTE_RESOLUCION", strPdtesDeResolucion); rdFormulario.SetParameterValue("@PENDTE_ACEPTACION", strPdtesDeAcepPpta); rdFormulario.SetParameterValue("@ENRESOLUCION", strEnResolucion); rdFormulario.SetParameterValue("@RESUELTAS", strResueltas); rdFormulario.SetParameterValue("@NOAPROBADAS", strNoAprobadas); rdFormulario.SetParameterValue("@APROBADAS", strAprobadas); rdFormulario.SetParameterValue("@ANULADAS", strAnuladas); } else if (strOpcion == "PANT_VENCIMIENTO") { rdFormulario.SetParameterValue("@OPCION", (((Hashtable)Session["PANT_VENCIMIENTO"])["rdlOpciones"]).ToString()); rdFormulario.SetParameterValue("@T001_IDFICEPI", strIDFICEPI); rdFormulario.SetParameterValue("@IDAREA", (((Hashtable)Session["PANT_VENCIMIENTO"])["hdnIDArea"]).ToString()); rdFormulario.SetParameterValue("@FECHA_INI", (((Hashtable)Session["PANT_VENCIMIENTO"])["txtFechaInicio"]).ToString()); rdFormulario.SetParameterValue("@FECHA_FIN", (((Hashtable)Session["PANT_VENCIMIENTO"])["txtFechaFin"]).ToString()); rdFormulario.SetParameterValue("@COLUMNA", "1"); rdFormulario.SetParameterValue("@ORDEN", "0"); } DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); string strTipoFormato = "PDF"; // ESTO LO RECOGERE COMO PARAMETRO ExportOptions exportOpts = new ExportOptions(); try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdFormulario.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "RTF": // RTF rdFormulario.ExportToHttpResponse(ExportFormatType.EditableRTF, Response, false, "Exportacion"); return; break; } rdFormulario.Close(); rdFormulario.Dispose(); // FIN Response.ClearContent(); Response.ClearHeaders(); switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "RTF": // RTF Response.ContentType = "application/msword"; break; } //String nav = HttpContext.Current.Request.Browser.Browser.ToString(); //if (nav.IndexOf("IE") == -1) //{ switch (strTipoFormato) { case "PDF": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.pdf"); break; case "EXC": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.xls"); break; } //} Response.Clear(); Response.BinaryWrite(byteArray); Response.Flush(); Response.Close(); Response.End(); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("Report could not be created: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = Utilidades.CadenaConexion; int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdTarea = new ReportDocument(); try { rdTarea.Load(Server.MapPath(".") + @"\tarea_super.rpt"); } catch (Exception ex) { rdTarea.Close(); rdTarea.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdTarea.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdTarea.Close(); rdTarea.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon . CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdTarea.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdTarea.Close(); rdTarea.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } string strTipoFormato = Utilidades.decodpar(Request.QueryString["fm"].ToString()); // ESTO LO RECOGERE COMO PARAMETRO DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); try { rdTarea.SetParameterValue("@nIdTarea", Utilidades.decodpar(Request.QueryString["it"].ToString())); rdTarea.SetParameterValue("nodo", Estructura.getDefLarga(Estructura.sTipoElem.NODO)); //rdTarea.SetParameterValue("@nIdTarea", Request.QueryString["IDTAREA"],"PROFESIONAL"); //rdTarea.SetParameterValue("@nIdRecurso", Request.QueryString["IDTAREA"],"PROFESIONAL"); //rdTarea.SetParameterValue("@t332_idtarea", Request.QueryString["IDTAREA"], "POOL_GFUNCIONAL"); //rdTarea.SetParameterValue("@t332_idtarea", Request.QueryString["IDTAREA"], "ATRIBUTOS_ESTADISTICOS"); //rdTarea.SetParameterValue("@t331_idpt", Request.QueryString["IDPT"], "ATRIB_ESTAD_PROY_TEC"); //rdTarea.SetParameterValue("@t332_idtarea", Request.QueryString["IDTAREA"], "DOCUMENTACION"); } catch (Exception ex) { rdTarea.Close(); rdTarea.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdTarea.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); //String nav = HttpContext.Current.Request.Browser.Browser.ToString(); //if (nav.IndexOf("IE") == -1) //{ Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.pdf")); Response.ContentType = "application/pdf"; //} Response.BinaryWrite(byteArray); //Response.Flush(); //Response.Close(); Response.End(); break; case "EXC": // RTF rdTarea.ExportToHttpResponse(ExportFormatType.Excel, Response, false, "Exportacion"); break; } // FIN //Response.ClearContent(); //Response.ClearHeaders(); //switch (strTipoFormato) //{ // // PDF // case "PDF": // Response.ContentType = "application/pdf"; // break; // case "EXCEL": // // EXCEL // Response.ContentType = "application/vnd.ms-excel"; // break; //} //Response.Clear(); //Response.BinaryWrite(byteArray); //Response.Flush(); //Response.Close(); //Response.End(); } catch (Exception ex) { rdTarea.Close(); rdTarea.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (Session["IDRED"] == null) { try { Response.Redirect("~/SesionCaducadaModal.aspx", true); } catch (System.Threading.ThreadAbortException) { return; } } if (!Page.IsPostBack) { try { int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones #region Conexion BBDD string strconexion = Utilidades.CadenaConexion; int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); #endregion #region Objeto ReportDocument //creo un objeto ReportDocument ReportDocument rdCurriculum = new ReportDocument(); try { rdCurriculum.Load(Server.MapPath(".") + @"\..\Reports\cvt_curriculum.rpt"); } catch (Exception ex) { rdCurriculum.Close(); rdCurriculum.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdCurriculum.SetDatabaseLogon(strUid, strPwd); } catch (Exception ex) { rdCurriculum.Close(); rdCurriculum.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } #endregion #region Objeto Logon //creo un objeto logon . CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdCurriculum.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdCurriculum.Close(); rdCurriculum.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } #endregion DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); #region Parametros Report //string strFiltros = (Request.Form["hdnFiltros"] == null) ? Request.Form["ctl00$CPHC$hdnFiltros"] : Request.Form["hdnFiltros"]; //string[] sFiltros = Regex.Split(strFiltros,"{filtro}"); string[] sFiltros = Regex.Split(Request.QueryString["FILTROS"], "{filtro}"); string[] aDesglose = Regex.Split(sFiltros[1], "{valor}"); //Desglose (DO,FOR,FACAD,CUR,CURIMP,CERT,IDI,EXP,ENIBER,FUERA) string[] aDesgloseFACAD = Regex.Split(sFiltros[20], "{valor}"); //Desglose FORMACION ACADEMICA (Tipo, Modalidad, Tic, FInicio, FFIn) string[] aDesgloseIdioma = Regex.Split(sFiltros[21], "{valor}"); //Desglose IDIOMAS (Lectura, Escritura, Oral, Titulo, F.Obtencion) string[] aDesgloseDO = Regex.Split(sFiltros[22], "{valor}"); //Desglose Datos Organizativos (Empresa, Unidad de negocio, CR, Antifuedad, Rol, Perfil, Oficina, Provincia, Pais, Trayectoria, Movilidad, Observaciones) string[] aDesgloseCURREC = Regex.Split(sFiltros[23], "{valor}"); //Desglose CURSOS RECIBIDOS (Proveedor, Entorno tecnologico, Provincia, Horas, F.Inicio, F. Fin) string[] aDesgloseCERTEXAM = Regex.Split(sFiltros[24], "{valor}"); //Desglose Certificados (Proveedor, Entorno tecnologico, F.Obtencion, Tipo) string[] aDesgloseEXPFUERA = Regex.Split(sFiltros[25], "{valor}"); //Desglose EXPeriencia FUERA de Ibermatica (Empresa Origen, Cliente, Funcion, F Inicio, F Fin, Descripcion, ACS-ACT, Sector, Segmento, Perfil, Entorno, Nº mes) string[] aDesgloseEXPIBER = Regex.Split(sFiltros[26], "{valor}"); //Desglose EXPeriencia en IBERmatica(Cliente, Funcion, F Inicio, F Fin, Descripcion, ACS-ACT, Sector, Segmento, Perfil, Entorno, Nº mes) string[] aDesgloseDP = Regex.Split(sFiltros[27], "{valor}"); //Desglose Datos Personales(Foto, NIF, F Nacimiento, Nacionalidad, Sexo) string[] aDesgloseCURIMP = Regex.Split(sFiltros[28], "{valor}"); //Desglose CURSOS IMPARTIDOS (Proveedor, Entorno tecnologico, Provincia, Horas, F.Inicio, F. Fin) string strTipoFormato = sFiltros[18]; //Tipo formato rdCurriculum.SetParameterValue("formato_expiber", strTipoFormato); //Tipo de formato rdCurriculum.SetParameterValue("formato_expfuera", strTipoFormato); //Tipo de formato try { rdCurriculum.SetParameterValue("@t001_idficepi", sFiltros[0]); //Si es un Encargado de CV o un Consultor de CV en el impreso figurará el Perfil de Mercado if (User.IsInRole("ECV") || User.IsInRole("EVAL") || User.IsInRole("VSN4") || User.IsInRole("VSN3") || User.IsInRole("VSN2") || User.IsInRole("VSN1") || User.IsInRole("VN")) { rdCurriculum.SetParameterValue("EsSoloUsuario", "N"); } else { rdCurriculum.SetParameterValue("EsSoloUsuario", "S"); } //FORMACION //FormacionAcad rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "FormacionAcad"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@t019_idcodtitulo", (sFiltros[4] == "") ? 0 : int.Parse(sFiltros[4]), "FormacionAcad"); //IdcodTitulo rdCurriculum.SetParameterValue("@t019_descripcion", sFiltros[3], "FormacionAcad"); //Titulacion rdCurriculum.SetParameterValue("@t019_tipo", (sFiltros[5] == "") ? 0 : int.Parse(sFiltros[5]), "FormacionAcad"); //Tipologia rdCurriculum.SetParameterValue("@t019_modalidad", (sFiltros[6] == "") ? 0 : int.Parse(sFiltros[6]), "FormacionAcad"); //Modalidad rdCurriculum.SetParameterValue("@t019_tic", (sFiltros[7] == "") ? 3 : int.Parse(sFiltros[7]), "FormacionAcad"); //Tic //CurRecibidos rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "CurRecibidos"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@lft036_idcodentorno", sFiltros[10], "CurRecibidos"); //Lista EntornoTecnologicos Formacion //CurImpartidos rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "CurImpartidos"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@lft036_idcodentorno", sFiltros[10], "CurImpartidos"); //Lista EntornoTecnologicos Formacion //CertExam rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "CertExam"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@t582_nombre", sFiltros[8], "CertExam"); //certificado rdCurriculum.SetParameterValue("@t582_idcertificado", (sFiltros[9] == "") ? 0 : int.Parse(sFiltros[9]), "CertExam"); //IdCertificado rdCurriculum.SetParameterValue("@lft036_idcodentorno", sFiltros[10], "CertExam"); //Lista EntornoTecnologicos Formacion rdCurriculum.SetParameterValue("@origenConsulta", (sFiltros[19] == "") ? 1 : int.Parse(sFiltros[19]), "CertExam"); //origenConsulta 0 MiCV 1 Consultas //Idiomas rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "Idiomas"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@t020_idcodidioma", (sFiltros[11] == "") ? 0 : int.Parse(sFiltros[11]), "Idiomas"); //IdIdioma rdCurriculum.SetParameterValue("@nivelidioma", (sFiltros[12] == "") ? 0 : int.Parse(sFiltros[12]), "Idiomas"); //NivelIdioma //EXPERIENCIA PROFESIONAL //ExpFuera rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "ExpFuera"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@nombrecuenta", sFiltros[13], "ExpFuera"); //Clientes/Cuentas rdCurriculum.SetParameterValue("@idcuenta", (sFiltros[14] == "") ? 0 : int.Parse(sFiltros[14]), "ExpFuera"); //Id Clientes/Cuentas rdCurriculum.SetParameterValue("@t483_idsector", (sFiltros[15] == "") ? 0 : int.Parse(sFiltros[15]), "ExpFuera"); //IdSector rdCurriculum.SetParameterValue("@t035_codperfile", (sFiltros[16] == "") ? 0 : int.Parse(sFiltros[16]), "ExpFuera"); //IdPerfil rdCurriculum.SetParameterValue("@let036_idcodentorno", sFiltros[17], "ExpFuera"); //Lista EntornoTecnologicos Experiencia //ExpIber rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "ExpIber"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@nombrecuenta", sFiltros[13], "ExpIber"); //Clientes/Cuentas rdCurriculum.SetParameterValue("@idcuenta", (sFiltros[14] == "") ? 0 : int.Parse(sFiltros[14]), "ExpIber"); //Id Clientes/Cuentas rdCurriculum.SetParameterValue("@t483_idsector", (sFiltros[15] == "") ? 0 : int.Parse(sFiltros[15]), "ExpIber"); //IdSector rdCurriculum.SetParameterValue("@t035_codperfile", (sFiltros[16] == "") ? 0 : int.Parse(sFiltros[16]), "ExpIber"); //IdPerfil rdCurriculum.SetParameterValue("@let036_idcodentorno", sFiltros[17], "ExpIber"); //Lista EntornoTecnologicos Experiencia rdCurriculum.SetParameterValue("visible_dorganizativos", aDesglose[0]); rdCurriculum.SetParameterValue("visible_formacion", aDesglose[1]); //Formacion(Titulo) rdCurriculum.SetParameterValue("visible_formacad", aDesglose[2]); //Formacion Academica (SubReport) rdCurriculum.SetParameterValue("visible_currec", aDesglose[3]); //Acciones formativas recibidas (SubReport) rdCurriculum.SetParameterValue("visible_curimp", aDesglose[4]); //Acciones formativas impartidas (SubReport) rdCurriculum.SetParameterValue("visible_certexam", aDesglose[5]); //Certificados Examenes (SubReport) rdCurriculum.SetParameterValue("visible_idiomas", aDesglose[6]); //Idiomas (SubReport) rdCurriculum.SetParameterValue("visible_experiencia", aDesglose[7]); //Experiencia profesional (Titulo) rdCurriculum.SetParameterValue("visible_expfuera", aDesglose[8]); //Experiencia en Ibermatica (SubReport) rdCurriculum.SetParameterValue("visible_expiber", aDesglose[9]); //Experiencia fuera de Ibermatica (SubReport) //DESGLOSE FORMACION ACADEMICA rdCurriculum.SetParameterValue("visible_FACADTipo", aDesgloseFACAD[0]); //Formacion Academica Tipo (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADModalidad", aDesgloseFACAD[1]); //Formacion Academica Modalidad (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADTic", aDesgloseFACAD[2]); //Formacion Academica Tic (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADFInicio", aDesgloseFACAD[3]); //Formacion Academica FInicio (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADFFin", aDesgloseFACAD[4]); //Formacion Academica FFin (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADEspecialidad", aDesgloseFACAD[5]); //Formacion Academica Especialidad (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADCentro", aDesgloseFACAD[6]); //Formacion Academica Centro (Dato SubReport) //DESGLOSE IDIOMAS rdCurriculum.SetParameterValue("visible_IdiomaLectura", aDesgloseIdioma[0]); //Idioma Lectura (Dato SubReport) rdCurriculum.SetParameterValue("visible_IdiomaEscritura", aDesgloseIdioma[1]); //Idioma Escritura (Dato SubReport) rdCurriculum.SetParameterValue("visible_IdiomaOral", aDesgloseIdioma[2]); //Idioma Oral (Dato SubReport) rdCurriculum.SetParameterValue("visible_IdiomaTitulo", aDesgloseIdioma[3]); //Idioma Titulo (Dato SubReport) rdCurriculum.SetParameterValue("visible_IdiomaFObtencion", aDesgloseIdioma[4]); //Idioma FObtencion (Dato SubReport) rdCurriculum.SetParameterValue("visible_IdiomaCentro", aDesgloseIdioma[5]); //Idioma Centro (Dato SubReport) //DESGLOSE Datos Organizativos rdCurriculum.SetParameterValue("visible_DOEmpresa", aDesgloseDO[0]); //Datos organizativos Empresa rdCurriculum.SetParameterValue("visible_DOUnidadNegocio", aDesgloseDO[1]); //Datos organizativos Unidad de negocio rdCurriculum.SetParameterValue("visible_DOCR", aDesgloseDO[2]); //Datos organizativos CR rdCurriculum.SetParameterValue("visible_DOFAntiguedad", aDesgloseDO[3]); //Datos organizativos F.Antiguedad rdCurriculum.SetParameterValue("visible_DORol", aDesgloseDO[4]); //Datos organizativos Rol rdCurriculum.SetParameterValue("visible_DOPerfil", aDesgloseDO[5]); //Datos organizativos Perfil rdCurriculum.SetParameterValue("visible_DOOficina", aDesgloseDO[6]); //Datos organizativos Oficina rdCurriculum.SetParameterValue("visible_DOProvincia", aDesgloseDO[7]); //Datos organizativos Provincia rdCurriculum.SetParameterValue("visible_DOPais", aDesgloseDO[8]); //Datos organizativos Pais rdCurriculum.SetParameterValue("visible_DOTrayectoria", aDesgloseDO[9]); //Datos organizativos Trayectoria rdCurriculum.SetParameterValue("visible_DOMovilidad", aDesgloseDO[10]); //Datos organizativos Movilidad rdCurriculum.SetParameterValue("visible_DOObservaciones", aDesgloseDO[11]); //Datos organizativos Observaciones //DESGLOSE CURsos RECibidos rdCurriculum.SetParameterValue("visible_CURRECProveedor", aDesgloseCURREC[0]); //Cursos Recibidos Proveedor (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECEntornoTecno", aDesgloseCURREC[1]); //Cursos Recibidos Entorno tecnologico (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECProvincia", aDesgloseCURREC[2]); //Cursos Recibidos Provincia (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECHoras", aDesgloseCURREC[3]); //Cursos Recibidos Horas (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECFInicio", aDesgloseCURREC[4]); //Cursos Recibidos F. Inicio(Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECFFin", aDesgloseCURREC[5]); //Cursos Recibidos F. Fin (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECTipo", aDesgloseCURREC[6]); //Cursos Recibidos Tipo (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECModalidad", aDesgloseCURREC[7]); //Cursos Recibidos Modalidad (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECContenido", aDesgloseCURREC[8]); //Cursos Recibidos Contenido (Dato SubReport) //DESGLOSE Certificados rdCurriculum.SetParameterValue("visible_CERTEXAMProveedor", aDesgloseCERTEXAM[0]); //Certificados Proveedor (Dato SubReport) rdCurriculum.SetParameterValue("visible_CERTEXAMEntornoTecno", aDesgloseCERTEXAM[1]); //Certificados Entorno tecnologico (Dato SubReport) rdCurriculum.SetParameterValue("visible_CERTEXAMFObtencion", aDesgloseCERTEXAM[2]); //Certificados F. Obtencion(Dato SubReport) rdCurriculum.SetParameterValue("visible_CERTEXAMTipo", aDesgloseCERTEXAM[3]); //Certificados Tipo (Dato SubReport) rdCurriculum.SetParameterValue("visible_CERTEXAMFCaducidad", aDesgloseCERTEXAM[4]); //Certificados F. Caducidad (Dato SubReport) //DESGLOSE EXPERIENCIA FUERA rdCurriculum.SetParameterValue("visible_EXPFUERAEmpresaOri", aDesgloseEXPFUERA[0]); //Experiencia Fuera Empresa Origen (Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERACliente", aDesgloseEXPFUERA[1]); //Experiencia Fuera Cliente(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAFuncion", aDesgloseEXPFUERA[2]); //Experiencia Fuera Funcion(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAFinicio", aDesgloseEXPFUERA[3]); //Experiencia Fuera Fecha Inicio(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAFFin", aDesgloseEXPFUERA[4]); //Experiencia Fuera Fecha Fin(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERADescripcion", aDesgloseEXPFUERA[5]); //Experiencia Fuera Descripcion(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAACSACT", aDesgloseEXPFUERA[6]); //Experiencia Fuera ACS-ACT(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERASector", aDesgloseEXPFUERA[7]); //Experiencia Fuera Sector(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERASegmento", aDesgloseEXPFUERA[8]); //Experiencia Fuera Segmento(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAPerfil", aDesgloseEXPFUERA[9]); //Experiencia Fuera Perfil(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAEntorno", aDesgloseEXPFUERA[10]); //Experiencia Fuera Entorno(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERANmes", aDesgloseEXPFUERA[11]); //Experiencia Fuera Nº Mes(Dato SubReport) //DESGLOSE EXPERIENCIA IBERMATICA rdCurriculum.SetParameterValue("visible_EXPIBERCliente", aDesgloseEXPIBER[0]); //Experiencia Ibermatica Cliente(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERFuncion", aDesgloseEXPIBER[1]); //Experiencia Ibermatica Funcion(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERFinicio", aDesgloseEXPIBER[2]); //Experiencia Ibermatica Fecha Inicio(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERFFin", aDesgloseEXPIBER[3]); //Experiencia Ibermatica Fecha Fin(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERDescripcion", aDesgloseEXPIBER[4]); //Experiencia Ibermatica Descripcion(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERACSACT", aDesgloseEXPIBER[5]); //Experiencia Ibermatica ACS-ACT(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERSector", aDesgloseEXPIBER[6]); //Experiencia Ibermatica Sector(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERSegmento", aDesgloseEXPIBER[7]); //Experiencia Ibermatica Segmento(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERPerfil", aDesgloseEXPIBER[8]); //Experiencia Ibermatica Perfil(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBEREntorno", aDesgloseEXPIBER[9]); //Experiencia Ibermatica Entorno(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERNmes", aDesgloseEXPIBER[10]); //Experiencia Ibermatica Nº Mes(Dato SubReport) //DESGLOSE DATOS PERSONALES rdCurriculum.SetParameterValue("visible_DPFoto", aDesgloseDP[0]); //Datos Personales FOTO rdCurriculum.SetParameterValue("visible_DPNIF", aDesgloseDP[1]); //Datos Personales NIF rdCurriculum.SetParameterValue("visible_DPFNacimiento", aDesgloseDP[2]); //Datos Personales F Nacimiento rdCurriculum.SetParameterValue("visible_DPNacionalidad", aDesgloseDP[3]); //Datos Personales Nacionalidad rdCurriculum.SetParameterValue("visible_DPSexo", aDesgloseDP[4]); //Datos Personales Sexo //DESGLOSE CURsos IMPartidos rdCurriculum.SetParameterValue("visible_CURIMPProveedor", aDesgloseCURIMP[0]); //Cursos Impartidos Proveedor (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPEntornoTecno", aDesgloseCURIMP[1]); //Cursos Impartidos Entorno tecnologico (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPProvincia", aDesgloseCURIMP[2]); //Cursos Impartidos Provincia (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPHoras", aDesgloseCURIMP[3]); //Cursos Impartidos Horas (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPFInicio", aDesgloseCURIMP[4]); //Cursos Impartidos F. Inicio(Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPFFin", aDesgloseCURIMP[5]); //Cursos Impartidos F. Fin (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPTipo", aDesgloseCURIMP[6]); //Cursos Impartidos Tipo (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPModalidad", aDesgloseCURIMP[7]); //Cursos Impartidos Modalidad (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPContenido", aDesgloseCURIMP[8]); //Cursos Impartidos Contenido (Dato SubReport) } catch (Exception ex) { rdCurriculum.Close(); rdCurriculum.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } #endregion #region Exportar a disco //string strFichero = aCIP[0]; string strFichero = Session["IDFICEPI_CVT_ACTUAL"].ToString(); strFichero = Server.MapPath(".") + @"\" + strFichero; if (strTipoFormato == "PDF") { exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat; strFichero = strFichero + ".pdf"; } else { // WORD exportOpts.ExportFormatType = ExportFormatType.EditableRTF; strFichero = strFichero + ".doc"; } exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; // set the disk file options //diskOpts.DiskFileName = Server.MapPath(".") + @"\" + strFichero; diskOpts.DiskFileName = strFichero; exportOpts.ExportDestinationOptions = diskOpts; try { rdCurriculum.Export(exportOpts); } catch (Exception ex) { rdCurriculum.Close(); rdCurriculum.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } #endregion #region Enviar por correo string strMensaje = ""; string strCabecera = ""; string strDatos = ""; string strAsunto = ""; string strTO = ""; strAsunto = "Aviso de CURVIT"; strCabecera = @" <LABEL class='TITULO'>Adjuntamos los curriculums de las personas que se muestran a continuación:</LABEL>"; //string strNombreProfesionales = (Request.Form["hdnNombreProfesionales"] == null) ? Request.Form["ctl00$CPHC$hdnNombreProfesionales"] : Request.Form["hdnNombreProfesionales"]; //string[] aNombreProfesionales = Regex.Split(strNombreProfesionales, @"/"); string[] aNombreProfesionales = Regex.Split(Request.QueryString["NOMBREPROFESIONALES"], @"/"); strDatos = "<br><br><table id='tblTitulo' width='100%' class='texto' border='0' cellspacing='0' cellpadding='0'>"; for (int i = 0; i < aNombreProfesionales.Length; i++) { if (aNombreProfesionales[i] == "") { continue; } strDatos += "<tr>"; strDatos += "<td width='100%'>- " + aNombreProfesionales[i].ToString() + "</td>"; strDatos += "</tr>"; } strDatos += "</table>"; ArrayList aListCorreo = new ArrayList(); //string strDestinatarios = (Request.Form["hdnDestinatarios"] == null) ? Request.Form["ctl00$CPHC$hdnDestinatarios"] : Request.Form["hdnDestinatarios"]; //string[] aDestinatarios = Regex.Split(strDestinatarios, @","); string[] aDestinatarios = Regex.Split(Request.QueryString["DESTINATARIOS"], @","); for (int i = 0; i < aDestinatarios.Length; i++) { try { strMensaje = strCabecera + strDatos; strTO = aDestinatarios[i].ToString(); string[] aMail = { strAsunto, strMensaje, strTO, strFichero }; aListCorreo.Add(aMail); } catch (System.Exception objError) { Response.Write(Errores.mostrarError("Error al enviar el mail a evaluadores.", objError)); return; } } if (aDestinatarios.Length != 0) { Correo.EnviarCorreosCita(aListCorreo); } File.Delete(strFichero); Response.Write("OK"); #endregion } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } Response.End(); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones #region Conexion BBDD string strconexion = Utilidades.CadenaConexion; int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); #endregion #region Objeto ReportDocument //creo un objeto ReportDocument //ReportDocument rdCurriculum = new ReportDocument(); rdCurriculum = new ReportDocument(); try { rdCurriculum.Load(Server.MapPath(".") + @"\..\Reports\cvt_curriculum.rpt"); } catch (Exception ex) { rdCurriculum.Close(); rdCurriculum.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdCurriculum.SetDatabaseLogon(strUid, strPwd); } catch (Exception ex) { rdCurriculum.Close(); rdCurriculum.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } #endregion #region Objeto Logon //creo un objeto logon . CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdCurriculum.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdCurriculum.Close(); rdCurriculum.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } #endregion DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); #region Parametros Report string strFiltros = (Request.Form["hdnFiltros"] == null) ? Request.Form["ctl00$CPHC$hdnFiltros"] : Request.Form["hdnFiltros"]; string[] sFiltros = Regex.Split(strFiltros, "{filtro}"); string[] aDesglose = Regex.Split(sFiltros[1], "{valor}"); //Desglose (DO,FOR,FACAD,CUR,CURIMP,CERT,IDI,EXP,ENIBER,FUERA) string[] aDesgloseFACAD = Regex.Split(sFiltros[20], "{valor}"); //Desglose FORMACION ACADEMICA (Tipo, Modalidad, Tic, FInicio, FFIn) string[] aDesgloseIdioma = Regex.Split(sFiltros[21], "{valor}"); //Desglose IDIOMAS (Lectura, Escritura, Oral, Titulo, F.Obtencion) string[] aDesgloseDO = Regex.Split(sFiltros[22], "{valor}"); //Desglose Datos Organizativos (Empresa, Unidad de negocio, CR, Antifuedad, Rol, Perfil, Oficina, Provincia, Pais, Trayectoria, Movilidad, Observaciones) string[] aDesgloseCURREC = Regex.Split(sFiltros[23], "{valor}"); //Desglose CURSOS RECIBIDOS (Proveedor, Entorno tecnologico, Provincia, Horas, F.Inicio, F. Fin) string[] aDesgloseCERTEXAM = Regex.Split(sFiltros[24], "{valor}"); //Desglose Certificados (Proveedor, Entorno tecnologico, F.Obtencion, Tipo) string[] aDesgloseEXPFUERA = Regex.Split(sFiltros[25], "{valor}"); //Desglose EXPeriencia FUERA de Ibermatica (Empresa Origen, Cliente, Funcion, F Inicio, F Fin, Descripcion, ACS-ACT, Sector, Segmento, Perfil, Entorno, Nº mes) string[] aDesgloseEXPIBER = Regex.Split(sFiltros[26], "{valor}"); //Desglose EXPeriencia en IBERmatica(Cliente, Funcion, F Inicio, F Fin, Descripcion, ACS-ACT, Sector, Segmento, Perfil, Entorno, Nº mes) string[] aDesgloseDP = Regex.Split(sFiltros[27], "{valor}"); //Desglose Datos Personales(Foto, NIF, F Nacimiento, Nacionalidad, Sexo) string[] aDesgloseCURIMP = Regex.Split(sFiltros[28], "{valor}"); //Desglose CURSOS IMPARTIDOS (Proveedor, Entorno tecnologico, Provincia, Horas, F.Inicio, F. Fin) strTipoFormato = sFiltros[18]; //Tipo formato rdCurriculum.SetParameterValue("formato_expiber", strTipoFormato); //Tipo de formato rdCurriculum.SetParameterValue("formato_expfuera", strTipoFormato); //Tipo de formato try { rdCurriculum.SetParameterValue("@t001_idficepi", sFiltros[0]); //Si es un Encargado de CV o un Consultor de CV en el impreso figurará el Perfil de Mercado if (User.IsInRole("ECV") || User.IsInRole("EVAL") || User.IsInRole("VSN4") || User.IsInRole("VSN3") || User.IsInRole("VSN2") || User.IsInRole("VSN1") || User.IsInRole("VN")) { rdCurriculum.SetParameterValue("EsSoloUsuario", "N"); } else { rdCurriculum.SetParameterValue("EsSoloUsuario", "S"); } //FORMACION //FormacionAcad rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "FormacionAcad"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@t019_idcodtitulo", (sFiltros[4] == "") ? 0 : int.Parse(sFiltros[4]), "FormacionAcad"); //IdcodTitulo rdCurriculum.SetParameterValue("@t019_descripcion", sFiltros[3], "FormacionAcad"); //Titulacion rdCurriculum.SetParameterValue("@t019_tipo", (sFiltros[5] == "") ? 0 : int.Parse(sFiltros[5]), "FormacionAcad"); //Tipologia rdCurriculum.SetParameterValue("@t019_modalidad", (sFiltros[6] == "") ? 0 : int.Parse(sFiltros[6]), "FormacionAcad"); //Modalidad rdCurriculum.SetParameterValue("@t019_tic", (sFiltros[7] == "") ? 3 : int.Parse(sFiltros[7]), "FormacionAcad"); //Tic //CurRecibidos rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "CurRecibidos"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@lft036_idcodentorno", sFiltros[10], "CurRecibidos"); //Lista EntornoTecnologicos Formacion //CurImpartidos rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "CurImpartidos"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@lft036_idcodentorno", sFiltros[10], "CurImpartidos"); //Lista EntornoTecnologicos Formacion //CertExam rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "CertExam"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@t582_nombre", sFiltros[8], "CertExam"); //certificado rdCurriculum.SetParameterValue("@t582_idcertificado", (sFiltros[9] == "") ? 0 : int.Parse(sFiltros[9]), "CertExam"); //IdCertificado rdCurriculum.SetParameterValue("@lft036_idcodentorno", sFiltros[10], "CertExam"); //Lista EntornoTecnologicos Formacion rdCurriculum.SetParameterValue("@origenConsulta", (sFiltros[19] == "") ? 1 : int.Parse(sFiltros[19]), "CertExam"); //origenConsulta 0 MiCV 1 Consultas //Idiomas rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "Idiomas"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@t020_idcodidioma", (sFiltros[11] == "") ? 0 : int.Parse(sFiltros[11]), "Idiomas"); //IdIdioma rdCurriculum.SetParameterValue("@nivelidioma", (sFiltros[12] == "") ? 0 : int.Parse(sFiltros[12]), "Idiomas"); //NivelIdioma //EXPERIENCIA PROFESIONAL //ExpFuera rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "ExpFuera"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@nombrecuenta", sFiltros[13], "ExpFuera"); //Clientes/Cuentas rdCurriculum.SetParameterValue("@idcuenta", (sFiltros[14] == "") ? 0 : int.Parse(sFiltros[14]), "ExpFuera"); //Id Clientes/Cuentas rdCurriculum.SetParameterValue("@t483_idsector", (sFiltros[15] == "") ? 0 : int.Parse(sFiltros[15]), "ExpFuera"); //IdSector rdCurriculum.SetParameterValue("@t035_codperfile", (sFiltros[16] == "") ? 0 : int.Parse(sFiltros[16]), "ExpFuera"); //IdPerfil rdCurriculum.SetParameterValue("@let036_idcodentorno", sFiltros[17], "ExpFuera"); //Lista EntornoTecnologicos Experiencia //ExpIber rdCurriculum.SetParameterValue("@bfiltros", int.Parse(sFiltros[2]), "ExpIber"); //Indica si hay que filtrar o no rdCurriculum.SetParameterValue("@nombrecuenta", sFiltros[13], "ExpIber"); //Clientes/Cuentas rdCurriculum.SetParameterValue("@idcuenta", (sFiltros[14] == "") ? 0 : int.Parse(sFiltros[14]), "ExpIber"); //Id Clientes/Cuentas rdCurriculum.SetParameterValue("@t483_idsector", (sFiltros[15] == "") ? 0 : int.Parse(sFiltros[15]), "ExpIber"); //IdSector rdCurriculum.SetParameterValue("@t035_codperfile", (sFiltros[16] == "") ? 0 : int.Parse(sFiltros[16]), "ExpIber"); //IdPerfil rdCurriculum.SetParameterValue("@let036_idcodentorno", sFiltros[17], "ExpIber"); //Lista EntornoTecnologicos Experiencia rdCurriculum.SetParameterValue("visible_dorganizativos", aDesglose[0]); rdCurriculum.SetParameterValue("visible_formacion", aDesglose[1]); //Formacion(Titulo) rdCurriculum.SetParameterValue("visible_formacad", aDesglose[2]); //Formacion Academica (SubReport) rdCurriculum.SetParameterValue("visible_currec", aDesglose[3]); //Acciones formativas recibidas (SubReport) rdCurriculum.SetParameterValue("visible_curimp", aDesglose[4]); //Acciones formativas impartidas (SubReport) rdCurriculum.SetParameterValue("visible_certexam", aDesglose[5]); //Certificados Examenes (SubReport) rdCurriculum.SetParameterValue("visible_idiomas", aDesglose[6]); //Idiomas (SubReport) rdCurriculum.SetParameterValue("visible_experiencia", aDesglose[7]); //Experiencia profesional (Titulo) rdCurriculum.SetParameterValue("visible_expfuera", aDesglose[8]); //Experiencia en Ibermatica (SubReport) rdCurriculum.SetParameterValue("visible_expiber", aDesglose[9]); //Experiencia fuera de Ibermatica (SubReport) //SINOPSIS rdCurriculum.SetParameterValue("visible_sinopsis", aDesglose[10]);//Sinopsis(Titulo) //DESGLOSE FORMACION ACADEMICA rdCurriculum.SetParameterValue("visible_FACADTipo", aDesgloseFACAD[0]); //Formacion Academica Tipo (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADModalidad", aDesgloseFACAD[1]); //Formacion Academica Modalidad (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADTic", aDesgloseFACAD[2]); //Formacion Academica Tic (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADFInicio", aDesgloseFACAD[3]); //Formacion Academica FInicio (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADFFin", aDesgloseFACAD[4]); //Formacion Academica FFin (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADEspecialidad", aDesgloseFACAD[5]); //Formacion Academica Especialidad (Dato SubReport) rdCurriculum.SetParameterValue("visible_FACADCentro", aDesgloseFACAD[6]); //Formacion Academica Centro (Dato SubReport) //DESGLOSE IDIOMAS rdCurriculum.SetParameterValue("visible_IdiomaLectura", aDesgloseIdioma[0]); //Idioma Lectura (Dato SubReport) rdCurriculum.SetParameterValue("visible_IdiomaEscritura", aDesgloseIdioma[1]); //Idioma Escritura (Dato SubReport) rdCurriculum.SetParameterValue("visible_IdiomaOral", aDesgloseIdioma[2]); //Idioma Oral (Dato SubReport) rdCurriculum.SetParameterValue("visible_IdiomaTitulo", aDesgloseIdioma[3]); //Idioma Titulo (Dato SubReport) rdCurriculum.SetParameterValue("visible_IdiomaFObtencion", aDesgloseIdioma[4]); //Idioma FObtencion (Dato SubReport) rdCurriculum.SetParameterValue("visible_IdiomaCentro", aDesgloseIdioma[5]); //Idioma Centro (Dato SubReport) //DESGLOSE Datos Organizativos rdCurriculum.SetParameterValue("visible_DOEmpresa", aDesgloseDO[0]); //Datos organizativos Empresa rdCurriculum.SetParameterValue("visible_DOUnidadNegocio", aDesgloseDO[1]); //Datos organizativos Unidad de negocio rdCurriculum.SetParameterValue("visible_DOCR", aDesgloseDO[2]); //Datos organizativos CR rdCurriculum.SetParameterValue("visible_DOFAntiguedad", aDesgloseDO[3]); //Datos organizativos F.Antiguedad rdCurriculum.SetParameterValue("visible_DORol", aDesgloseDO[4]); //Datos organizativos Rol rdCurriculum.SetParameterValue("visible_DOPerfil", aDesgloseDO[5]); //Datos organizativos Perfil rdCurriculum.SetParameterValue("visible_DOOficina", aDesgloseDO[6]); //Datos organizativos Oficina rdCurriculum.SetParameterValue("visible_DOProvincia", aDesgloseDO[7]); //Datos organizativos Provincia rdCurriculum.SetParameterValue("visible_DOPais", aDesgloseDO[8]); //Datos organizativos Pais rdCurriculum.SetParameterValue("visible_DOTrayectoria", aDesgloseDO[9]); //Datos organizativos Trayectoria rdCurriculum.SetParameterValue("visible_DOMovilidad", aDesgloseDO[10]); //Datos organizativos Movilidad rdCurriculum.SetParameterValue("visible_DOObservaciones", aDesgloseDO[11]); //Datos organizativos Observaciones //DESGLOSE CURsos RECibidos rdCurriculum.SetParameterValue("visible_CURRECProveedor", aDesgloseCURREC[0]); //Cursos Recibidos Proveedor (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECEntornoTecno", aDesgloseCURREC[1]); //Cursos Recibidos Entorno tecnologico (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECProvincia", aDesgloseCURREC[2]); //Cursos Recibidos Provincia (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECHoras", aDesgloseCURREC[3]); //Cursos Recibidos Horas (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECFInicio", aDesgloseCURREC[4]); //Cursos Recibidos F. Inicio(Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECFFin", aDesgloseCURREC[5]); //Cursos Recibidos F. Fin (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECTipo", aDesgloseCURREC[6]); //Cursos Recibidos Tipo (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECModalidad", aDesgloseCURREC[7]); //Cursos Recibidos Modalidad (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURRECContenido", aDesgloseCURREC[8]); //Cursos Recibidos Contenido (Dato SubReport) //DESGLOSE Certificados rdCurriculum.SetParameterValue("visible_CERTEXAMProveedor", aDesgloseCERTEXAM[0]); //Certificados Proveedor (Dato SubReport) rdCurriculum.SetParameterValue("visible_CERTEXAMEntornoTecno", aDesgloseCERTEXAM[1]); //Certificados Entorno tecnologico (Dato SubReport) rdCurriculum.SetParameterValue("visible_CERTEXAMFObtencion", aDesgloseCERTEXAM[2]); //Certificados F. Obtencion(Dato SubReport) rdCurriculum.SetParameterValue("visible_CERTEXAMTipo", aDesgloseCERTEXAM[3]); //Certificados Tipo (Dato SubReport) rdCurriculum.SetParameterValue("visible_CERTEXAMFCaducidad", aDesgloseCERTEXAM[4]); //Certificados F. Caducidad (Dato SubReport) //DESGLOSE EXPERIENCIA FUERA rdCurriculum.SetParameterValue("visible_EXPFUERAEmpresaOri", aDesgloseEXPFUERA[0]); //Experiencia Fuera Empresa Origen (Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERACliente", aDesgloseEXPFUERA[1]); //Experiencia Fuera Cliente(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAFuncion", aDesgloseEXPFUERA[2]); //Experiencia Fuera Funcion(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAFinicio", aDesgloseEXPFUERA[3]); //Experiencia Fuera Fecha Inicio(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAFFin", aDesgloseEXPFUERA[4]); //Experiencia Fuera Fecha Fin(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERADescripcion", aDesgloseEXPFUERA[5]); //Experiencia Fuera Descripcion(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAACSACT", aDesgloseEXPFUERA[6]); //Experiencia Fuera ACS-ACT(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERASector", aDesgloseEXPFUERA[7]); //Experiencia Fuera Sector(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERASegmento", aDesgloseEXPFUERA[8]); //Experiencia Fuera Segmento(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAPerfil", aDesgloseEXPFUERA[9]); //Experiencia Fuera Perfil(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERAEntorno", aDesgloseEXPFUERA[10]); //Experiencia Fuera Entorno(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPFUERANmes", aDesgloseEXPFUERA[11]); //Experiencia Fuera Nº Mes(Dato SubReport) //DESGLOSE EXPERIENCIA IBERMATICA rdCurriculum.SetParameterValue("visible_EXPIBERCliente", aDesgloseEXPIBER[0]); //Experiencia Ibermatica Cliente(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERFuncion", aDesgloseEXPIBER[1]); //Experiencia Ibermatica Funcion(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERFinicio", aDesgloseEXPIBER[2]); //Experiencia Ibermatica Fecha Inicio(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERFFin", aDesgloseEXPIBER[3]); //Experiencia Ibermatica Fecha Fin(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERDescripcion", aDesgloseEXPIBER[4]); //Experiencia Ibermatica Descripcion(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERACSACT", aDesgloseEXPIBER[5]); //Experiencia Ibermatica ACS-ACT(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERSector", aDesgloseEXPIBER[6]); //Experiencia Ibermatica Sector(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERSegmento", aDesgloseEXPIBER[7]); //Experiencia Ibermatica Segmento(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERPerfil", aDesgloseEXPIBER[8]); //Experiencia Ibermatica Perfil(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBEREntorno", aDesgloseEXPIBER[9]); //Experiencia Ibermatica Entorno(Dato SubReport) rdCurriculum.SetParameterValue("visible_EXPIBERNmes", aDesgloseEXPIBER[10]); //Experiencia Ibermatica Nº Mes(Dato SubReport) //DESGLOSE DATOS PERSONALES rdCurriculum.SetParameterValue("visible_DPFoto", aDesgloseDP[0]); //Datos Personales FOTO rdCurriculum.SetParameterValue("visible_DPNIF", aDesgloseDP[1]); //Datos Personales NIF rdCurriculum.SetParameterValue("visible_DPFNacimiento", aDesgloseDP[2]); //Datos Personales F Nacimiento rdCurriculum.SetParameterValue("visible_DPNacionalidad", aDesgloseDP[3]); //Datos Personales Nacionalidad rdCurriculum.SetParameterValue("visible_DPSexo", aDesgloseDP[4]); //Datos Personales Sexo //SINOPSIS //DESGLOSE CURsos IMPartidos rdCurriculum.SetParameterValue("visible_CURIMPProveedor", aDesgloseCURIMP[0]); //Cursos Impartidos Proveedor (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPEntornoTecno", aDesgloseCURIMP[1]); //Cursos Impartidos Entorno tecnologico (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPProvincia", aDesgloseCURIMP[2]); //Cursos Impartidos Provincia (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPHoras", aDesgloseCURIMP[3]); //Cursos Impartidos Horas (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPFInicio", aDesgloseCURIMP[4]); //Cursos Impartidos F. Inicio(Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPFFin", aDesgloseCURIMP[5]); //Cursos Impartidos F. Fin (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPTipo", aDesgloseCURIMP[6]); //Cursos Impartidos Tipo (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPModalidad", aDesgloseCURIMP[7]); //Cursos Impartidos Modalidad (Dato SubReport) rdCurriculum.SetParameterValue("visible_CURIMPContenido", aDesgloseCURIMP[8]); //Cursos Impartidos Contenido (Dato SubReport) } catch (Exception ex) { rdCurriculum.Close(); rdCurriculum.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } #endregion strNombreProfesionales = Request.Form[prefijo + "hdnNombreProfesionales"]; trackingId = Request.Form[prefijo + "hdnTrackingId"]; nombreDoc = trackingId; strDestinatarios = Request.Form[prefijo + "hdnDestinatarios"]; strDestinatariosIdFicepi = Request.Form[prefijo + "hdnDestinatarioIdFicepi"]; if (Request.Form[prefijo + "rdbTipoExp"] == "0") //Petición On line { #region Exportacion try { Response.ClearContent(); Response.ClearHeaders(); System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { case "PDF": Response.AddHeader("content-type", "application/pdf; charset=utf-8"); Response.AddHeader("Content-Disposition", "attachment;filename=\"Curriculum.pdf\""); // PDF oStream = rdCurriculum.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "WORD": Response.AddHeader("content-type", "application/msword; charset=utf-8"); Response.AddHeader("Content-Disposition", "attachment; filename=\"Curriculum.doc\""); // WORD (Para que el fichero sea editable y los textos se recoloquen usamos el RTF) //rdCurriculum.ExportToHttpResponse(ExportFormatType.WordForWindows, Response, false, "Exportacion"); //rdCurriculum.ExportToHttpResponse(ExportFormatType.EditableRTF, Response, false, "Exportacion"); //Response.End(); //string sFileName = @"D:\tmp\wordresult\" + Guid.NewGuid().ToString() + ".doc"; sFileName = Request.PhysicalApplicationPath + "TempImagesGraficos\\" + Guid.NewGuid().ToString() + ".doc"; rdCurriculum.ExportToDisk(ExportFormatType.EditableRTF, sFileName); byteArray = System.IO.File.ReadAllBytes(sFileName.ToString()); break; case "EXC": rdCurriculum.ExportToHttpResponse(ExportFormatType.Excel, Response, false, "Exportacion"); break; } if (Request.QueryString["descargaToken"] != null) { Response.AppendCookie(new HttpCookie("fileDownloadToken", Request.QueryString["descargaToken"].ToString())); //downloadTokenValue will have been provided in the form submit via the hidden input field } Response.BinaryWrite(byteArray); Response.Flush(); //Response.Close(); //Response.End(); } catch (Exception ex) { rdCurriculum.Close(); rdCurriculum.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } finally { rdCurriculum.Close(); rdCurriculum.Dispose(); } #endregion } else // Correo { enviarCorreoConfPedido(); ThreadStart ts = new ThreadStart(GenerarCorreoCV); Thread workerThread = new Thread(ts); workerThread.Start(); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; //IB.Progress.Models.Estadisticas rf = new IB.Progress.Models.Estadisticas(); // string pf = "ctl00$CPHC$"; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = IB.Progress.Shared.Database.GetConStr(); int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdFormulario = new ReportDocument(); string IdEvaluacion = Utils.decodpar(Request.QueryString["IdEvaluacion"].ToString()); int iModelo = int.Parse(Request.QueryString["modelo"].ToString()); try { if (iModelo == 1) { rdFormulario.Load(Server.MapPath(".") + @"\pro_formulario_mod_1_salto.rpt"); } else { rdFormulario.Load(Server.MapPath(".") + @"\pro_formulario_mod_2_salto.rpt"); } } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdFormulario.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdFormulario.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } string strTipoFormato = "PDF"; // Request.QueryString[pf + "FORMATO"]; // ESTO LO RECOGERE COMO PARAMETRO strControl = strTipoFormato; DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); try { int idficepiConectado = int.Parse(((IB.Progress.Models.Profesional)HttpContext.Current.Session["PROFESIONAL"]).t001_idficepi.ToString()); rdFormulario.SetParameterValue("@idvaloraciones", IdEvaluacion); rdFormulario.SetParameterValue("@t001_idficepi_encurso", idficepiConectado); //rdFormulario.SetParameterValue("@idvaloraciones", "18435"); rdFormulario.SetParameterValue("path", Server.MapPath(".") + "//"); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdFormulario.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC": oStream = rdFormulario.ExportToStream(ExportFormatType.Excel); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; } // FIN //Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "EXC": // EXCEL Response.ContentType = "application/vnd.ms-excel"; //Response.ContentType = "Application/x-msexcel"; break; } Response.Clear(); //String nav = HttpContext.Current.Request.Browser.Browser.ToString(); //if (nav.IndexOf("IE") == -1) //{ switch (strTipoFormato) { case "PDF": //Response.AddHeader //("Content-Disposition", "attachment;filename=Filename.pdf"); break; case "EXC": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.xls"); break; } //} Response.BinaryWrite(byteArray); Response.Flush(); Response.Close(); //HttpContext.Current.Response.End(); Response.End(); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { string pf = "ctl00$CPHC$"; int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = GASVI.DAL.Conexion.GetCadenaConexion; int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdFormulario = new ReportDocument(); try { rdFormulario.Load(Server.MapPath(".") + @"\PagoConcertado.rpt"); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdFormulario.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdFormulario.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } //rdFormulario.SetParameterValue("@sReferencia", Request.Form[pf + "hdnReferencia"].ToString()); if (Request.Form[pf + "hdnReferencia"] != null) { rdFormulario.SetParameterValue("@sReferencia", Request.Form[pf + "hdnReferencia"].ToString()); } else { rdFormulario.SetParameterValue("@sReferencia", Request.Form["hdnReferencia"].ToString()); } //rdFormulario.SetParameterValue("path", Server.MapPath(".") + "//"); string sPath = Server.MapPath("."); rdFormulario.SetParameterValue("path", sPath.Substring(0, sPath.IndexOf("INFORMES") + 8) + "//Images//"); DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); //string strTipoFormato = Request.QueryString["FORMATO"]; // ESTO LO RECOGERE COMO PARAMETRO //string strTipoFormato = "PDF"; ExportOptions exportOpts = new ExportOptions(); try { System.IO.Stream oStream = rdFormulario.ExportToStream(ExportFormatType.PortableDocFormat); byte[] byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); rdFormulario.Close(); rdFormulario.Dispose(); // FIN Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.Buffer = true; //String nav = HttpContext.Current.Request.Browser.Browser.ToString(); //if (nav.IndexOf("IE") == -1) //{ Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.pdf")); Response.ContentType = "application/pdf"; //} Response.BinaryWrite(byteArray); //Response.Flush(); //Response.Close(); Response.End(); } catch (Exception ex) { rdFormulario.Close(); rdFormulario.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //pointerle any exceptions catch (Exception ex) { Response.Write("Report could not be created: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; //IB.Progress.Models.Estadisticas rf = new IB.Progress.Models.Estadisticas(); // string pf = "ctl00$CPHC$"; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = IB.Progress.Shared.Database.GetConStr(); int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdEstadisticas = new ReportDocument(); int iOpcion = int.Parse(Request.QueryString["opcion"].ToString()); int iPantalla = int.Parse(Request.QueryString["pantalla"].ToString()); int iModelo = 0; try { if (iPantalla == 1) { if ((iOpcion >= 1 && iOpcion <= 6)) { rdEstadisticas.Load(Server.MapPath(".") + @"\estadisticas_modelo_1.rpt"); } if ((iOpcion >= 7 && iOpcion <= 18)) { rdEstadisticas.Load(Server.MapPath(".") + @"\estadisticas_modelo_2.rpt"); } } if (iPantalla == 2) { if (iOpcion == 1 || iOpcion == 3 || iOpcion == 5 || iOpcion == 6 || iOpcion == 7 || iOpcion == 9 || iOpcion == 10 || iOpcion == 11 || (iOpcion >= 13 && iOpcion <= 19 && iOpcion != 16)) { rdEstadisticas.Load(Server.MapPath(".") + @"\estadisticas_modelo_2.rpt"); } else if (iOpcion == 25 || iOpcion == 31) { rdEstadisticas.Load(Server.MapPath(".") + @"\estadisticas_modelo_4.rpt"); } else { rdEstadisticas.Load(Server.MapPath(".") + @"\estadisticas_modelo_3.rpt"); } } } catch (Exception ex) { rdEstadisticas.Close(); rdEstadisticas.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdEstadisticas.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdEstadisticas.Close(); rdEstadisticas.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon . CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdEstadisticas.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdEstadisticas.Close(); rdEstadisticas.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } string strTipoFormato = "PDF"; // Request.QueryString[pf + "FORMATO"]; // ESTO LO RECOGERE COMO PARAMETRO strControl = strTipoFormato; DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); try { IB.Progress.Models.Estadisticas rf = new IB.Progress.Models.Estadisticas(); IB.Progress.Models.OtrasEstadisticasRRHH rf2 = new IB.Progress.Models.OtrasEstadisticasRRHH(); if (iPantalla == 1) { rf = (IB.Progress.Models.Estadisticas)Session["FiltrosInforme"]; } else { rf2 = (IB.Progress.Models.OtrasEstadisticasRRHH)Session["FiltrosInforme"]; } IB.Progress.Models.ParamsRPT rfParamsRpt = (IB.Progress.Models.ParamsRPT)Session["ParamsRPT"]; string sTitulo = String.Empty; if (iPantalla == 1) { switch (iOpcion) { case 1: sTitulo = "Profesionales dependientes evaluados"; break; case 2: sTitulo = "Profesionales dependientes evaluados"; break; case 3: sTitulo = "Profesionales dependientes no evaluados"; break; case 4: sTitulo = "Profesionales dependientes no evaluados"; break; case 5: sTitulo = "Profesionales dependientes"; break; case 6: sTitulo = "Profesionales dependientes"; break; case 7: sTitulo = "Profesionales dependientes con evaluaciones abiertas"; break; case 8: sTitulo = "Profesionales dependientes con evaluaciones abiertas"; break; case 9: sTitulo = "Profesionales dependientes con evaluaciones en curso"; break; case 10: sTitulo = "Profesionales dependientes con evaluaciones en curso"; break; case 11: sTitulo = "Profesionales dependientes con evaluaciones cerradas"; break; case 12: sTitulo = "Profesionales dependientes con evaluaciones cerradas"; break; case 13: sTitulo = "Profesionales dependientes con evaluaciones cerradas y firmadas"; break; case 14: sTitulo = "Profesionales dependientes con evaluaciones cerradas y firmadas"; break; case 15: sTitulo = "Profesionales dependientes con evaluaciones cerradas sin firmar"; break; case 16: sTitulo = "Profesionales dependientes con evaluaciones cerradas sin firmar"; break; case 17: sTitulo = "Profesionales dependientes con evaluaciones"; break; case 18: sTitulo = "Profesionales dependientes con evaluaciones"; break; } } else if (iPantalla == 2) { switch (iOpcion) { case 1: sTitulo = "Profesionales-evaluaciones con evaluaciones abiertas"; break; case 2: sTitulo = "Evaluadores con evaluaciones abiertas"; break; case 3: sTitulo = "Profesionales-evaluaciones con evaluaciones en curso"; break; case 4: sTitulo = "Evaluadores con evaluacioens en curso"; break; case 5: sTitulo = "Profesionales-evaluaciones con evaluaciones cerradas"; break; case 6: sTitulo = "Profesionales-evaluaciones con evaluaciones cerradas válidas"; break; case 7: sTitulo = "Profesionales-evaluaciones con evaluaciones cerradas no válidas"; break; case 8: sTitulo = "Evaluadores con evaluaciones cerradas"; break; case 9: sTitulo = "Profesionales-evaluacioenes con evaluaciones cerradas firmadas"; break; case 10: sTitulo = "Profesionales-evaluaciones con evaluaciones cerradas firmadas válidas"; break; case 11: sTitulo = "Profesionales-evaluaciones con evaluaciones cerradas firmadas no válidas"; break; case 12: sTitulo = "Evaluadores con evaluaciones cerradas firmadas"; break; case 13: sTitulo = "Profesionales-evaluaciones con evaluaciones cerradas sin firmar"; break; case 14: sTitulo = "Profesionales-evaluaciones con evaluaciones cerradas sin firmar válidas"; break; case 15: sTitulo = "Profesionales-evaluaciones con evaluaciones cerradas sin firmar no válidas"; break; case 16: sTitulo = "Evaluadores con evaluaciones cerradas sin firmar"; break; case 17: sTitulo = "Total de profesionales-evaluaciones"; break; case 18: sTitulo = "Total de profesionales-evaluaciones con evaluaciones válidas"; break; case 19: sTitulo = "Total de profesionales-evaluaciones con evaluaciones no válidas"; break; case 20: sTitulo = "Total de evaluadores con evaluaciones"; break; case 21: sTitulo = "Evaluadores sin confirmar equipo"; break; case 22: sTitulo = "Evaluadores con el equipo confirmado"; break; case 23: sTitulo = "Total evaluadores"; break; case 24: sTitulo = "Profesionales sin evaluador"; break; case 25: sTitulo = "Profesionales con evaluaciones abiertas"; break; case 26: sTitulo = "Profesionales con evaluaciones en curso"; break; case 27: sTitulo = "Profesionales con evaluaciones cerradas"; break; case 28: sTitulo = "Profesionales con evaluaciones cerradas firmadas"; break; case 29: sTitulo = "Profesionales con evaluaciones cerradas sin firmar"; break; case 30: sTitulo = "Total profesionales con evaluaciones"; break; case 31: sTitulo = "Total profesionales sin evaluación"; break; } } if (iPantalla == 1) { if (iOpcion >= 1 && iOpcion <= 6) { iModelo = 1; } if (iOpcion >= 7 && iOpcion <= 18) { iModelo = 2; } } if (iPantalla == 2) { if (iOpcion == 1 || iOpcion == 3 || iOpcion == 5 || iOpcion == 6 || iOpcion == 7 || iOpcion == 9 || iOpcion == 10 || iOpcion == 11 || (iOpcion >= 13 && iOpcion <= 19 && iOpcion != 16)) { iModelo = 2; } else if (iOpcion == 25 || iOpcion == 31) { iModelo = 4; } else { iModelo = 3; } } if (iModelo == 1) { //Parámetros Modelo 1 rdEstadisticas.SetParameterValue("@opcion", iOpcion); rdEstadisticas.SetParameterValue("@t932_idfoto", (rf.t932_idfoto == null) ? null : rf.t932_idfoto); rdEstadisticas.SetParameterValue("@desde", rf.Desde); rdEstadisticas.SetParameterValue("@hasta", rf.Hasta); rdEstadisticas.SetParameterValue("@t001_fecantigu", rf.t001_fecantigu); //rdEstadisticas.SetParameterValue("@t001_fecantigu", (rf.t001_fecantigu == null) ? null : rf.t001_fecantigu); rdEstadisticas.SetParameterValue("@profundidad", rf.Profundidad); rdEstadisticas.SetParameterValue("@t001_idficepi", rf.t001_idficepi); rdEstadisticas.SetParameterValue("@t941_idcolectivo", (rf.t941_idcolectivo == null) ? null : rf.t941_idcolectivo); rdEstadisticas.SetParameterValue("Situacion", rfParamsRpt.txtSituacion.ToString()); rdEstadisticas.SetParameterValue("Sexo", (rfParamsRpt.sexo == null) ? "" : rfParamsRpt.sexo.ToString()); rdEstadisticas.SetParameterValue("Evaluador", rfParamsRpt.txtEvaluador.ToString()); rdEstadisticas.SetParameterValue("Profundizacion", rfParamsRpt.txtProfundizacion.ToString()); //rdEstadisticas.SetParameterValue("AntiguedadReferencia", rf.t001_fecantigu.ToString()); if (iOpcion == 1 || iOpcion == 3 || iOpcion == 5) { rdEstadisticas.SetParameterValue("AntiguedadReferencia", ""); } else { rdEstadisticas.SetParameterValue("AntiguedadReferencia", rf.t001_fecantigu.ToShortDateString()); } rdEstadisticas.SetParameterValue("Colectivo", rfParamsRpt.txtColectivo.ToString()); } else if (iModelo == 2) { rdEstadisticas.SetParameterValue("@pantalla", iPantalla); if (iPantalla == 1) { //Parámetros Modelo 1 rdEstadisticas.SetParameterValue("@opcion1", iOpcion); rdEstadisticas.SetParameterValue("@t932_idfoto", (rf.t932_idfoto == null) ? null : rf.t932_idfoto); rdEstadisticas.SetParameterValue("@desde", rf.Desde); rdEstadisticas.SetParameterValue("@hasta", rf.Hasta); rdEstadisticas.SetParameterValue("@t001_fecantigu", rf.t001_fecantigu); //rdEstadisticas.SetParameterValue("@t001_fecantigu", (rf.t001_fecantigu == null) ? null : rf.t001_fecantigu); rdEstadisticas.SetParameterValue("@profundidad", rf.Profundidad); rdEstadisticas.SetParameterValue("@t001_idficepi", rf.t001_idficepi); rdEstadisticas.SetParameterValue("@t941_idcolectivo", (rf.t941_idcolectivo == null) ? null : rf.t941_idcolectivo); //Parámetros Modelo 2 rdEstadisticas.SetParameterValue("@opcion2", null); rdEstadisticas.SetParameterValue("@desde_evaluaciones", null); rdEstadisticas.SetParameterValue("@hasta_evaluaciones", null); rdEstadisticas.SetParameterValue("@t001_fecantigu_evaluaciones", null); rdEstadisticas.SetParameterValue("@estadoprofesional_evaluaciones", null); rdEstadisticas.SetParameterValue("@t941_idcolectivo_evaluaciones", null); rdEstadisticas.SetParameterValue("@t930_denominacionCR_evaluaciones", null); rdEstadisticas.SetParameterValue("@t303_idnodo_evaluadores", null); rdEstadisticas.SetParameterValue("@desde_colectivos", null); rdEstadisticas.SetParameterValue("@hasta_colectivos", null); rdEstadisticas.SetParameterValue("@t001_fecantigu_colectivos", null); rdEstadisticas.SetParameterValue("@t303_idnodo_colectivos", null); rdEstadisticas.SetParameterValue("@t941_idcolectivo_colectivos", null); rdEstadisticas.SetParameterValue("@t001_idficepievaluador_colectivos", null); rdEstadisticas.SetParameterValue("Submodelo", 1); rdEstadisticas.SetParameterValue("Estado", ""); rdEstadisticas.SetParameterValue("CR", ""); if (iOpcion == 7 || iOpcion == 9 || iOpcion == 11 || iOpcion == 13 || iOpcion == 15 || iOpcion == 17) { rdEstadisticas.SetParameterValue("AntiguedadReferencia", ""); } else { rdEstadisticas.SetParameterValue("AntiguedadReferencia", rf.t001_fecantigu.ToShortDateString()); } } else if (iPantalla == 2) { //Parámetros Modelo 1 rdEstadisticas.SetParameterValue("@opcion1", null); rdEstadisticas.SetParameterValue("@t932_idfoto", null); rdEstadisticas.SetParameterValue("@desde", null); rdEstadisticas.SetParameterValue("@hasta", null); rdEstadisticas.SetParameterValue("@t001_fecantigu", null); rdEstadisticas.SetParameterValue("@profundidad", null); rdEstadisticas.SetParameterValue("@t001_idficepi", null); rdEstadisticas.SetParameterValue("@t941_idcolectivo", null); //Parámetros Modelo 2 rdEstadisticas.SetParameterValue("@opcion2", iOpcion); rdEstadisticas.SetParameterValue("@desde_evaluaciones", rf2.Desde); rdEstadisticas.SetParameterValue("@hasta_evaluaciones", rf2.Hasta); rdEstadisticas.SetParameterValue("@t001_fecantigu_evaluaciones", rf2.t001_fecantigu); //rdEstadisticas.SetParameterValue("@t001_fecantigu_evaluaciones", "20141103"); //rdEstadisticas.SetParameterValue("@t001_fecantigu_evaluaciones", (rf2.t001_fecantigu == null) ? null : rf.t001_fecantigu); rdEstadisticas.SetParameterValue("@estadoprofesional_evaluaciones", (rf2.estado == null) ? null : rf2.estado.ToString()); rdEstadisticas.SetParameterValue("@t941_idcolectivo_evaluaciones", (rf2.t941_idcolectivo == null) ? null : rf2.t941_idcolectivo); rdEstadisticas.SetParameterValue("@t930_denominacionCR_evaluaciones", (rf2.t930_denominacionCR == "")? null : rf2.t930_denominacionCR); rdEstadisticas.SetParameterValue("@t303_idnodo_evaluadores", (rf2.T303_idnodo_evaluadores == null) ? null : rf2.T303_idnodo_evaluadores); rdEstadisticas.SetParameterValue("@desde_colectivos", rf2.DesdeColectivos); rdEstadisticas.SetParameterValue("@hasta_colectivos", rf2.HastaColectivos); rdEstadisticas.SetParameterValue("@t001_fecantigu_colectivos", rf2.T001_fecantiguColectivos); //rdEstadisticas.SetParameterValue("@t001_fecantigu_colectivos", "20150216"); //rdEstadisticas.SetParameterValue("@t001_fecantigu_colectivos", (rf2.T001_fecantiguColectivos == null) ? null : rf2.T001_fecantiguColectivos); rdEstadisticas.SetParameterValue("@t303_idnodo_colectivos", (rf2.T303_idnodo_colectivos == null) ? null : rf2.T303_idnodo_colectivos); rdEstadisticas.SetParameterValue("@t941_idcolectivo_colectivos", (rf2.T941_idcolectivo_colectivos == null) ? null : rf2.T941_idcolectivo_colectivos); rdEstadisticas.SetParameterValue("@t001_idficepievaluador_colectivos", rf2.t001_idficepi); rdEstadisticas.SetParameterValue("Submodelo", 2); rdEstadisticas.SetParameterValue("Estado", rfParamsRpt.txtEstado.ToString()); rdEstadisticas.SetParameterValue("CR", rfParamsRpt.txtCR_Evaluaciones.ToString()); //rdEstadisticas.SetParameterValue("AntiguedadReferencia", rf2.t001_fecantigu); rdEstadisticas.SetParameterValue("AntiguedadReferencia", rf2.t001_fecantigu.ToShortDateString()); } rdEstadisticas.SetParameterValue("Situacion", rfParamsRpt.txtSituacion.ToString()); rdEstadisticas.SetParameterValue("Sexo", (rfParamsRpt.sexo == null) ? "" : rfParamsRpt.sexo.ToString()); rdEstadisticas.SetParameterValue("Evaluador", rfParamsRpt.txtEvaluador.ToString()); rdEstadisticas.SetParameterValue("Profundizacion", rfParamsRpt.txtProfundizacion.ToString()); rdEstadisticas.SetParameterValue("Colectivo", rfParamsRpt.txtColectivo.ToString()); } else if (iModelo == 3) { rdEstadisticas.SetParameterValue("@opcion", iOpcion); rdEstadisticas.SetParameterValue("@desde_evaluaciones", rf2.Desde); rdEstadisticas.SetParameterValue("@hasta_evaluaciones", rf2.Hasta); rdEstadisticas.SetParameterValue("@t001_fecantigu_evaluaciones", rf2.t001_fecantigu); //rdEstadisticas.SetParameterValue("@t001_fecantigu_evaluaciones", (rf2.t001_fecantigu == null) ? null : rf.t001_fecantigu); rdEstadisticas.SetParameterValue("@estadoprofesional_evaluaciones", (rf2.estado == null) ? null : rf2.estado.ToString()); rdEstadisticas.SetParameterValue("@t941_idcolectivo_evaluaciones", rf2.t941_idcolectivo); rdEstadisticas.SetParameterValue("@t930_denominacionCR_evaluaciones", (rf2.t930_denominacionCR == "") ? null : rf2.t930_denominacionCR); rdEstadisticas.SetParameterValue("@t303_idnodo_evaluadores", (rf2.T303_idnodo_evaluadores == null) ? null : rf2.T303_idnodo_evaluadores); rdEstadisticas.SetParameterValue("@desde_colectivos", rf2.DesdeColectivos); rdEstadisticas.SetParameterValue("@hasta_colectivos", rf2.HastaColectivos); rdEstadisticas.SetParameterValue("@t001_fecantigu_colectivos", rf2.T001_fecantiguColectivos); rdEstadisticas.SetParameterValue("@t303_idnodo_colectivos", (rf2.T303_idnodo_colectivos == null) ? null : rf2.T303_idnodo_colectivos); rdEstadisticas.SetParameterValue("@t941_idcolectivo_colectivos", (rf2.T941_idcolectivo_colectivos == null) ? null : rf2.T941_idcolectivo_colectivos); rdEstadisticas.SetParameterValue("@t001_idficepievaluador_colectivos", rf2.t001_idficepi); if (iOpcion == 2 || iOpcion == 4 || iOpcion == 8 || iOpcion == 12 || iOpcion == 16 || iOpcion == 20) { rdEstadisticas.SetParameterValue("Submodelo", 1); } if (iOpcion >= 21 && iOpcion <= 24) { rdEstadisticas.SetParameterValue("Submodelo", 2); } if (iOpcion >= 25 && iOpcion <= 31) { rdEstadisticas.SetParameterValue("Submodelo", 3); } rdEstadisticas.SetParameterValue("Sexo", (rfParamsRpt.sexo == null) ? "" : rfParamsRpt.sexo.ToString()); rdEstadisticas.SetParameterValue("Estado", rfParamsRpt.txtEstado.ToString()); rdEstadisticas.SetParameterValue("CR_Evaluaciones", rfParamsRpt.txtCR_Evaluaciones.ToString()); rdEstadisticas.SetParameterValue("CR_Evaluadores", rfParamsRpt.txtCR_Evaluadores.ToString()); rdEstadisticas.SetParameterValue("CR_Profesionales", rfParamsRpt.txtCR_Profesionales.ToString()); //rdEstadisticas.SetParameterValue("AntiguedadReferencia", rf2.t001_fecantigu.ToString()); rdEstadisticas.SetParameterValue("AntiguedadReferencia", rf2.t001_fecantigu.ToShortDateString()); rdEstadisticas.SetParameterValue("AntiguedadReferenciaColectivo", rf2.T001_fecantiguColectivos.ToString()); rdEstadisticas.SetParameterValue("Evaluador", rfParamsRpt.txtEvaluador); rdEstadisticas.SetParameterValue("Colectivo", rfParamsRpt.txtColectivoProgress.ToString()); } else if (iModelo == 4) { rdEstadisticas.SetParameterValue("@opcion", iOpcion); rdEstadisticas.SetParameterValue("@desde_evaluaciones", rf2.Desde); rdEstadisticas.SetParameterValue("@hasta_evaluaciones", rf2.Hasta); rdEstadisticas.SetParameterValue("@t001_fecantigu_evaluaciones", rf2.t001_fecantigu); //rdEstadisticas.SetParameterValue("@t001_fecantigu_evaluaciones", (rf2.t001_fecantigu == null) ? null : rf.t001_fecantigu); rdEstadisticas.SetParameterValue("@estadoprofesional_evaluaciones", (rf2.estado == null) ? null : rf2.estado.ToString()); rdEstadisticas.SetParameterValue("@t941_idcolectivo_evaluaciones", rf2.t941_idcolectivo); rdEstadisticas.SetParameterValue("@t930_denominacionCR_evaluaciones", (rf2.t930_denominacionCR == "") ? null : rf2.t930_denominacionCR); rdEstadisticas.SetParameterValue("@t303_idnodo_evaluadores", (rf2.T303_idnodo_evaluadores == null) ? null : rf2.T303_idnodo_evaluadores); rdEstadisticas.SetParameterValue("@desde_colectivos", rf2.DesdeColectivos); rdEstadisticas.SetParameterValue("@hasta_colectivos", rf2.HastaColectivos); rdEstadisticas.SetParameterValue("@t001_fecantigu_colectivos", rf2.T001_fecantiguColectivos); rdEstadisticas.SetParameterValue("@t303_idnodo_colectivos", (rf2.T303_idnodo_colectivos == null) ? null : rf2.T303_idnodo_colectivos); rdEstadisticas.SetParameterValue("@t941_idcolectivo_colectivos", (rf2.T941_idcolectivo_colectivos == null) ? null : rf2.T941_idcolectivo_colectivos); rdEstadisticas.SetParameterValue("@t001_idficepievaluador_colectivos", rf2.t001_idficepi); //if (iOpcion == 25 || iOpcion == 31) rdEstadisticas.SetParameterValue("Submodelo", 4); rdEstadisticas.SetParameterValue("Submodelo", 4); rdEstadisticas.SetParameterValue("Sexo", (rfParamsRpt.sexo == null) ? "" : rfParamsRpt.sexo.ToString()); rdEstadisticas.SetParameterValue("Estado", rfParamsRpt.txtEstado.ToString()); rdEstadisticas.SetParameterValue("CR_Evaluaciones", rfParamsRpt.txtCR_Evaluaciones.ToString()); rdEstadisticas.SetParameterValue("CR_Evaluadores", rfParamsRpt.txtCR_Evaluadores.ToString()); rdEstadisticas.SetParameterValue("CR_Profesionales", rfParamsRpt.txtCR_Profesionales.ToString()); //rdEstadisticas.SetParameterValue("AntiguedadReferencia", rf2.t001_fecantigu.ToString()); rdEstadisticas.SetParameterValue("AntiguedadReferencia", rf2.t001_fecantigu.ToShortDateString()); rdEstadisticas.SetParameterValue("AntiguedadReferenciaColectivo", rf2.T001_fecantiguColectivos.ToString()); rdEstadisticas.SetParameterValue("Evaluador", rfParamsRpt.txtEvaluador); rdEstadisticas.SetParameterValue("Colectivo", rfParamsRpt.txtColectivoProgress.ToString()); } rdEstadisticas.SetParameterValue("Titulo", sTitulo); rdEstadisticas.SetParameterValue("FechaDesde", rfParamsRpt.fecDesde.ToString()); rdEstadisticas.SetParameterValue("FechaHasta", rfParamsRpt.fecHasta.ToString()); } catch (Exception ex) { rdEstadisticas.Close(); rdEstadisticas.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdEstadisticas.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC": oStream = rdEstadisticas.ExportToStream(ExportFormatType.Excel); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; } // FIN //Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "EXC": // EXCEL Response.ContentType = "application/vnd.ms-excel"; //Response.ContentType = "Application/x-msexcel"; break; } Response.Clear(); //String nav = HttpContext.Current.Request.Browser.Browser.ToString(); //if (nav.IndexOf("IE") == -1) //{ switch (strTipoFormato) { case "PDF": //Response.AddHeader //("Content-Disposition", "attachment;filename=Filename.pdf"); break; case "EXC": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.xls"); break; } //} Response.BinaryWrite(byteArray); Response.Flush(); Response.Close(); //HttpContext.Current.Response.End(); Response.End(); } catch (Exception ex) { rdEstadisticas.Close(); rdEstadisticas.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { bool bMostrar = true; int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; string pf = "ctl00$CPHC$"; // pf = ""; // obtengo de la cadena de conexión los parámetros para luego // modificar localizaciones string strconexion = Utilidades.CadenaConexion; int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";Trusted_Connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdInforme = new ReportDocument(); try { //rdInforme.Load(Server.MapPath(".") + @"\..\..\Rpts\sup_recursosexternos.rpt"); rdInforme.Load(Server.MapPath(".") + @"\sup_recursosexternos.rpt"); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdInforme.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon . CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdInforme.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } string strTipoFormato = Request.Form[pf + "FORMATO"]; // ESTO LO RECOGERE COMO PARAMETRO strControl = strTipoFormato; DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); try { rdInforme.SetParameterValue("@ESTADO", Request.Form[pf + "ESTADO"]); rdInforme.SetParameterValue("@CODIGO", Request.Form[pf + "CODIGO"]); //rdInforme.SetParameterValue("path", ""); rdInforme.SetParameterValue("path", Server.MapPath(".") + "//"); rdInforme.SetParameterValue("@t422_idmoneda", Session["MONEDA_VDC"].ToString()); rdInforme.SetParameterValue("ImportesEn", "* Importes en " + Session["DENOMINACION_VDC"].ToString()); //rdInforme.SetParameterValue("path", Server.MapPath(".") + "\\..\\..\\Rpts//"); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } try { System.IO.Stream oStream; byte[] byteArray = null; switch (strTipoFormato) { // PDF case "PDF": oStream = rdInforme.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC": oStream = rdInforme.ExportToStream(ExportFormatType.Excel); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); break; case "EXC2": // rdInforme.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Exportacion"); bMostrar = false; break; } // FIN if (bMostrar) { Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); //String nav = HttpContext.Current.Request.Browser.Browser.ToString(); //if (nav.IndexOf("IE") == -1) //{ switch (strTipoFormato) { case "PDF": Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.pdf")); break; case "EXC": Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", "Filename.xls")); break; } //} switch (strTipoFormato) { // PDF case "PDF": Response.ContentType = "application/pdf"; break; case "EXC": // EXCEL Response.ContentType = "application/xls"; break; } Response.BinaryWrite(byteArray); //Response.Flush(); //Response.Close(); //HttpContext.Current.Response.End(); Response.End(); } } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { // since we are using Crystal to do everything, the web page is built here if (!IsPostBack) { Session["dtPrint"] = null; if (Session["UserName"] == null) { UserPrefix = "NoUser"; } else { UserPrefix = Session["UserName"].ToString().Trim(); } if ((Request.QueryString["InvoiceNo"] != null) || (Request.QueryString["OrderNo"] != null)) { // clear out any previous user exports first DirectoryInfo OldPages = new DirectoryInfo(Server.MapPath(DocName)); if (OldPages.Exists) { // Get a reference to each file in that directory. FileInfo[] AllOldPages = OldPages.GetFiles(); // go through the files foreach (FileInfo OldPage in AllOldPages) { if (OldPage.Name.Substring(0, UserPrefix.Length) == UserPrefix) { OldPage.Delete(); } } } // get the TEST watermark indicator DataSet dsAppPref = new DataSet(); dsAppPref = SqlHelper.ExecuteDataset(connectionString, "[UGEN_SP_Select]", new SqlParameter("@tableName", "SystemMaster with (NOLOCK)"), new SqlParameter("@displayColumns", "PrintRqst"), new SqlParameter("@whereCondition", " SystemMasterID = 0")); PrintRequest = dsAppPref.Tables[0].Rows[0]["PrintRqst"].ToString().Trim(); // load the crystal report using the path in an app pref record dsAppPref = SqlHelper.ExecuteDataset(connectionString, "[UGEN_SP_Select]", new SqlParameter("@tableName", "AppPref with (NOLOCK)"), new SqlParameter("@displayColumns", "AppOptionValue"), new SqlParameter("@whereCondition", " (ApplicationCd = 'SOE') AND (AppOptionType = 'InvoiceLocation')")); CrystalPath = dsAppPref.Tables[0].Rows[0]["AppOptionValue"].ToString(); RGADoc.Load(CrystalPath + DocName + ".rpt", OpenReportMethod.OpenReportByTempCopy); // set the database connections for the report SqlConnectionStringBuilder ConnectBuilder = new SqlConnectionStringBuilder(); ConnectBuilder.ConnectionString = connectionString; ConnectionInfo ConnectInfo = new ConnectionInfo(); ConnectInfo.DatabaseName = ConnectBuilder["Initial Catalog"].ToString(); ConnectInfo.UserID = ConnectBuilder["User Id"].ToString(); ConnectInfo.Password = ConnectBuilder["Password"].ToString(); ConnectInfo.ServerName = ConnectBuilder["Data Source"].ToString(); // AutoDataBind="true" foreach (CrystalDecisions.CrystalReports.Engine.Table RGATable in RGADoc.Database.Tables) { TableLogOnInfo RGATableLogonInfo = RGATable.LogOnInfo; RGATableLogonInfo.ConnectionInfo = ConnectInfo; RGATable.ApplyLogOnInfo(RGATableLogonInfo); } //ReportDocument RGASub = new ReportDocument(); //foreach (CrystalDecisions.CrystalReports.Engine.Section RGASect in RGADoc.ReportDefinition.Sections) //{ // foreach (CrystalDecisions.CrystalReports.Engine.ReportObject RGAObj in RGASect.ReportObjects) // { // if (RGAObj.Kind == ReportObjectKind.SubreportObject) // { // RGASub = RGADoc.OpenSubreport(RGAObj.Name); // foreach (CrystalDecisions.CrystalReports.Engine.Table RGATable in RGASub.Database.Tables) // { // TableLogOnInfo RGATableLogonInfo = RGATable.LogOnInfo; // RGATableLogonInfo.ConnectionInfo = ConnectInfo; // RGATable.ApplyLogOnInfo(RGATableLogonInfo); // } // } // } //} // set the selection criteria if (Request.QueryString["InvoiceNo"] != null) { RGADoc.RecordSelectionFormula = "{SOHeaderRel.InvoiceNo}=\"" + Request.QueryString["InvoiceNo"].ToString() + "\" and isnull({SODetailRel.DeleteDt})"; } if (Request.QueryString["OrderNo"] != null) { RGADoc.RecordSelectionFormula = "{SOHeaderRel.OrderNo}=" + Request.QueryString["OrderNo"].ToString() + " and isnull({SODetailRel.DeleteDt})"; } // we are ready to go RGADoc.Refresh(); // Now set up the export DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); exportOpts.ExportFormatType = ExportFormatType.HTML40; exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; exportOpts.ExportDestinationOptions = diskOpts; HTMLFormatOptions htmlFormatOpts = new HTMLFormatOptions(); htmlFormatOpts.FirstPageNumber = 1; htmlFormatOpts.HTMLEnableSeparatedPages = true; htmlFormatOpts.HTMLHasPageNavigator = false; htmlFormatOpts.HTMLBaseFolderName = Server.MapPath(""); htmlFormatOpts.HTMLFileName = UserPrefix + "RGAExport.htm"; exportOpts.ExportFormatOptions = htmlFormatOpts; // set the parameters if (PrintRequest == "T") { RGADoc.SetParameterValue("IsTest", true); } else { RGADoc.SetParameterValue("IsTest", false); } RGADoc.Export(exportOpts); RGADoc.Close(); // now that we have created the individual pages, make one big page DirectoryInfo PageFiles = new DirectoryInfo(Server.MapPath(DocName)); // Get a reference to each file in that directory. FileInfo[] AllPages = PageFiles.GetFiles(); // start the HTML page Response.Write("<html>\n<head>\n<title>RGA Document</title>\n"); if ((Request.QueryString["ScriptX"] != null) && (Request.QueryString["ScriptX"] == "YES")) { // Embed ScriptX objects using (StreamReader sr = new StreamReader(Server.MapPath("common/include/ScriptX.inc"))) { String incline; // Read and display lines from the Spriptx include file while ((incline = sr.ReadLine()) != null) { Response.Write(incline + "\n"); } } //Response.Write("<!-- #Include virtual=\"common/include/ScriptX.inc\" -->\n"); // Load ScriptX javascript function Response.Write("<script src=\"" + ConfigurationManager.AppSettings["SOESiteURL"].ToString() + "Common/JavaScript/ScriptX.js\" type=\"text/javascript\"></script>\n"); } Response.Write("</head>\n<body style=\"margin: 0px\" >\n"); PagePosition = (decimal)0.0; foreach (FileInfo InvPage in AllPages) { // get only the files for the current user if (InvPage.Name.Substring(0, UserPrefix.Length) == UserPrefix) { WriteOK = false; Response.Write("<DIV style=\"position:absolute; top:" + PagePosition.ToString() + "pt; height:1000px; \">\n"); //Response.Write(""); using (StreamReader sr = new StreamReader(InvPage.FullName)) { String line; // Read and display lines from the file until the end of // the file is reached. while ((line = sr.ReadLine()) != null) { if (line.Contains("</BODY>")) { WriteOK = false; } if (line.Contains("<style>")) { WriteOK = true; } if (line.Contains("class=\"crystalstyle\"")) { line = line.Replace("31", "0"); } if (line.Contains("images/")) { line = line.Replace("images/", ConfigurationManager.AppSettings["SOESiteURL"].ToString() + DocName + "/images/"); } if (line.Contains("<DIV style=\"position:absolute; top:")) { WriteOK = false; } if (line.Contains("</TR></TABLE></CENTER></Div>")) { WriteOK = false; } // write the line if (WriteOK) { Response.Write(line + "\n"); } if (line.Contains("</style>")) { WriteOK = false; } if (line.Contains("<BODY")) { WriteOK = true; } } } Response.Write("</DIV>\n"); if (PagePosition == (decimal)0.0) { PagePosition += (decimal)757; } } } Response.Write("</body>\n"); if ((Request.QueryString["ScriptX"] != null) && (Request.QueryString["ScriptX"] == "YES")) { Response.Write("<script language=\"javascript\">\n"); Response.Write("SetPrintSettings(true, 0.25, 0.25, 0.25, 0.25);\n"); Response.Write("</script>\n"); } Response.Write("</html>\n"); } } }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); try { int int_pinicio; int int_pfin; string strServer; string strDataBase; string strUid; string strPwd; string strconexion = Utilidades.CadenaConexion.ToLower(); int_pfin = strconexion.IndexOf(";database=", 0); strServer = strconexion.Substring(7, int_pfin - 7); int_pinicio = int_pfin + 10; int_pfin = strconexion.IndexOf(";uid=", int_pinicio); strDataBase = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";pwd=", int_pinicio); strUid = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); int_pinicio = int_pfin + 5; int_pfin = strconexion.IndexOf(";trusted_connection=", int_pinicio); strPwd = strconexion.Substring(int_pinicio, int_pfin - int_pinicio); //creo un objeto ReportDocument ReportDocument rdInforme = new ReportDocument(); try { rdInforme.Load(Server.MapPath(".") + @"\cr2_conexionwifi.rpt"); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al abrir el report: " + ex.Message); } try { rdInforme.SetDatabaseLogon(strUid, strPwd, strServer, strDataBase); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al logarse al report: " + ex.Message); } //creo un objeto logon . CrystalDecisions.Shared.TableLogOnInfo tliCurrent; try { foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in rdInforme.Database.Tables) { //obtengo el logon por tabla tliCurrent = tbCurrent.LogOnInfo; tliCurrent.ConnectionInfo.DatabaseName = strDataBase; tliCurrent.ConnectionInfo.UserID = strUid; tliCurrent.ConnectionInfo.Password = strPwd; tliCurrent.ConnectionInfo.ServerName = strServer; //aplico los cambios hechos al objeto TableLogonInfo tbCurrent.ApplyLogOnInfo(tliCurrent); } } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al actualizar la localización: " + ex.Message); } DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); try { rdInforme.SetParameterValue("@t085_idreserva", int.Parse(Request.Form["ctl00$CPHC$hdnIDReserva"].ToString())); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al actualizar los parámetros del report: " + ex.Message); } try { System.IO.Stream oStream; byte[] byteArray = null; oStream = rdInforme.ExportToStream(ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.Clear(); string strTipoFormato = "PDF"; string nav = HttpContext.Current.Request.Browser.Browser.ToString(); if (nav.IndexOf("IE") == -1) { switch (strTipoFormato) { case "PDF": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.pdf"); break; case "EXC": Response.AddHeader ("Content-Disposition", "attachment;filename=Filename.xls"); break; } } Response.BinaryWrite(byteArray); Response.Flush(); Response.Close(); //HttpContext.Current.Response.End(); Response.End(); } catch (Exception ex) { rdInforme.Close(); rdInforme.Dispose(); Response.Write("Error al exportar el report: " + ex.Message); } } //handle any exceptions catch (Exception ex) { Response.Write("No se puede crear el report: " + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { Response.Write("test3ed"); Response.End(); // since we are using Crystal to do everything, the web page is built here if (!IsPostBack) { Session["dtPrint"] = null; if (Session["UserName"] == null) { UserPrefix = "NoUser"; } else { UserPrefix = Session["UserName"].ToString().Trim(); } if (Request.QueryString["ShipperNo"] != null) { ShipperNo = Request.QueryString["ShipperNo"].ToString(); // clear out any previous exports first DirectoryInfo OldPages = new DirectoryInfo(Server.MapPath(@"SOEShipper")); // Get a reference to each file in that directory. FileInfo[] AllOldPages = OldPages.GetFiles(); // go through the files foreach (FileInfo OldPage in AllOldPages) { if (OldPage.Name.Substring(0, UserPrefix.Length) == UserPrefix) { OldPage.Delete(); } } // load the crystal report using the path in an app pref record DataSet dsAppPref = new DataSet(); dsAppPref = SqlHelper.ExecuteDataset(connectionString, "[UGEN_SP_Select]", new SqlParameter("@tableName", "AppPref with (NOLOCK)"), new SqlParameter("@displayColumns", "AppOptionValue"), new SqlParameter("@whereCondition", " (ApplicationCd = 'SOE') AND (AppOptionType = 'InvoiceLocation')")); CrystalPath = dsAppPref.Tables[0].Rows[0]["AppOptionValue"].ToString(); Response.Write("Windows Account which runs ASP.NET is: " + Environment.Username); Response.Write("test3"); Response.End(); try { ShipperDoc.Load(CrystalPath + "SOEShipper.rpt", OpenReportMethod.OpenReportByTempCopy); } catch (Exception ex) { throw ex; } // set the database connections for the report SqlConnectionStringBuilder ConnectBuilder = new SqlConnectionStringBuilder(); ConnectBuilder.ConnectionString = connectionString; ConnectionInfo ConnectInfo = new ConnectionInfo(); ConnectInfo.DatabaseName = ConnectBuilder["Initial Catalog"].ToString(); ConnectInfo.UserID = ConnectBuilder["User Id"].ToString(); ConnectInfo.Password = ConnectBuilder["Password"].ToString(); ConnectInfo.ServerName = ConnectBuilder["Data Source"].ToString(); // AutoDataBind="true" foreach (CrystalDecisions.CrystalReports.Engine.Table ShipperTable in ShipperDoc.Database.Tables) { TableLogOnInfo ShipperTableLogonInfo = ShipperTable.LogOnInfo; ShipperTableLogonInfo.ConnectionInfo = ConnectInfo; ShipperTable.ApplyLogOnInfo(ShipperTableLogonInfo); } ShipperDoc.RecordSelectionFormula = "{SOHeaderRel.OrderNo}=" + ShipperNo; // we are ready to go ShipperDoc.Refresh(); // Now set up the export DiskFileDestinationOptions diskOpts = ExportOptions.CreateDiskFileDestinationOptions(); ExportOptions exportOpts = new ExportOptions(); exportOpts.ExportFormatType = ExportFormatType.HTML40; exportOpts.ExportDestinationType = ExportDestinationType.DiskFile; exportOpts.ExportDestinationOptions = diskOpts; HTMLFormatOptions htmlFormatOpts = new HTMLFormatOptions(); htmlFormatOpts.FirstPageNumber = 1; htmlFormatOpts.HTMLEnableSeparatedPages = true; htmlFormatOpts.HTMLHasPageNavigator = false; htmlFormatOpts.HTMLBaseFolderName = Server.MapPath(""); htmlFormatOpts.HTMLFileName = UserPrefix + "ShipperExport.htm"; exportOpts.ExportFormatOptions = htmlFormatOpts; ShipperDoc.Export(exportOpts); ShipperDoc.Close(); // now that we have created the individual pages, make one big page DirectoryInfo PageFiles = new DirectoryInfo(Server.MapPath(@"SOEShipper")); // Get a reference to each file in that directory. FileInfo[] AllPages = PageFiles.GetFiles(); // start the HTML page Response.Write("<head>\n"); // write the styles Response.Write("<style type=\"text/css\">\n"); Response.Write(".barcode{height:30px;font-size:15pt;color:#000000;font-family:IDAutomationC39M;font-weight:normal;overflow:hidden;}\n"); Response.Write("</style>\n"); // finish the header start the body Response.Write("\n<title>Shipper Document</title>\n</head>\n<body LEFTMARGIN=31 TOPMARGIN=31 >\n"); PagePosition = (decimal)0.0; foreach (FileInfo InvPage in AllPages) { // get only the files for the current user if (InvPage.Name.Substring(0, UserPrefix.Length) == UserPrefix) { WriteOK = false; Response.Write("<DIV style=\"position:absolute; left:0px; top:" + PagePosition.ToString() + "pt; height:590px \">\n"); //Response.Write(""); using (StreamReader sr = new StreamReader(InvPage.FullName)) { String line; // Read and display lines from the file until the end of // the file is reached. while ((line = sr.ReadLine()) != null) { if (line.Contains("</BODY>")) { WriteOK = false; } if (line.Contains("<style>")) { WriteOK = true; } if (line.Contains("images/")) { line = line.Replace("images/", ConfigurationManager.AppSettings["SOESiteURL"].ToString() + "SOEShipper/images/"); } // write the line if (WriteOK) { Response.Write(line + "\n"); } if (line.Contains("</style>")) { WriteOK = false; } if (line.Contains("<BODY")) { WriteOK = true; } } } Response.Write("</DIV>\n"); if (PagePosition == (decimal)0.0) { PagePosition += (decimal)590; } } } Response.Write("</body>\n</html>\n"); } } }