20260129 - 01
This commit is contained in:
61
bdGrupoSanchoToro/Importaciones/ImportaCTESGESL.cs
Normal file
61
bdGrupoSanchoToro/Importaciones/ImportaCTESGESL.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bdGrupoSanchoToro.Importaciones
|
||||
{
|
||||
public class ImportaCTESGESL
|
||||
{
|
||||
public static void Importar(byte[] Fichero)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscGrupoSanchoToro.NuevoContexto();
|
||||
var le = bd.enumeraciones.ToList();
|
||||
var grs = bd.gruposenumeraciones.ToList();
|
||||
var dsprueba = new XSD.CTESGESL();
|
||||
|
||||
dsprueba.ReadXml(new System.IO.MemoryStream(Fichero));
|
||||
int i = 1;
|
||||
int Ultimalinea = dsprueba.Tables["Datos"].Rows.Count;
|
||||
foreach (XSD.CTESGESL.DatosRow Proant in dsprueba.Tables["Datos"].Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
bdGrupoSanchoToro.db.enumeraciones Pronue;
|
||||
Pronue = le.FirstOrDefault(x => x.Codigo == Proant.LCCOD.Trim());
|
||||
if (Pronue == null)
|
||||
{
|
||||
Pronue = new bdGrupoSanchoToro.db.enumeraciones();
|
||||
bd.enumeraciones.Add(Pronue);
|
||||
}
|
||||
Pronue.Codigo = Proant.LCCOD.Trim();
|
||||
int idgrupo = grs.First(x => x.Grupo == Proant.LCGRU.Trim()).idGrupoEnumeracion;
|
||||
Pronue.idGrupoEnumeracion = idgrupo;
|
||||
Pronue.ValorAlfabetico1 = Proant.LCDES.Trim();
|
||||
Pronue.Descripcion = Proant.LCVAA.Trim();
|
||||
Pronue.Orden = int.Parse(Proant.LCORD);
|
||||
i = i + 1;
|
||||
if (i > 1000)
|
||||
{
|
||||
bd.SaveChanges();
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
57
bdGrupoSanchoToro/Importaciones/ImportaFAMILIAS.cs
Normal file
57
bdGrupoSanchoToro/Importaciones/ImportaFAMILIAS.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
using bdGrupoSanchoToro.db;
|
||||
using Microsoft.VisualBasic;
|
||||
using System.Linq.Dynamic.Core;
|
||||
namespace bdGrupoSanchoToro.Importaciones
|
||||
|
||||
{
|
||||
public class ImportaFAMILIAS
|
||||
{
|
||||
public static void Importar(byte[] Fichero)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscGrupoSanchoToro.NuevoContexto();
|
||||
var ds = new XSD.FAMILIAS();
|
||||
|
||||
ds.ReadXml(new System.IO.MemoryStream(Fichero));
|
||||
int Ultimalinea = ds.Tables["Datos"].Rows.Count;
|
||||
var lf = bd.familias.ToList();
|
||||
var fams = ds.Tables["Datos"].Rows.Cast<XSD.FAMILIAS.DatosRow>().ToList();
|
||||
|
||||
foreach (XSD.FAMILIAS.DatosRow fam in fams)
|
||||
{
|
||||
try
|
||||
{
|
||||
bdGrupoSanchoToro.db.familias f = lf.FirstOrDefault(x => x.Codigo == fam.FACOD);
|
||||
if (f == null)
|
||||
{
|
||||
f = new familias()
|
||||
{
|
||||
Codigo = fam.FACOD
|
||||
};
|
||||
lf.Add(f);
|
||||
bd.familias.Add(f);
|
||||
}
|
||||
f.Descripcion = fam.FADES;
|
||||
f.CuentaContableCompra = fam.FACCC;
|
||||
f.CuentaContableVenta = fam.FACCV;
|
||||
f.CuentaContableVentaAlquiler = fam.FACCVA;
|
||||
f.CuentaContableCompraAlquiler = fam.FACCCA;
|
||||
bd.SaveChanges();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,5 @@
|
||||
using bdGrupoSanchoToro.db;
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bdGrupoSanchoToro.Importaciones
|
||||
{
|
||||
public class ImportaGRUASGC
|
||||
|
||||
130
bdGrupoSanchoToro/Importaciones/ImportaPRODUCTOS.cs
Normal file
130
bdGrupoSanchoToro/Importaciones/ImportaPRODUCTOS.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
|
||||
using bdGrupoSanchoToro.db;
|
||||
using Microsoft.VisualBasic;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Globalization;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.Importaciones
|
||||
|
||||
{
|
||||
public class ImportaPRODUCTOS
|
||||
{
|
||||
public static void Importar(byte[] Fichero)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bd = tscGrupoSanchoToro.NuevoContexto();
|
||||
var ds = new XSD.PRODUCTOS();
|
||||
|
||||
ds.ReadXml(new System.IO.MemoryStream(Fichero));
|
||||
int Ultimalinea = ds.Tables["Datos"].Rows.Count;
|
||||
var lp = bd.productos.ToList();
|
||||
var lf = bd.familias.ToList();
|
||||
var lm = bd.marcas.ToList();
|
||||
var lfh = bd.enumeraciones.Where(x=> x.idGrupoEnumeracionNavigation.Grupo=="FAMH").ToList();
|
||||
var pros = ds.Tables["Datos"].Rows.Cast<XSD.PRODUCTOS.DatosRow>().ToList();
|
||||
|
||||
foreach (XSD.PRODUCTOS.DatosRow pro in pros)
|
||||
{
|
||||
try
|
||||
{
|
||||
bdGrupoSanchoToro.db.productos p = lp.FirstOrDefault(x => x.Codigo == pro.PRCOD || x.DescripcionAbreviada.RemoveDiacritics() ==pro.PRDES.Trim().RemoveDiacritics().ToUpper() || x.Descripcion.RemoveDiacritics().ToUpper()==pro.PRDESL.Trim().RemoveDiacritics().ToUpper() );
|
||||
if (p == null)
|
||||
{
|
||||
p = new productos()
|
||||
{
|
||||
Codigo = pro.PRCOD
|
||||
};
|
||||
lp.Add(p);
|
||||
bd.productos.Add(p);
|
||||
}
|
||||
p.CodigoBarras = pro.PRCBR;
|
||||
p.Descripcion = pro.PRDESL.Trim().RemoveDiacritics().ToUpper();
|
||||
p.DescripcionAbreviada = pro.PRDES.Trim().RemoveDiacritics().ToUpper();
|
||||
p.FechaAlta = DateOnly.FromDateTime(DateTime.Now);
|
||||
familias? fam = bd.familias.FirstOrDefault(x => x.Codigo == pro.PRFAM);
|
||||
p.idFamilia = fam == null ? null : fam.idFamilia;
|
||||
if (pro.PRMAR.NothingAVacio() != "")
|
||||
{
|
||||
var mar = lm.FirstOrDefault(x => x.Marca == pro.PRMAR);
|
||||
if (mar == null)
|
||||
{
|
||||
mar = new marcas()
|
||||
{
|
||||
Marca = pro.PRMAR
|
||||
};
|
||||
lm.Add(mar);
|
||||
bd.marcas.Add(mar);
|
||||
p.idMarcaNavigation = mar;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p.idMarca = null;
|
||||
}
|
||||
p.Modelo = pro.PRMDL;
|
||||
p.Servicio = (pro.PRCFP=="AL" ? true : false);
|
||||
p.idFamiliaHomologacion = null;
|
||||
if (pro.PRFAMH!="")
|
||||
{
|
||||
var fh=lfh.FirstOrDefault(x=> x.Codigo==("FAMH." + pro.PRFAMH));
|
||||
if (fh != null)
|
||||
{
|
||||
p.idFamiliaHomologacion = fh.idEnumeracion;
|
||||
switch (fh.ValorAlfabetico1)
|
||||
{
|
||||
case "P":
|
||||
{
|
||||
p.Tipo = (int)productos.TipoProductoEnum.OTROS_PRODUCTOS;
|
||||
break;
|
||||
}
|
||||
case "C":
|
||||
{
|
||||
p.Tipo = (int)productos.TipoProductoEnum.CONSUMIBLES;
|
||||
break;
|
||||
}
|
||||
case "CG":
|
||||
{
|
||||
p.Tipo = (int)productos.TipoProductoEnum.ELEMENTO_GRUA;
|
||||
break;
|
||||
}
|
||||
case "MO":
|
||||
{
|
||||
p.Tipo = (int)productos.TipoProductoEnum.MATERIAL_OFICINA;
|
||||
break;
|
||||
}
|
||||
case "S":
|
||||
{
|
||||
p.Tipo = (int)productos.TipoProductoEnum.SERVICIO;
|
||||
break;
|
||||
}
|
||||
case "R":
|
||||
{
|
||||
p.Tipo = (int)productos.TipoProductoEnum.REPUESTO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
p.PrecioVenta = double.Parse(pro.PRPVP, CultureInfo.InvariantCulture);
|
||||
p.ReferenciaFabrica = pro.PRRFA;
|
||||
p.PrefijoNumeroSerie = pro.PRPNS;
|
||||
bd.SaveChanges();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,12 @@ namespace bdGrupoSanchoToro.Importaciones
|
||||
tscGrupoSanchoToro bd = tscGrupoSanchoToro.NuevoContexto();
|
||||
|
||||
//00
|
||||
Importa("GRUASGC", bdGrupoSanchoToro.Importaciones.ImportaGRUASGC.Importar, de); //00
|
||||
//Importa("GRUASGC", bdGrupoSanchoToro.Importaciones.ImportaGRUASGC.Importar, de); //00
|
||||
//Importa("FAMILIAS", bdGrupoSanchoToro.Importaciones.ImportaFAMILIAS.Importar, de); //00
|
||||
//Importa("FAMILIAS", bdGrupoSanchoToro.Importaciones.ImportaFAMILIAS.Importar, de); //00
|
||||
//Importa("CTESGESL", bdGrupoSanchoToro.Importaciones.ImportaCTESGESL.Importar, de); //00
|
||||
Importa("PRODUCTOS", bdGrupoSanchoToro.Importaciones.ImportaPRODUCTOS.Importar, de); //00
|
||||
|
||||
//Importa("GRUPRO", bdGrupoSanchoToro.Importaciones.ImportaGrupoProductos.Importar, de); //01
|
||||
//Importa("CAMPAÑAS", bdGrupoSanchoToro.Importaciones.ImportaCampañas.Importar, de); //02
|
||||
//Importa("PRODUCTOS", bdGrupoSanchoToro.Importaciones.ImportaProductos.Importar, de); //03
|
||||
@@ -37,7 +42,7 @@ namespace bdGrupoSanchoToro.Importaciones
|
||||
//Importa("PROVEEDORH", bdGrupoSanchoToro.Importaciones.ImportaProveedoresh.Importar, de); //25
|
||||
//Importa("CLIENTES", bdGrupoSanchoToro.Importaciones.ImportaClientes.Importar, de); //15
|
||||
//Importa("CLIENTESH", bdGrupoSanchoToro.Importaciones.ImportaClientesh.Importar, de); //26
|
||||
// Importa("PERSONAL", bdGrupoSanchoToro.Importaciones.ImportaClientesh.Importar, de); //26
|
||||
// Importa("PERSONAL", bdGrupoSanchoToro.Importaciones.ImportaClientesh.Importar, de); //26
|
||||
}
|
||||
|
||||
//public static void ImportarPersonal(DelegadoErroresImportacion de)
|
||||
@@ -70,11 +75,15 @@ namespace bdGrupoSanchoToro.Importaciones
|
||||
string Fichh = "/var/tecnosis/DATAXML/HISTORICO/" + Fichero + ".DATA";
|
||||
var sftp = ConfiguraFTPHP(bd);
|
||||
var st = new MemoryStream();
|
||||
var std = new MemoryStream();
|
||||
if (tsFluentFTP.ftp.ExisteFichero(Fich, sftp))
|
||||
{
|
||||
tsFluentFTP.ftp.DescargaFichero(Fich, st, sftp);
|
||||
st.Seek(0, 0);
|
||||
tsUtilidades.Ficheros.EliminaCaracteresInvalidosXML(st, std);
|
||||
std.Seek(0, 0);
|
||||
// tsFluentFTP.ftp.RenombraFichero(Fich,Fichh, sftp);
|
||||
return st.ToArray();
|
||||
return std.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user