From 58241cd68df7ab44ff326ef740f0d460abc3d988 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 28 Jan 2020 20:58:04 +0000 Subject: [PATCH] --- server/AyaNova/Startup.cs | 2 +- server/AyaNova/util/License.cs | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 57819e61..c0607f2d 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -484,7 +484,7 @@ namespace AyaNova _newLog.LogInformation($"BOOT: Active techs - {UserBiz.ActiveCountAsync().Result}"); //Log the license info so it's on the record - _newLog.LogInformation($"BOOT: License -\r\n=-=-=-=-=-=-=-=-=-=-\r\n{AyaNova.Core.License.LicenseInfo}=-=-=-=-=-=-=-=-=-=-"); + _newLog.LogInformation($"BOOT: License {AyaNova.Core.License.LicenseInfoLogFormat}"); diff --git a/server/AyaNova/util/License.cs b/server/AyaNova/util/License.cs index d55bd106..4019f811 100644 --- a/server/AyaNova/util/License.cs +++ b/server/AyaNova/util/License.cs @@ -280,6 +280,52 @@ namespace AyaNova.Core } +/// + /// Fetch a summary of the license key for displaying in the log + /// + /// string containing current license information + internal static string LicenseInfoLogFormat + { + get + { + StringBuilder sb = new StringBuilder(); + + if (ActiveKey.IsEmpty) + { + return $"UNLICENSED, DB ID: {DbId}"; + } + else + { + + if (ActiveKey.TrialLicense) + sb.Append("TRIAL, "); + + sb.Append($"regto: {ActiveKey.RegisteredTo}, "); + sb.Append($"keyid: {ActiveKey.Id}, "); + sb.Append($"dbid: {DbId}, "); + sb.Append($"type: {(ActiveKey.RentalLicense ? "service" : "perpetual")}, "); + if (ActiveKey.WillExpire) + sb.Append($"exp: {DateUtil.ServerDateTimeString(ActiveKey.LicenseExpiration)}, "); + sb.Append($"maint. sub. exps: {DateUtil.ServerDateTimeString(ActiveKey.MaintenanceExpiration)}, "); + sb.Append("feat:"); + foreach (LicenseFeature l in ActiveKey.Features) + { + //don't show the rental or trial features + if (l.Feature != TRIAL_FEATURE_NAME && l.Feature != RENTAL_FEATURE_NAME) + { + if (l.Count != 0) + sb.Append($"{l.Feature} - {l.Count}, "); + else + sb.Append($"{l.Feature}, "); + } + } + + } + return sb.ToString(); + } + } + + /// /// Fetch a summary of the license key for displaying to the end user /// via the API