public async Task <bool> ValidateFields(string class_name, ArcGIS.Core.Data.FeatureClassDefinition fc_def)
        {
            Type type = Type.GetType(class_name);
            var  item = Activator.CreateInstance(type);

            PropertyInfo[] properties = item.GetType().GetProperties();
            foreach (PropertyInfo property in properties)
            {
                var name  = property.Name;
                int index = await QueuedTask.Run(() => { return(fc_def.FindField(name)); });

                if (index < 0)
                {
                    //MessageBox.Show($"El campo {name} no fue encontrado en el elemento seleccionado.", "Validación de campos", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return(false);
                }
            }
            return(true);
        }
示例#2
0
        /// <summary>
        /// Create Pipeline Route from input pipeline centerline
        /// </summary>
        /// <param name="fcPath"></param>
        /// <returns></returns>
        public static async Task <ArcGIS.Desktop.Core.Geoprocessing.IGPResult> CreatePipelineRoute(string fcPath)
        {
            // Check if input pipeline has "ROUTEID" field // Active Map must hvae fcPath
            var output = await QueuedTask.Run(() =>
            {
                var lyr = ArcGIS.Desktop.Mapping.MapView.Active.Map.FindLayers(fcPath).First() as ArcGIS.Desktop.Mapping.FeatureLayer;
                var gdb = lyr.GetTable().GetDatastore() as ArcGIS.Core.Data.Geodatabase;

                Uri path        = gdb.GetPath();
                string fullPath = Path.Combine(path.LocalPath, lyr.GetTable().GetName().ToString());

                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("GDB is: " + path);
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("path is: " + fullPath);

                fcPath = fullPath;

                Uri uri = new Uri(path.ToString());
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("database uri here: " + uri);

                // Check if input pipline layer has a "ROUTEID" field
                using (ArcGIS.Core.Data.Geodatabase fileGeodatabase = new ArcGIS.Core.Data.Geodatabase(new ArcGIS.Core.Data.FileGeodatabaseConnectionPath(uri)))
                    using (ArcGIS.Core.Data.FeatureClass featureClass = fileGeodatabase.OpenDataset <ArcGIS.Core.Data.FeatureClass>(lyr.Name))
                    {
                        ArcGIS.Core.Data.FeatureClassDefinition lyrDefinition = featureClass.GetDefinition();
                        IReadOnlyList <ArcGIS.Core.Data.Field> fields         = lyrDefinition.GetFields();
                        List <string> fieldsList = new List <string>();
                        ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Checking fields");
                        foreach (var field in fields)
                        {
                            fieldsList.Add(field.Name);
                        }

                        return(fieldsList);
                    }
            });
        }
示例#3
0
        private string FeatureString(ArcGIS.Core.Data.FeatureClassDefinition fcDef)
        {
            string alias = fcDef.GetAliasName();

            return(string.Format("{0} ({1})", !string.IsNullOrEmpty(alias) ? alias : fcDef.GetName(), fcDef.GetName()));
        }