From f94b4e3a2e17deb702d518cd6f0f37cd7adcfd4d Mon Sep 17 00:00:00 2001 From: Gerardo Date: Fri, 3 Nov 2023 23:56:06 +0100 Subject: [PATCH] =?UTF-8?q?A=C3=B1adido=20configuracion=20tipo=20de=20red.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Helper/HelperGdb.cs | 40 +++++++++++++- Model/ComunDef.cs | 13 +++-- Model/OliviaConf.cs | 87 ++++++++++++++++++++++++++++--- Model/OliviaConfNW.cs | 24 +++++++++ Model/OliviaDef.cs | 12 ++++- Model/OliviaGlob.cs | 22 ++++---- Services/ConfigServ.cs | 4 +- Services/EjecServ.cs | 65 ++++++++++++++++++++++- Services/LanzaSrv/LanzaOlvServ.cs | 2 + 9 files changed, 244 insertions(+), 25 deletions(-) create mode 100644 Model/OliviaConfNW.cs diff --git a/Helper/HelperGdb.cs b/Helper/HelperGdb.cs index aa65567..1ebe186 100644 --- a/Helper/HelperGdb.cs +++ b/Helper/HelperGdb.cs @@ -1444,7 +1444,7 @@ namespace OliviaAddInPro.Helper if (!System.IO.Directory.Exists(outpath)) System.IO.Directory.CreateDirectory(outpath); FeatureClass fc = null; - bool debug = true; + bool debug = false; ///////////////////////////////////////////////////////// //Prepara una where_clause con las entidades que cumplen el filtro //Abre la featureclass @@ -2807,6 +2807,44 @@ namespace OliviaAddInPro.Helper { } + return res; + } + /* + * Añadir columna calculada + */ + public static bool CalculateFieldsSync(string fcname, string field, string sqlquery) + { + bool res = false; + + var args = Geoprocessing.MakeValueArray(fcname, field, sqlquery, "ARCADE"); + + // run the tool + try + { + var gpres = Geoprocessing.ExecuteToolAsync("management.CalculateField", args); + + while (!gpres.IsCompleted && !gpres.IsCanceled && !gpres.IsFaulted) + Thread.Sleep(10); + if (gpres.IsFaulted) + { + var gpResult = gpres.Result; + string msg; + if (gpResult.ErrorMessages != null) + msg = gpResult.ErrorMessages.First().Text; + else + msg = "Errores al calcular campo "+ field; + } + else + { + res = true; //ha ido bien + } + gpres.Dispose(); + return res; + } + catch + { + } + return res; } } diff --git a/Model/ComunDef.cs b/Model/ComunDef.cs index 7702d33..abe6a95 100644 --- a/Model/ComunDef.cs +++ b/Model/ComunDef.cs @@ -17,11 +17,16 @@ namespace OliviaAddInPro.Model */ public struct CamposNW { - public static string cons_onew; // i) + return ListaNw[i]; + return null; + } private int s2m(string str, int defec) { var match = Regex.Match(str, @"^([0-9]*):([0-9]*)"); @@ -66,16 +87,15 @@ namespace OliviaAddInPro.Model } return defec; } - public OliviaConf() { Ip = "127.0.0.1"; Puerto = 19995; TiempoOutSocket = 20; - } - #region PropiedadesOcultas - #region parametrosConexion + } + #region PropiedadesOcultas + #region parametrosConexion /** * IP donde va a realizar la conexión a OliviaTask, se inicializa al arrancar con la local */ @@ -174,7 +194,8 @@ namespace OliviaAddInPro.Model #endregion #region ParametrosReco_Ocultos - + [Browsable(false)] + public List ListaNw { get; set; } [Browsable(false)] public int t_vaciado_max { get; set; } [Browsable(false)] @@ -217,7 +238,15 @@ namespace OliviaAddInPro.Model [PropertyOrder(1)] [Description("Red de carreteras que se usa para la navegación")] [Editor(typeof(PropertyGridFilePickerLine), typeof(PropertyGridFilePickerLine))] - public string Path_Eje_via { get; set; } + public string Path_Eje_via { get; set; } + + [Category("General")] + [DisplayName("Tipo Red de carreteras")] + [PropertyOrder(1)] + [Description("Tipo de Red de carreteras que se usa para la navegación")] + [RefreshProperties(System.ComponentModel.RefreshProperties.All)] + //[Editor(typeof(PropertyGridFilePickerLine), typeof(PropertyGridFilePickerLine))] + public OpsNW Tipo_eje_via { get; set; } [Category("General")] [PropertyOrder(2)] @@ -1327,9 +1356,55 @@ namespace OliviaAddInPro.Model public string atr_suelo { get; set; } #endregion + } + public class EnumOpsNWToString : TypeConverter + { + public static List ListaNw { get; set; } + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return (sourceType.Equals(typeof(OpsNW))); + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { + return (destinationType.Equals(typeof(String))); + } + + public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + { + return base.ConvertFrom(context, culture, value); + } + + public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) + { + if (!destinationType.Equals(typeof(String))) + { + throw new ArgumentException("Can only convert to string.", "destinationType"); + } + + if (!value.GetType().Equals(typeof(OpsNW))) + { + throw new ArgumentException("Can only convert an instance of enum.", "value"); + } + int i = 0; + + if (int.TryParse(value.ToString().Substring(3), out i) && ListaNw != null && i < ListaNw.Count()) + { + var aux = ListaNw[i]; + if (aux == null) + + return ""; + else + return aux.nombre; + + } + return ""; + } + } public class EnumToStringUsingDescription : TypeConverter { + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return (sourceType.Equals(typeof(Enum))); diff --git a/Model/OliviaConfNW.cs b/Model/OliviaConfNW.cs new file mode 100644 index 0000000..0236a3c --- /dev/null +++ b/Model/OliviaConfNW.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace OliviaAddInPro.Model +{ + [Serializable] + public class OliviaConfNW + { + public OliviaConfNW() + { + } + + public string nombre { get; set; } + public string campo_velocidad { get; set; } + public string campo_nombre { get; set; } + public string campo_sentidoFT { get; set; } + public string campo_sentidoTf { get; set; } + public string campo_peatonal { get; set; } + } +} diff --git a/Model/OliviaDef.cs b/Model/OliviaDef.cs index fe9ffd1..eacd624 100644 --- a/Model/OliviaDef.cs +++ b/Model/OliviaDef.cs @@ -598,7 +598,17 @@ namespace OliviaAddInPro.Model /** * Define el nombre para mandar a oliviatasks la configuración para planificación, ya se ha hecho sectorización */ - public const string SockConfTodo = "CONFIG_TODO"; + public const string SockConfTodo = "CONFIG_TODO"; + + + //atributos network por defecto------------------------------------------------------------------------------ + public const string cons_camp_sentido_tf = "_sen_ft"; //