Esempio n. 1
0
        async private void btnOK_Click(object sender, EventArgs e)
        {
            if (_dataset != null &&
                _dataset.ConnectionString != _dsConnectionString)
            {
                await _dataset.SetConnectionString(_dsConnectionString);

                await _dataset.Open();

                int      dsIndex = 0;
                IDataset ds;
                while ((ds = _map[dsIndex]) != null)
                {
                    if (ds == _dataset)
                    {
                        break;
                    }
                    dsIndex++;
                }
                if (ds == null)
                {
                    return;
                }

                foreach (IDatasetElement element in _map.MapElements)
                {
                    if (!(element is DatasetElement))
                    {
                        continue;
                    }

                    if (element.DatasetID == dsIndex)
                    {
                        IDatasetElement el = await _dataset.Element(element.Title);

                        if (el == null)
                        {
                            ((DatasetElement)element).Class2 = null;
                        }
                        else
                        {
                            ((DatasetElement)element).Class2 = el.Class;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        async public Task <IFeature> GetNodeFeatureAttributes(int nodeId, string[] attributes)
        {
            try
            {
                QueryFilter filter = new QueryFilter();
                filter.WhereClause = "FDB_OID=" + nodeId;
                filter.AddField("FCID");
                filter.AddField("OID");

                IFeature feature;
                using (IFeatureCursor cursor = await GetNodeFeatures(filter))
                    feature = await cursor.NextFeature();
                if (feature == null)
                {
                    return(null);
                }

                string fcName = await _fdb.GetFeatureClassName((int)feature["FCID"]);

                IDatasetElement element = await _dataset.Element(fcName);

                if (element == null)
                {
                    return(null);
                }
                IFeatureClass fc = element.Class as IFeatureClass;
                if (fc == null)
                {
                    return(null);
                }

                filter = new QueryFilter();
                if (fc is IDatabaseNames)
                {
                    filter.WhereClause = ((IDatabaseNames)fc).DbColName(fc.IDFieldName) + "=" + Convert.ToInt32(feature["OID"]);
                }
                else
                {
                    filter.WhereClause = _fdb.DbColName(fc.IDFieldName) + "=" + Convert.ToInt32(feature["OID"]);
                }

                if (attributes == null)
                {
                    filter.AddField("*");
                }
                else
                {
                    foreach (string attribute in attributes)
                    {
                        if (attribute == "*")
                        {
                            filter.AddField(attribute);
                        }
                        else if (fc.FindField(attribute) != null)
                        {
                            filter.AddField(attribute);
                        }
                    }
                }

                using (IFeatureCursor cursor = await fc.GetFeatures(filter))
                    feature = await cursor.NextFeature();

                if (feature != null)
                {
                    feature.Fields.Add(new FieldValue("_classname", fc.Name));
                }

                return(feature);
            }
            catch
            {
                return(null);
            }
        }