case 4491
This commit is contained in:
2
dist/latest-version.json
vendored
2
dist/latest-version.json
vendored
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"version":"8.0.44",
|
"latestversion":"8.0.44",
|
||||||
"changelogurl":"https://ayanova.com/docs/changelog/#ayanova-8042-2023-04-06"
|
"changelogurl":"https://ayanova.com/docs/changelog/#ayanova-8042-2023-04-06"
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,11 @@ namespace AyaNova.Api.Controllers
|
|||||||
MaintenanceExpired = AyaNova.Core.License.ActiveKey.MaintenanceExpired,
|
MaintenanceExpired = AyaNova.Core.License.ActiveKey.MaintenanceExpired,
|
||||||
ServerDbId = AyaNova.Core.License.ServerDbId,
|
ServerDbId = AyaNova.Core.License.ServerDbId,
|
||||||
Company = AyaNova.Core.License.ActiveKey.RegisteredTo,
|
Company = AyaNova.Core.License.ActiveKey.RegisteredTo,
|
||||||
SBuild = IsSubscriptionBuild
|
SBuild = IsSubscriptionBuild,
|
||||||
|
//used to drive UI in case of out of date release message to be shown to staff users non subscription only
|
||||||
|
ShowUpdateAvailable = (Util.AyaNovaVersion.VersionString != AyaNova.Util.ServerGlobalOpsSettingsCache.LATEST_VERSION && !IsSubscriptionBuild),
|
||||||
|
LatestVersion = AyaNova.Util.ServerGlobalOpsSettingsCache.LATEST_VERSION,
|
||||||
|
ChangeLogUrl = AyaNova.Util.ServerGlobalOpsSettingsCache.CHANGE_LOG_URL
|
||||||
|
|
||||||
// ,
|
// ,
|
||||||
// TestTSDaysWMS=new TimeSpan(22,10,15,22,33),
|
// TestTSDaysWMS=new TimeSpan(22,10,15,22,33),
|
||||||
|
|||||||
107
server/AyaNova/generator/CoreJobVersionCheck.cs
Normal file
107
server/AyaNova/generator/CoreJobVersionCheck.cs
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using AyaNova.Models;
|
||||||
|
using AyaNova.Util;
|
||||||
|
|
||||||
|
namespace AyaNova.Biz
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// called by Generator to check new releases automatically
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
internal static class CoreJobVersionCheck
|
||||||
|
{
|
||||||
|
private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("CoreJobVersionCheck");
|
||||||
|
private static DateTime _lastCheck = DateTime.MinValue;
|
||||||
|
|
||||||
|
#if (DEBUG)
|
||||||
|
private static TimeSpan FAST_TRACK = new TimeSpan(0, 1, 0);
|
||||||
|
private static TimeSpan SLOW_TRACK = new TimeSpan(0, 5, 0);
|
||||||
|
#else
|
||||||
|
#if (SUBSCRIPTION_BUILD)
|
||||||
|
//subscription servers need to check more frequently because the month to month rentals could be dodgy when 24 hours
|
||||||
|
//also it's all in-network so there is no downside or performance hit for this
|
||||||
|
private static TimeSpan FAST_TRACK = new TimeSpan(0, 30, 0);
|
||||||
|
private static TimeSpan SLOW_TRACK = new TimeSpan(0, 30, 0);
|
||||||
|
#else
|
||||||
|
private static TimeSpan FAST_TRACK = new TimeSpan(0, 30, 0);
|
||||||
|
private static TimeSpan SLOW_TRACK = new TimeSpan(24, 0, 0);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// DoWork
|
||||||
|
//
|
||||||
|
public static async Task DoWorkAsync()
|
||||||
|
{
|
||||||
|
log.LogTrace("Job starting");
|
||||||
|
var tsSinceLastCheck = DateTime.UtcNow - _lastCheck;
|
||||||
|
//which track are we on?
|
||||||
|
/*
|
||||||
|
FAST TRACK=30 minutes
|
||||||
|
SLOW TRACK= 24 hours
|
||||||
|
NONE = 0,//fast track (no license)
|
||||||
|
ActiveTrial = 1,//fast track (because they may be testing a migration and running out of time and don't want to cancel it)
|
||||||
|
ExpiredTrial = 2,//fast track
|
||||||
|
ActivePurchased = 3,//slow track
|
||||||
|
ExpiredPurchased = 4,//fast track
|
||||||
|
Revoked = 5//slow track
|
||||||
|
*/
|
||||||
|
TimeSpan tsCheckFrequency;
|
||||||
|
switch (AyaNova.Core.License.ActiveKey.Status)
|
||||||
|
{
|
||||||
|
case AyaNova.Core.License.AyaNovaLicenseKey.LicenseStatus.NONE:
|
||||||
|
case AyaNova.Core.License.AyaNovaLicenseKey.LicenseStatus.ActiveTrial:
|
||||||
|
case AyaNova.Core.License.AyaNovaLicenseKey.LicenseStatus.ExpiredTrial:
|
||||||
|
case AyaNova.Core.License.AyaNovaLicenseKey.LicenseStatus.ExpiredPurchased:
|
||||||
|
tsCheckFrequency = FAST_TRACK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
tsCheckFrequency = SLOW_TRACK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
log.LogTrace($"Check frequency{tsCheckFrequency}");
|
||||||
|
if (tsSinceLastCheck < tsCheckFrequency)
|
||||||
|
{
|
||||||
|
log.LogTrace($"Not yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext)
|
||||||
|
{
|
||||||
|
try//allow exception to bubble up but using try block to ensure the lastcheck is set properly regardless so this doesn't spin out of control
|
||||||
|
{
|
||||||
|
var ServerState = (AyaNova.Api.ControllerHelpers.ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(AyaNova.Api.ControllerHelpers.ApiServerState));
|
||||||
|
|
||||||
|
var ret = await AyaNova.Core.License.FetchKeyAsync(ServerState, ct, log, true);
|
||||||
|
//When this was enabled never saw a failed fetch, trying again without it
|
||||||
|
//#if (DEBUG)
|
||||||
|
// log.LogInformation("TEMP TEST LOG: CoreJobVersionCheck - result is: " + ret);
|
||||||
|
//#endif
|
||||||
|
//most often the result will be "notfound" but in future might be other results
|
||||||
|
if (ret == "ok")
|
||||||
|
{
|
||||||
|
//Eventlog
|
||||||
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(1, 0, AyaType.License, AyaEvent.LicenseFetch, "FromCoreJob"), ct);
|
||||||
|
}
|
||||||
|
if (ret != "notfound")
|
||||||
|
{
|
||||||
|
//I'm thinking do not log internally failed except as debug event as this would fill up log file
|
||||||
|
//instead if they have a license issue they can do manual fetch and then that will log so they can see error
|
||||||
|
//(also it will return an error to the client)
|
||||||
|
log.LogDebug($"FetchLicense - failed: {ret}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_lastCheck = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
}//eoc
|
||||||
|
}//eons
|
||||||
|
|
||||||
@@ -22,11 +22,23 @@ namespace AyaNova.Util
|
|||||||
internal static GlobalOpsBackupSettings Backup { get; set; }
|
internal static GlobalOpsBackupSettings Backup { get; set; }
|
||||||
internal static GlobalOpsNotificationSettings Notify { get; set; }
|
internal static GlobalOpsNotificationSettings Notify { get; set; }
|
||||||
internal static DateTime NextBackup { get; set; }
|
internal static DateTime NextBackup { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
//VERSION CHECKING
|
||||||
|
//set by CoreJobVersionCheck once daily and kept here statically while server is up
|
||||||
|
internal static string LATEST_VERSION { get; set; }
|
||||||
|
internal static string CHANGE_LOG_URL { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Populate and / or create the settings
|
/// Populate and / or create the settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static void Initialize(AyContext ct = null)
|
internal static void Initialize(AyContext ct = null)
|
||||||
{
|
{
|
||||||
|
//set to current servers boot version so as to not trigger messaging at client on login until job has had a chance to set
|
||||||
|
LATEST_VERSION = Util.AyaNovaVersion.VersionString;
|
||||||
|
CHANGE_LOG_URL = "https://ayanova.com/docs/changelog/";//just something to default to, should never come up as it's not a different version at this point
|
||||||
|
|
||||||
//fetch or create as not provided (meaning this was called from Startup.cs)
|
//fetch or create as not provided (meaning this was called from Startup.cs)
|
||||||
Backup = ct.GlobalOpsBackupSettings.FirstOrDefault(z => z.Id == 1);
|
Backup = ct.GlobalOpsBackupSettings.FirstOrDefault(z => z.Id == 1);
|
||||||
if (Backup == null)
|
if (Backup == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user