Ejemplo n.º 1
0
        private bool editorCheckedOut()
        {
            bool         bRetVal      = false;
            CSpatialSubs oSpatialSubs = new CSpatialSubs();

            ESRI.ArcGIS.esriSystem.esriLicenseProductCode productCode = oSpatialSubs.returnCurrentProductCode();


            if (productCode == ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcEditor)
            {
                bRetVal = true;
            }
            else
            {
                //if (CMedToolsSubs.isProductAvailable(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcEditor) == ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseAvailable)
                //{
                ESRI.ArcGIS.esriSystem.esriLicenseStatus status = oSpatialSubs.checkOutLicenses(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcEditor);
                if ((status == ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseAlreadyInitialized) || (status == ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseAlreadyInitialized))
                {
                    bRetVal = true;
                }

                //}
            }
            oSpatialSubs.Dispose();
            return(bRetVal);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// call this to confirm the license has been checked out before using any other arcobjects stuff
        /// </summary>
        /// <returns>boolean success</returns>
        public static bool InitializeLicence()
        {
            //Bind to runtime
            ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
            LicenseInit.init = new ESRI.ArcGIS.esriSystem.AoInitializeClass();

            //try to get the initialized class, will throw exception if not available
            try
            {
                Debug.WriteLine("first try, check initialization");
                string initializedProduct = LicenseInit.init.InitializedProduct().ToString();
                Debug.WriteLine(initializedProduct);
                return(true);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);

                //make list of product codes
                List <ESRI.ArcGIS.esriSystem.esriLicenseProductCode> prodCodeList = new List <ESRI.ArcGIS.esriSystem.esriLicenseProductCode> {
                    ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeBasic,
                    ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeStandard,
                    ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeAdvanced
                };

                //variable for licences status enum
                ESRI.ArcGIS.esriSystem.esriLicenseStatus esriStatus = ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseNotInitialized;

                //loop over the product codes
                for (int i = 0; i < prodCodeList.Count; i++)
                {
                    //try to initialize
                    esriStatus = LicenseInit.init.Initialize(prodCodeList[i]);

                    //break on the one that worked
                    if (esriStatus == ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseCheckedOut)
                    {
                        Debug.WriteLine("checked out");
                        Debug.WriteLine(LicenseInit.init.InitializedProduct().ToString());
                        return(true);
                    }
                }

                return(false);
            }
        }