コード例 #1
0
        /// <summary>
        /// Check to make sure the enviornment is set up correctly before processing the users request
        ///
        /// </summary>
        /// <returns></returns>
        private async Task <bool> CheckRequirements()
        {
            if (_selectedMap == null)
            {
                MessageBox.Show("Select A Map In Domain Appointer Settings");
                return(false);
            }

            if (_selectedLayer == null)
            {
                MessageBox.Show("Select A Layer in Domain Appointer Settings");
                return(false);
            }

            if (_selectedField == null)
            {
                MessageBox.Show("Select a Field in Domain Appointer Settings");
            }

            bool canEditData = false;

            await QueuedTask.Run(() =>
            {
                canEditData = _selectedLayer.CanEditData();
            });

            if (!canEditData)
            {
                MessageBox.Show("Feature Layer '" + _selectedLayer.Name + "' Is not Editable");
                return(false);
            }

            IEnumerable <Field> fields = null;

            await QueuedTask.Run(() =>
            {
                Table table = _selectedLayer.GetTable();
                if (table is FeatureClass)
                {
                    FeatureClass featureclass = table as FeatureClass;
                    using (FeatureClassDefinition def = featureclass.GetDefinition())
                    {
                        fields = def.GetFields();
                    }
                }
            });

            var match = fields.FirstOrDefault(field => field.Name.ToLower().Contains(_selectedField.ToLower()));

            if (match == null)
            {
                MessageBox.Show("The field '" + _selectedField + "' is Missing From '" + _selectedLayer.Name + "' Feature Layer");
                return(false);
            }


            return(true);
        }