diff --git a/AyaNovaQBI/AyaNovaLicense.cs b/AyaNovaQBI/AyaNovaLicense.cs new file mode 100644 index 0000000..34b7236 --- /dev/null +++ b/AyaNovaQBI/AyaNovaLicense.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AyaNovaQBI +{ + internal class AyaNovaLicense + { + public string serverDbId { get; set; } + public string licensedTo { get; set; } + public string dbId { get; set; } + public string keySerial { get; set; } + public DateTime licenseExpiration { get; set; } + public bool licenseWillExpire { get; set; } + public bool maintenanceExpired { get; set; } + public DateTime maintenanceExpiration { get; set; } + + public List features { get; set; } + } + internal class AyaNovaLicenseFeatures + { + //name of feature / product + public string Feature { get; set; } + + //Optional count for items that require it + public long Count { get; set; } + + } +} diff --git a/AyaNovaQBI/AyaNovaQBI.csproj b/AyaNovaQBI/AyaNovaQBI.csproj index 6625521..547a173 100644 --- a/AyaNovaQBI/AyaNovaQBI.csproj +++ b/AyaNovaQBI/AyaNovaQBI.csproj @@ -76,6 +76,7 @@ auth.cs + Form diff --git a/AyaNovaQBI/util.cs b/AyaNovaQBI/util.cs index 34ffa4c..4933e3d 100644 --- a/AyaNovaQBI/util.cs +++ b/AyaNovaQBI/util.cs @@ -30,6 +30,8 @@ namespace AyaNovaQBI internal static string AyaNovaUserName { get; set; } internal static AuthorizationRoles AyaNovaUserRoles { get; set; } internal static UserType AyaNovaUserType { get; set; } + + internal static AyaNovaLicense ALicense { get; set; } = null; @@ -459,14 +461,21 @@ namespace AyaNovaQBI if (d.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return false; - //Check if licensed - var r = await GetAsync("license/has-feature/XQBI"); - if (!r.ObjectResponse["data"].Value()) + //Get license + var r = await GetAsync("license"); + ALicense = r.ObjectResponse["data"]["license"].ToObject < AyaNovaLicense>(); + if (ALicense.features.FirstOrDefault(z => z.Feature == "QBI") == null) { - initErrors.AppendLine("This AyaNova server is not licensed to use QBI"); + initErrors.AppendLine("QBI not licensed"); return false; } + //if (!r.ObjectResponse["data"].Value()) + //{ + // initErrors.AppendLine("QBI not licensed"); + // return false; + //} + //check if build date is within licensed date (how did I do that automated build date thing?) // copy timestamp.cs and the createtimestamp.exe utility from v7 qbi and create build event to run it here and do same thing //check that AyaNova version matches required minimum for this QBI ( @@ -479,6 +488,7 @@ namespace AyaNovaQBI //PFC - PopulateQBListCache() //PFC - PopulateAyaListCache() //PFC - integration object check (fetch or create if not present) (Util.integrationObjectCheck()) + //NOTE: probably can make a class for this and use newtonsoft to convert dynamic returned from api call to class object? //PFC - Validate settings, create if necessary (Util.ValidateSettings()) and save //PFC - verify integration mapped objects still exist at each end (Util.PreFlightCheck() line 199) //DONE @@ -487,6 +497,8 @@ namespace AyaNovaQBI } + + #endregion