コード例 #1
0
        protected void btn_exportar_Click(object sender, ImageClickEventArgs e)
        {
            var filters = new object[2] {
                txt_fec_ini_o.Text, txt_fec_hasta_o.Text
            };
            var eLog = new HLogOperacion()
            {
                IDE_CONTRATO = Convert.ToInt32(ddl_contrato.SelectedItem.Value),
                TipoOper     = ddl_tipo_evento.SelectedItem.Value,
                Evento       = txt_evento_descripcion.Text
            };
            var ruta = new nLogOperacion().descargarConsultaExcel(eLog, filters);

            Response.Clear();
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", Path.GetFileName(ruta)));
            Response.TransmitFile(ruta);
            Response.End();
        }
コード例 #2
0
        public List <HLogOperacion> getListLogOperacion(HLogOperacion log, int jtStartIndex, int jtPageSize, object[] filters, out int total)
        {
            var listLogOperacion = new List <HLogOperacion>();

            try
            {
                DateTime fecha_ini = string.IsNullOrEmpty(filters[0].ToString())?new DateTime(1900, 01, 01):Convert.ToDateTime(filters[0].ToString());
                DateTime fecha_fin = string.IsNullOrEmpty(filters[1].ToString()) ? DateTime.Now : Convert.ToDateTime(filters[1].ToString());
                using (var db = new DISEntities())
                {
                    var query = db.pa_sel_LogOperacion(log.IDE_CONTRATO, log.TipoOper, fecha_ini, fecha_fin, log.Evento).ToList();
                    total = query.Count();

                    foreach (var item in query.Skip(jtStartIndex).Take(jtPageSize))
                    {
                        var logOperacion = new HLogOperacion()
                        {
                            IDE_CONTRATO = Convert.ToInt32(item.IDE_CONTRATO),
                            CONTRATO_SYS = new CONTRATO_SYS()
                            {
                                DES_CONTRATO = item.DES_CONTRATO
                            },
                            TipoOper   = item.TipoOper,
                            FechEven   = Convert.ToDateTime(item.FechEven),
                            Evento     = item.Evento,
                            TipoEvento = item.TipoEvento,
                            CodiEven   = item.CodiEven,
                            CodiUsu    = item.CodiUsu,
                            Columna    = item.Columna,
                            Tabla      = string.Format("{0} - {1}", item.tabla, item.CodiOper)
                        };

                        listLogOperacion.Add(logOperacion);
                    }
                }
                return(listLogOperacion);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #3
0
        public string descargarConsultaExcel(HLogOperacion log, object[] filters)
        {
            var helperStyle = new Helpers.excelStyle();

            try
            {
                var      nombreArchivo = string.Format("Log {0}_{1}", log.IDE_CONTRATO, DateTime.Now.ToString("yyyyMMdd"));
                var      rutaTemporal  = @HttpContext.Current.Server.MapPath("~/Temp/Descargas/" + nombreArchivo + ".xlsx");
                int      total;
                var      book        = new XSSFWorkbook();
                string[] columns     = { "Contrato", "Tabla - ID", "Tipo evento", "Fecha  evento", "Evento", "Columna - Dato", "Usuario" };
                var      sheet       = book.CreateSheet();
                var      rowBook     = sheet.CreateRow(1);
                var      headerStyle = helperStyle.setFontText(12, true, book);
                var      bodyStyle   = helperStyle.setFontText(11, false, book);
                ICell    cellBook;
                for (int i = 0; i < columns.Length; i++)
                {
                    cellBook = rowBook.CreateCell(i + 1);
                    cellBook.SetCellValue(columns[i]);
                    cellBook.CellStyle = headerStyle;
                }
                var listLogOperacion = getListLogOperacion(log, 0, 100000, filters, out total);
                for (int i = 0; i < listLogOperacion.Count; i++)
                {
                    var rowBody = sheet.CreateRow(2 + i);

                    ICell cellContrato = rowBody.CreateCell(1);
                    cellContrato.SetCellValue(listLogOperacion[i].CONTRATO_SYS.DES_CONTRATO);
                    cellContrato.CellStyle = bodyStyle;

                    ICell cellTablaId = rowBody.CreateCell(2);
                    cellTablaId.SetCellValue(listLogOperacion[i].Tabla);
                    cellTablaId.CellStyle = bodyStyle;

                    ICell cellTipoEvento = rowBody.CreateCell(3);
                    cellTipoEvento.SetCellValue(listLogOperacion[i].TipoEvento);
                    cellTipoEvento.CellStyle = bodyStyle;

                    ICell cellFechaEvento = rowBody.CreateCell(4);
                    cellFechaEvento.SetCellValue(listLogOperacion[i].FechEven.ToString());
                    cellFechaEvento.CellStyle = bodyStyle;

                    ICell cellEvento = rowBody.CreateCell(5);
                    cellEvento.SetCellValue(listLogOperacion[i].Evento);
                    cellEvento.CellStyle = bodyStyle;

                    ICell cellColDato = rowBody.CreateCell(6);
                    cellColDato.SetCellValue(listLogOperacion[i].Columna);
                    cellColDato.CellStyle = bodyStyle;

                    ICell cellUsuario = rowBody.CreateCell(7);
                    cellUsuario.SetCellValue(listLogOperacion[i].CodiUsu);
                    cellUsuario.CellStyle = bodyStyle;
                }
                if (File.Exists(rutaTemporal))
                {
                    File.Delete(rutaTemporal);
                }
                using (var file = new FileStream(rutaTemporal, FileMode.Create, FileAccess.ReadWrite))
                {
                    book.Write(file);
                    file.Close();
                    book.Close();
                }

                return(rutaTemporal);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #4
0
 public List <HLogOperacion> getListLogOperacion(HLogOperacion log, int jtStartIndex, int jtPageSize, object[] filters, out int total)
 {
     return(new dLogOperacion().getListLogOperacion(log, jtStartIndex, jtPageSize, filters, out total));
 }
コード例 #5
0
        public static object listLogOperacion(int jtStartIndex, int jtPageSize, string jtSorting, HLogOperacion log, object[] filters)
        {
            //var listLogOperacion = new nLogOperacion().getListLogOperacion(log, jtStartIndex, jtPageSize, out total);
            //return new { Result = "OK", Records = listLogOperacion, TotalRecordCount = total };
            var listLogOperacion = new nLogOperacion().getListLogOperacion(log, jtStartIndex, jtPageSize, filters, out total);

            return(new { Result = "OK", Records = listLogOperacion, TotalRecordCount = total });
        }