using ESRI.ArcGIS;
using ESRI.ArcGIS.esriSystem;

namespace SouthSmart.GISService.Infrastructure.Module
{
    public static class LicenseProduct
    {
        private static IAoInitialize m_AoInitialize;

        #region 初始化许可
        /// <summary>
        /// 初始化许可
        /// </summary>
        public static void InitialLincese ()
        {

            ESRI.ArcGIS.RuntimeManager.Bind ( ESRI.ArcGIS.ProductCode.EngineOrDesktop );
            if ( !RuntimeManager.Bind ( ProductCode.EngineOrDesktop ) )
            {
                return;
            }
            m_AoInitialize = new AoInitializeClass ();
            esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;
            licenseStatus = m_AoInitialize.Initialize ( esriLicenseProductCode.esriLicenseProductCodeAdvanced );
            if ( licenseStatus != esriLicenseStatus.esriLicenseCheckedOut )
            {
                licenseStatus = m_AoInitialize.Initialize ( esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB );
                if ( licenseStatus != esriLicenseStatus.esriLicenseCheckedOut )
                {
                    return;
                }
            }
            //迁出空间分析扩展模块
            if ( m_AoInitialize.CheckOutExtension ( esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst ) != esriLicenseStatus.esriLicenseCheckedOut )
            {
                return;
            }

        }
        #endregion
    }
}