先简要来一句,关于server contexts 的一句,如果要实现复杂的功能,那么就必须用到它!
IServerObjectManager--->CreateServerContext --->
IServerContext
在Server Context 中,对于SO的操作有下面几种
CreateObject, SaveObject, and LoadObject
不用NEW,而.CreateObject创建对象,通过其接口,我们可以像在本地使用一样使用创建的对象
我们不能直接去对对象进行修改,而是使用其复制版本.
server contexts 就像一个容器,可以存储创建的对象,如下面的代码:
Dim pPointCollection as IPointCollection = pServerContext.CreateObject("esriGeometry.Polygon")
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
pServerContext.SetObject ("myPoly", pPointCollection)
Dim pPoly as IPolygon = pServerContext.GetObject("myPoly")
可以创建临时的Geodatabase,前提是要获取其文件夹的路径,前缀_ags将会在程序结束后删除,而其他非此前缀的将会被保存.
Dim
pServerContext
As
IServerContext
=
pSOM.CreateServerContext(
""
,
""
)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
Dim
pWSF
As
IWorkspaceFactory
=
pServerContext.CreateObject(
"
esriDataSourcesGDB.AccessWorkspaceFactory
"
)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
Dim
pEnumSDI
As
IEnumServerDirectoryInfo
=
pSOM.GetServerDirectoryInfos
Dim
pSDI
As
IServerDirectoryInfo
=
pEnumSDI.Next
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
Dim
pProps
As
IPropertySet
=
pServerContext.CreateObject(
"
esriSystem.PropertySet
"
)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
'
this database will be cleaned by the GIS server
pProps.SetProperty (
"
DATABASE
"
, pSDI.Path
&
"
\_ags_db1.mdb
"
)
pWSF.Create (pSDI.Path,
"
_ags_db1
"
, pProps,
0
)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
'
this database will not be cleaned by the GIS server
pProps.SetProperty (
"
DATABASE
"
, pSDI.Path
&
"
\db2.mdb
"
)
pWSF.Create (pSDI.Path,
"
db2
"
, pProps,
0
)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
'
this database will not be cleaned by the GIS server
pProps.SetProperty (
"
DATABASE
"
, pSDI.Path
&
"
\db2.mdb
"
)
pWSF.Create (pSDI.Path,
"
db2
"
, pProps,
0
)