关于server contexts

本文介绍如何利用ServerContext接口进行对象的创建、保存与加载,并演示了如何通过此接口创建临时GeoDatabase,包括其具体步骤及代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    先简要来一句,关于server contexts 的一句,如果要实现复杂的功能,那么就必须用到它!

    IServerObjectManager--->CreateServerContext --->IServerContext
   
    在Server Context 中,对于SO的操作有下面几种
    CreateObject, SaveObject, and LoadObject 
  
    不用NEW,而.CreateObject创建对象,通过其接口,我们可以像在本地使用一样使用创建的对象

     我们不能直接去对对象进行修改,而是使用其复制版本.
    server contexts 就像一个容器,可以存储创建的对象,如下面的代码:
    
Dim pPointCollection as IPointCollection = pServerContext.CreateObject("esriGeometry.Polygon")

pServerContext.SetObject (
"myPoly", pPointCollection)
Dim pPoly as IPolygon = pServerContext.GetObject("myPoly")
    可以创建临时的Geodatabase,前提是要获取其文件夹的路径,前缀_ags将会在程序结束后删除,而其他非此前缀的将会被保存.
Dim pServerContext As IServerContext = pSOM.CreateServerContext("""")

Dim pWSF As IWorkspaceFactory = pServerContext.CreateObject("esriDataSourcesGDB.AccessWorkspaceFactory")

Dim pEnumSDI As IEnumServerDirectoryInfo = pSOM.GetServerDirectoryInfos
Dim pSDI As IServerDirectoryInfo = pEnumSDI.Next

Dim pProps As IPropertySet = pServerContext.CreateObject("esriSystem.PropertySet")

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

' this database will not be cleaned by the GIS server
pProps.SetProperty ("DATABASE", pSDI.Path & "\db2.mdb")
pWSF.Create (pSDI.Path, 
"db2", pProps, 0)

' 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/chinazhousheng/archive/2008/02/26/1082746.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值