首页 > 其他 > 详细

Arcengine实现创建网络数据集札记(三)

时间:2014-03-03 01:56:33      阅读:837      评论:0      收藏:0      [点我收藏+]

后记

    下面给出项目中用到的自定义的封装类。

    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 >=1)

                            {

                                     esriLicenseExtensionCode ExtensionCode = ExtensionCodes[0];

                                     _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;

                   }

         }

 

}

 

 

参考文献:

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/

 

Arcengine实现创建网络数据集札记(三),布布扣,bubuko.com

Arcengine实现创建网络数据集札记(三)

原文:http://www.cnblogs.com/chuzhouGIS/p/3576183.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!