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) |