Example #1
0
        protected override void FillEntityToCotrols()
        {
            if (_isNew)
            {
                Text = "新建空间要素类...";
                if (_dataset != null)
                {
                    FillDataset(_dataset);
                }
                return;
            }
            else
            {
                Text = "编辑空间要素类属性...";
            }
            SpatialFeatureClass ds = _entity as SpatialFeatureClass;

            if (ds.SpatialFeatureDataset != null)
            {
                FillDataset(ds.SpatialFeatureDataset);
            }
            txtName.Text       = _entity.Name;
            txtDecription.Text = _entity.Description;
            txtMapScale.Value  = ds.MapScale;
            txtSource.Text     = ds.Source;
            if (ds.SpatialRef != null)
            {
                ISpatialReference sref = SpatialReferenceFactory.GetSpatialReferenceByWKT(ds.SpatialRef, enumWKTSource.EsriPrjFile);
                ucSpatialRef1.SpatialReference = sref;
            }
        }
Example #2
0
        public override string ToString(object value)
        {
            ICatalogItem ci = value as ICatalogItem;

            if (ci is CatalogLocal)
            {
                return((ci as CatalogLocal).Tag.ToString());
            }
            else if (ci is CatalogFile)
            {
                return((ci as CatalogFile).Tag.ToString());
            }
            else if (ci is CatalogDatabaseConn)
            {
                return(((ci as CatalogDatabaseConn).Tag as SpatialDatabaseConn).ConnectionString);
            }
            else if (ci is CatalogFeatureDataset)
            {
                SpatialFeatureDataset sfd = (ci as CatalogFeatureDataset).Tag as SpatialFeatureDataset;
                return((sfd as CatalogEntityBase)._connString + "@" + sfd.Name);
            }
            else if (ci is CatalogFeatureClass)
            {
                SpatialFeatureClass sfc = (ci as CatalogFeatureClass).Tag as SpatialFeatureClass;
                return((sfc as CatalogEntityBase)._connString + "@" + sfc.Name);
            }
            else
            {
                return(base.ToString());
            }
        }
Example #3
0
        public override void Click(enumContextKeys key)
        {
            switch (key)
            {
            case enumContextKeys.AddFeatureClass:
                using (frmFetClassDlg frm = new frmFetClassDlg())
                {
                    ICatalogEntity entity = new SpatialFeatureClass();
                    frm.SetSpatialDataset(_tag as SpatialFeatureDataset);
                    (entity as CatalogEntityBase)._connString = (_tag as CatalogEntityBase)._connString;
                    if (frm.ShowDialog(ref entity, true, false))
                    {
                        if ((entity as SpatialFeatureClass).SpatialRef == null)
                        {
                            (entity as SpatialFeatureClass).SpatialRef = (_tag as SpatialFeatureDataset).SpatialRef;
                        }
                        entity.Store();
                        AddChild(new CatalogFeatureClass(entity.Name, entity, entity.Description));
                    }
                }
                Refresh();
                break;

            case enumContextKeys.Property:
                using (frmFeatureDatasetsEditor frm = new frmFeatureDatasetsEditor())
                {
                    ICatalogEntity entity = _tag as ICatalogEntity;
                    if (frm.ShowDialog(ref entity, false, false))
                    {
                        entity.Store();
                        Refresh();
                    }
                }
                break;

            case enumContextKeys.Delete:
                if (MsgBox.ShowQuestionYesNo("确定要删除要素集\"" + _name + "\"吗?\n\n删除以后不能恢复。") == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
                SpatialFeatureDataset ds = _tag as SpatialFeatureDataset;
                using (ICatalogEntityClass c = new CatalogEntityClassFeatureDataset(ds._connString))
                {
                    c.Delete(ds);
                    ICatalogItem pIt = _parent;
                    _parent.Remove(this);
                    pIt.Refresh();
                }
                break;

            case enumContextKeys.ImportData:
                ImportData();
                break;

            default:
                base.Click(key);
                break;
            }
        }
Example #4
0
        private static FeatureDataSourceBase GetDataSource(CatalogFeatureClass catalogFeatureClass)
        {
            FeatureDataSourceBase ds = null;
            string name = catalogFeatureClass.Name;
            SpatialFeatureClass fetc = catalogFeatureClass.Tag as SpatialFeatureClass;

            ds = new SpatialDbDataSource(name, fetc._connString + "@" + fetc.DataTable);
            return(ds);
        }
Example #5
0
        public override void Click(enumContextKeys key)
        {
            switch (key)
            {
            case enumContextKeys.AddFeatureDataset:
                using (frmFeatureDatasetsEditor frm = new frmFeatureDatasetsEditor())
                {
                    ICatalogEntity entity = new SpatialFeatureDataset();
                    (entity as CatalogEntityBase)._connString = (_tag as SpatialDatabaseConn).ConnectionString;
                    if (frm.ShowDialog(ref entity, true, false))
                    {
                        entity.Store();
                        AddChild(new CatalogFeatureDataset(entity.Name, entity, entity.Description));
                    }
                }
                Refresh();
                break;

            case enumContextKeys.AddFeatureClass:
                using (frmFetClassDlg frm = new frmFetClassDlg())
                {
                    ICatalogEntity entity = new SpatialFeatureClass();
                    frm.SetSpatialDataset(null);
                    (entity as CatalogEntityBase)._connString = (_tag as SpatialDatabaseConn).ConnectionString;
                    if (frm.ShowDialog(ref entity, true, false))
                    {
                        entity.Store();
                        AddChild(new CatalogFeatureClass(entity.Name, entity, entity.Description));
                    }
                }
                Refresh();
                break;

            case enumContextKeys.ImportData:
                ImportData();
                break;

            default:
                if (key == enumContextKeys.Refresh)
                {
                    (_tag as SpatialDatabaseConn).Refresh();
                }
                base.Click(key);
                break;
            }
        }
Example #6
0
        public override void Click(enumContextKeys key)
        {
            switch (key)
            {
            case enumContextKeys.Delete:
                if (MsgBox.ShowQuestionYesNo("确定要删除要素类\"" + _name + "\"吗?\n\n删除以后不能恢复。") == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
                SpatialFeatureClass ds = _tag as SpatialFeatureClass;
                using (ICatalogEntityClass c = new CatalogEntityClassFeatureClass(ds._connString))
                {
                    c.Delete(ds);
                    ICatalogItem pIt = _parent;
                    _parent.Remove(this);
                    pIt.Refresh();
                    break;
                }

            case enumContextKeys.Property:
                using (frmFetClassDlg frm = new frmFetClassDlg())
                {
                    ICatalogEntity entity = _tag as ICatalogEntity;
                    if (frm.ShowDialog(ref entity, false, false))
                    {
                        entity.Store();
                        Refresh();
                    }
                }
                break;

            default:
                base.Click(key);
                break;
            }
        }
Example #7
0
 public override void Delete(ICatalogEntity entity)
 {
     using (IDbCommand cmd = _dbConnection.CreateCommand())
     {
         TransactionManager.BeginTransaction(_dbConnection, cmd);
         string sql = null;
         try
         {
             int ret = 0;
             //delete table
             SpatialFeatureClass fetc = entity as SpatialFeatureClass;
             if (fetc.DataTable != null)
             {
                 //delete fetclass table
                 sql             = _adapter.GetTableIsExistSql(fetc.DataTable, _adapter.GetDataSource(_connString));
                 cmd.CommandText = sql;
                 object v = cmd.ExecuteScalar();
                 ret = int.Parse(v.ToString());
                 if (ret > 0)
                 {
                     sql             = "drop table " + fetc.DataTable;
                     cmd.CommandText = sql;
                     ret             = cmd.ExecuteNonQuery();
                     //delete spatialindex metadata
                     sql = _adapter.DeleteSpatiaoIndexMetadata(fetc.DataTable);
                     if (sql != null)
                     {
                         cmd.CommandText = sql;
                         cmd.ExecuteNonQuery();
                     }
                 }
                 //delete ann table
                 sql             = _adapter.GetTableIsExistSql(fetc.AnnoTable, _adapter.GetDataSource(_connString));
                 cmd.CommandText = sql;
                 v   = cmd.ExecuteScalar();
                 ret = int.Parse(v.ToString());
                 if (ret > 0)
                 {
                     sql             = "drop table " + fetc.AnnoTable;
                     cmd.CommandText = sql;
                     ret             = cmd.ExecuteNonQuery();
                     //delete spatialindex metadata
                     sql = _adapter.DeleteSpatiaoIndexMetadata(fetc.AnnoTable);
                     if (sql != null)
                     {
                         cmd.CommandText = sql;
                         cmd.ExecuteNonQuery();
                     }
                 }
             }
             //delete fetclass
             sql             = "delete from " + GetTableName() + " where id='" + entity.Id + "'";
             cmd.CommandText = sql;
             ret             = cmd.ExecuteNonQuery();
             TransactionManager.Commit();
         }
         catch
         {
             TransactionManager.Rollback();
             throw;
         }
     }
 }