1、了解ArcSDE的Client API
ArcSDE提供两种常用的Client API,通过调用这些API,可以实现“通过命令方式(SDEMON、SDESERVICE、SDELAYER、SDEVERSION等)实现的”大部分功能。
1)C Client API
sde#.dll(pe#.dll、sg#.dll)为主要提供接口的动态库;
2)Java Client API
jsde#_sdk.jar(jpe#_sdk.jar)为主要接口函数包。
2、接口实现方法
理解Java开发技巧,结合Java Client API例子和开发帮助(安装后就存在),很容易实现基于ArcIMS的空间数据编辑、管理等功能;
这里重点介绍C#如何调用sde#.dll来实现特定的功能。
1)学习资料:C#如何调用WinAPI(重点)
http://blog.youkuaiyun.com/binwind/archive/2006/02/24/608812.aspx
http://blog.youkuaiyun.com/Net_Ghost/archive/2006/06/17/805080.aspx
http://blog.youkuaiyun.com/net_ghost/archive/2006/06/17/805142.aspx
以上资料详细讲解了有关调用技巧及注意事项,理解了以上知识,sde#.dll的调用就豁然开朗。
2)调用接口举例(接口参数描述可见SDEHelp.chm,安装C Client API就存在)
// 创建连接接口,注意C函数参数类型到C#类型的转换
[DllImport("sde91.dll", SetLastError=true)]
static extern int SE_connection_create(string server, string instance, string database, string username, string pwd, ref Se_Error error, out IntPtr conn);
//释放连接空间,断开连接
[DllImport("sde91.dll", SetLastError=true)]
static extern int SE_connection_free(IntPtr conn);
//删除空间图层
[DllImport("sde91.dll", SetLastError=true)]
static extern int SE_layer_delete(IntPtr conn, string tablename, string shapename);
//创建图层
[DllImport("sde91.dll", SetLastError=true)]
static extern int SE_layerinfo_create(string coordref, out int layer);
//创建版本
[DllImport("sde91.dll", SetLastError=true)]
static extern int SE_version_create(IntPtr conn, int ptversion, bool uniquename, out int version);
//删除版本
[DllImport("sde91.dll", SetLastError=true)]
static extern int SE_version_delete(IntPtr conn, string version);
//属性信息查询
[DllImport("sde91.dll", SetLastError=true)]
static extern int SE_stream_prepare_sql(IntPtr Stream, string sql);
[DllImport("sde91.dll", SetLastError=true)]
static extern int SE_stream_query(IntPtr mStream, short numcolumns, string[] columns, IntPtr sqlconstruct);
特别注意类型转换,注意结构体在C#环境下的重新定义。
这些要点需重点学习1)有关资料。
抛砖之博,学习为要。