后记
下面给出项目中用到的自定义的封装类。
AE许可初始化封装类:
public class AELicenseChecker { private static volatile AELicenseChecker _instance = null; private static readonly object lockHelper = new object(); //AE许可对象 private IAoInitialize _aoInitialize = null; private AELicenseChecker() { ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop); } /// <summary> /// 单例对象 /// </summary> /// <returns></returns> public static AELicenseChecker CreateInstance() { if (_instance == null) { lock (lockHelper) { if (_instance == null) _instance = new AELicenseChecker(); } } return _instance; } /// <summary> /// 初始化许可 /// </summary> /// <param name="pruductcode">产品类型</param> public void InitApplicationwithProductCode(esriLicenseProductCode pruductcode) { try { if (_aoInitialize == null) _aoInitialize = new AoInitializeClass(); ESRI.ArcGIS.esriSystem.esriLicenseStatus licenseStatus = (ESRI.ArcGIS.esriSystem.esriLicenseStatus)_aoInitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB); if (licenseStatus == esriLicenseStatus.esriLicenseAvailable) { licenseStatus = (esriLicenseStatus)_aoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB); if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut) { throw new Exception("没有ArcEngine中的GDBEdit许可!"); } } else { throw new Exception("没有ArcEngine中的GDBEdit许可!"); } _aoInitialize.Initialize(pruductcode); } catch (Exception ex) { throw ex; } } /// <summary> /// 停止许可对象 /// </summary> /// <param name="ExtensionCode">扩展类型,可选</param> public void ShutdownApplication(params esriLicenseExtensionCode[] ExtensionCodes) { try { if (_aoInitialize == null) return; if (ExtensionCodes.Length >=) { esriLicenseExtensionCode ExtensionCode = ExtensionCodes[]; _aoInitialize.CheckInExtension(ExtensionCode); } //关闭 AoInitilaize对象 _aoInitialize.Shutdown(); _aoInitialize = null; } catch (Exception ex) { throw ex; } } /// <summary> /// 初始化带扩展的许可 /// </summary> /// <param name="pruductcode">产品类型</param> /// <param name="ExtensionCode">扩展类型</param> public void InitApplicationwithExtensionCode(esriLicenseProductCode pruductcode, esriLicenseExtensionCode ExtensionCode) { try { //esriLicenseStatus myLicenseStatus = this.CheckOutLicenses(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB); esriLicenseStatus myLicenseStatus = this.CheckOutExtensionLicenses(pruductcode, ExtensionCode); if (myLicenseStatus == esriLicenseStatus.esriLicenseNotLicensed) { throw new Exception("本机器没有安装ArcEngine扩展认证,请安装!"); } else if (myLicenseStatus == esriLicenseStatus.esriLicenseUnavailable) { throw new Exception("本机器上安装的ArcEngine扩展认证不可用,请重新安装!"); } else if (myLicenseStatus == esriLicenseStatus.esriLicenseFailure) { throw new Exception("本机器上的ArcEngine扩展认证启动失败,请联系管理员!"); } else if (myLicenseStatus == esriLicenseStatus.esriLicenseCheckedOut) { return; } } catch (Exception ex) { throw ex; } } /// <summary> /// 检测带扩展的证书 /// </summary> /// <param name="pProductCode">esriLicenseProductCode.esriLicenseProductCodeEngine</param> /// <param name="ExtensionCode">esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork</param> /// <returns></returns> private esriLicenseStatus CheckOutExtensionLicenses(esriLicenseProductCode pProductCode, esriLicenseExtensionCode ExtensionCode) { try { esriLicenseStatus myLicenseStatus = esriLicenseStatus.esriLicenseUnavailable; if (this._aoInitialize == null) { _aoInitialize = new AoInitializeClass(); } myLicenseStatus = this._aoInitialize.IsExtensionCodeAvailable(pProductCode, ExtensionCode); if (myLicenseStatus == esriLicenseStatus.esriLicenseAvailable) { myLicenseStatus = this._aoInitialize.Initialize(pProductCode); if (myLicenseStatus == esriLicenseStatus.esriLicenseCheckedOut) { myLicenseStatus = this._aoInitialize.CheckOutExtension(ExtensionCode); } } return myLicenseStatus; } catch (Exception ex) { throw ex; } } }
AELicenseChecker定义
参考文献:
1 ESRI,网络分析,http://help.arcgis.com/zh-cn/ARCGISDESKTOP/10.0/HELP../index.html#/na/004700000001000000/
2 何宇兵, 网络分析与网络数据集,http://wenku.baidu.com/link?url=z1SUivF9acs6-WfNfSU4SjnyioLJyIHoqlB5_WtLiFEqhq_xDKUpNBbwk2tPzW2NIfkGRus_zao6JuQsC4h0LYZQHJVdcu_X6PKLWBVpj-7
3 ArcGIS的SanFrancisco网络数据集制作(网络分析数据篇),http://virgoooos.iteye.com/blog/340568
4 esri example:How to create a network dataset, http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000000w7000000
5 AO许可问题,http://www.cnblogs.com/qb371/archive/2011/10/12/2366295.html
6 创建网络数据集(How to Create a Geodatabase Network Dataset),http://blog.sina.com.cn/s/blog_5d25ac4e0100uu47.html
7 arcengine创建network dataset,http://www.cnblogs.com/gisoracle/archive/2010/10/09/1846856.html
8 创建network dataset,http://jhlong12345.blog.163.com/blog/static/12306312920137217205787/
9 How to create a multimodal network dataset,http://edndoc.esri.com/arcobjects/9.2/net/de3d1979-ae9f-4e0a-8fba-6dc351e76822.htm
10 扩展许可设置,http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_use_extensions/00010000033w000000/