转自:http://www.cnblogs.com/chuzhouGIS/p/3576183.html
后记
下面给出项目中用到的自定义的封装类。
AE许可初始化封装类:
1 public class AELicenseChecker 2 3 { 4 5 private static volatile AELicenseChecker _instance = null; 6 7 private static readonly object lockHelper = new object(); 8 9 10 11 //AE许可对象 12 13 private IAoInitialize _aoInitialize = null; 14 15 16 17 private AELicenseChecker() 18 19 { 20 21 ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop); 22 23 } 24 25 26 27 ///28 29 /// 单例对象 30 31 /// 32 33 ///34 35 public static AELicenseChecker CreateInstance() 36 37 { 38 39 if (_instance == null) 40 41 { 42 43 lock (lockHelper) 44 45 { 46 47 if (_instance == null) 48 49 _instance = new AELicenseChecker(); 50 51 } 52 53 } 54 55 return _instance; 56 57 } 58 59 /// 60 61 /// 初始化许可 62 63 /// 64 65 /// 产品类型 66 67 public void InitApplicationwithProductCode(esriLicenseProductCode pruductcode) 68 69 { 70 71 try 72 73 { 74 75 if (_aoInitialize == null) 76 77 _aoInitialize = new AoInitializeClass(); 78 79 80 81 ESRI.ArcGIS.esriSystem.esriLicenseStatus licenseStatus = (ESRI.ArcGIS.esriSystem.esriLicenseStatus)_aoInitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB); 82 83 if (licenseStatus == esriLicenseStatus.esriLicenseAvailable) 84 85 { 86 87 licenseStatus = (esriLicenseStatus)_aoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB); 88 89 if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut) 90 91 { 92 93 throw new Exception("没有ArcEngine中的GDBEdit许可!"); 94 95 } 96 97 } 98 99 else 100 101 { 102 103 throw new Exception("没有ArcEngine中的GDBEdit许可!"); 104 105 } 106 107 108 109 _aoInitialize.Initialize(pruductcode); 110 111 } 112 113 catch (Exception ex) 114 115 { 116 117 118 119 throw ex; 120 121 } 122 123 124 125 } 126 127 128 129 ///130 131 /// 停止许可对象 132 133 /// 134 135 /// 扩展类型,可选 136 137 public void ShutdownApplication(params esriLicenseExtensionCode[] ExtensionCodes) 138 139 { 140 141 try 142 143 { 144 145 if (_aoInitialize == null) return; 146 147 148 149 if (ExtensionCodes.Length >=1) 150 151 { 152 153 esriLicenseExtensionCode ExtensionCode = ExtensionCodes[0]; 154 155 _aoInitialize.CheckInExtension(ExtensionCode); 156 157 } 158 159 160 161 //关闭 AoInitilaize对象 162 163 _aoInitialize.Shutdown(); 164 165 _aoInitialize = null; 166 167 } 168 169 catch (Exception ex) 170 171 { 172 173 throw ex; 174 175 176 177 } 178 179 } 180 181 182 183 ///184 185 /// 初始化带扩展的许可 186 187 /// 188 189 /// 产品类型 190 191 /// 扩展类型 192 193 public void InitApplicationwithExtensionCode(esriLicenseProductCode pruductcode, esriLicenseExtensionCode ExtensionCode) 194 195 { 196 197 try 198 199 { 200 201 //esriLicenseStatus myLicenseStatus = this.CheckOutLicenses(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB); 202 203 204 205 esriLicenseStatus myLicenseStatus = this.CheckOutExtensionLicenses(pruductcode, ExtensionCode); 206 207 208 209 210 211 if (myLicenseStatus == esriLicenseStatus.esriLicenseNotLicensed) 212 213 { 214 215 throw new Exception("本机器没有安装ArcEngine扩展认证,请安装!"); 216 217 } 218 219 220 221 else if (myLicenseStatus == esriLicenseStatus.esriLicenseUnavailable) 222 223 { 224 225 throw new Exception("本机器上安装的ArcEngine扩展认证不可用,请重新安装!"); 226 227 } 228 229 230 231 else if (myLicenseStatus == esriLicenseStatus.esriLicenseFailure) 232 233 { 234 235 throw new Exception("本机器上的ArcEngine扩展认证启动失败,请联系管理员!"); 236 237 } 238 239 240 241 else if (myLicenseStatus == esriLicenseStatus.esriLicenseCheckedOut) 242 243 { 244 245 return; 246 247 } 248 249 } 250 251 catch (Exception ex) 252 253 { 254 255 256 257 throw ex; 258 259 } 260 261 262 263 } 264 265 266 267 268 269 ///270 271 /// 检测带扩展的证书 272 273 /// 274 275 /// esriLicenseProductCode.esriLicenseProductCodeEngine 276 277 /// esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork 278 279 ///280 281 private esriLicenseStatus CheckOutExtensionLicenses(esriLicenseProductCode pProductCode, esriLicenseExtensionCode ExtensionCode) 282 283 { 284 285 try 286 287 { 288 289 esriLicenseStatus myLicenseStatus = esriLicenseStatus.esriLicenseUnavailable; 290 291 292 293 294 295 if (this._aoInitialize == null) 296 297 { 298 299 _aoInitialize = new AoInitializeClass(); 300 301 302 303 } 304 305 306 307 myLicenseStatus = this._aoInitialize.IsExtensionCodeAvailable(pProductCode, ExtensionCode); 308 309 if (myLicenseStatus == esriLicenseStatus.esriLicenseAvailable) 310 311 { 312 313 myLicenseStatus = this._aoInitialize.Initialize(pProductCode); 314 315 if (myLicenseStatus == esriLicenseStatus.esriLicenseCheckedOut) 316 317 { 318 319 myLicenseStatus = this._aoInitialize.CheckOutExtension(ExtensionCode); 320 321 } 322 323 } 324 325 326 327 return myLicenseStatus; 328 329 } 330 331 catch (Exception ex) 332 333 { 334 335 336 337 throw ex; 338 339 } 340 341 } 342 343 344 345 } 346 347
参考文献:
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/