case 4170

This commit is contained in:
2022-08-15 21:02:01 +00:00
parent 42681283c9
commit 467c0acc59
3 changed files with 65 additions and 10 deletions

View File

@@ -302,11 +302,48 @@ namespace AyaNova.Util
}
//case 4170
///////////////////////////////////////////
// Remove license key from database
// triggered by AYANOVA_REMOVE_LICENSE_FROM_DB flag on boot
// This is for potential edge cases when we need
// to fix a weird license issue for a customer remotely
// by issuing a new license when they can't boot due to a bad license
// e.g. they upgrade and no maint so get too new error on boot
// want to renew and keep working so they contact us, buy a maintenance
// and need to have it fetch. (or some other unknown future issue)
//
internal static void RemoveLicenseFromDB(ILogger _log)
{
_log.LogInformation("Removing license from database \"{0}\"", _dbName);
//clear all connections so that the database can be dropped
Npgsql.NpgsqlConnection.ClearAllPools();
using (var conn = new Npgsql.NpgsqlConnection(_dbConnectionString))
{
conn.Open();
// Create the database desired
using (var cmd = new Npgsql.NpgsqlCommand())
{
cmd.Connection = conn;
cmd.CommandText = "delete from alicense;";
cmd.ExecuteNonQuery();
_log.LogDebug("License removed");
}
conn.Close();
}
}
/////////////////////////////////////////////////////////
// Erase all user entered data from the db
// This is called by seeder for trial seeding purposes
// and by v8 migrate and by license controller when erasing db
internal static async Task EmptyBizDataFromDatabaseForSeedingOrImportingAsync(ILogger _log, Guid jobIdToKeep, bool isMigrate=false)
internal static async Task EmptyBizDataFromDatabaseForSeedingOrImportingAsync(ILogger _log, Guid jobIdToKeep, bool isMigrate = false)
{
bool forSeeding = jobIdToKeep != Guid.Empty;