Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1282979
  • 博文数量: 135
  • 博客积分: 10588
  • 博客等级: 上将
  • 技术积分: 1325
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-18 11:12
文章分类

全部博文(135)

文章存档

2013年(6)

2012年(3)

2011年(11)

2010年(7)

2009年(14)

2008年(6)

2007年(42)

2006年(46)

分类:

2009-08-05 17:00:56

arcgis92开始提供了Archiving功能,Enable Archving之后可以建立 不同时间点的版本数据库的链接,也可以建立与某个历史标记 的库的链接,用程序连接sde的时候一般是这样写,
public static  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);
        }
如果要连接到某个时间点,或者某个历史标记,只需要稍微改变一下SetProperty里面的Key参数就可以了。
//连接到某个时间点:
public static ESRI.ArcGIS.Geodatabase.IWorkspace ConnectHistoryVersion(String server, String instance, String user,
                                                                   String password, String database,  string  versionText)
        {
            // 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);
            propertySet.SetProperty("HISTORICAL_TIMESTAMP", DateTime.Parse(versionText) );
            ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2 workspaceFactory;
            workspaceFactory = (ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2)new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();
            return workspaceFactory.Open(propertySet, 0);
        }

//链接到某个历史标记
        public static ESRI.ArcGIS.Geodatabase.IWorkspace ConnectHistoryMarker(String server, String instance, String user,
                                                                   String password, String database, string versionText)
        {
            // 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("HISORICALMARKER", versionText);
            //propertySet.SetProperty("VERSION", versionText);
            //propertySet.SetProperty("HISTORICAL_TIMESTAMP", dt);
            ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2 workspaceFactory;
            workspaceFactory = (ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2)new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();
            return workspaceFactory.Open(propertySet, 0);
        }

阅读(2593) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~