180 lines
6.6 KiB
C#
180 lines
6.6 KiB
C#
using ArcGIS.Desktop.Framework.Contracts;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using System.Text.RegularExpressions;
|
||
using System.Runtime.InteropServices.WindowsRuntime;
|
||
using OliviaAddInPro.Model;
|
||
using OliviaAddInPro.Helper;
|
||
|
||
namespace OliviaAddInPro
|
||
{
|
||
public abstract class PanelViewModelBase : PropertyChangedBase
|
||
{
|
||
|
||
#region Properties
|
||
|
||
public abstract string DisplayName { get; }
|
||
public PaneLimpiezaSub2ViewModel _subPanel2ViewModel;
|
||
public PaneLimpiezaSub3ViewModel _subPanel3ViewModel;
|
||
public PaneLimpiezaSub4ViewModel _subPanel4ViewModel;
|
||
|
||
private string lblCapaElems = Resource1.String_selec_capa;
|
||
public string LblCapaElems
|
||
{
|
||
get { return lblCapaElems; }
|
||
set { base.SetProperty(ref lblCapaElems, value, () => LblCapaElems); }
|
||
}
|
||
private bool capaAbierta = false;
|
||
public bool CapaAbierta
|
||
{
|
||
get { return capaAbierta; }
|
||
set
|
||
{
|
||
capaAbierta = value;
|
||
base.NotifyPropertyChanged("CapaAbierta");
|
||
}
|
||
}
|
||
private string capaElems = "";
|
||
public string CapaElems
|
||
{
|
||
get { return capaElems; }
|
||
set
|
||
{
|
||
capaElems = value;
|
||
base.NotifyPropertyChanged("CapaElems");
|
||
}
|
||
}
|
||
#endregion Properties
|
||
|
||
public bool LeeComun(TratamientoComun com, out string err_str)
|
||
{
|
||
err_str = string.Empty;
|
||
////////////////////////////////////////////////////////////
|
||
///Lee el panel 2
|
||
///Lee las capas
|
||
com.GeomRestr = _subPanel2ViewModel.GeomRestr;
|
||
if (com.GeomRestr!=null)
|
||
com.TextGeomRestr = _subPanel2ViewModel.LblCapaRestr;
|
||
com.GeomNiv = _subPanel2ViewModel.GeomNiv;
|
||
if (com.GeomNiv != null)
|
||
com.TextGeomNiv = _subPanel2ViewModel.LblCapaNiv;
|
||
com.GeomZon = _subPanel2ViewModel.GeomZon;
|
||
if (com.GeomZon != null)
|
||
com.TextGeomZon = _subPanel2ViewModel.LblCapaZon;
|
||
com.CoordsInstal = _subPanel2ViewModel.CoordsInstal;
|
||
|
||
//lee el buffer de export
|
||
if ((_subPanel2ViewModel.TxtBuffExport <= 0) || (_subPanel2ViewModel.TxtBuffExport > 100000))
|
||
{
|
||
err_str = "El buffer de exportaci<63>n no est<73> dentro de los l<>mites configurados";
|
||
return false;
|
||
}
|
||
com.BuffExport = _subPanel2ViewModel.TxtBuffExport;
|
||
|
||
////////////////////////////////////////////////////////////
|
||
///Lee el panel 3
|
||
if (_subPanel3ViewModel.CheckSectAuto)
|
||
com.NSect = 0; //env<6E>a 0 si es sector automat
|
||
else
|
||
{
|
||
com.NSect = _subPanel3ViewModel.NumSect; //limitado entre 1 y 30 por c<>digo del spinner
|
||
if (_subPanel3ViewModel.CheckAjustSect)
|
||
com.NSect = com.NSect * (-1);//lo env<6E>a negativo si es ajustar a sectores
|
||
}
|
||
com.NPtosCtrl = _subPanel3ViewModel.NumPtosCtrl; //limitado entre 3 y 10 por c<>digo del spinner
|
||
com.IgnoAis = _subPanel3ViewModel.CheckIgnoAis;
|
||
|
||
////////////////////////////////////////////////////////////
|
||
///Lee el panel 4
|
||
//lee los tiempos
|
||
com.TDescarg = PanelGlobal.Hm_DateTime2int(_subPanel4ViewModel.TimeCargDesc);
|
||
if ((com.TDescarg == 0) || (com.TDescarg > LimpiezaDef.Parametros.t_cardescM) || (com.TDescarg < LimpiezaDef.Parametros.t_cardescm))
|
||
{
|
||
err_str = "El valor introducido para el tiempo de carga y descarga no es v<>lido.";
|
||
return false;
|
||
}
|
||
com.TDesplIniFin = PanelGlobal.Hm_DateTime2int(_subPanel4ViewModel.TimeDespIniFin);
|
||
if ((com.TDesplIniFin == 0) || (com.TDesplIniFin > LimpiezaDef.Parametros.t_despM) || (com.TDesplIniFin < LimpiezaDef.Parametros.t_despm))
|
||
{
|
||
err_str = "El valor introducido para el tiempo de desplazamiento no es v<>lido.";
|
||
return false;
|
||
}
|
||
com.TDescan = PanelGlobal.Hm_DateTime2int(_subPanel4ViewModel.TimeDescPers);
|
||
if ((com.TDescan == 0) || (com.TDescan > LimpiezaDef.Parametros.t_descansoM) || (com.TDescan < LimpiezaDef.Parametros.t_descansom))
|
||
{
|
||
err_str = "El valor introducido para el tiempo de descanso no es v<>lido.";
|
||
return false;
|
||
}
|
||
com.TConv = PanelGlobal.Hm_DateTime2int(_subPanel4ViewModel.TimeJornadaConv);
|
||
if ((com.TConv == 0) || (com.TConv > LimpiezaDef.Parametros.t_convM) || (com.TConv < LimpiezaDef.Parametros.t_convm))
|
||
{
|
||
err_str = "El valor introducido para el tiempo de trabajo por convenio no es v<>lido.";
|
||
return false;
|
||
}
|
||
com.HIni = PanelGlobal.Hm_DateTime2int(_subPanel4ViewModel.TimeIniJornada);
|
||
//porcent reducc traf
|
||
com.Trafico = _subPanel4ViewModel.TextPercentTrafico;
|
||
if ((com.Trafico <= 0) || (com.Trafico > 100))
|
||
{
|
||
err_str = "El porcentaje de tr<74>fico en las v<>as no est<73> dentro de los l<>mites configurados";
|
||
return false;
|
||
}
|
||
return true;
|
||
|
||
}
|
||
|
||
public void finEjecuta(OliviaAddInPro.Model.ComunDef.TareaRes res)
|
||
{
|
||
OliviaGlob.progrDialog.Hide();
|
||
if (res.Errores)
|
||
{
|
||
HelperGlobal.ponMsg(res.msg);
|
||
}
|
||
else
|
||
{
|
||
HelperGlobal.ponMsg(Resource1.String_exito);
|
||
}
|
||
}
|
||
}
|
||
|
||
//******************************************************
|
||
|
||
public static class PanelGlobal
|
||
{
|
||
public static bool IsValid(string str, int ini, int fin)
|
||
{
|
||
int i;
|
||
return int.TryParse(str, out i) && i >= ini && i <= fin;
|
||
}
|
||
/**
|
||
* Dado un tiempo en minutos devuelve las horas modulo 60 y los minutos restantes
|
||
*/
|
||
|
||
public static DateTime Hm_int2DateTime(double t)
|
||
{
|
||
int[] hm = { 0, 0 };
|
||
|
||
hm[0] = (int)(t / 60);
|
||
hm[1] = (int)(t - hm[0] * 60);
|
||
DateTime dt=new DateTime(2021, 01, 01, hm[0], hm[1], 0);
|
||
return dt;
|
||
}
|
||
public static int Hm_DateTime2int(DateTime dt)
|
||
{
|
||
int h = 0;
|
||
int m = 0;
|
||
int t = 0;
|
||
|
||
h = dt.Hour;
|
||
m = dt.Minute;
|
||
t = h * 60 + m;
|
||
return t;
|
||
}
|
||
|
||
}
|
||
|
||
}
|