Beispiel #1
0
        public List <TransaccionDTO> LeerOrdenesExcel()
        {
            this._archivos = new DirectoryInfo(_directorio).GetFiles("*.xlsx");
            List <TransaccionDTO> transacciones = new List <TransaccionDTO>();

            foreach (FileInfo archivo in this._archivos)
            {
                using (SpreadsheetDocument doc = SpreadsheetDocument.Open(archivo.FullName, false))
                {
                    Sheet             sheet     = doc.WorkbookPart.Workbook.Sheets.GetFirstChild <Sheet>();
                    Worksheet         worksheet = (doc.WorkbookPart.GetPartById(sheet.Id.Value) as WorksheetPart).Worksheet;
                    IEnumerable <Row> rows      = worksheet.GetFirstChild <SheetData>().Descendants <Row>();
                    foreach (Row row in rows)
                    {
                        if (row.RowIndex.Value >= 3)
                        {
                            Cell        cells    = row.Descendants <Cell>().Skip(1).First();
                            string      concepto = GetValue(doc, cells);
                            Transaccion tr       = new Transaccion(concepto);
                            if (!tr.esTransaccion())
                            {
                                continue;
                            }

                            VentaDAO dao       = new VentaDAO();
                            OrdenDAO _ordenDao = new OrdenDAO();
                            string   tienda    = "Sin tienda";
                            //dao.obtenerTienda(tr.WorkOrder);
                            _ordenDao.ActualizaPago(tr.WorkOrder);
                            transacciones.Add(new TransaccionDTO()
                            {
                                WorkOrden = tr.WorkOrder,
                                Tienda    = tienda
                            }
                                              );
                            this._bitacoraExcel.AgregarRow(tr.WorkOrder, tienda);
                            tr.Imprimir();
                        }
                    }
                }
                String fecha = String.Format("{0:dd-MM-yyyy_HH_mm_ss}", DateTime.Now);
                //File.Move(archivo.FullName, $"{_directorio_bitacora}\\{fecha}-{archivo.Name}");
            }

            //if (transacciones.Count > 0)
            //{
            //    String fecha = String.Format("{0:dd-MM-yyyy_HH_mm_ss}", DateTime.Now);
            //    String mes = String.Format("{0:MMMM}", DateTime.Now);
            //    String directory = $@"{this._directorio_bitacora}\{mes}";
            //    if (!Directory.Exists(directory))
            //    {
            //        Directory.CreateDirectory(directory);
            //    }
            //    Row cabecera = new Row();
            //    cabecera.Append(
            //        _bitacoraExcel.ConstructCell("WorkOrder", CellValues.String),
            //        _bitacoraExcel.ConstructCell("Tienda", CellValues.String));

            //    _bitacoraExcel.SalvarExcel($@"{directory}\{fecha}-{DateTime.Now.Millisecond}.xlsx", "informacion", cabecera);
            //}
            return(transacciones);
        }