diff --git a/Helper/HelperGdb.cs b/Helper/HelperGdb.cs index 0eb5818..5596b61 100644 --- a/Helper/HelperGdb.cs +++ b/Helper/HelperGdb.cs @@ -434,25 +434,39 @@ namespace OliviaAddInPro.Helper public static int CheckFileds(string pathCapa, string[] camps) { int i; - - if (string.IsNullOrEmpty(pathCapa)) + FeatureClass fc = null; + try + { + fc = GetFtClass(pathCapa); + if (fc == null) + { + OutStr = "No se puede abrir la capa " + pathCapa; + return -1; + } + + ObservableCollection fields = GetFields(fc).Result; + OutStr = "No se encuentran el/los campo/s: "; + int mal = 0; + for (i = 0; i < camps.Length; i++) + { + if (!fields.Contains(camps[i])) + { + OutStr = OutStr + camps[i] + " "; + mal++; + } + } + if (mal == 0) + OutStr = ""; + return mal; + } + catch { - OutStr = "No se encuentra la capa"; return -1; } - OutStr = "No se encuentran el/los campo/s: "; - int mal = 0; - for (i = 0; i < camps.Length; i++) + finally { - if (!CheckField(pathCapa, camps[i])) - { - OutStr = OutStr + camps[i] + " "; - mal++; - } + Free(fc); } - if (mal == 0) - OutStr = ""; - return mal; } diff --git a/Model/OliviaConf.cs b/Model/OliviaConf.cs index a21565f..4a2ff06 100644 --- a/Model/OliviaConf.cs +++ b/Model/OliviaConf.cs @@ -34,13 +34,14 @@ namespace OliviaAddInPro.Model [Serializable] class OliviaConf { + [TypeConverter(typeof(EnumToStringUsingDescription))] public enum OpsRecoCont { - [Description("Contenedor lleno (usa capacidad y densidad cont.)")] + [Description("Contenedor lleno (usa capac. y densidad cont.)")] LlenoUsaDensidad, - [Description("Lee campo 'Kg Contenedor'")] + [Description("Lee campo 'Kg del Contenedor'")] LeeCampoTabla, - [Description("Usa 'Kg Defecto'")] + [Description("Usa 'Kg por Defecto'")] UsaKgDef } private string m2s(int min) @@ -381,7 +382,7 @@ namespace OliviaAddInPro.Model [Category("Campos Recogida")] [PropertyOrder(8)] [ReadOnly(false)] - [DisplayName("Campo 'Kg a recoger'")] + [DisplayName("Campo 'Kg del contenedor'")] [Description("Nombre del campo que indica los kg del contenedor")] public string kgrec { get; set; } @@ -1289,5 +1290,39 @@ namespace OliviaAddInPro.Model #endregion } - + public class EnumToStringUsingDescription : TypeConverter + { + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + return (sourceType.Equals(typeof(Enum))); + } + + 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().BaseType.Equals(typeof(Enum))) + { + throw new ArgumentException("Can only convert an instance of enum.", "value"); + } + + string name = value.ToString(); + object[] attrs = + value.GetType().GetField(name).GetCustomAttributes(typeof(DescriptionAttribute), false); + return (attrs.Length > 0) ? ((DescriptionAttribute)attrs[0]).Description : name; + } + } } diff --git a/Services/ImportaResServ.cs b/Services/ImportaResServ.cs index 41f77bb..fe85e5c 100644 --- a/Services/ImportaResServ.cs +++ b/Services/ImportaResServ.cs @@ -58,7 +58,6 @@ namespace OliviaAddInPro.Services OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecNOk); } - borra_files(); if (mal) { HelperGlobal.ponMsg(err, System.Windows.MessageBoxImage.Error); @@ -67,45 +66,6 @@ namespace OliviaAddInPro.Services OliviaGlob.ShowHidePane(true); - } - /** - * Borra los archivos exportados para el proceso - */ - public static void borra_files() - { - 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 = Directory.GetFiles(OliviaGlob.Paths.DirData, capa_principal + "*"); - if (list.Length > 0) - { - foreach (string f in list) - { - if (System.IO.Path.GetExtension(f) == ".lock") - continue; - File.Delete(f); - } - } - if (capa_principal_nw == null) - return; - list = Directory.GetFiles(OliviaGlob.Paths.DirData, capa_principal_nw + "*"); - if (list.Length > 0) - { - foreach (string f in list) - { - File.Delete(f); - } - } - } - catch (Exception ex) - { - HelperGlobal.ponMsg(ex.Message, System.Windows.MessageBoxImage.Error); - } - } + } } } diff --git a/Services/RecogidaServ.cs b/Services/RecogidaServ.cs index 042adc6..39650bc 100644 --- a/Services/RecogidaServ.cs +++ b/Services/RecogidaServ.cs @@ -37,12 +37,13 @@ namespace OliviaAddInPro.Services camps[4] = RecogidaDef.campos_def.cons_uds; camps[5] = RecogidaDef.campos_def.cons_kgrec; int compCamp = HelperGdb.CheckFileds(pathCapa, camps); + ErrStr = HelperGdb.OutStr; if (compCamp == 0) return 0; - else if (compCamp == 1 && ErrStr.Contains(RecogidaDef.campos_def.cons_kgrec)) + else if (compCamp == 1 && HelperGdb.OutStr.Contains(RecogidaDef.campos_def.cons_kgrec)) //le falta el de kg recogida, que igual no le hace falta return 1; else - return 2; + return 2; //error o le falta 1 que no es el de kg reco o más } /* diff --git a/View/Recogida/PaneRecogidaSub1.xaml b/View/Recogida/PaneRecogidaSub1.xaml index 7dbcfa7..fee26b9 100644 --- a/View/Recogida/PaneRecogidaSub1.xaml +++ b/View/Recogida/PaneRecogidaSub1.xaml @@ -33,6 +33,7 @@ + - + +