Exemplo n.º 1
0
        public IArray get_DatasetNames(esriDatasetType datasetType)
        {
            if (m_connString == null)
                return null;

            if (datasetType == esriDatasetType.esriDTAny ||
                datasetType == esriDatasetType.esriDTFeatureClass)
            {
                IArray datasets = new ArrayClass();

                int count = m_datasource.GetLayerCount();

                for (int i = 0; i < count; i++)
                {
                    OSGeo.OGR.Layer layer = m_datasource.GetLayerByIndex(i);

                    OGRDataset dataset = new OGRDataset(layer);

                    datasets.Add(dataset);
                }

                return datasets;
            }

            return null;
        }
        public frmAddProjectLayers(IMap map2, esriDatasetType dType)
        {
            InitializeComponent();
            if (map2 == null)
            {
                OpenFileDialog ofdMxd = new OpenFileDialog();
                ofdMxd.Filter = "Map Doc|*.mxd";
                ofdMxd.Multiselect = false;
                DialogResult rslt = ofdMxd.ShowDialog();
                if (rslt == DialogResult.OK)
                {
                    mapDoc = new MapDocumentClass();
                    mapDoc.Open(ofdMxd.FileName, "");
                    map = mapDoc.get_Map(0);
                }
                else
                {
                    MessageBox.Show("A map document must be selected to work. Shutting down");
                    this.Close();
                }
            }
            else
            {
                map = map2;
            }
            if (dType == esriDatasetType.esriDTAny)
            {
                dType = esriDatasetType.esriDTFeatureClass;
            }
            switch (dType)
            {
                case esriDatasetType.esriDTTable:
                    this.Text = "Add Table";
                    label1.Text = "Select Table";
                    break;
                case esriDatasetType.esriDTRasterDataset:
                    this.Text = "Add Raster";
                    label1.Text = "Select Raster";
                    break;
                default:
                    this.Text = "Add Feature";
                    label1.Text = "Select Feature";
                    break;
            }
            mapserviceutility msUtil = new mapserviceutility();

            prjDatabase = msUtil.LcCacheDb;
            if (prjDatabase == "")
            {
                msUtil.changeLocalDatabase();
                prjDatabase = msUtil.LcCacheDb;
            }
            this.cmbLayers.Items.Clear();
            foreach (string s in getNames(dType))
            {
                lyrDic.Add(s, prjDatabase + "\\" + s);
                cmbLayers.Items.Add(s);
            }
            this.Refresh();
        }
Exemplo n.º 3
0
        public IArray get_DatasetNames(esriDatasetType datasetType)
        {
            IArray datasets = new ArrayClass();

            if (datasetType == esriDatasetType.esriDTAny || datasetType != esriDatasetType.esriDTFeatureDataset)
            {
                // Since the state of the filesystem is beyond our control,
                // GetFiles() could throw.  If it does, we return an empty array.
                try
                {
                    foreach (var file in Directory.GetFiles(_workspacePath, GpxFilter))
                    {
                        string localName = Path.GetFileNameWithoutExtension(file);
                        if (!String.IsNullOrEmpty(localName))
                        {
                            datasets.Add(new GpxDataset(_workspacePath, localName));
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (ex is IOException || ex is UnauthorizedAccessException)
                        System.Diagnostics.Trace.TraceError(ex.Message);
                    else
                        throw;
                }
            }
            return datasets;
        }
 public string get_DatasetDescription(esriDatasetType DatasetType)
 {
   switch (DatasetType)
   {
     case esriDatasetType.esriDTTable:
       return "SimplePoint Table";
     case esriDatasetType.esriDTFeatureClass:
       return "SimplePoint Feature Class";
     case esriDatasetType.esriDTFeatureDataset:
       return "SimplePoint Feature Dataset";
     default:
       return null;
   }
 }
		public IArray get_DatasetNames(esriDatasetType DatasetType)
		{
			if (m_sWkspPath == null)
				return null;

			//HIGHLIGHT: get_DatasetNames - Go through wksString to look for csp files
			if (DatasetType != esriDatasetType.esriDTAny && 
				DatasetType != esriDatasetType.esriDTTable)
				return null;

			string[] sFiles = System.IO.Directory.GetFiles(m_sWkspPath, "*.csp");
			if (sFiles == null || sFiles.Length == 0)
				return null;

			IArray datasets = new ArrayClass();
			foreach (string sFileName in sFiles)
			{
				SimplePointDataset ds = new SimplePointDataset(m_sWkspPath, System.IO.Path.GetFileNameWithoutExtension(sFileName));
				datasets.Add(ds);
			}

			return datasets;
		}
Exemplo n.º 6
0
        /// <summary>
        /// Checks to see if the specified dataset exists in the workspace by name.
        /// </summary>
        /// <param name="wrkSpace">The workspace.</param>
        /// <param name="name">The name of the dataset.</param>
        /// <param name="type">The dataset type.</param>
        /// <returns>Returns true if the dataset exists in the workspace, false if it doesn't.</returns>
        public static bool DoesNameExist(IWorkspace wrkSpace, string name, esriDatasetType type)
        {
            bool nameExists = false;
            if (wrkSpace != null && name != string.Empty)
            {
                if (wrkSpace is IWorkspace2)
                    nameExists = ((IWorkspace2)wrkSpace).get_NameExists(type, name);
            }

            return nameExists;
        }
Exemplo n.º 7
0
        //复制GDB数据
        public static void CopyPasteGeodatabaseData(IWorkspace sourceWorkspace, IWorkspace targetWorkspace, string objectName, esriDatasetType esriDataType)
        {
            // Validate input

            if ((sourceWorkspace.Type == esriWorkspaceType.esriFileSystemWorkspace) || (targetWorkspace.Type == esriWorkspaceType.esriFileSystemWorkspace))
            {
                return; // Should be a throw
            }
            //create source workspace name

            IDataset sourceWorkspaceDataset = (IDataset)sourceWorkspace;

            IWorkspaceName sourceWorkspaceName = (IWorkspaceName)sourceWorkspaceDataset.FullName;

            //create target workspace name

            IDataset targetWorkspaceDataset = (IDataset)targetWorkspace;

            IWorkspaceName targetWorkspaceName = (IWorkspaceName)targetWorkspaceDataset.FullName;

            //Create Name Object Based on data type

            IDatasetName datasetName;

            switch (esriDataType)
            {
            case esriDatasetType.esriDTFeatureDataset:

                IFeatureDatasetName inFeatureDatasetName = new FeatureDatasetNameClass();

                datasetName = (IDatasetName)inFeatureDatasetName;
                break;

            case esriDatasetType.esriDTFeatureClass:

                IFeatureClassName inFeatureClassName = new FeatureClassNameClass();

                datasetName = (IDatasetName)inFeatureClassName;

                break;

            case esriDatasetType.esriDTTable:

                ITableName inTableName = new TableNameClass();

                datasetName = (IDatasetName)inTableName;

                break;

            case esriDatasetType.esriDTGeometricNetwork:

                IGeometricNetworkName inGeometricNetworkName = new GeometricNetworkNameClass();

                datasetName = (IDatasetName)inGeometricNetworkName;

                break;

            case esriDatasetType.esriDTRelationshipClass:

                IRelationshipClassName inRelationshipClassName = new RelationshipClassNameClass();

                datasetName = (IDatasetName)inRelationshipClassName;
                break;

            case esriDatasetType.esriDTNetworkDataset:

                INetworkDatasetName inNetworkDatasetName = new NetworkDatasetNameClass();

                datasetName = (IDatasetName)inNetworkDatasetName;

                break;

            case esriDatasetType.esriDTTopology:

                ITopologyName inTopologyName = new TopologyNameClass();

                datasetName = (IDatasetName)inTopologyName;

                break;

            default:

                return;     // Should be a throw
            }

            // Set the name of the object to be copied

            datasetName.WorkspaceName = (IWorkspaceName)sourceWorkspaceName;

            datasetName.Name = objectName;

            //Setup mapping for copy/paste

            IEnumNameMapping fromNameMapping;

            ESRI.ArcGIS.esriSystem.IEnumNameEdit editFromName;

            ESRI.ArcGIS.esriSystem.IEnumName fromName = new NamesEnumerator();

            editFromName = (ESRI.ArcGIS.esriSystem.IEnumNameEdit)fromName;

            editFromName.Add((ESRI.ArcGIS.esriSystem.IName)datasetName);

            ESRI.ArcGIS.esriSystem.IName toName = (ESRI.ArcGIS.esriSystem.IName)targetWorkspaceName;

            // Generate name mapping


            ESRI.ArcGIS.Geodatabase.IGeoDBDataTransfer geoDBDataTransfer = new GeoDBDataTransferClass();

            bool targetWorkspaceExists;

            targetWorkspaceExists = geoDBDataTransfer.GenerateNameMapping(fromName, toName, out fromNameMapping);

            // Copy/Pate the data

            geoDBDataTransfer.Transfer(fromNameMapping, toName);
        }
Exemplo n.º 8
0
        public frmAddProjectLayers(IMap map2, esriDatasetType dType)
        {
            InitializeComponent();
            if (map2 == null)
            {
                OpenFileDialog ofdMxd = new OpenFileDialog();
                ofdMxd.Filter      = "Map Doc|*.mxd";
                ofdMxd.Multiselect = false;
                DialogResult rslt = ofdMxd.ShowDialog();
                if (rslt == DialogResult.OK)
                {
                    mapDoc = new MapDocumentClass();
                    mapDoc.Open(ofdMxd.FileName, "");
                    map = mapDoc.get_Map(0);
                }
                else
                {
                    MessageBox.Show("A map document must be selected to work. Shutting down");
                    this.Close();
                }
            }
            else
            {
                map = map2;
            }
            if (dType == esriDatasetType.esriDTAny)
            {
                dType = esriDatasetType.esriDTFeatureClass;
            }
            switch (dType)
            {
            case esriDatasetType.esriDTTable:
                this.Text   = "Add Table";
                label1.Text = "Select Table";
                break;

            case esriDatasetType.esriDTRasterDataset:
                this.Text   = "Add Raster";
                label1.Text = "Select Raster";
                break;

            default:
                this.Text   = "Add Feature";
                label1.Text = "Select Feature";
                break;
            }
            mapserviceutility msUtil = new mapserviceutility();

            prjDatabase = msUtil.LcCacheDb;
            if (prjDatabase == "")
            {
                msUtil.changeLocalDatabase();
                prjDatabase = msUtil.LcCacheDb;
            }
            this.cmbLayers.Items.Clear();
            foreach (string s in getNames(dType))
            {
                lyrDic.Add(s, prjDatabase + "\\" + s);
                cmbLayers.Items.Add(s);
            }
            this.Refresh();
        }
Exemplo n.º 9
0
 /// <summary>
 ///     Indicates if the workspace extension owns the dataset type.
 /// </summary>
 /// <param name="datasetType">Type of the dataset.</param>
 /// <returns>
 ///     Return <c>true</c> when the extension owns the dataset; otherwise <c>false</c>
 /// </returns>
 /// <remarks>
 ///     The OwnDatasetType method returns a boolean indicating whether the workspace extension supports the specified
 ///     dataset type.
 /// </remarks>
 public virtual bool OwnsDatasetType(esriDatasetType datasetType)
 {
     return(false);
 }
Exemplo n.º 10
0
 public abstract IEnumerable <IDataset> GetDatasets(esriDatasetType datasetType);
 public string get_DatasetDescription(esriDatasetType datasetType)
 {
     return datasetType == esriDatasetType.esriDTFeatureDataset ? "Gpx Feature Dataset" : null;
 }
Exemplo n.º 12
0
        private static IDatasetName GetDatasetName(IWorkspace workspace, string data, esriDatasetType type)
        {
            IDatasetName results = null;

            // look for workspace\container\dataset
            if (data.Contains("\\"))
            {
                string[] parts = data.Split('\\');
                if (parts.Length == 2)
                {
                    results = GetDatasetNameFromContainer(workspace, parts[0], parts[1], type);
                }
            }
            if (results != null)
            {
                return(results);
            }

            //look for workspace\data
            results = GetDatasetNameInWorkspaceSearchTop(workspace, data, type);
            if (results != null)
            {
                return(results);
            }

            //look for workspace\*\data
            return(GetDatasetNameInWorkspaceSearchContainers(workspace, data, type));
        }
Exemplo n.º 13
0
        private static IDatasetName GetDatasetName(IWorkspace workspace, string data, esriDatasetType type)
        {
            IDatasetName results = null;

            // look for workspace\container\dataset
            if (data.Contains("\\"))
            {
                string[] parts = data.Split('\\');
                if (parts.Length == 2)
                    results = GetDatasetNameFromContainer(workspace, parts[0], parts[1], type);
            }
            if (results != null)
                return results;

            //look for workspace\data
            results = GetDatasetNameInWorkspaceSearchTop(workspace, data, type);
            if (results != null)
                return results;

            //look for workspace\*\data
            return GetDatasetNameInWorkspaceSearchContainers(workspace, data, type);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Deletes the dataset.
        /// </summary>
        /// <param name="targetWorkspace">The target workspace.</param>
        /// <param name="sTargetName">Name of the s target.</param>
        /// <param name="type">The type.</param>
        public static void DeleteDataset(IWorkspace targetWorkspace, string sTargetName, esriDatasetType type = esriDatasetType.esriDTFeatureClass)
        {
            IDatasetName datasetName = null;

            switch (type)
            {
            case esriDatasetType.esriDTFeatureDataset:
                datasetName = new FeatureDatasetNameClass();
                break;

            case esriDatasetType.esriDTFeatureClass:
                datasetName = new FeatureClassNameClass();
                break;

            default:
                if (type == esriDatasetType.esriDTTable)
                {
                    datasetName = new TableNameClass();
                }
                break;
            }
            if (datasetName != null)
            {
                datasetName.Name          = sTargetName;
                datasetName.WorkspaceName = ((targetWorkspace as IDataset).FullName as IWorkspaceName);
                EngineAPI.DeleteDataset(targetWorkspace, datasetName);
            }
        }
Exemplo n.º 15
0
        private static string GetMetaData(string workspaceType, string workspacePath, string container, string data, esriDatasetType type)
        {
            IDatasetName results   = null;
            IWorkspace   workspace = GetWorkspace(workspaceType, workspacePath, null);

            if (string.IsNullOrEmpty(container))
            {
                results = GetDatasetName(workspace, data, type);
            }
            else if (container == "*")
            {
                results = GetDatasetNameInWorkspaceSearchContainers(workspace, data, type);
            }
            else
            {
                results = GetDatasetNameFromContainer(workspace, container, data, type);
            }
            if (results == null)
            {
                return(null);
            }
            return(((IXmlPropertySet2)((IMetadata)results).Metadata).GetXml(""));
        }
Exemplo n.º 16
0
 /// <summary>
 /// Determines whether [DataSet exist] [the specified workspace].
 /// </summary>
 /// <param name="pWorkspace">The p workspace.</param>
 /// <param name="sName">Name of the s.</param>
 /// <param name="type">The type.</param>
 /// <returns><c>true</c> if [is name exist] [the specified p workspace]; otherwise, <c>false</c>.</returns>
 public static bool IsNameExist(IWorkspace pWorkspace, string sName, esriDatasetType type = esriDatasetType.esriDTFeatureClass)
 {
     return((pWorkspace as IWorkspace2).get_NameExists(type, sName));
 }
Exemplo n.º 17
0
        //
        // CONSTRUCTOR
        //
        public Dataset(IXPathNavigable path) : base(path) {
            // Suspend
            this.SuspendEvents = true;

            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <Name>
            XPathNavigator navigatorName = navigator.SelectSingleNode(Xml.NAME);
            if (navigatorName != null) {
                this._name = navigatorName.Value;
            }

            // <ChildrenExpanded>
            XPathNavigator navigatorChildrenExpanded = navigator.SelectSingleNode(Xml.CHILDRENEXPANDED);
            if (navigatorChildrenExpanded != null) {
                this._childrenExpanded = navigatorChildrenExpanded.ValueAsBoolean;
            }

            // <FullPropsRetrieved>
            XPathNavigator navigatorFullPropsRetrieved = navigator.SelectSingleNode(Xml.FULLPROPSRETRIEVED);
            if (navigatorFullPropsRetrieved != null) {
                this._fullPropsDefault = navigatorFullPropsRetrieved.ValueAsBoolean;
            }

            // <MetadataRetrieved>
            XPathNavigator navigatorMetadataRetrieved = navigator.SelectSingleNode(Xml.METADATARETRIEVED);
            if (navigatorMetadataRetrieved != null) {
                this._metadataRetrieved = navigatorMetadataRetrieved.ValueAsBoolean;
            }

            // <Metadata><XmlDoc>
            if (this._metadataRetrieved) {
                XPathNavigator navigatorMetadata = navigator.SelectSingleNode(string.Format("{0}/{1}", Xml.METADATA, Xml.XMLDOC));
                if (navigatorMetadata != null) {
                    this._metadata = navigatorMetadata.Value;
                }
            }

            // <DatasetType>
            XPathNavigator navigatorDatasetType = navigator.SelectSingleNode(Xml.DATASETTYPE);
            if (navigatorDatasetType != null) {
                this._datasetType = (esriDatasetType)Enum.Parse(typeof(esriDatasetType), navigatorDatasetType.Value, true);
            }

            // <DSID>
            if (this._fullPropsDefault) {
                XPathNavigator navigatorDSID = navigator.SelectSingleNode(Xml.DSID);
                if (navigatorDSID != null) {
                    this._dsid = navigatorDSID.ValueAsInt;
                }
            }

            // <Versioned>
            if (this._fullPropsDefault) {
                XPathNavigator navigatorVersioned = navigator.SelectSingleNode(Xml.VERSIONED);
                if (navigatorVersioned != null) {
                    this._versioned = navigatorVersioned.ValueAsBoolean;
                }
            }

            // <CanVersion>
            if (this._fullPropsDefault) {
                XPathNavigator navigatorCanVersion = navigator.SelectSingleNode(Xml.CANVERSION);
                if (navigatorCanVersion != null) {
                    this._canVersion = navigatorCanVersion.ValueAsBoolean;
                }
            }

            // Refresh Dataset
            this.Refresh();

            // Resume
            this.SuspendEvents = false;
        }
Exemplo n.º 18
0
 public Dataset(Dataset prototype) : base(prototype) {
     this._name = prototype.Name;
     this._childrenExpanded = prototype.ChildrenExpanded;
     this._fullPropsDefault = prototype.FullPropsDefault;
     this._metadataRetrieved = prototype.MetadataRetrieved;
     this._metadata = prototype.Metadata;
     this._datasetType = prototype.DatasetType;
     this._dsid = prototype.DSID;
     this._versioned = prototype.Versioned;
     this._canVersion = prototype.CanVersion;
 }
Exemplo n.º 19
0
 public IEnumDataset get_Datasets(esriDatasetType DatasetType)
 {
     return new PostGisEnumDataset();
 }
Exemplo n.º 20
0
        private static IDatasetName GetDatasetNameInWorkspaceSearchTop(IWorkspace workspace, string dataname, esriDatasetType type)
        {
            //look for data in top level names
            IEnumDatasetName names = workspace.DatasetNames[type];
            IDatasetName     name  = names.Next();

            while (name != null)
            {
                if (name.Name.ToLower() == dataname.ToLower())
                {
                    return(name);
                }
                name = names.Next();
            }
            return(null);
        }
        // check if data exists in file geodatabase
        #region "check if name exists in database"
        // this method checks if the feature class or table exist in the geodatabase
        public static bool NameExists(string strFCName, esriDatasetType dataType)
        {
            bool blnNameExists = clsGlobals.arcWorkspace2GeocodeFGD.get_NameExists(dataType, strFCName);

            return(blnNameExists);
        }
Exemplo n.º 22
0
        private static IDatasetName GetDatasetNameFromContainer(IWorkspace workspace, string container, string dataset, esriDatasetType type)
        {
            //look for data in all FeatureDatasets
            IEnumDatasetName containers = workspace.DatasetNames[esriDatasetType.esriDTFeatureDataset];
            IDatasetName     name1      = containers.Next();

            while (name1 != null)
            {
                if (name1.Name.ToLower() == container.ToLower())
                {
                    break;
                }
                name1 = containers.Next();
            }

            //look for data in all containers (feature datasets are not containers, why I don't know)
            //containers are rasters (contain bands), coverage feature classes (contain arc, lines, ...), etc.
            //find the container
            if (name1 == null)
            {
                containers = workspace.DatasetNames[esriDatasetType.esriDTContainer];
                name1      = containers.Next();
                while (name1 != null)
                {
                    if (name1.Name.ToLower() == container.ToLower())
                    {
                        break;
                    }
                    name1 = containers.Next();
                }
                if (name1 == null)
                {
                    return(null);
                }
            }

            // look for data in the feature dataset
            IEnumDatasetName names = name1.SubsetNames;
            IDatasetName     name2 = names.Next();

            while (name2 != null)
            {
                if (name2.Name.ToLower() == dataset.ToLower())
                {
                    return(name2);
                }
                name2 = names.Next();
            }
            return(null);
        }
Exemplo n.º 23
0
        public Dataset(SerializationInfo info, StreamingContext context) : base(info, context) {
            // Suspend
            this.SuspendEvents = true;

            this._name = info.GetString(Dataset.NAME_);
            this._childrenExpanded = info.GetBoolean(Dataset.CHILDRENEXPANDED_);
            this._fullPropsDefault = info.GetBoolean(Dataset.FULLPROPSDEFAULT_);
            this._metadataRetrieved = info.GetBoolean(Dataset.METADATARETRIEVED_);
            this._metadata = info.GetString(Dataset.METADATA_);
            this._datasetType = (esriDatasetType)Enum.Parse(typeof(esriDatasetType), info.GetString(Dataset.DATASETTYPE_), true);
            this._dsid = info.GetInt32(Dataset.DSID_);
            this._versioned = info.GetBoolean(Dataset.VERSIONED_);
            this._canVersion = info.GetBoolean(Dataset.CANVERSION_);

            // Resume
            this.SuspendEvents = false;
        }
 private List<string> getNames(esriDatasetType dType)
 {
     geoDatabaseUtility geoUtil = new geoDatabaseUtility();
     List<string> lyrLst = new List<string>();
     switch (dType)
     {
         case esriDatasetType.esriDTFeatureClass:
             lyrLst = geoUtil.getAllFeatureNames(prjDatabase);
             break;
         case esriDatasetType.esriDTRasterDataset:
             lyrLst = geoUtil.getAllRasterNames(prjDatabase);
             break;
         case esriDatasetType.esriDTTable:
             lyrLst = geoUtil.getAllTableNames(prjDatabase);
             break;
         default:
             break;
     }
     return lyrLst;
 }
Exemplo n.º 25
0
        public static IEnumerable <IDataset> FeatureDatasetsInWorkspace(this IWorkspace workspace, string userFilter, esriDatasetType esriDatasetType)
        {
            var      datasets = workspace.Datasets[esriDatasetType];
            IDataset dataset  = null;

            while ((dataset = datasets.Next()) != null)
            {
                yield return(dataset);
            }
        }
Exemplo n.º 26
0
        public static string GetFinalName2(IWorkspace iworkspace_0, esriDatasetType esriDatasetType_0, string string_0,
                                           string string_1, string string_2)
        {
            string text = string_0 + string_1 + string_2;
            int    num  = 1;

            if (esriDatasetType_0 == esriDatasetType.esriDTFeatureDataset)
            {
                try
                {
                    while (true)
                    {
                        IFeatureDataset featureDataset = (iworkspace_0 as IFeatureWorkspace).OpenFeatureDataset(text);
                        if (featureDataset == null)
                        {
                            break;
                        }
                        text = string.Concat(new string[]
                        {
                            string_0,
                            string_1,
                            string_2,
                            "_",
                            num.ToString()
                        });
                        num++;
                    }
                    return(text);
                }
                catch
                {
                    return(text);
                }
            }
            string text2;

            ((IFieldChecker) new FieldChecker
            {
                ValidateWorkspace = iworkspace_0
            }).ValidateTableName(string_1, out text2);
            text = string_0 + text2 + string_2;
            if (iworkspace_0.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace ||
                iworkspace_0.Type == esriWorkspaceType.esriLocalDatabaseWorkspace)
            {
                while (((IWorkspace2)iworkspace_0).get_NameExists(esriDatasetType.esriDTFeatureClass, text))
                {
                    text = string.Concat(new string[]
                    {
                        string_0,
                        text2,
                        string_2,
                        "_",
                        num.ToString()
                    });
                    num++;
                }
            }
            else if (iworkspace_0.Type != esriWorkspaceType.esriFileSystemWorkspace)
            {
            }
            return(text);
        }
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IGxApplication  gxApp     = m_application as IGxApplication;
            IGxDataset      gxDataset = null;
            esriDatasetType dsType    = esriDatasetType.esriDTAny;

            if (gxApp != null)
            {
                gxDataset = gxApp.SelectedObject as IGxDataset;
                dsType    = gxDataset.Type;
            }

            if (dsType != esriDatasetType.esriDTNetworkDataset)
            {
                return;
            }

            IDataset ds = gxDataset.Dataset;

            if (ds == null)
            {
                return;
            }

            INetworkDataset nds = ds as INetworkDataset;

            if (nds == null)
            {
                return;
            }

            if (!nds.Buildable)
            {
                return;
            }

            INetworkBuild netBuild = nds as INetworkBuild;

            if (netBuild == null)
            {
                return;
            }

            IDatasetComponent dsComponent = nds as IDatasetComponent;
            IDENetworkDataset deNet       = null;

            if (dsComponent != null)
            {
                deNet = dsComponent.DataElement as IDENetworkDataset;
            }

            if (deNet == null)
            {
                return;
            }

            FilterSubsetEvaluator.RemoveFilterSubsetAttribute(deNet);
            ScaleSubsetEvaluator.RemoveScaleSubsetAttributes(deNet);

            FilterSubsetEvaluator.AddFilterSubsetAttribute(deNet);
            ScaleSubsetEvaluator.AddScaleSubsetAttributes(deNet);

            netBuild.UpdateSchema(deNet);
        }
Exemplo n.º 28
0
 /// <summary>
 /// delete a featureclass that is within the NPS geodatabase
 /// </summary>
 public static void DeleteDataset(string FCName, esriDatasetType DatasetType, ref string ErrorMessage)
 {
     Util.DeleteDataset(FCName, DatasetType, NPSGlobal.Instance.Workspace, ref ErrorMessage);
 }
Exemplo n.º 29
0
 public INativeType get_NativeType(esriDatasetType DatasetType, string localName)
 {
     return(null);
 }
Exemplo n.º 30
0
        /// <summary>
        /// delete a featureclass that is within the specified workspace
        /// </summary>
        public static void DeleteDataset(string DSName, esriDatasetType DatasetType,
            IWorkspace ThisWorkspace, ref string ErrorMessage)
        {
            string InternalMessage = "";
            IDataset ThisDataset = null;

            try
            {
                switch (DatasetType)
                {
                    case esriDatasetType.esriDTFeatureClass:
                        ThisDataset = Util.GetFeatureClass(DSName, ThisWorkspace, ref InternalMessage) as IDataset;
                        break;
                    case esriDatasetType.esriDTTable:
                        ThisDataset = Util.GetTable(DSName, ThisWorkspace, ref InternalMessage) as IDataset;
                        break;

                }

                if (string.IsNullOrEmpty(InternalMessage) == false) return;

                ThisDataset.Delete();
            }
            catch (Exception ex)
            {
                ErrorMessage = "Error occured while deleting dataset " + DSName + ". " + ex.Message;
            }
        }
Exemplo n.º 31
0
        private static object OpenObjectFromWorkspace(IWorkspace wrkSpace, string name, esriDatasetType objType)
        {
            //string methodName = MethodInfo.GetCurrentMethod().Name;
            object o = null;

            IFeatureWorkspace featWorkspace = (IFeatureWorkspace)wrkSpace;
            try
            {
                switch (objType)
                {
                    case esriDatasetType.esriDTFeatureClass:
                        o = featWorkspace.OpenFeatureClass(name);
                        break;
                    case esriDatasetType.esriDTFeatureDataset:
                        o = featWorkspace.OpenFeatureDataset(name);
                        break;
                    case esriDatasetType.esriDTRelationshipClass:
                        o = featWorkspace.OpenRelationshipClass(name);
                        break;
                    case esriDatasetType.esriDTTable:
                        o = featWorkspace.OpenTable(name);
                        break;
                    default:
                        break;
                }
            }
            catch (Exception e)
            {
                // _logger.Log(string.Format("Failed to open object from workspace. ObjectName:{0}; Error:{1}.", name, e.ToString()), LogLevel.enumLogLevelDebug);
            }

            return o;
        }
Exemplo n.º 32
0
        // check if data exists in file geodatabase

        #region "check if name exists in database"

        // this method checks if the feature class or table exist in the geodatabase
        public static bool NameExists(IWorkspace2 workspace, string strFCName, esriDatasetType dataType)
        {
            var blnNameExists = workspace.get_NameExists(dataType, strFCName);

            return(blnNameExists);
        }
Exemplo n.º 33
0
 /// <summary>
 /// Gets all the datasets from the given dataset of a specified dataset type.
 /// </summary>
 /// <param name="dSet">The dataset object from which to get the datasets.</param>
 /// <param name="type">The type of dataset to get.</param>
 /// <param name="dSets">A list of datasets.</param>
 public static void GetDatasetsByType(IDataset dSet, esriDatasetType type, ref IList<IDataset> dSets)
 {
     if (dSet != null)
     {
         if (dSet.Type == type || type == esriDatasetType.esriDTAny)
         {
             if (!dSets.Contains(dSet))
                 dSets.Add(dSet);
         }
         IEnumDataset dataSets;
         try
         {
             dataSets = dSet.Subsets;
         }
         catch
         {
             dataSets = null;
         }
         if (dataSets != null)
         {
             dataSets.Reset();
             IDataset ds = null;
             try { ds = dataSets.Next(); }
             catch { ds = null; }
             while (ds != null)
             {
                 GetDatasetsByType(ds, type, ref dSets);
                 try { ds = dataSets.Next(); }
                 catch (Exception e)
                 {
                     ds = null;
                 }
             }
         }
     }
 }
Exemplo n.º 34
0
        private  void GetXyDomain(IWorkspace ipWs, ref double dblXMin, ref double dblYMin, ref double dblXMax, ref double dblYMax)
        {
            dblXMin = 10000000;
            dblYMin = 10000000;
            dblXMax = -10000000;
            dblYMax = -10000000;

            IEnumDataset ipEnumFeatureClassDataset;
            ipEnumFeatureClassDataset = ipWs.get_Datasets(esriDatasetType.esriDTAny);
            IDataset ipFeatureClassDataset = ipEnumFeatureClassDataset.Next();
            double x1;
            double y1;
            double x2;
            double y2;
            string sX1, sY1;
            if (ipFeatureClassDataset != null)
            {
                esriDatasetType enuEsriDsType = ipFeatureClassDataset.Type;

                //独立要素类
                if (enuEsriDsType == esriDatasetType.esriDTFeatureClass)
                {
                    IFeatureClass ipFeaCls = (IFeatureClass)ipFeatureClassDataset;
                    IGeoDataset ipGeoDataset = ipFeaCls as IGeoDataset;
                    IEnvelope ipEnve = ipGeoDataset.Extent;
                    if (ipGeoDataset == null)
                    {
                        ipFeatureClassDataset = ipEnumFeatureClassDataset.Next();
                    }

                    x1 = ipEnve.XMin;
                    y1 = ipEnve.YMin;
                    x2 = ipEnve.XMax;
                    y2 = ipEnve.YMax;

                    sX1 = x1.ToString();
                    sY1 = y1.ToString();

                    if (x1 < dblXMin && sX1.IndexOf("QNAN", 0) == -1)
                    {
                        dblXMin = x1;
                    }
                    if (y1 < dblYMin && sY1.IndexOf("QNAN", 0) == -1)
                    {
                        dblYMin = y1;
                    }
                    if (x2 > dblXMax)
                    {
                        dblXMax = x2;
                    }
                    if (y2 > dblYMax)
                    {
                        dblYMax = y2;
                    }

                }
                //要素集中的要素类
                else if (enuEsriDsType == esriDatasetType.esriDTFeatureDataset)
                {
                    IEnumDataset ipEnumDs = ipFeatureClassDataset.Subsets;
                    IDataset ipDs;

                    while ((ipDs = ipEnumDs.Next()) != null)
                    {
                        IFeatureClass ipFeaCls = ipDs as IFeatureClass;
                        IGeoDataset ipGeoDataset = ipFeaCls as IGeoDataset;
                        IEnvelope ipEnve;
                        if (ipGeoDataset == null)
                            continue;
                        ipEnve = ipGeoDataset.Extent;

                        x1 = ipEnve.XMin;
                        y1 = ipEnve.YMin;
                        x2 = ipEnve.XMax;
                        y2 = ipEnve.YMax;

                        sX1 = x1.ToString();
                        sY1 = y1.ToString();

                        if (x1 < dblXMin && sX1.IndexOf("QNAN", 0) == -1)
                        {
                            dblXMin = x1;
                        }
                        if (y1 < dblYMin && sY1.IndexOf("QNAN", 0) == -1)
                        {
                            dblYMin = y1;
                        }
                        if (x2 > dblXMax)
                        {
                            dblXMax = x2;
                        }
                        if (y2 > dblYMax)
                        {
                            dblYMax = y2;
                        }
                        break;
                    }
                }
            }
        }
Exemplo n.º 35
0
        public IEnumDatasetName get_DatasetNames(esriDatasetType DatasetType)
        {
            if (DatasetType == esriDatasetType.esriDTFeatureClass)
            {
                // Todo - this should return any table registered with the geometry columns table.
            }

            return new PostGisEnumDatasetName(connection);

            // Todo - perhaps in the future support of tables might be nice.
        }
Exemplo n.º 36
0
        private static IDatasetName GetDatasetNameFromContainer(IWorkspace workspace, string container, string dataset, esriDatasetType type)
        {
            //look for data in all FeatureDatasets
            IEnumDatasetName containers = workspace.DatasetNames[esriDatasetType.esriDTFeatureDataset];
            IDatasetName name1 = containers.Next();
            while (name1 != null)
            {
                if (name1.Name.ToLower() == container.ToLower())
                    break;
                name1 = containers.Next();
            }

            //look for data in all containers (feature datasets are not containers, why I don't know)
            //containers are rasters (contain bands), coverage feature classes (contain arc, lines, ...), etc.
            //find the container
            if (name1 == null)
            {
                containers = workspace.DatasetNames[esriDatasetType.esriDTContainer];
                name1 = containers.Next();
                while (name1 != null)
                {
                    if (name1.Name.ToLower() == container.ToLower())
                        break;
                    name1 = containers.Next();
                }
                if (name1 == null)
                    return null;
            }

            // look for data in the feature dataset
            IEnumDatasetName names = name1.SubsetNames;
            IDatasetName name2 = names.Next();
            while (name2 != null)
            {
                if (name2.Name.ToLower() == dataset.ToLower())
                    return name2;
                name2 = names.Next();
            }
            return null;
        }
Exemplo n.º 37
0
 public INameMapping FindDatasetName(string string_0, esriDatasetType esriDatasetType_0)
 {
     return(null);
 }
Exemplo n.º 38
0
 public override IEnumerable <IDataset> GetDatasets(esriDatasetType datasetType)
 {
     return(_tablesByName.Values.Where(
                t => t.Type == datasetType ||
                datasetType == esriDatasetType.esriDTAny));
 }
Exemplo n.º 39
0
 private static string GetMetaData(string workspaceType, string workspacePath, string container, string data, esriDatasetType type)
 {
     IDatasetName results = null;
     IWorkspace workspace = GetWorkspace(workspaceType, workspacePath, null);
     if (string.IsNullOrEmpty(container))
         results = GetDatasetName(workspace, data, type);
     else if (container == "*")
         results = GetDatasetNameInWorkspaceSearchContainers(workspace, data, type);
     else
         results = GetDatasetNameFromContainer(workspace, container, data, type);
     if (results == null)
         return null;
      return ((IXmlPropertySet2)((IMetadata)results).Metadata).GetXml("");
 }
Exemplo n.º 40
0
 /// <summary>
 /// Indicates whether the extension owns a dataset type.
 /// </summary>
 /// <param name="datasetType">The type of dataset to check.</param>
 /// <returns>False; this extension owns no dataset types.</returns>
 public Boolean OwnsDatasetType(esriDatasetType datasetType)
 {
     return(false);
 }
Exemplo n.º 41
0
 private static IDatasetName GetDatasetNameInWorkspaceSearchTop(IWorkspace workspace, string dataname, esriDatasetType type)
 {
     //look for data in top level names
     IEnumDatasetName names = workspace.DatasetNames[type];
     IDatasetName name = names.Next();
     while (name != null)
     {
         if (name.Name.ToLower() == dataname.ToLower())
             return name;
         name = names.Next();
     }
     return null;
 }
Exemplo n.º 42
0
 private string FixDatasetType(esriDatasetType dt)
 {
     // Do not add spaces - to maintain compatibility with ArcObjects 10.x
     return(dt.ToString().Replace("esriDT", ""));
 }
Exemplo n.º 43
0
 IEnumDataset IWorkspace.get_Datasets(esriDatasetType DatasetType)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 44
0
 /// <summary>
 /// 删除已存在的指定类型的数据集
 /// </summary>
 /// <param name="targetWorkspace"></param>
 /// <param name="datasetName"></param>
 /// <param name="type"></param>
 public void DeleteDataset(IWorkspace targetWorkspace, IDatasetName datasetName, esriDatasetType type = esriDatasetType.esriDTFeatureClass)
 {
     if (IsNameExist(targetWorkspace, datasetName.Name, type))
     {
         (targetWorkspace as IFeatureWorkspaceManage).DeleteByName(datasetName);
     }
 }
Exemplo n.º 45
0
 /// <summary>
 /// An enumerator of private dataset names used by the extension.
 /// Not used in this implementation.
 /// </summary>
 /// <param name="datasetType">The dataset type.</param>
 /// <returns>An enumerator of strings.</returns>
 public IEnumBSTR get_PrivateDatasetNames(esriDatasetType datasetType)
 {
     return(null);
 }
Exemplo n.º 46
0
 public IEnumDataset get_Datasets(esriDatasetType datasetType)
 {
     return(new DatasetEnum(_backingDataStore.GetDatasets(datasetType)));
 }
Exemplo n.º 47
0
        //
        // CONSTRUCTOR
        //
        public Dataset(IXPathNavigable path) : base(path)
        {
            // Suspend
            this.SuspendEvents = true;

            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <Name>
            XPathNavigator navigatorName = navigator.SelectSingleNode(Xml.NAME);

            if (navigatorName != null)
            {
                this._name = navigatorName.Value;
            }

            // <ChildrenExpanded>
            XPathNavigator navigatorChildrenExpanded = navigator.SelectSingleNode(Xml.CHILDRENEXPANDED);

            if (navigatorChildrenExpanded != null)
            {
                this._childrenExpanded = navigatorChildrenExpanded.ValueAsBoolean;
            }

            // <FullPropsRetrieved>
            XPathNavigator navigatorFullPropsRetrieved = navigator.SelectSingleNode(Xml.FULLPROPSRETRIEVED);

            if (navigatorFullPropsRetrieved != null)
            {
                this._fullPropsDefault = navigatorFullPropsRetrieved.ValueAsBoolean;
            }

            // <MetadataRetrieved>
            XPathNavigator navigatorMetadataRetrieved = navigator.SelectSingleNode(Xml.METADATARETRIEVED);

            if (navigatorMetadataRetrieved != null)
            {
                this._metadataRetrieved = navigatorMetadataRetrieved.ValueAsBoolean;
            }

            // <Metadata><XmlDoc>
            if (this._metadataRetrieved)
            {
                XPathNavigator navigatorMetadata = navigator.SelectSingleNode(string.Format("{0}/{1}", Xml.METADATA, Xml.XMLDOC));
                if (navigatorMetadata != null)
                {
                    this._metadata = navigatorMetadata.Value;
                }
            }

            // <DatasetType>
            XPathNavigator navigatorDatasetType = navigator.SelectSingleNode(Xml.DATASETTYPE);

            if (navigatorDatasetType != null)
            {
                this._datasetType = (esriDatasetType)Enum.Parse(typeof(esriDatasetType), navigatorDatasetType.Value, true);
            }

            // <DSID>
            if (this._fullPropsDefault)
            {
                XPathNavigator navigatorDSID = navigator.SelectSingleNode(Xml.DSID);
                if (navigatorDSID != null)
                {
                    this._dsid = navigatorDSID.ValueAsInt;
                }
            }

            // <Versioned>
            if (this._fullPropsDefault)
            {
                XPathNavigator navigatorVersioned = navigator.SelectSingleNode(Xml.VERSIONED);
                if (navigatorVersioned != null)
                {
                    this._versioned = navigatorVersioned.ValueAsBoolean;
                }
            }

            // <CanVersion>
            if (this._fullPropsDefault)
            {
                XPathNavigator navigatorCanVersion = navigator.SelectSingleNode(Xml.CANVERSION);
                if (navigatorCanVersion != null)
                {
                    this._canVersion = navigatorCanVersion.ValueAsBoolean;
                }
            }

            // Refresh Dataset
            this.Refresh();

            // Resume
            this.SuspendEvents = false;
        }
 /// <summary>
 /// returns a dictionary of elements by name/ elementobject
 /// </summary>
 /// <param name="geoDatabase">geodatabase path</param>
 /// <param name="dtype">data type</param>
 /// <returns>dicitonary key=name value=IName object</returns>
 public Dictionary<string, IName> getElementINames(string geoDatabase, esriDatasetType dtype)
 {
     if (wksExists(geoDatabase))
     {
         IWorkspace wks = OpenWorkSpace(geoDatabase);
         return getElementINames(wks, dtype);
     }
     else
     {
         return new Dictionary<string, IName>();
     }
 }
Exemplo n.º 49
0
 private void listView1_DoubleClick(object sender, EventArgs e)
 {
     if (this.listView1.SelectedItems.Count != 0)
     {
         MyDoubleClickResult myDCRShowChildren;
         IGxObject           tag = this.listView1.SelectedItems[0].Tag as IGxObject;
         if ((this.igxObjectFilter_0 != null) && (tag is IGxDatabase))
         {
             myDCRShowChildren = MyDoubleClickResult.myDCRShowChildren;
             this.igxObjectFilter_0.CanChooseObject(tag, ref myDCRShowChildren);
             if (myDCRShowChildren == MyDoubleClickResult.myDCRChooseAndDismiss)
             {
                 this.method_4();
                 return;
             }
         }
         if (!(tag is IGxObjectContainer))
         {
             if (tag is IGxNewDatabase)
             {
                 IWorkspaceName name;
                 IGxObject      obj3;
                 ListViewItem   item;
                 if (tag.FullName == "添加OLE DB连接")
                 {
                     try
                     {
                         string path = Environment.SystemDirectory.Substring(0, 2) +
                                       @"\Documents and Settings\Administrator\Application Data\ESRI\ArcCatalog\";
                         string str2 = path + "OLE DB Connection.odc";
                         if (Directory.Exists(path))
                         {
                             str2 = this.method_6(str2);
                             IWorkspaceFactory factory = new OLEDBWorkspaceFactoryClass();
                             name = factory.Create(path, System.IO.Path.GetFileName(str2), null, 0);
                             obj3 = new GxDatabase();
                             (obj3 as IGxDatabase).WorkspaceName = name;
                             obj3.Attach(tag.Parent, this.igxCatalog_0);
                             item = new ListViewItem(new string[] { obj3.Name, obj3.Category }, this.method_2(obj3))
                             {
                                 Tag = obj3
                             };
                             this.listView1.Items.Add(item);
                         }
                     }
                     catch (Exception exception)
                     {
                         exception.ToString();
                     }
                 }
                 else if (tag.FullName == "添加空间数据库连接")
                 {
                     frmCreateGDBConnection connection = new frmCreateGDBConnection
                     {
                         TopMost = true
                     };
                     if (connection.ShowDialog() == DialogResult.OK)
                     {
                         obj3 = new GxDatabase();
                         name = new WorkspaceNameClass
                         {
                             WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory",
                             PathName = connection.ConnectionPath
                         };
                         (obj3 as IGxDatabase).WorkspaceName = name;
                         obj3.Attach(tag.Parent, this.igxCatalog_0);
                         item = new ListViewItem(new string[] { obj3.Name, obj3.Category }, this.method_2(obj3))
                         {
                             Tag = obj3
                         };
                         this.listView1.Items.Add(item);
                     }
                 }
             }
             else
             {
                 this.method_4();
             }
         }
         else
         {
             ImageComboBoxItemEx ex;
             if (tag is IGxDataset)
             {
                 esriDatasetType type = (tag as IGxDataset).Type;
                 myDCRShowChildren = MyDoubleClickResult.myDCRShowChildren;
                 this.igxObjectFilter_0.CanChooseObject(tag, ref myDCRShowChildren);
                 if ((((type != esriDatasetType.esriDTFeatureDataset) &&
                       (type != esriDatasetType.esriDTContainer)) &&
                      ((type != esriDatasetType.esriDTRasterCatalog) &&
                       (type != esriDatasetType.esriDTCadDrawing))) &&
                     (type != esriDatasetType.esriDTRasterDataset))
                 {
                     this.method_4();
                     return;
                 }
             }
             this.method_10(tag);
             this.bool_0 = false;
             if (tag.Parent is IGxCatalog)
             {
                 for (int i = 0; i < this.imageComboBoxEdit1.Properties.Items.Count; i++)
                 {
                     ex = this.imageComboBoxEdit1.Properties.Items[i] as ImageComboBoxItemEx;
                     if (ex.Tag == tag)
                     {
                         this.imageComboBoxEdit1.SelectedIndex = i;
                         break;
                     }
                 }
             }
             else
             {
                 ex =
                     this.imageComboBoxEdit1.Properties.Items[this.imageComboBoxEdit1.SelectedIndex] as
                     ImageComboBoxItemEx;
                 int degree = ex.Degree;
                 ex = new ImageComboBoxItemEx(tag.Name, tag.FullName, this.method_2(tag), degree + 1)
                 {
                     Tag = tag
                 };
                 int selectedIndex = this.imageComboBoxEdit1.SelectedIndex;
                 this.imageComboBoxEdit1.Properties.Items.Insert(selectedIndex + 1, ex);
                 this.imageComboBoxEdit1.SelectedIndex = selectedIndex + 1;
             }
             this.bool_0 = true;
         }
     }
 }
        /// <summary>
        /// returns a dictionary of elements by name/ elementobject
        /// </summary>
        /// <param name="geoDatabase">Iworkspace</param>
        /// <param name="dtype">data type</param>
        /// <returns>dicitonary key=name value=IName object</returns>
        public Dictionary<string, IName> getElementINames(IWorkspace wks, esriDatasetType dtype)
        {
            Dictionary<string,IName> lstFeatureClasses = new Dictionary<string,IName>();
            if (wks.Exists())
            {
                esriDatasetType dttype = esriDatasetType.esriDTAny;
                IEnumDataset eDatasets = wks.get_Datasets(dttype);
                IEnumDataset eDatasets2;
                IDataset dataset2;
                IDataset dataset = eDatasets.Next();
                while (dataset != null)
                {
                    dttype = dataset.Type;
                    switch (dttype)
                    {
                        case esriDatasetType.esriDTFeatureDataset:
                            eDatasets2 = dataset.Subsets;
                            dataset2 = eDatasets2.Next();
                            while (dataset2 != null)
                            {
                                if (dataset2.Type == dtype)
                                {
                                    lstFeatureClasses.Add(dataset2.BrowseName, dataset2.FullName);
                                }
                                dataset2 = eDatasets2.Next();
                            }
                            break;

                        default:
                            if (dttype == dtype)
                            {
                                lstFeatureClasses.Add(dataset.BrowseName, dataset.FullName);
                            }
                            break;
                    }
                    dataset = eDatasets.Next();
                }
            }

            return lstFeatureClasses;
        }
Exemplo n.º 51
0
        private void txtWorkspace_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            m_Workspace = null;
            switch (m_SelectedWorkspaceType)
            {
            case enumWorkspaceType.SDE:
                FrmSDESetting frmSetting = new FrmSDESetting();
                if (m_SDEPropertySet != null)
                {
                    frmSetting.SDEPropertySet = m_SDEPropertySet;
                }

                if (frmSetting.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                m_SDEPropertySet  = frmSetting.SDEPropertySet;
                txtWorkspace.Text = Utility.WorkspaceHelper.PropertySetToString(m_SDEPropertySet);
                m_Workspace       = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.SDE, m_SDEPropertySet);

                break;

            case enumWorkspaceType.FileGDB:
                if (folderBrowserWorkspace.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                txtWorkspace.Text = folderBrowserWorkspace.SelectedPath;
                m_Workspace       = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.FileGDB, folderBrowserWorkspace.SelectedPath);

                break;

            case enumWorkspaceType.PGDB:
                dlgWorkspace.Filter = "PGDB |*.mdb";
                if (dlgWorkspace.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                txtWorkspace.Text = dlgWorkspace.FileName;
                m_Workspace       = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.PGDB, dlgWorkspace.FileName);

                break;

            case enumWorkspaceType.File:
                if (folderBrowserWorkspace.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                txtWorkspace.Text = folderBrowserWorkspace.SelectedPath;
                m_Workspace       = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.File, folderBrowserWorkspace.SelectedPath);

                break;
            }

            // 判断
            if (m_Workspace == null)
            {
                XtraMessageBox.Show("非正确的数据库!");
                return;
            }

            // 加载Dataset
            cmbDataset.Properties.Items.Clear();
            cmbDataset.Properties.Items.Add("");
            esriDatasetType  dsType        = (this.m_PathType == enumPathType.Feature ? esriDatasetType.esriDTFeatureDataset : esriDatasetType.esriDTRasterCatalog);
            IEnumDatasetName enDatasetName = m_Workspace.get_DatasetNames(dsType);
            IDatasetName     dsName        = enDatasetName.Next();

            while (dsName != null)
            {
                cmbDataset.Properties.Items.Add(dsName.Name);
                dsName = enDatasetName.Next();
            }
        }
 /// <summary>
 /// copies the feature Class table from one database to another
 /// </summary>
 /// <param name="inWks">inWorkspace</param>
 /// <param name="inObjName">object name</param>
 /// <param name="outWks">out workspace</param>
 /// <param name="dType">data type</param>
 /// <returns>messages</returns>
 public string copyFeatureClassTable(IWorkspace inWks, string inObjName, IWorkspace outWks, esriDatasetType dType)
 {
     if (!(dType == esriDatasetType.esriDTFeatureClass || dType == esriDatasetType.esriDTTable))
     {
         return "Error: must specify a FeatureClass or Table";
     }
     if (!((IWorkspace2)inWks).get_NameExists(dType, inObjName))
     {
         return "Error: Parent object does not exist!";
     }
     Console.WriteLine(inObjName);
     string x = "successfully copied " + inObjName;
     try
     {
         IDataset outWksDset = (IDataset)outWks;
         IName targetWks = outWksDset.FullName;
         IEnumName eName = new NamesEnumeratorClass();
         IEnumNameEdit eNameEdit = (IEnumNameEdit)eName;
         //need to get name of table
         IFeatureWorkspace ftrWks = (IFeatureWorkspace)inWks;
         IObjectClass objCls;
         if (dType == esriDatasetType.esriDTTable)
         {
             ITable inTbl = ftrWks.OpenTable(inObjName);
             objCls = (IObjectClass)inTbl;
         }
         else
         {
             IFeatureClass inFtr = ftrWks.OpenFeatureClass(inObjName);
             objCls = (IObjectClass)inFtr;
         }
         IDataset tblDset = (IDataset)objCls;
         eNameEdit.Add(tblDset.FullName);
         IGeoDBDataTransfer geoTrans = new GeoDBDataTransferClass();
         IEnumNameMapping enumNameMapping = null;
         Boolean conflictsFound = geoTrans.GenerateNameMapping(eName, targetWks, out enumNameMapping);
         enumNameMapping.Reset();
         try
         {
             if (conflictsFound)
             {
                 Console.WriteLine("Conflicts found can't transfer");
             }
             else
             {
                 geoTrans.Transfer(enumNameMapping, targetWks);
             }
         }
         catch (Exception e)
         {
             x = "Error in trasfering data: " + e.ToString();
             MessageBox.Show(x);
         }
     }
     catch (Exception e)
     {
         x = "Error: " + e.ToString();
         Console.WriteLine(x);
     }
     return x;
 }
 public static string GetDescription(esriDatasetType type) {
     switch (type) {
         case esriDatasetType.esriDTAny: return "Any";
         case esriDatasetType.esriDTCadastralFabric: return "Cadastral Fabric";
         case esriDatasetType.esriDTCadDrawing: return "Cad Drawing";
         case esriDatasetType.esriDTContainer: return "Container";
         case esriDatasetType.esriDTFeatureClass: return "Feature Class";
         case esriDatasetType.esriDTFeatureDataset: return "Feature Dataset";
         case esriDatasetType.esriDTGeo: return "Geo";
         case esriDatasetType.esriDTGeometricNetwork: return "Geometric Network";
         case esriDatasetType.esriDTLocator: return "Locator";
         case esriDatasetType.esriDTNetworkDataset: return "Network Dataset";
         case esriDatasetType.esriDTPlanarGraph: return "Planar Graph";
         case esriDatasetType.esriDTRasterBand: return "Raster Band";
         case esriDatasetType.esriDTRasterCatalog: return "Raster Catalog";
         case esriDatasetType.esriDTRasterDataset: return "Raster Dataset";
         case esriDatasetType.esriDTRelationshipClass: return "Relationship Class";
         case esriDatasetType.esriDTRepresentationClass: return "Representation Class";
         case esriDatasetType.esriDTSchematicDataset: return "Schematic Dataset";
         case esriDatasetType.esriDTTable: return "Table";
         case esriDatasetType.esriDTTerrain: return "Terrain";
         case esriDatasetType.esriDTText: return "Text";
         case esriDatasetType.esriDTTin: return "Tin";
         case esriDatasetType.esriDTTool: return "Tool";
         case esriDatasetType.esriDTToolbox: return "Toolbox";
         case esriDatasetType.esriDTTopology: return "Topology";
         default:
             return "UNKNOWN";
     }
 }
        /// <summary>
        /// returns a list of all feature names for a given data type
        /// </summary>
        /// <param name="geoDatabase">path to database</param>
        /// <param name="dtype">esri data type</param>
        /// <returns>string list of names</returns>
        private List<string> getElementNames(string geoDatabase, esriDatasetType dtype)
        {
            List<string> lstFeatureClasses = new List<string>();
            if (wksExists(geoDatabase))
            {
                IWorkspace wks = OpenWorkSpace(geoDatabase);
                esriDatasetType dttype = esriDatasetType.esriDTAny;
                IEnumDataset eDatasets = wks.get_Datasets(dttype);
                IEnumDataset eDatasets2;
                IDataset dataset2;
                IDataset dataset = eDatasets.Next();
                while (dataset != null)
                {
                    dttype = dataset.Type;
                    switch (dttype)
                    {
                        case esriDatasetType.esriDTFeatureDataset:
                            eDatasets2 = dataset.Subsets;
                            dataset2 = eDatasets2.Next();
                            while (dataset2 != null)
                            {
                                if (dataset2.Type == dtype)
                                {
                                    lstFeatureClasses.Add(dataset2.Name);
                                }
                                dataset2 = eDatasets2.Next();
                            }
                            break;

                        default:
                            if (dataset.Type == dtype)
                            {
                                lstFeatureClasses.Add(dataset.Name);
                            }
                            break;
                    }
                    dataset = eDatasets.Next();
                }
            }
            return lstFeatureClasses;
        }
Exemplo n.º 55
0
 /// <summary>
 ///     Determines whether the workspace contains the table name and type combination.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="source">The source.</param>
 /// <param name="type">The type.</param>
 /// <returns>
 ///     Returns a <see cref="bool" /> representing <c>true</c> when the workspace contains the table name and type.
 /// </returns>
 public static bool Contains <T>(this IWorkspace source, esriDatasetType type) where T : Entity
 {
     return(source.Contains(type, Entity.GetFullName <T>()));
 }
Exemplo n.º 56
0
        /// <summary>
        /// Gets the dataset name objects from the given dataset name.
        /// </summary>
        /// <param name="dsName">The dataset name from which to get dataset name objects.</param>
        /// <param name="type">The type of dataset name objects to get.</param>
        /// <param name="names">A dictionary of dataset name objects by qualified name.</param>
        private static void GetDatasetNames(IWorkspace workspace, IDatasetName dsName, esriDatasetType type, string[] networkClasses, ref IDictionary<string, IDatasetName> names, ref IDictionary<string, int> objClassIdByName)
        {
            try
            {
                if (dsName != null)
                {
                    if (dsName.Type == type || type == esriDatasetType.esriDTAny)
                    {
                        string key = (DisplayMap.GetQualifiedName(dsName, workspace)).ToLower();
                        if (key != string.Empty)
                        {
                            foreach (string clsName in networkClasses)
                            {
                                if (string.Compare(key, clsName, true) == 0)
                                {
                                    names[clsName] = dsName;
                                    if (dsName is IObjectClassName)
                                        objClassIdByName[clsName] = ((IObjectClassName)dsName).ObjectClassID;
                                    break;
                                }
                            }
                        }
                    }

                    IEnumDatasetName dataNames = dsName.SubsetNames;
                    if (dataNames != null)
                    {
                        dataNames.Reset();
                        IDatasetName name = dataNames.Next();

                        try
                        {
                            while (name != null)
                            {
                                GetDatasetNames(workspace, name, type, networkClasses, ref names, ref objClassIdByName);
                                name = dataNames.Next();
                            }
                        }
                        catch (Exception e)
                        {
                            // _logger.LogAndDisplayException(e);
                        }
                    }
                }
                // else
                //   _logger.LogFormat("{0}: Null dataset name parameter.", methodName, LogLevel.enumLogLevelWarn);
            }
            catch (Exception e)
            {
                // _logger.LogAndDisplayException(e);
            }
        }
Exemplo n.º 57
0
 public INativeType get_NativeType(esriDatasetType datasetType, string localName)
 {
     return null;
 }
Exemplo n.º 58
0
        private static object OpenFeatureWorkspaceObject(IWorkspace wrkSpace, string name, esriDatasetType objType)
        {
            // string methodName = MethodInfo.GetCurrentMethod().Name;
            object o = null;

            if (wrkSpace != null && name != string.Empty)
            {
                try
                {
                    if (wrkSpace is IFeatureWorkspace && wrkSpace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                    {
                        string dbName = string.Empty;
                        string ownerName = string.Empty;
                        if (wrkSpace != null && name != string.Empty)
                        {
                            // GetSdeDatabaseAndOwner(wrkSpace, out ownerName, out dbName);
                            string[] users = new string[] { "DBO", "SDE" };

                            name = (name.IndexOf('.') != -1) ? name.Substring(name.LastIndexOf('.') + 1) : name;
                            for (int i = 0; i < users.Length; i++)
                            {
                                string qualifiedName = name;
                                if (wrkSpace is ISQLSyntax)
                                    qualifiedName = ((ISQLSyntax)wrkSpace).QualifyTableName(dbName, users[i], name);

                                o = OpenObjectFromWorkspace(wrkSpace, qualifiedName, objType);
                                if (o != null)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else if (wrkSpace is IFeatureWorkspace)
                        o = OpenObjectFromWorkspace(wrkSpace, name, objType);
                    // else
                    //_logger.LogFormat("{0}: Workspace is not a Feature Workspace.", methodName, LogLevel.enumLogLevelInfo);
                }
                catch (Exception e)
                {
                    //_logger.LogException(e);
                }
            }
            // else
            // _logger.LogFormat("{0}: Null workspace or name parameter.", methodName, LogLevel.enumLogLevelWarn);

            return o;
        }
Exemplo n.º 59
0
        public string get_DatasetDescription(esriDatasetType datasetType)
        {
            switch (datasetType)
            {
                case esriDatasetType.esriDTTable:
                    return "OGR Table";
                case esriDatasetType.esriDTFeatureClass:
                    return "OGR Feature Class";
                case esriDatasetType.esriDTFeatureDataset:
                    return "OGR Feature Dataset";

                default:
                    return null;
            }
        }
Exemplo n.º 60
0
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count != 0)
            {
                MyDoubleClickResult myDCRShowChildren;
                IGxObject           tag = this.listView1.SelectedItems[0].Tag as IGxObject;
                if ((this._gxObjectFilter != null) && (tag is IGxDatabase))
                {
                    myDCRShowChildren = MyDoubleClickResult.myDCRShowChildren;
                    this._gxObjectFilter.CanChooseObject(tag, ref myDCRShowChildren);
                    if (myDCRShowChildren == MyDoubleClickResult.myDCRChooseAndDismiss)
                    {
                        this.PassListItem();
                        return;
                    }
                }
                if (!(tag is IGxObjectContainer))
                {
                    if (tag is IGxNewDatabase)
                    {
                        IWorkspaceName name;
                        IGxObject      obj3;
                        ListViewItem   item;
                        if (tag.FullName == "添加OLE DB连接")
                        {
                            try
                            {
                                string path = Environment.SystemDirectory.Substring(0, 2) +
                                              @"\Documents and Settings\Administrator\Application Data\ESRI\ArcCatalog\";
                                string str2 = path + "OLE DB Connection.odc";
                                if (Directory.Exists(path))
                                {
                                    str2 = this.ChangeODCExtension(str2);
                                    IWorkspaceFactory factory = new OLEDBWorkspaceFactory() as IWorkspaceFactory;
                                    name = factory.Create(path, System.IO.Path.GetFileName(str2), null, 0);
                                    IGxObject gxDatabase = new GxDatabase() as IGxObject;
                                    (gxDatabase as IGxDatabase).WorkspaceName = name;
                                    gxDatabase.Attach(tag.Parent, this._gxCatalog);
                                    item = new ListViewItem(new string[] { gxDatabase.Name, gxDatabase.Category },
                                                            this.GetImageIndex(gxDatabase))
                                    {
                                        Tag = gxDatabase
                                    };
                                    this.listView1.Items.Add(item);
                                }
                            }
                            catch (Exception exception)
                            {
                                exception.ToString();
                            }
                        }
                        else if (tag.FullName == "添加空间数据库连接")
                        {
                            frmCreateGDBConnection connection = new frmCreateGDBConnection
                            {
                                TopMost = true
                            };
                            if (connection.ShowDialog() == DialogResult.OK)
                            {
                                IGxObject      oneObj = new GxDatabase() as IGxObject;
                                IWorkspaceName name2  = new WorkspaceName() as IWorkspaceName;
                                name2.WorkspaceFactoryProgID = "esriDataSourcesGDB.SdeWorkspaceFactory";
                                name2.PathName = connection.ConnectionPath;

                                (oneObj as IGxDatabase).WorkspaceName = name2;
                                oneObj.Attach(tag.Parent, this._gxCatalog);
                                item = new ListViewItem(new string[] { oneObj.Name, oneObj.Category },
                                                        this.GetImageIndex(oneObj))
                                {
                                    Tag = oneObj
                                };
                                this.listView1.Items.Add(item);
                            }
                        }
                    }
                    else
                    {
                        this.PassListItem();
                    }
                }
                else
                {
                    GISDataComboItem ex;
                    if (tag is IGxDataset)
                    {
                        esriDatasetType type = (tag as IGxDataset).Type;
                        myDCRShowChildren = MyDoubleClickResult.myDCRShowChildren;
                        this._gxObjectFilter.CanChooseObject(tag, ref myDCRShowChildren);
                        if ((((type != esriDatasetType.esriDTFeatureDataset) &&
                              (type != esriDatasetType.esriDTContainer)) &&
                             ((type != esriDatasetType.esriDTRasterCatalog) &&
                              (type != esriDatasetType.esriDTCadDrawing))) &&
                            (type != esriDatasetType.esriDTRasterDataset))
                        {
                            this.PassListItem();
                            return;
                        }
                    }
                    this.LoadViewer(tag);
                    this._isFree = false;
                    if (tag.Parent is IGxCatalog)
                    {
                        for (int i = 0; i < this.gisDataComboBox1.Items.Count; i++)
                        {
                            ex = this.gisDataComboBox1.Items[i] as GISDataComboItem;
                            if (ex.Tag == tag)
                            {
                                this.gisDataComboBox1.SelectedIndex = i;
                                break;
                            }
                        }
                    }
                    else
                    {
                        ex = this.gisDataComboBox1.Items[this.gisDataComboBox1.SelectedIndex] as GISDataComboItem;
                        int degree = ex.Level;
                        ex = new GISDataComboItem(tag.Name, tag.FullName, this.GetImageIndex(tag), degree + 1)
                        {
                            Tag = tag
                        };
                        int selectedIndex = this.gisDataComboBox1.SelectedIndex;
                        this.gisDataComboBox1.AddChildNode(ex);
                        this.gisDataComboBox1.SelectedIndex = selectedIndex + 1;
                    }
                    this._isFree = true;
                }
            }
        }