示例#1
0
        private bool CheckOutLicenses(esriLicenseProductCode currentProduct)
        {
            bool allSuccessful = true;

            //Request extensions
            if (m_requestedExtensions != null && currentProduct != 0)
            {
                foreach (esriLicenseExtensionCode ext in m_requestedExtensions)
                {
                    esriLicenseStatus licenseStatus = m_AoInit.IsExtensionCodeAvailable(currentProduct, ext);
                    if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)                    //skip unavailable extensions
                    {
                        licenseStatus = m_AoInit.CheckOutExtension(ext);
                    }
                    allSuccessful = (allSuccessful && licenseStatus == esriLicenseStatus.esriLicenseCheckedOut);
                    if (m_extensionStatus.ContainsKey(ext))
                    {
                        m_extensionStatus[ext] = licenseStatus;
                    }
                    else
                    {
                        m_extensionStatus.Add(ext, licenseStatus);
                    }
                }

                m_requestedExtensions.Clear();
            }

            return(allSuccessful);
        }
        public void InitializeApplication(esriLicenseProductCode[] products,esriLicenseExtensionCode [] extensions)
        {
            // Binding a product
            RuntimeManager.Bind(ProductCode.EngineOrDesktop);
            // Initialize a product code
            m_AoInit = new AoInitializeClass();
            esriLicenseProductCode currentProduct = new esriLicenseProductCode();
            foreach (esriLicenseProductCode prod in products)
            {
                esriLicenseStatus prodStatus = m_AoInit.IsProductCodeAvailable(prod);
                if(prodStatus==esriLicenseStatus.esriLicenseAvailable)
                {
                    prodStatus=m_AoInit.Initialize(prod);
                    if(prodStatus==esriLicenseStatus.esriLicenseAlreadyInitialized||prodStatus==esriLicenseStatus.esriLicenseCheckedOut)
                    {
                        currentProduct = prod;
                    }
                }
            }

            if(m_AoInit.InitializedProduct()!=null)
            {
                foreach (esriLicenseExtensionCode ext in extensions)
                {
                    m_RequetedExtensionCodes.Add(ext);

                    esriLicenseStatus extStatus = m_AoInit.IsExtensionCodeAvailable(currentProduct,ext);
                    if (extStatus == esriLicenseStatus.esriLicenseAvailable)
                        m_AoInit.CheckOutExtension(ext);

                }
            }
        }
示例#3
0
        private esriLicenseStatus CheckOutLicenses()
        {
            esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseNotInitialized;

            //Determine if the product is available
            for (int i = 0; i < m_productsCode.Length; i++)
            {
                esriLicenseProductCode pc = m_productsCode[i];
                licenseStatus = m_AoInitialize.IsProductCodeAvailable(pc);
                if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
                {
                    licenseStatus = m_AoInitialize.Initialize(pc);
                    if (licenseStatus == esriLicenseStatus.esriLicenseCheckedOut)
                    {
                        m_initProduct = pc;
                        break;
                    }
                }
            }

            if (m_pExtensionsCode != null)
            {
                //Checkout the extensions - only when product is initialized
                if (licenseStatus == esriLicenseStatus.esriLicenseCheckedOut)
                {
                    System.Collections.ArrayList initExts = new System.Collections.ArrayList(m_pExtensionsCode.Length);
                    foreach (esriLicenseExtensionCode extLicense in m_pExtensionsCode)
                    {
                        //Determine if the extensions are available - some may not be available depending on the product initialized
                        //If so, initialization fails...
                        licenseStatus = m_AoInitialize.IsExtensionCodeAvailable(m_initProduct, extLicense);
                        if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
                        {
                            licenseStatus = m_AoInitialize.CheckOutExtension(extLicense);
                            if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut && licenseStatus != esriLicenseStatus.esriLicenseAlreadyInitialized)
                            {
                                break;
                            }

                            //Add to license initialized list
                            initExts.Add(extLicense);
                        }
                        else
                        {
                            break; //Exit when failed to check out any extension
                        }
                    }
                    if (initExts.Count > 0)
                    {
                        m_initExts = new esriLicenseExtensionCode[initExts.Count];
                        m_initExts = (esriLicenseExtensionCode[])initExts.ToArray(typeof(esriLicenseExtensionCode));
                    }
                }
            }
            return(licenseStatus);
        }
示例#4
0
        public static bool StartUp()
        {
            try
            {
                if (aoinitialize == null)
                {
                    Console.WriteLine("没有安装ARCEngine,系统无法进行");
                    return(false);
                }
                ESRI.ArcGIS.esriSystem.esriLicenseStatus licensesStatus = (ESRI.ArcGIS.esriSystem.esriLicenseStatus)aoinitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);
                if (licensesStatus == esriLicenseStatus.esriLicenseAvailable)
                {
                    licensesStatus = (esriLicenseStatus)aoinitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);
                    if (licensesStatus != esriLicenseStatus.esriLicenseCheckedOut)
                    {
                        Console.WriteLine("没有ARCEngine中的GDBEdit许可!");
                        return(false);
                    }
                }
                else
                {
                    Console.WriteLine("没有ARCEngine中的GDBEdit许可!");
                    return(false);
                }

                licensesStatus = aoinitialize.IsExtensionCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine, esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork);
                licensesStatus = (ESRI.ArcGIS.esriSystem.esriLicenseStatus)aoinitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork);
                if (licensesStatus == esriLicenseStatus.esriLicenseCheckedOut)
                {
                }
                else
                {
                    Console.WriteLine("没有ARCEngine中的NetWork许可!");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ArcEngine的许可错误" + ex.Message);
                return(false);
            }

            return(true);
        }
示例#5
0
        private static esriLicenseStatus CheckOutLicenses(esriLicenseProductCode esriLicenseProductCode_0,
                                                          esriLicenseExtensionCode esriLicenseExtensionCode_0)
        {
            if (m_pAoInitialize == null)
            {
                // m_pAoInitialize = new AoInitializeClass();
            }
            esriLicenseStatus status = m_pAoInitialize.IsProductCodeAvailable(esriLicenseProductCode_0);

            if (status == esriLicenseStatus.esriLicenseAvailable)
            {
                status = m_pAoInitialize.IsExtensionCodeAvailable(esriLicenseProductCode_0, esriLicenseExtensionCode_0);
                if (status == esriLicenseStatus.esriLicenseAvailable)
                {
                    status = m_pAoInitialize.Initialize(esriLicenseProductCode_0);
                    if (status == esriLicenseStatus.esriLicenseCheckedOut)
                    {
                        status = m_pAoInitialize.CheckOutExtension(esriLicenseExtensionCode_0);
                    }
                }
            }
            return(status);
        }
示例#6
0
        private esriLicenseStatus CheckOutLicenses()
        {
            var licenseStatus = esriLicenseStatus.esriLicenseNotInitialized;

            //Determine if the product is available
            foreach (esriLicenseProductCode productCode in _productsCodes)
            {
                licenseStatus = _aoInitialize.IsProductCodeAvailable(productCode);

                if (licenseStatus != esriLicenseStatus.esriLicenseAvailable)
                {
                    continue;
                }

                // NOTE: in case the license expires in less than 15 days and the registry key
                //       HKEY_LOCAL_MACHINE\Software\ESRI\License does not have a string value
                //       with the name TIMEOUTWARNING and the value FALSE
                //       a message box will pop up here. This is a problem if running as scheduled
                //       task - make sure this value exists and is set to false on all servers!
                _msg.DebugFormat("Initializing license: {0}", productCode);
                licenseStatus = _aoInitialize.Initialize(productCode);

                if (licenseStatus == esriLicenseStatus.esriLicenseCheckedOut)
                {
                    _initProduct = productCode;
                    break;
                }
            }

            if (_extensionsCodes != null)
            {
                //Checkout the extensions - only when product is initialized
                if (licenseStatus == esriLicenseStatus.esriLicenseCheckedOut)
                {
                    var checkedOutExtensions =
                        new List <esriLicenseExtensionCode>(_extensionsCodes.Length);

                    foreach (esriLicenseExtensionCode extLicense in _extensionsCodes)
                    {
                        //Determine if the extensions are available - some may not be available depending on the product initialized
                        //If so, initialization fails...
                        licenseStatus =
                            _aoInitialize.IsExtensionCodeAvailable(_initProduct, extLicense);
                        if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
                        {
                            _msg.DebugFormat("Checking out extension: {0}", extLicense);

                            licenseStatus = _aoInitialize.CheckOutExtension(extLicense);

                            if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut &&
                                licenseStatus != esriLicenseStatus.esriLicenseAlreadyInitialized)
                            {
                                break;
                            }

                            //Add to license initialized list
                            checkedOutExtensions.Add(extLicense);
                        }
                        else
                        {
                            break;                             //Exit when failed to check out any extension
                        }
                    }

                    if (checkedOutExtensions.Count > 0)
                    {
                        _initializedExtensions = checkedOutExtensions.ToList();
                    }
                }
            }

            return(licenseStatus);
        }