Merge branch 'Elena/import' into develop

# Conflicts:
#	Services/FinProcServ.cs
Elena/develop
Elena 2022-03-27 15:51:27 +02:00
commit 00182b5260
4 changed files with 106 additions and 86 deletions

View File

@ -1403,5 +1403,24 @@ namespace OliviaAddInPro.Helper
} }
/**
* Dado un nombre de capa mira si está abierta y la cierra
*/
public static bool CloseLayer(string nombCapa)
{
try
{
var lyr = MapView.Active.Map.FindLayers(nombCapa).FirstOrDefault() as FeatureLayer;
if (lyr == null)
return false;
MapView.Active.Map.RemoveLayer(lyr);
return true;
}
catch (Exception ex)
{
return false;
}
}
} }
} }

View File

@ -20,22 +20,44 @@ namespace OliviaAddInPro.Services
if (res.HasError) if (res.HasError)
{ {
msg = res.Error.First(); msg = res.Error.First();
//actualiza los flags
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecNOk);
} }
else else
{ {
msg = Resource1.String_exito; msg = Resource1.String_exito;
bool todoOk = true;
//importa resultados
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecSecto)) //Ha terminado bien la sectorización
{
/*if (!gdb.import_secto_ini())
{
todoOk=false;
msg = msg + " " + gdb.err_st;
}*/
}
else if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
{
/*guarda_csv();
if (!gdb.import_planif())
{
todoOk=false;
msg = msg + " " + gdb.err_st;
}*/
}
//actualiza los flags
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecOk);
if (todoOk)
{
//pone modo config2
OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2);
}
} }
//importa resultados
//borra los archivos que le toca borrar //borra los archivos que le toca borrar
//hay una funcion borrafiles en EjecServ, usar esa? BorraFiles();
//pone modo config2
HelperGlobal.ponMsg(msg); HelperGlobal.ponMsg(msg);
Application.Current.Dispatcher.Invoke(new Action(() => { finEjecuta2(); })); Application.Current.Dispatcher.Invoke(new Action(() => { finEjecuta2(); }));
} }
@ -46,62 +68,7 @@ namespace OliviaAddInPro.Services
OliviaGlob.ShowHidePane(true); OliviaGlob.ShowHidePane(true);
} }
//se le llama cuando ha terminado el proceso de ejecución en Olivia Tasks
//puede haber ido bien, haberse cancelado, etc. En función de ello se realizan
//unas tareas u otras
public void FinProceso()
{
bool mal = true;
string err = "";
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.FinEjecOk)) //ha terminado bien
{
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecSecto)) //Ha terminado bien la sectorización
{
/*if (gdb.import_secto_ini())
{
mal = false;
}
else
{
mal = true;
err = gdb.err_st;
}*/
}
else if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
{
/*guarda_csv();
if (gdb.import_planif())
{
mal = false;
}
else
{
mal = true;
err = gdb.err_st;
}*/
}
//actualiza los flags
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecOk);
OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2);
}
else if(OliviaGlob.HasFlagTipEjec(TiposEjecucion.FinEjecNOk)) //ha habido error
{
/*mal = true;
err = progr_eje.err_str;*/
//actualiza los flags
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecNOk);
}
if (mal)
{
HelperGlobal.ponMsg(err, System.Windows.MessageBoxImage.Error);
}
OliviaGlob.ShowHidePane(true);
}
/** /**
* Borra los archivos exportados para el proceso * Borra los archivos exportados para el proceso
@ -114,26 +81,30 @@ namespace OliviaAddInPro.Services
try try
{ {
if (capa_principal == null) if (capa_principal != null && HelperGdb.CloseLayer(capa_principal))
return;
list = System.IO.Directory.GetFiles(OliviaGlob.Paths.DirData, capa_principal + "*");
if (list.Length > 0)
{ {
foreach (string f in list) list = System.IO.Directory.GetFiles(OliviaGlob.Paths.DirData, capa_principal + "*");
if (list.Length > 0)
{ {
if (System.IO.Path.GetExtension(f) == ".lock") foreach (string f in list)
continue; {
System.IO.File.Delete(f); if (System.IO.Path.GetExtension(f) == ".lock")
continue;
System.IO.File.Delete(f);
}
} }
} }
if (capa_principal_nw == null) if (capa_principal_nw != null && HelperGdb.CloseLayer(capa_principal_nw))
return;
list = System.IO.Directory.GetFiles(OliviaGlob.Paths.DirData, capa_principal_nw + "*");
if (list.Length > 0)
{ {
foreach (string f in list) list = System.IO.Directory.GetFiles(OliviaGlob.Paths.DirData, capa_principal_nw + "*");
if (list.Length > 0)
{ {
System.IO.File.Delete(f); foreach (string f in list)
{
if (System.IO.Path.GetExtension(f) == ".lock")
continue;
System.IO.File.Delete(f);
}
} }
} }
} }

View File

@ -43,9 +43,6 @@ namespace OliviaAddInPro.Services.LanzaSrv
NombreTratamiento = NTratamiento; NombreTratamiento = NTratamiento;
add_cfg_comun(); add_cfg_comun();
//lanza ventana marchando que lanza proceso en bucle para actualizar barra progreso
//OliviaGlob.progr_eje = new ProgresoEjec();
//lanza proceso OliviaTask //lanza proceso OliviaTask
var res = lanza(); var res = lanza();
if (!res.Value) if (!res.Value)
@ -54,8 +51,6 @@ namespace OliviaAddInPro.Services.LanzaSrv
return res; return res;
} }
//OliviaGlob.progr_eje.start(str_cfg);
return res; return res;
} }
@ -107,6 +102,7 @@ namespace OliviaAddInPro.Services.LanzaSrv
GeneralDef.EjecGeoParamSep + GeneralDef.GG_pcfg + GeneralDef.EjecGeoParamIgual + OliviaGlob.Paths.PathCfg + "D:\\Proyectos\\Olivia\\Instal2.0\\cfg.ini"; GeneralDef.EjecGeoParamSep + GeneralDef.GG_pcfg + GeneralDef.EjecGeoParamIgual + OliviaGlob.Paths.PathCfg + "D:\\Proyectos\\Olivia\\Instal2.0\\cfg.ini";
pfi = new ProcessStartInfo(OliviaGlob.Paths.PathExeOlivia, args); pfi = new ProcessStartInfo(OliviaGlob.Paths.PathExeOlivia, args);
pfi.UseShellExecute = false;
System.Diagnostics.Process.Start(pfi); System.Diagnostics.Process.Start(pfi);
//comprueba que haya arrancado OliviaTask //comprueba que haya arrancado OliviaTask
@ -183,5 +179,38 @@ namespace OliviaAddInPro.Services.LanzaSrv
else else
return null; return null;
} }
/**
* Comprueba si OliviaTask ha salido y le espera durante T seg. Si no, para la tarea
* return true si ha terminado, false si no
*/
private bool EsperaProcess(string nombproc)
{
bool esta_geo = true;
Process[] pg;
//le da 3 seg de margen para que se cierre
pg = Is_process(nombproc, 1, false);
esta_geo = (pg != null);
if (esta_geo)
{
//mata a la fuerza la tarea
try
{
for (int i = 0; i < pg.Length; i++)
{
pg[i].Kill();
if (pg[i].WaitForExit(500))
esta_geo = false;
}
}
catch (Exception)
{
esta_geo = false;
}
}
return !esta_geo;
}
} }
} }

View File

@ -56,6 +56,7 @@ namespace OliviaAddInPro.Services
return res; return res;
} }
res.Value = true; res.Value = true;
return res; return res;
} }