147 lines
4.5 KiB
C#
147 lines
4.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.IO;
|
|
using OliviaAddInPro.Model;
|
|
using OliviaAddInPro.Helper;
|
|
using System.Windows;
|
|
|
|
namespace OliviaAddInPro.Services
|
|
{
|
|
public class FinProcServ
|
|
{
|
|
public void finEjecuta(Respuesta<TiposEjecucion> res)
|
|
{
|
|
|
|
String msg=string.Empty;
|
|
//gestiona los flags, el estado de finok o finnok va en res.Vale
|
|
if (res.HasError)
|
|
{
|
|
msg = res.Error.First();
|
|
}
|
|
else
|
|
{
|
|
msg = Resource1.String_exito;
|
|
}
|
|
|
|
//importa resultados
|
|
|
|
//borra los archivos que le toca borrar
|
|
//hay una funcion borrafiles en EjecServ, usar esa?
|
|
//pone modo config2
|
|
|
|
|
|
HelperGlobal.ponMsg(msg);
|
|
|
|
Application.Current.Dispatcher.Invoke(new Action(() => { finEjecuta2(); }));
|
|
}
|
|
|
|
|
|
public void finEjecuta2()
|
|
{
|
|
OliviaGlob.progrDialog.Hide();
|
|
//muestra la ventana
|
|
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
|
|
*/
|
|
public static void BorraFiles()
|
|
{
|
|
string[] list = null;
|
|
string capa_principal = System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData);
|
|
string capa_principal_nw = System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathNW);
|
|
|
|
try
|
|
{
|
|
if (capa_principal == null)
|
|
return;
|
|
list = System.IO.Directory.GetFiles(OliviaGlob.Paths.DirData, capa_principal + "*");
|
|
if (list.Length > 0)
|
|
{
|
|
foreach (string f in list)
|
|
{
|
|
if (System.IO.Path.GetExtension(f) == ".lock")
|
|
continue;
|
|
System.IO.File.Delete(f);
|
|
}
|
|
}
|
|
if (capa_principal_nw == null)
|
|
return;
|
|
list = System.IO.Directory.GetFiles(OliviaGlob.Paths.DirData, capa_principal_nw + "*");
|
|
if (list.Length > 0)
|
|
{
|
|
foreach (string f in list)
|
|
{
|
|
System.IO.File.Delete(f);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|