Esempio n. 1
0
 public override void Run(object sender, System.EventArgs e)
 {
     if (CommonUtils.Instance().CurEditLayer != null)
     {
         bool               inProjectTree = false;
         bool               isCheckOut    = false;
         IFeatureLayer      fl            = CommonUtils.Instance().CurEditLayer.GetFeatureLayer();
         IDataSourceFactory dsf           = new DataSourceFactory();
         if (dsf.HasDataSourceByString(fl.FeatureClassInfo.DataSourceConnectionString))
         {
             IDataSource     ds  = dsf.OpenDataSourceByString(fl.FeatureClassInfo.DataSourceConnectionString);
             IFeatureDataSet fds = ds.OpenFeatureDataset(fl.FeatureClassInfo.DataSetName);
             if (fds != null)
             {
                 using (FCPropertyFrm fCPropertyForm = new FCPropertyFrm(ds, fl.FeatureClassInfo.DataSetName, CommonUtils.Instance().CurEditLayer.GetFeatureClass(), inProjectTree, isCheckOut))
                 {
                     fCPropertyForm.ShowDialog();
                 }
             }
         }
     }
     else
     {
         XtraMessageBox.Show("请设置当前编辑要素类!");
     }
 }
Esempio n. 2
0
        private Dictionary <string, string> GetQueryResult(IFeatureClassInfo fcInfo, int featureId)
        {
            if (fcInfo == null || featureId < 0)
            {
                return(null);
            }
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IDataSourceFactory dsf = new DataSourceFactory();
                if (!dsf.HasDataSourceByString(fcInfo.DataSourceConnectionString))
                {
                    return(null);
                }
                IDataSource ds = dsf.OpenDataSourceByString(fcInfo.DataSourceConnectionString);
                if (ds == null)
                {
                    return(null);
                }
                IFeatureDataSet fds = ds.OpenFeatureDataset(fcInfo.DataSetName);
                if (fds == null)
                {
                    return(null);
                }
                IFeatureClass fc = fds.OpenFeatureClass(fcInfo.FeatureClassName);
                if (fc == null)
                {
                    return(null);
                }
                IQueryFilter filter = new QueryFilter();
                filter.WhereClause = fc.FidFieldName + "=" + featureId;
                if (fc.GetCount(filter) == 0)
                {
                    return(null);
                }
                cursor = fc.Search(filter, false);
                if (cursor == null)
                {
                    return(null);
                }
                row = cursor.NextRow();
                if (row == null)
                {
                    return(null);
                }
                IFieldInfoCollection        fiCol = row.Fields;
                Dictionary <string, string> dict  = new Dictionary <string, string>();
                for (int i = 0; i < fiCol.Count; i++)
                {
                    IFieldInfo fi  = row.Fields.Get(i);
                    object     obj = row.GetValue(fiCol.IndexOf(fi.Name));
                    if (obj == null)
                    {
                        continue;
                    }
                    string str = "";
                    switch (fi.FieldType)
                    {
                    case gviFieldType.gviFieldBlob:
                    case gviFieldType.gviFieldUnknown:
                    case gviFieldType.gviFieldGeometry:
                        break;

                    case gviFieldType.gviFieldFloat:
                    case gviFieldType.gviFieldDouble:
                        double d;
                        if (double.TryParse(obj.ToString(), out d))
                        {
                            str = d.ToString("0.00");
                        }
                        break;

                    default:
                        str = obj.ToString();
                        break;
                    }
                    if (!string.IsNullOrEmpty(str.Trim()))
                    {
                        string temp = (string.IsNullOrEmpty(fi.Alias)) ? fi.Name : fi.Alias;
                        dict[temp] = str;
                    }
                }
                return(dict);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }