This commit is contained in:
2022-06-22 03:18:13 +00:00
parent 9e51fc18f9
commit cae8a82783
3 changed files with 48 additions and 4 deletions

View File

@@ -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<AyaNovaLicenseFeatures> 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; }
}
}

View File

@@ -76,6 +76,7 @@
<DependentUpon>auth.cs</DependentUpon>
</Compile>
<Compile Include="AuthorizationRoles.cs" />
<Compile Include="AyaNovaLicense.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>

View File

@@ -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<bool>())
//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<bool>())
//{
// 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