139 lines
5.5 KiB
C#
139 lines
5.5 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;
|
|
|
|
namespace OliviaAddInPro
|
|
{
|
|
public abstract class PanelViewModelBase : PropertyChangedBase
|
|
{
|
|
|
|
#region Properties
|
|
|
|
public abstract string DisplayName { get; }
|
|
public PaneLimpiezaSub2ViewModel _subPanel2ViewModel;
|
|
public PaneLimpiezaSub3ViewModel _subPanel3ViewModel;
|
|
public PaneLimpiezaSub4ViewModel _subPanel4ViewModel;
|
|
|
|
#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ón no está dentro de los límites configurados";
|
|
return false;
|
|
}
|
|
com.BuffExport = _subPanel2ViewModel.TxtBuffExport;
|
|
|
|
////////////////////////////////////////////////////////////
|
|
///Lee el panel 3
|
|
if (_subPanel3ViewModel.CheckSectAuto)
|
|
com.NSect = 0; //enví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í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áfico en las vías no está dentro de los límites configurados";
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
//******************************************************
|
|
|
|
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;
|
|
}
|
|
|
|
}
|
|
|
|
}
|