本文整理汇总了C#中esriLicenseProductCode类的典型用法代码示例。如果您正苦于以下问题:C# esriLicenseProductCode类的具体用法?C# esriLicenseProductCode怎么用?C# esriLicenseProductCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
esriLicenseProductCode类属于命名空间,在下文中一共展示了esriLicenseProductCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeApplication
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);
}
}
}
示例2: OnStartup
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// Binding to ArcGIS Desktop
RuntimeManager.Bind(ProductCode.Desktop);
// Get ESRI License
this._aoInitialize = new AoInitializeClass();
esriLicenseProductCode[] codes = new esriLicenseProductCode[] {
esriLicenseProductCode.esriLicenseProductCodeStandard,
esriLicenseProductCode.esriLicenseProductCodeAdvanced
};
bool ok = false;
foreach (esriLicenseProductCode code in codes) {
if (this._aoInitialize.IsProductCodeAvailable(code) == esriLicenseStatus.esriLicenseAvailable) {
if (this._aoInitialize.Initialize(code) == esriLicenseStatus.esriLicenseCheckedOut) {
ok = true;
break;
}
}
}
if (!ok) {
MessageBox.Show("Unable to checkout Esri license", "Zeta", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
示例3: InitializeApplication
/// <summary>
/// Initialize the application with the specified product and extension license code.
/// </summary>
/// <returns>Initialization is successful.</returns>
/// <remarks>
/// If no active runtime has been bound to the application before license initialization
/// takes place, the ResolveBindingEvent is raised.
/// </remarks>
public bool InitializeApplication(esriLicenseProductCode[] productCodes, esriLicenseExtensionCode[] extensionLics)
{
//Cache product codes by enum int so can be sorted without custom sorter
m_requestedProducts = new List<int>();
foreach (esriLicenseProductCode code in productCodes)
{
int requestCodeNum = Convert.ToInt32(code);
if (!m_requestedProducts.Contains(requestCodeNum))
{
m_requestedProducts.Add(requestCodeNum);
}
}
AddExtensions(extensionLics);
// Make sure an active version has been loaded before calling any ArcObjects code.
RuntimeInfo boundRuntime = RuntimeManager.ActiveRuntime;
if (boundRuntime != null &&
(this.AllowImplicitRuntimeBinding || boundRuntime.Product > ProductCode.ArcGIS))
{
m_AoInit = new AoInitializeClass();
}
else
{
EventHandler temp = ResolveBindingEvent;
if (temp != null)
{
temp(this, new EventArgs());
if (RuntimeManager.ActiveRuntime != null)
m_AoInit = new AoInitializeClass();
}
}
return Initialize();
}
示例4: InitializeApplication
/// <summary>
/// Initialize the application with the specified product and extension license code.
/// </summary>
/// <returns>Initialization is successful.</returns>
/// <remarks>
/// Make sure an active ArcGIS runtime has been bound before license initialization.
/// </remarks>
public bool InitializeApplication(esriLicenseProductCode[] productCodes, esriLicenseExtensionCode[] extensionLics)
{
//Cache product codes by enum int so can be sorted without custom sorter
m_requestedProducts = new List<int>();
foreach (esriLicenseProductCode code in productCodes)
{
int requestCodeNum = Convert.ToInt32(code);
if (!m_requestedProducts.Contains(requestCodeNum))
{
m_requestedProducts.Add(requestCodeNum);
}
}
AddExtensions(extensionLics);
// Make sure an active runtime has been bound before calling any ArcObjects code.
if (RuntimeManager.ActiveRuntime == null)
{
EventHandler temp = ResolveBindingEvent;
if (temp != null)
{
temp(this, new EventArgs());
}
}
return Initialize();
}
示例5: CheckOutLicenses
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;
}
示例6: InitializeApplication
private bool m_productCheckOrdering = true; //default from low to high
#endregion
public bool InitializeApplication(esriLicenseProductCode[] productCodes, esriLicenseExtensionCode[] extensionLics)
{
//Cache product codes by enum int so can be sorted without custom sorter
m_requestedProducts = new List<int>();
foreach (esriLicenseProductCode code in productCodes)
{
int requestCodeNum = Convert.ToInt32(code);
if (!m_requestedProducts.Contains(requestCodeNum))
{
m_requestedProducts.Add(requestCodeNum);
}
}
AddExtensions(extensionLics);
return Initialize();
}
示例7: CheckoutESRILicense
public static IAoInitialize CheckoutESRILicense(esriLicenseProductCode pESRIProdCode)
{
ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Desktop); // SET A REFERENCE TO THE ESRI DESKTOP APPLICATION
var license = new AoInitializeClass(); // INSTANTIATE THE LICENSE
esriLicenseStatus pLicenseStatus = (esriLicenseStatus)license.IsProductCodeAvailable(pESRIProdCode); // DETERMINE THE STATUS OF THE REQUESTED LICENSE
if (pLicenseStatus == esriLicenseStatus.esriLicenseCheckedOut) { return license; } // RETURN IF A LICENSE IS ALREADY CHECKED OUT
if (pLicenseStatus == esriLicenseStatus.esriLicenseAvailable) // DETERMINE IF A LICENSE IS AVAILABLE
{
pLicenseStatus = (esriLicenseStatus)license.Initialize(pESRIProdCode);
if (pLicenseStatus == esriLicenseStatus.esriLicenseCheckedOut || pLicenseStatus == esriLicenseStatus.esriLicenseAlreadyInitialized)
return license;
}
return null;
}
示例8: InitializeApplication
public bool InitializeApplication(esriLicenseProductCode[] productCodes, esriLicenseExtensionCode[] extensionLics)
{
bool bInitialized = true;
if (m_AoInitialize == null)
{
bInitialized = false;
}
//Initialize the application
esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;
m_productsCode = productCodes;
m_pExtensionsCode = extensionLics;
licenseStatus = CheckOutLicenses();
if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut)
{
bInitialized = false;
}
return bInitialized;
}
示例9: InitializeProduct
/// <summary>
/// 初始化产品,只初始化第一个
/// </summary>
/// <returns></returns>
public bool InitializeProduct()
{
if (RuntimeManager.ActiveRuntime == null)
return false;
if (productCodeList == null || extensionCodeList.Count == 0)
return false;
bool productInitialized = false;
productCodeList.Sort();//对于产品集合进行排序
if (!InitializeLowerProductFirst)
{
productCodeList.Reverse();//反转整个集合
}
aoInitialize = new AoInitializeClass();
esriLicenseProductCode currentProductCode = new esriLicenseProductCode();
foreach (int item in productCodeList)
{
esriLicenseProductCode proCode = (esriLicenseProductCode)Enum.ToObject(typeof(esriLicenseProductCode), item);
esriLicenseStatus status = aoInitialize.IsProductCodeAvailable(proCode);
if (status == esriLicenseStatus.esriLicenseAvailable)
{
status = aoInitialize.Initialize(proCode);
if (status == esriLicenseStatus.esriLicenseAlreadyInitialized || status == esriLicenseStatus.esriLicenseCheckedOut)
{
productInitialized = true;
currentProductCode = aoInitialize.InitializedProduct();
}
}
dic_ProductStatus.Add(proCode, status);
if (productInitialized)
break;//只初始化第一个成功的产品!
}
this.hasInitialProduct = productInitialized;
this.productCodeList.Clear();
if (!productInitialized)//如果所有的产品都不成功
return false;
return CheckOutLicense(currentProductCode);//验证扩展
}
示例10: GetArcGISLicense
/// <summary>
/// Attempts to checkout a license for the specified ESRI product and returns true if successful.
/// </summary>
public bool GetArcGISLicense(esriLicenseProductCode prodCode)
{
//Create a new AoInitialize object
try
{
_AoInitialize = new AoInitializeClass();
}//The initialization object
catch
{
_log.Warn("Warning: Unable to initialize Arc Objects. License cannot be checked out.");
return false;
}
if (_AoInitialize == null)
{
_log.Warn("Warning: Unable to initialize Arc Objects. License cannot be checked out.");
return false;
}
//Determine if the product is available
esriLicenseStatus licenseStatus = (esriLicenseStatus)_AoInitialize.IsProductCodeAvailable(prodCode);
if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
{
licenseStatus = (esriLicenseStatus)_AoInitialize.Initialize(prodCode);
if (licenseStatus != esriLicenseStatus.esriLicenseCheckedOut)
{
_log.Warn("Warning: The license checkout for " + prodCode.ToString() + " failed!");
return false;
}
}
else
{
_log.Warn("Warning: The ArcGIS product " + prodCode.ToString() + " is unavailable!");
return false;
}
return true;
}
示例11: InitialLicensesCode
public bool InitialLicensesCode(esriLicenseProductCode[] esriProductCodes,params esriLicenseExtensionCode[] esriExtensionCodes)
{
if(productCodeList==null)
productCodeList = new List<int>();//将产品码添加到list集合中,Cache product codes by enum int so can be sorted without custom sorter
foreach (esriLicenseProductCode item in esriProductCodes)
{
int codeNum = Convert.ToInt32(item);
if (!productCodeList.Contains(codeNum))
{
productCodeList.Add(codeNum);
}
}
AddExtensions(esriExtensionCodes);
//验证runtime绑定
if (RuntimeManager.ActiveRuntime == null)
{
EventHandler eventHandler = ResolveBindingEvent;
if (eventHandler != null)
{
eventHandler(this,new EventArgs());
}
}
return InitializeProduct();
}
示例12: CheckOutLicenses
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;
}
示例13: Initialize
private bool Initialize()
{
if (RuntimeManager.ActiveRuntime == null)
return false;
if (m_requestedProducts == null || m_requestedProducts.Count == 0)
return false;
bool productInitialized = false;
m_requestedProducts.Sort();
if (!InitializeLowerProductFirst) //Request license from highest to lowest
m_requestedProducts.Reverse();
m_AoInit = new AoInitializeClass();
esriLicenseProductCode currentProduct = new esriLicenseProductCode();
foreach (int prodNumber in m_requestedProducts)
{
esriLicenseProductCode prod = (esriLicenseProductCode)Enum.ToObject(typeof(esriLicenseProductCode), prodNumber);
esriLicenseStatus status = m_AoInit.IsProductCodeAvailable(prod);
if (status == esriLicenseStatus.esriLicenseAvailable)
{
status = m_AoInit.Initialize(prod);
if (status == esriLicenseStatus.esriLicenseAlreadyInitialized ||
status == esriLicenseStatus.esriLicenseCheckedOut)
{
productInitialized = true;
currentProduct = m_AoInit.InitializedProduct();
}
}
m_productStatus.Add(prod, status);
if (productInitialized)
break;
}
m_hasInitializeProduct = productInitialized;
m_requestedProducts.Clear();
//No product is initialized after trying all requested licenses, quit
if (!productInitialized)
{
return false;
}
//Check out extension licenses
return CheckOutLicenses(currentProduct);
}
示例14: IsExtensionCodeAvailable
public esriLicenseStatus IsExtensionCodeAvailable(esriLicenseProductCode p, esriLicenseExtensionCode e)
{
return esriLicenseStatus.esriLicenseCheckedIn;
}
示例15: CheckOutLicenses
/// <summary>
/// Checkout licenses
/// </summary>
/// <param name="currentProduct">producto code</param>
private bool CheckOutLicenses(esriLicenseProductCode currentProduct)
{
var allSuccessful = true;
// Request extensions
if (_requestedExtensions != null && currentProduct != 0)
{
foreach (var ext in _requestedExtensions)
{
var licenseStatus = _aoInit.IsExtensionCodeAvailable(currentProduct, ext);
if (licenseStatus == esriLicenseStatus.esriLicenseAvailable)
{
licenseStatus = _aoInit.CheckOutExtension(ext);
}
allSuccessful = allSuccessful && licenseStatus == esriLicenseStatus.esriLicenseCheckedOut;
if (_extensionStatus.ContainsKey(ext))
{
_extensionStatus[ext] = licenseStatus;
}
else
{
_extensionStatus.Add(ext, licenseStatus);
}
}
_requestedExtensions.Clear();
}
return allSuccessful;
}