/// <summary>
        /// Check out spatial analyst license
        /// </summary>
        /// <returns>esriLicenseStatus</returns>
        public esriLicenseStatus GetSpatialAnalystLicense()
        {
            //Check out a Spatial Analyst license with the ArcView product.
            esriLicenseProductCode productCode =
                esriLicenseProductCode.esriLicenseProductCodeAdvanced;
            IAoInitialize     pAoInitialize = new AoInitializeClass();
            esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;

            //Check the productCode.
            licenseStatus = pAoInitialize.IsProductCodeAvailable(productCode);
            if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
            {
                //Check the extensionCode.
                licenseStatus = pAoInitialize.IsExtensionCodeAvailable(productCode,
                                                                       esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst);
                if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
                {
                    //Initialize the license.
                    licenseStatus = pAoInitialize.Initialize(productCode);
                    if ((licenseStatus == esriLicenseStatus.esriLicenseCheckedOut))
                    {
                        //Check out the Spatial Analyst extension.
                        licenseStatus = pAoInitialize.CheckOutExtension
                                            (esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst)
                        ;
                    }
                }
            }

            return(licenseStatus);
        }
示例#2
0
        public bool IsLicensed()
        {
            // check for a Network Analyst license
            IAoInitialize       aoInitialize = new AoInitializeClass();
            ILicenseInformation licInfo      = (ILicenseInformation)aoInitialize;

            esriLicenseStatus licenseStatus = aoInitialize.IsExtensionCodeAvailable(aoInitialize.InitializedProduct(), esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork);

            bool isLicensed = false;

            if (licenseStatus != esriLicenseStatus.esriLicenseUnavailable)
            {
                isLicensed = true;
            }

            return(isLicensed);
        }
			private bool InitializeEngineLicense ()
			{
					AoInitialize aoi = new AoInitializeClass ();

					//more license choices could be included here
					esriLicenseProductCode productCode = esriLicenseProductCode.esriLicenseProductCodeEngine;
          esriLicenseExtensionCode extensionCode = esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst;

          if (aoi.IsProductCodeAvailable(productCode) == esriLicenseStatus.esriLicenseAvailable  && aoi.IsExtensionCodeAvailable(productCode, extensionCode) == esriLicenseStatus.esriLicenseAvailable)
          {
              aoi.Initialize(productCode);
              aoi.CheckOutExtension(extensionCode);
              return true;
          }
          else
              return false;
			}
示例#4
0
        public static void AoInitialize()
        {
            ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
            IAoInitialize pAoInitialize = new AoInitializeClass();

            if (pAoInitialize == null)
            {
                throw new Exception("AO Initialize failed");
            }

            esriLicenseStatus status = pAoInitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeAdvanced);

            if (status == esriLicenseStatus.esriLicenseAvailable)
            {
                pAoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
            }
            else if (status == esriLicenseStatus.esriLicenseUnavailable)
            {
                throw new Exception("esriLicenseProductCodeAdvanced is unavailable");
            }

            status = pAoInitialize.IsExtensionCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeAdvanced, esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst);
            if (status == esriLicenseStatus.esriLicenseAvailable)
            {
                status = pAoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst);
                if (status == esriLicenseStatus.esriLicenseNotInitialized)
                {
                    throw new Exception("esriLicenseExtensionCodeSpatialAnalyst is not initialized");
                }
            }
            else if (status == esriLicenseStatus.esriLicenseNotLicensed)
            {
                throw new Exception("esriLicenseExtensionCodeSpatialAnalyst is not licensed");
            }
            else if (status == esriLicenseStatus.esriLicenseUnavailable)
            {
                throw new Exception("esriLicenseExtensionCodeSpatialAnalyst is  unavailable");
            }
        }
示例#5
0
        private static bool checkLicense()
        {
            //ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine);
            ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);

            IAoInitialize m_AoInitialize = new AoInitializeClass();

            esriLicenseStatus licenseStatus = (esriLicenseStatus)m_AoInitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine);

            if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
            {
                licenseStatus = (esriLicenseStatus)m_AoInitialize.IsExtensionCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine, esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst);
                if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
                {
                    licenseStatus = (esriLicenseStatus)m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);//esriLicenseProductCodeEngine);
                    if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut)
                    {
                        System.Windows.Forms.MessageBox.Show("The initialization failed. This application cannot run!");
                        return(false);
                    }
                    else
                    {
                        licenseStatus = (esriLicenseStatus)m_AoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeDesigner);
                        if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut)
                        {
                            System.Windows.Forms.MessageBox.Show("Unable to check out the Designer extension. This application cannot run!");
                            return(false);
                        }
                    }
                }
                return(true);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("The ArcGIS Engine product is unavailable. This application cannot run!");
                return(false);
            }
        }
        public bool IsLicensed()
        {
            // check for a Network Analyst license
            IAoInitialize aoInitialize = new AoInitializeClass();
            ILicenseInformation licInfo = (ILicenseInformation)aoInitialize;

            esriLicenseStatus licenseStatus = aoInitialize.IsExtensionCodeAvailable(aoInitialize.InitializedProduct(), esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork);

            bool isLicensed = false;

            if (licenseStatus != esriLicenseStatus.esriLicenseUnavailable)
            {
                isLicensed = true;
            }

            return isLicensed;
        }
示例#7
0
        private bool InitializeEngineLicense()
        {
            AoInitialize aoi = new AoInitializeClass();

            //more license choices could be included here
            esriLicenseProductCode   productCode   = esriLicenseProductCode.esriLicenseProductCodeEngine;
            esriLicenseExtensionCode extensionCode = esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst;

            if (aoi.IsProductCodeAvailable(productCode) == esriLicenseStatus.esriLicenseAvailable && aoi.IsExtensionCodeAvailable(productCode, extensionCode) == esriLicenseStatus.esriLicenseAvailable)
            {
                aoi.Initialize(productCode);
                aoi.CheckOutExtension(extensionCode);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// Check out spatial analyst license
        /// </summary>
        /// <returns>esriLicenseStatus</returns>
        public esriLicenseStatus GetSpatialAnalystLicense()
        {
            //Check out a Spatial Analyst license with the ArcView product.
            esriLicenseProductCode productCode =
                esriLicenseProductCode.esriLicenseProductCodeAdvanced;
            IAoInitialize pAoInitialize = new AoInitializeClass();
            esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;
            //Check the productCode.
            licenseStatus = pAoInitialize.IsProductCodeAvailable(productCode);
            if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
            {
                //Check the extensionCode.
                licenseStatus = pAoInitialize.IsExtensionCodeAvailable(productCode,
                    esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst);
                if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
                {
                    //Initialize the license.
                    licenseStatus = pAoInitialize.Initialize(productCode);
                    if ((licenseStatus == esriLicenseStatus.esriLicenseCheckedOut))
                    {
                        //Check out the Spatial Analyst extension.
                        licenseStatus = pAoInitialize.CheckOutExtension
                            (esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst)
                            ;
                    }
                }
            }

            return licenseStatus;
        }