20260129 - 01

This commit is contained in:
2026-01-29 13:04:08 +01:00
parent a222729a6a
commit e043d4bdee
39 changed files with 7528 additions and 67 deletions

View 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);
}
}
}
}