Beispiel #1
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);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            ESRI.ArcGIS.RuntimeManager.Bind(ProductCode.Engine);

            // 1. Authorize the ESLF license
            ESRI.ArcGIS.esriSystem.IAuthorizeLicense aoAuthorizeLicense = new AoAuthorizeLicenseClass();

            try
            {
                string pathToLicenseFile = @"C:\temp\EngineTest.Eslf";
                string password          = "";

                aoAuthorizeLicense.AuthorizeASRFromFile(pathToLicenseFile, password);

                string featuresAdded = aoAuthorizeLicense.FeaturesAdded;
                System.Diagnostics.Debug.WriteLine("Features Added: " + featuresAdded);

                // 2. De-Authorize ESLF License
                aoAuthorizeLicense.DeauthorizeASRFromFile(pathToLicenseFile, password);

                featuresAdded = aoAuthorizeLicense.FeaturesAdded;
                System.Diagnostics.Debug.WriteLine("Features Added: " + featuresAdded);
            }
            catch (Exception e)
            {
                string lastError;
                int    errorNumber = aoAuthorizeLicense.get_LastError(out lastError);
                System.Diagnostics.Debug.WriteLine("Error Number " + errorNumber + " : " + e.Message + ". Last Error: " + lastError);
            }



            // Check if the Engine Product Code is available
            ESRI.ArcGIS.esriSystem.IAoInitialize     aoInitialize       = new AoInitialize();
            ESRI.ArcGIS.esriSystem.esriLicenseStatus esriLicense_Status = aoInitialize.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine);
            System.Diagnostics.Debug.WriteLine("esriLicenseStatus: " + esriLicense_Status);
        }