Exemplo n.º 1
0
        //PCCoverageWorkspaceFactoryClass
        public override IFeatureClass getIFeatureClass()
        {
            string dir = this.getDir(this.LocalShapePathFileName);

            if (System.IO.Directory.Exists(dir))
            {
                dir = this.getDir(this.LocalShapePathFileName);
                string name = this.getFileNameEx(this.LocalShapePathFileName);

                ESRI.ArcGIS.esriSystem.IPropertySet propertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass();
                // path to coverage workspace directory
                propertySet.SetProperty("DATABASE", dir);

                PCCoverageWorkspaceFactoryClass objwsf = new PCCoverageWorkspaceFactoryClass();
                //propertySet =objwsf.ReadConnectionPropertiesFromFile(this.LocalShapePathFileName);
                IWorkspace objws = objwsf.Open(propertySet, 0);  //dir

                IFeatureWorkspace feaureWS = objws as IFeatureWorkspace;

                if (feaureWS != null)
                {
                    return(feaureWS.OpenFeatureClass(name));
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        private void TestConn_Click(object sender, EventArgs e)
        {
            Success = false;
            try
            {
                IWorkspace Currworkspace = null;
                string     IP            = textEdit1.Text;
                string     Instance      = textEdit2.Text;
                string     version       = textEdit6.Text;
                string     database      = textEdit3.Text;
                string     user          = textEdit7.Text;
                string     password      = textEdit4.Text;
                string     ConnCname     = textEdit5.Text;

                IPropertySet propertyset = new ESRI.ArcGIS.esriSystem.PropertySetClass();
                propertyset.SetProperty("Server", IP);
                propertyset.SetProperty("instance", Instance);
                propertyset.SetProperty("database", database);
                propertyset.SetProperty("user", user);
                propertyset.SetProperty("password", password);
                propertyset.SetProperty("version", version);
                IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactory();
                Currworkspace = workspaceFactory.Open(propertyset, 0);
                MessageBox.Show("连接成功!");
                Success = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("连接失败!");
                Success = false;
                string Error = ex.Message;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 打开personal geodatabase工作空间
 /// </summary>
 /// <param name="database">mdb文件所在的路径</param>
 /// <returns></returns>
 public static IWorkspace OpenPGDBWorkspace(string database)
 {
     try
     {
         ESRI.ArcGIS.esriSystem.IPropertySet propertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass();
         propertySet.SetProperty("DATABASE", database);
         IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass();
         return(workspaceFactory.Open(propertySet, 0));
     }
     catch (Exception ex)
     {
         LOG.Error("空间数据库打开错误,详情:" + ex.Message);
         // Console.WriteLine("空间数据库打开错误");
         return(null);
     }
 }
Exemplo n.º 4
0
        //SDEWorkspaceFromPropertySet

        // Returns a reference to an existing workspace via a propertyset
        // The connection parameters are passed in as arguements
        //
        //REFERENCES(REQUIRED)
        //ESRI.ArcGIS.Geodatabase
        //ESRI.ArcGIS.DataSourcesGDB
        public ESRI.ArcGIS.Geodatabase.IWorkspace SDEWorkspaceFromPropertySet(String server, String instance, String user,
                                                                              String password, String database, String version)
        {
            // Create and populate the property set
            ESRI.ArcGIS.esriSystem.IPropertySet propertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass();
            propertySet.SetProperty("SERVER", server);
            propertySet.SetProperty("INSTANCE", instance);
            propertySet.SetProperty("DATABASE", database);
            propertySet.SetProperty("USER", user);
            propertySet.SetProperty("PASSWORD", password);
            propertySet.SetProperty("VERSION", version);

            ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2 workspaceFactory;
            workspaceFactory = (ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2) new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();
            return(workspaceFactory.Open(propertySet, 0));
        }
Exemplo n.º 5
0
        //SDEWorkspaceFromPropertySet
        // Returns a reference to an existing workspace via a propertyset
        // The connection parameters are passed in as arguements
        //
        //REFERENCES(REQUIRED)
        //ESRI.ArcGIS.Geodatabase
        //ESRI.ArcGIS.DataSourcesGDB
        public ESRI.ArcGIS.Geodatabase.IWorkspace SDEWorkspaceFromPropertySet(String server, String instance, String user,
                                                    String password, String database, String version)
        {
            // Create and populate the property set
            ESRI.ArcGIS.esriSystem.IPropertySet propertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass();
            propertySet.SetProperty("SERVER", server);
            propertySet.SetProperty("INSTANCE", instance);
            propertySet.SetProperty("DATABASE", database);
            propertySet.SetProperty("USER", user);
            propertySet.SetProperty("PASSWORD", password);
            propertySet.SetProperty("VERSION", version);

            ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2 workspaceFactory;
            workspaceFactory = (ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2)new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();
            return workspaceFactory.Open(propertySet, 0);
        }
Exemplo n.º 6
0
        private void TestConn_Click(object sender, EventArgs e)
        {
            Success = false;
            try
            {
                IWorkspace Currworkspace = null;
                string IP = textEdit1.Text;
                string Instance = textEdit2.Text;
                string version = textEdit6.Text;
                string database = textEdit3.Text;
                string user = textEdit7.Text;
                string password = textEdit4.Text;
                string ConnCname = textEdit5.Text;

                IPropertySet propertyset = new ESRI.ArcGIS.esriSystem.PropertySetClass();
                propertyset.SetProperty("Server", IP);
                propertyset.SetProperty("instance", Instance);
                propertyset.SetProperty("database", database);
                propertyset.SetProperty("user", user);
                propertyset.SetProperty("password", password);
                propertyset.SetProperty("version", version);
                IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactory();
                Currworkspace = workspaceFactory.Open(propertyset, 0);
                MessageBox.Show("连接成功!");
                Success = true;

            }
            catch (Exception ex)
            {
                MessageBox.Show("连接失败!");
                Success = false;
                string Error = ex.Message;
            }
        }
Exemplo n.º 7
0
 public IWorkspace GetSDEWorkspace(String _pServerIP, String _pInstance, String _pUser, String _pPassword, String _pDatabase, String _pVersion)
 {
     // Create and populate the property set
     ESRI.ArcGIS.esriSystem.IPropertySet pPropertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass();
     pPropertySet.SetProperty("SERVER", _pServerIP);
     pPropertySet.SetProperty("INSTANCE", _pInstance);
     pPropertySet.SetProperty("DATABASE", _pDatabase);
     pPropertySet.SetProperty("USER", _pUser);
     pPropertySet.SetProperty("PASSWORD", _pPassword);
     pPropertySet.SetProperty("VERSION", _pVersion);
     ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2 workspaceFactory;
     workspaceFactory = (ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2)new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();
     return workspaceFactory.Open(pPropertySet, 0);
 }