/// <summary> /// Reset the current license loaded by AGX Dynamics. /// </summary> public static void Reset() { try { agx.Runtime.instance().clear(); } catch (Exception) { } finally { LicenseInfo = new LicenseInfo(); } }
/// <summary> /// Update license information of the license loaded /// into AGX Dynamics. /// </summary> public static void UpdateLicenseInformation() { LicenseInfo = LicenseInfo.Create(); }
/// <summary> /// Create and parse native license info. /// </summary> /// <returns>Native license info.</returns> public static LicenseInfo Create() { var info = new LicenseInfo(); try { info.Version = agx.agxSWIG.agxGetVersion(false); if (info.Version.ToLower().StartsWith("agx-")) { info.Version = info.Version.Remove(0, 4); } var endDateString = agx.Runtime.instance().readValue("EndDate"); try { info.EndDate = DateTime.Parse(endDateString); } catch (FormatException) { if (endDateString.ToLower() == "none") { info.EndDate = DateTime.MaxValue; } else { info.EndDate = DateTime.MinValue; } } info.IsValid = agx.Runtime.instance().isValid(); info.Status = agx.Runtime.instance().getStatus(); info.User = agx.Runtime.instance().readValue("User"); info.Contact = agx.Runtime.instance().readValue("Contact"); var subscriptionType = agx.Runtime.instance().readValue("Product").Split('-'); if (subscriptionType.Length == 2) { info.TypeDescription = subscriptionType[1].Trim(); } if (string.IsNullOrEmpty(info.TypeDescription)) { info.TypeDescription = "Unknown"; } if (agx.Runtime.instance().hasKey("InstallationID")) { info.Type = LicenseType.Service; info.UniqueId = agx.Runtime.instance().readValue("InstallationID"); } else { info.Type = LicenseType.Legacy; info.UniqueId = agx.Runtime.instance().readValue("License"); } var enabledModules = agx.Runtime.instance().getEnabledModules().ToArray(); info.EnabledModules = Module.None; foreach (var module in enabledModules) { if (module == "AgX") { info.EnabledModules |= Module.AGX; continue; } else if (!module.StartsWith("AgX-")) { continue; } var enabledModule = module.Replace("AgX-", "AGX"); if (Enum.TryParse <Module>(enabledModule, out var enumModule)) { info.EnabledModules |= enumModule; } } } catch (System.Exception) { info = new LicenseInfo(); } return(info); }