// Export data in XML format
        public void ExportXmlDocument(ref cXMLDocument XmlDoc, bool HasParent, ref SqlDataReader Recordset, int StartRec, int StopRec, string ExportPageType)
        {
            if (Recordset == null || XmlDoc == null)
                return;
            if (!HasParent)
                XmlDoc.AddRoot(TableVar);

            // Move to first record
            int RecCnt = StartRec - 1;
            for (int i = 1; i <= StartRec - 1; i++)
                Recordset.Read();
            while (Recordset.Read() && RecCnt < StopRec) {
                RecCnt++;
                if (RecCnt >= StartRec) {
                    int RowCnt = RecCnt - StartRec + 1;
                    LoadListRowValues(ref Recordset);

                    // Render row
                    RowType = EW_ROWTYPE_VIEW; // Render view
                    ResetAttrs();
                    RenderListRow();
                    if (HasParent)
                        XmlDoc.AddRow(TableVar, "");
                    else
                        XmlDoc.AddRow("", "");
                    if (ExportPageType == "view") {
                        XmlDoc.AddField("IdTipoVehiculo", IdTipoVehiculo.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("TipoVehiculo", TipoVehiculo.ExportValue(Export, ExportOriginalValue));
                    } else {
                        XmlDoc.AddField("IdTipoVehiculo", IdTipoVehiculo.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("TipoVehiculo", TipoVehiculo.ExportValue(Export, ExportOriginalValue));
                    }
                }
            }
        }
        // Export data in XML format
        public void ExportXmlDocument(ref cXMLDocument XmlDoc, bool HasParent, ref SqlDataReader Recordset, int StartRec, int StopRec, string ExportPageType)
        {
            if (Recordset == null || XmlDoc == null)
                return;
            if (!HasParent)
                XmlDoc.AddRoot(TableVar);

            // Move to first record
            int RecCnt = StartRec - 1;
            for (int i = 1; i <= StartRec - 1; i++)
                Recordset.Read();
            while (Recordset.Read() && RecCnt < StopRec) {
                RecCnt++;
                if (RecCnt >= StartRec) {
                    int RowCnt = RecCnt - StartRec + 1;
                    LoadListRowValues(ref Recordset);

                    // Render row
                    RowType = EW_ROWTYPE_VIEW; // Render view
                    ResetAttrs();
                    RenderListRow();
                    if (HasParent)
                        XmlDoc.AddRow(TableVar, "");
                    else
                        XmlDoc.AddRow("", "");
                    if (ExportPageType == "view") {
                        XmlDoc.AddField("IdRegistroPeaton", IdRegistroPeaton.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("IdTipoDocumento", IdTipoDocumento.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Documento", Documento.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Nombre", Nombre.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Apellidos", Apellidos.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("IdArea", IdArea.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("IdPersona", IdPersona.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("FechaIngreso", FechaIngreso.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("FechaSalida", FechaSalida.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Observacion", Observacion.ExportValue(Export, ExportOriginalValue));
                    } else {
                        XmlDoc.AddField("IdRegistroPeaton", IdRegistroPeaton.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("IdTipoDocumento", IdTipoDocumento.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Documento", Documento.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Nombre", Nombre.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Apellidos", Apellidos.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("IdArea", IdArea.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("IdPersona", IdPersona.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("FechaIngreso", FechaIngreso.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("FechaSalida", FechaSalida.ExportValue(Export, ExportOriginalValue));
                    }
                }
            }
        }
        // Export data in XML format
        public void ExportXmlDocument(ref cXMLDocument XmlDoc, bool HasParent, ref SqlDataReader Recordset, int StartRec, int StopRec, string ExportPageType)
        {
            if (Recordset == null || XmlDoc == null)
                return;
            if (!HasParent)
                XmlDoc.AddRoot(TableVar);

            // Move to first record
            int RecCnt = StartRec - 1;
            for (int i = 1; i <= StartRec - 1; i++)
                Recordset.Read();
            while (Recordset.Read() && RecCnt < StopRec) {
                RecCnt++;
                if (RecCnt >= StartRec) {
                    int RowCnt = RecCnt - StartRec + 1;
                    LoadListRowValues(ref Recordset);

                    // Render row
                    RowType = EW_ROWTYPE_VIEW; // Render view
                    ResetAttrs();
                    RenderListRow();
                    if (HasParent)
                        XmlDoc.AddRow(TableVar, "");
                    else
                        XmlDoc.AddRow("", "");
                    if (ExportPageType == "view") {
                        XmlDoc.AddField("IdVehiculoAutorizado", IdVehiculoAutorizado.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("IdTipoVehiculo", IdTipoVehiculo.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Placa", Placa.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Autorizado", Autorizado.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("IdPersona", IdPersona.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("PicoyPlaca", PicoyPlaca.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Lunes", Lunes.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Martes", Martes.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Miercoles", Miercoles.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Jueves", Jueves.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Viernes", Viernes.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Sabado", Sabado.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Domingo", Domingo.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Marca", Marca.ExportValue(Export, ExportOriginalValue));
                    } else {
                        XmlDoc.AddField("IdVehiculoAutorizado", IdVehiculoAutorizado.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("IdTipoVehiculo", IdTipoVehiculo.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Placa", Placa.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Autorizado", Autorizado.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("IdPersona", IdPersona.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("PicoyPlaca", PicoyPlaca.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Lunes", Lunes.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Martes", Martes.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Miercoles", Miercoles.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Jueves", Jueves.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Viernes", Viernes.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Sabado", Sabado.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Domingo", Domingo.ExportValue(Export, ExportOriginalValue));
                        XmlDoc.AddField("Marca", Marca.ExportValue(Export, ExportOriginalValue));
                    }
                }
            }
        }
Exemplo n.º 4
0
        // Export data in HTML/CSV/Word/Excel/XML/Email/PDF format
        public void ExportData()
        {
            cXMLDocument XmlDoc = null;
            cExportDocument ExportDoc = null;
            bool utf8 = ew_SameText(EW_CHARSET, "utf-8");

            // Load recordset
            SqlDataReader Rs = LoadRecordset();
            StartRec = 1;

            // Export all
            if (Areas.ExportAll) {
            DisplayRecs = TotalRecs;
            StopRec = TotalRecs;
            } else { // Export one page only
            SetUpStartRec(); // Set up start record position

            // Set the last record to display
            if (DisplayRecs < 0) {
                StopRec = TotalRecs;
            } else {
                StopRec = StartRec + DisplayRecs - 1;
            }
            }
            if (Rs == null) {
            ew_AddHeader("Content-Type", ""); // Remove header
            ew_AddHeader("Content-Disposition", "");
            ShowMessage();
            return;
            }
            if (Areas.Export == "xml") {
            XmlDoc = new cXMLDocument();
            } else {
            ExportDoc = new cExportDocument(this, Areas, "h");
            }
            string ParentTable = "";
            if (Areas.Export == "xml") {
            Areas.ExportXmlDocument(ref XmlDoc, ew_NotEmpty(ParentTable), ref Rs, StartRec, StopRec, "");
            } else {
            string sHeader = PageHeader;
            Page_DataRendering(ref sHeader);
            ExportDoc.Text += sHeader;
            Areas.ExportDocument(ref ExportDoc, ref Rs, StartRec, StopRec, "");
            string sFooter = PageFooter;
            Page_DataRendered(ref sFooter);
            ExportDoc.Text += sFooter;
            }

            // Close recordset
            Rs.Close();
            Rs.Dispose();

            // Export header and footer
            if (Areas.Export != "xml")
            ExportDoc.ExportHeaderAndFooter();

            // Clean output buffer
            if (!EW_DEBUG_ENABLED)
            HttpContext.Current.Response.Clear();

            // Write BOM if utf-8
            if (utf8 && Areas.Export != "email" && Areas.Export != "xml")
            HttpContext.Current.Response.BinaryWrite(new byte[]{0xEF, 0xBB, 0xBF});

            // Write debug message if enabled
            if (EW_DEBUG_ENABLED)
            ew_Write(ew_DebugMsg());

            // Output data
            if (Areas.Export == "xml") {
            ew_AddHeader("Content-Type", "text/xml");
            ew_Write(XmlDoc.XML());
            } else if (Areas.Export == "pdf") {
            ExportPDF(ExportDoc.Text);
            } else {
            ew_Write(ExportDoc.Text);
            }
        }
        // Export data in HTML/CSV/Word/Excel/XML/Email/PDF format
        public void ExportData()
        {
            cXMLDocument XmlDoc = null;
            cExportDocument ExportDoc = null;
            bool utf8 = ew_SameText(EW_CHARSET, "utf-8");

            // Load recordset
            SqlDataReader Rs = LoadRecordset();
            StartRec = 1;

            // Export all
            if (Personas.ExportAll) {
            DisplayRecs = TotalRecs;
            StopRec = TotalRecs;
            } else { // Export one page only
            SetUpStartRec(); // Set up start record position

            // Set the last record to display
            if (DisplayRecs < 0) {
                StopRec = TotalRecs;
            } else {
                StopRec = StartRec + DisplayRecs - 1;
            }
            }
            if (Rs == null) {
            ew_AddHeader("Content-Type", ""); // Remove header
            ew_AddHeader("Content-Disposition", "");
            ShowMessage();
            return;
            }
            if (Personas.Export == "xml") {
            XmlDoc = new cXMLDocument();
            } else {
            ExportDoc = new cExportDocument(this, Personas, "h");
            }
            string ParentTable = "";

            // Export master record
            if (EW_EXPORT_MASTER_RECORD && ew_NotEmpty(Personas.MasterFilter) && Personas.CurrentMasterTable == "Areas") {
            SqlDataReader rsmaster = Areas.LoadRs(DbMasterFilter); // Load master record
            if (rsmaster != null && rsmaster.HasRows) {
                if (Personas.Export == "xml") {
                    ParentTable = "Areas";
                    Areas.ExportXmlDocument(ref XmlDoc, false, ref rsmaster, 1, 1, "");
                } else {
                    string ExportStyle = ExportDoc.Style;
                    ExportDoc.ChangeStyle("v"); // Change to vertical
                    if (Personas.Export != "csv" || EW_EXPORT_MASTER_RECORD_FOR_CSV) {
                        Areas.ExportDocument(ref ExportDoc, ref rsmaster, 1, 1, "");
                        ExportDoc.ExportEmptyLine();
                    }
                    ExportDoc.ChangeStyle(ExportStyle); // Restore
                }
                rsmaster.Close();
                rsmaster.Dispose();
            }
            }
            if (Personas.Export == "xml") {
            Personas.ExportXmlDocument(ref XmlDoc, ew_NotEmpty(ParentTable), ref Rs, StartRec, StopRec, "");
            } else {
            string sHeader = PageHeader;
            Page_DataRendering(ref sHeader);
            ExportDoc.Text += sHeader;
            Personas.ExportDocument(ref ExportDoc, ref Rs, StartRec, StopRec, "");
            string sFooter = PageFooter;
            Page_DataRendered(ref sFooter);
            ExportDoc.Text += sFooter;
            }

            // Close recordset
            Rs.Close();
            Rs.Dispose();

            // Export header and footer
            if (Personas.Export != "xml")
            ExportDoc.ExportHeaderAndFooter();

            // Clean output buffer
            if (!EW_DEBUG_ENABLED)
            HttpContext.Current.Response.Clear();

            // Write BOM if utf-8
            if (utf8 && Personas.Export != "email" && Personas.Export != "xml")
            HttpContext.Current.Response.BinaryWrite(new byte[]{0xEF, 0xBB, 0xBF});

            // Write debug message if enabled
            if (EW_DEBUG_ENABLED)
            ew_Write(ew_DebugMsg());

            // Output data
            if (Personas.Export == "xml") {
            ew_AddHeader("Content-Type", "text/xml");
            ew_Write(XmlDoc.XML());
            } else if (Personas.Export == "pdf") {
            ExportPDF(ExportDoc.Text);
            } else {
            ew_Write(ExportDoc.Text);
            }
        }