[HttpPost]
public ActionResult ImportarIntervencionesExcel(int progrcodi, int tipoProgramacion)
{
ArchivosModel model = new ArchivosModel();
Intervencion models = new Intervencion();
models.ListaIntervenciones = new List<InIntervencionDTO>();
model.ListaDocumentos = FileServer.ListarArhivos("Files", ConfigurationManager.AppSettings[Constantes.AdjuntosFiles].ToString());
string filename = model.ListaDocumentos[model.ListaDocumentos.Count - 1].FileName;
string path = ConfigurationManager.AppSettings[Constantes.ReportesFiles].ToString();
string strUsuario = User.Identity.Name;
List<InIntervencionDTO> lstRegIntervencionesCorrectos = new List<InIntervencionDTO>();
List<InIntervencionDTO> lstRegIntervencionesErroneos = new List<InIntervencionDTO>();
IntServicio.ImportarIntervencionesXLSX(path, filename, progrcodi, tipoProgramacion, strUsuario, ref lstRegIntervencionesCorrectos, ref lstRegIntervencionesErroneos);
models.ListaIntervenciones = lstRegIntervencionesErroneos;
return PartialView(models);
}
[HttpPost]
public JsonResult GrabarIntervencionesExcel(int progrcodi, int tipoProgramacion)
{
ArchivosModel model = new ArchivosModel();
string path = ConfigurationManager.AppSettings[Constantes.ReportesFiles].ToString();
List<InIntervencionDTO> lstRegIntervencionesCorrectos = new List<InIntervencionDTO>();
List<InIntervencionDTO> lstRegIntervencionesErroneos = new List<InIntervencionDTO>();
if (lstRegIntervencionesCorrectos.Count != 0 && lstRegIntervencionesErroneos.Count != 0)
{
IntServicio.CrearIntervencion(lstRegIntervencionesCorrectos);
IntServicio.GenerarArchivoIntervencionesErroneasCSV(path, lstRegIntervencionesCorrectos);
model.ListaDocumentos = FileServer.ListarArhivos("Files", ConfigurationManager.AppSettings[Constantes.AdjuntosFiles].ToString());
string filenameCSV = model.ListaDocumentos[model.ListaDocumentos.Count - 1].FileName;
return Json(filenameCSV);
}
else
{
if (lstRegIntervencionesCorrectos.Count != 0)
{
IntServicio.CrearIntervencion(lstRegIntervencionesCorrectos);
return Json("1");
}
else
{
if (lstRegIntervencionesErroneos.Count != 0)
{
IntServicio.GenerarArchivoIntervencionesErroneasCSV(path, lstRegIntervencionesErroneos);
model.ListaDocumentos = FileServer.ListarArhivos("Files", ConfigurationManager.AppSettings[Constantes.AdjuntosFiles].ToString());
string filenameCSV = model.ListaDocumentos[model.ListaDocumentos.Count - 1].FileName;
return Json(filenameCSV);
}
else
{
return Json("-1");
}
}
}
}