diff --git a/server/biz/GlobalBizSettingsBiz.cs b/server/biz/GlobalBizSettingsBiz.cs index 7dd7390..c333f1f 100644 --- a/server/biz/GlobalBizSettingsBiz.cs +++ b/server/biz/GlobalBizSettingsBiz.cs @@ -171,6 +171,7 @@ namespace Sockeye.Biz #region CUSTOMERS log.LogInformation("RFImport customers"); + res = await client.GetAsync($"{URL_ROCKFISH}api/customer/list"); responseText = await res.Content.ReadAsStringAsync(); var jaCustomerList = JArray.Parse(responseText); @@ -408,6 +409,7 @@ namespace Sockeye.Biz log.LogInformation("RFImport Licenses"); { + res = await client.GetAsync($"{URL_ROCKFISH}api/license/list"); responseText = await res.Content.ReadAsStringAsync(); var jaLicenseList = JArray.Parse(responseText); @@ -419,7 +421,7 @@ namespace Sockeye.Biz res = await client.GetAsync($"{URL_ROCKFISH}api/license/{jLicenseListItem["id"].Value()}"); responseText = await res.Content.ReadAsStringAsync(); var jLicense = JObject.Parse(responseText); - // log.LogInformation($"Importing license:{responseText}"); + // log.LogInformation($"Importing license:{responseText}"); /* {"regTo":"PDI Technologies","customerName":"PDI Technologies","dtcreated":1672261044,"email":"jberkel@pdisoftware.com","code":"na","fetched":true,"dtfetched":1672262347,"fetchFrom":null, "key":"[KEY\n{\n \"Key\": {\n \"LicenseFormat\": \"8\",\n \"Id\": \"1672261044\",\n \"RegisteredTo\": \"PDI Technologies\",\n \"DBID\": \"R6U37uNUN2hSQideG6Gg+MqoQY8vuUeyHFI6Kv7VDsE=\",\n \"Perpetual\": true,\n \"LicenseExpiration\": \"5555-01-01T00:00:00\",\n \"MaintenanceExpiration\": \"2023-12-28T00:00:00\",\n \"Features\": [\n {\n \"Name\": \"ActiveInternalUsers\",\n \"Count\": 5\n }\n ]\n }\n}\nKEY]\n[SIGNATURE\nkzVs8GH0MSIfsR7ZYQ5x+5wdVDJqpfOYvTfBCx32Vs+zqP7h89uUKI17jTx5rMvkOYX40GyJt0pTWOzltljzf+MaoTzoSvTsSPkWtdVWv8ZGOXUUdaZhzMoTJGxTg0JHka/8S5tLkTiuct3x+voiLAKXuFCp9TSZo4+UnejB6U2Bp6MfdZxLtKVZ/1RLu/h4SnP8ZbczuwbQReB1z4k4IRwjh5GHnUUm6YqZg/04m1X9FEeKQZQfGZk/qZ788jONbLQb4CLnq0/ZmIteeocDDBz59TYaC9BHwHp73y8jyPfEugVfyH2AE0J8ZILiFiozYQ7meP5X4ZOmd1nhTA8MkA==\nSIGNATURE]\n" @@ -436,6 +438,8 @@ namespace Sockeye.Biz if (cust != null) l.CustomerId = cust.Id; + + var KeyText = jLicense["key"].Value(); if (KeyText.Contains("AyaNovaLicenseKey")) { @@ -492,10 +496,29 @@ namespace Sockeye.Biz var jKey = JObject.Parse(keyNoWS); l.LicenseExpire = DateTime.MaxValue.ToUniversalTime(); l.MaintenanceExpire = jKey["AyaNovaLicenseKey"]["Expires"].Value().ToUniversalTime(); - + l.FetchCode = jLicense["code"].Value(); l.Tags.Add("v7"); } + else if (KeyText.Contains("AyaNovaLicenseKey")) + { + /* + "[KEY\n{\n \"AyaNovaLiteLicenseKey\": {\n \"SchemaVersion\": \"7\",\n \"Id\": \"1648506791\",\n \"Created\": \"2022-03-28T15:33:11.6010225-07:00\",\n + \"Sub\": \"true\",\n \"RegisteredTo\": \"Duncan Electric\",\n \"EmailAddress\": \"sandrajod@att.net\",\n + \"FetchCode\": \"hGAmScqYcU\",\n \"Source\": \"5246494431\",\n \"InstallableUntil\": \"2023-03-28T15:33:11.6009851-07:00\",\n + \"TotalScheduleableUsers\": \"1\",\n \"Expires\": \"2023-03-29T00:00:00\",\n \"RequestedTrial\": \"False\",\n \"Plugins\": {\n + \"Plugin\": []\n }\n }\n}\nKEY]\n + [SIGNATURE\nKuOF/SpBL1d8AFebvm2lipmKeGdbR6WzbhN68fun+ffVGRjXNX1jWI3rbf9P/shs2/M8gHqW/B7T0vVovGqosmNsGtvaYo30TKlZj9Eicr2+zDf7ojwZiBCeEnFzXr9+7aZrsZSvN20Pqof0xf/J4BVp1T66ecuZywMzH0NGsXXZtXhWYhGvLAZAR1X5/j5gqysSdysmV9j8Euz91zs/BRyfdU0uwwrdQzrJzI4V1MFl+/mIkhMUNcJ5bzjisWS2xeyNYCYnGpMF5oaGPaIcEtmTAdf5fPNNvw3sNhPaZgwlzN8FjfK6T0VgS19PcHCMOA1bTAiLLFNk6wkcjGp2Cw==\nSIGNATURE]\n" + */ + string keyNoWS = System.Text.RegularExpressions.Regex.Replace(StringUtil.Extract(KeyText, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"); + var jKey = JObject.Parse(keyNoWS); + l.LicenseExpire = DateTime.MaxValue.ToUniversalTime(); + l.MaintenanceExpire = jKey["AyaNovaLiteLicenseKey"]["Expires"].Value().ToUniversalTime(); + + l.FetchCode = jLicense["code"].Value(); + l.Tags.Add("v7"); + l.Tags.Add("lite"); + } else { //RAVEN KEY diff --git a/server/models/License.cs b/server/models/License.cs index 72c0ff5..a8d47b8 100644 --- a/server/models/License.cs +++ b/server/models/License.cs @@ -16,7 +16,7 @@ namespace Sockeye.Models public uint Concurrency { get; set; } public DateTime Created { get; set; } - public long CustomerId { get; set; } + public long? CustomerId { get; set; } [NotMapped] public string CustomerViz { get; set; } public string RegTo { get; set; } diff --git a/server/util/AySchema.cs b/server/util/AySchema.cs index fafe810..c825b92 100644 --- a/server/util/AySchema.cs +++ b/server/util/AySchema.cs @@ -24,14 +24,14 @@ namespace Sockeye.Util internal const long EXPECTED_COLUMN_COUNT = 498; internal const long EXPECTED_INDEX_COUNT = 74; - internal const long EXPECTED_CHECK_CONSTRAINTS = 239; + internal const long EXPECTED_CHECK_CONSTRAINTS = 238; internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 32; internal const long EXPECTED_VIEWS = 0; internal const long EXPECTED_ROUTINES = 2; //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!! - ///////////////////////////////////////// (C498:I74:CC239:FC32:V0:R2) + ///////////////////////////////////////// (C498:I74:CC238:FC32:V0:R2) /* @@ -875,7 +875,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); LogUpdateMessage(log); await ExecQueryAsync("CREATE TABLE alicense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created TIMESTAMPTZ NOT NULL, " - + "customerid BIGINT NOT NULL REFERENCES acustomer(id), regto TEXT NOT NULL, key TEXT NOT NULL, fetchcode TEXT, fetchemail TEXT, " + + "customerid BIGINT REFERENCES acustomer(id), regto TEXT NOT NULL, key TEXT NOT NULL, fetchcode TEXT, fetchemail TEXT, " + "fetchedon TIMESTAMPTZ, dbid TEXT, licenseexpire TIMESTAMPTZ, maintenanceexpire TIMESTAMPTZ NOT NULL, " + "wiki TEXT, tags VARCHAR(255) ARRAY )");