diff --git a/server/biz/GlobalBizSettingsBiz.cs b/server/biz/GlobalBizSettingsBiz.cs index 80321bc..8eb4939 100644 --- a/server/biz/GlobalBizSettingsBiz.cs +++ b/server/biz/GlobalBizSettingsBiz.cs @@ -154,11 +154,8 @@ namespace Sockeye.Biz var res = await client.PostAsync($"{URL_ROCKFISH}authenticate?login=john&password=b43698c255365ee739c05ba0d42855e96c2365c76bb2f9b9eb149cec7b52174c", content); var responseText = await res.Content.ReadAsStringAsync(); - if (res.IsSuccessStatusCode) - { - log.LogInformation(responseText); - } - else log.LogError($"E1020 - Error authenticating to rockfish: {res.ReasonPhrase}"); + if (!res.IsSuccessStatusCode) + throw new Exception($"E1020 - Error authenticating to rockfish: {res.ReasonPhrase}"); var responseJson = JObject.Parse(responseText); @@ -172,10 +169,12 @@ namespace Sockeye.Biz client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authToken); + #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); - log.LogInformation("RFImport customers"); + foreach (JObject jCustomerListItem in jaCustomerList) { res = await client.GetAsync($"{URL_ROCKFISH}api/customer/{jCustomerListItem["id"].Value()}"); @@ -297,6 +296,8 @@ namespace Sockeye.Biz }//end of all customers iteration + #endregion customers + #region CASES /* log.LogInformation("RFImport Cases"); @@ -418,7 +419,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}"); /* {"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" @@ -434,21 +435,101 @@ namespace Sockeye.Biz cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.EmailAddress.Contains(jLicense["email"].Value())); if (cust != null) l.CustomerId = cust.Id; - l.DbId = jLicense["DBID"].Value(); - if (l.DbId == "na/v7" || l.DbId == "na/v7") - l.DbId = null; - l.FetchCode = jLicense["DBID"].Value(); - if (l.FetchCode == "na") l.FetchCode = null; - l.FetchedOn = DateUtil.EpochToDateNullIsNull(jLicense["dtCreated"].Value()); + + var KeyText = jLicense["key"].Value(); + if (KeyText.Contains("AyaNovaLicenseKey")) + { + //v7 key + /* + [KEY + { + "AyaNovaLicenseKey": { + "SchemaVersion": "7", + "Id": "1517418112", + "Created": "2018-01-31T09:01:52.1878494-08:00", + "Sub": "true", + "RegisteredTo": "Direct Telecom Services", + "EmailAddress": "chrisw@dts.solutions", + "FetchCode": "AgYuDnjDyQ", + "Source": "5246494432", + "InstallableUntil": "2019-01-31T09:01:52.089767-08:00", + "TotalScheduleableUsers": "15", + "Expires": "2019-01-31T00:00:00", + "RequestedTrial": "False", + "Plugins": { + "Plugin": [ + { + "Item": "MBI - Minimal browser interface", + "SubscriptionExpires": "2018-06-13T00:00:00" + }, + { + "Item": "WBI - Web browser interface", + "SubscriptionExpires": "2018-06-13T00:00:00" + }, + { + "Item": "OutlookSchedule", + "SubscriptionExpires": "2018-06-13T00:00:00" + }, + { + "Item": "AyaNovaOLI", + "SubscriptionExpires": "2018-06-13T00:00:00" + }, + { + "Item": "RI - Responsive Interface", + "SubscriptionExpires": "2018-06-13T00:00:00" + } + ] + } + } + } + KEY] + [SIGNATURE + uBjnooIDd6MOiqT/z4tDQfeafkQiWDBtxDHXOxhZ7av1oWS72yPoe8BrAnDZiYbxE4+cHR3C0sPCgEVva5miV1foyi7P6YKkxkKQMxTUR5IssgWVHM59KnO1lR2ndCHWaqH3gHgSsb/sdvYfuHg8luTl1RgjNDZRdQqbPl4NLMcGGW86LoXjpLjsRRxImckBEJFnntd+aXCRmQjXEZWmfxDVW84qa6h+ZCOwL3KYJHuPQDcCmhcpp3MIR3OHoeYhmNG7TWuELsJ4hrsROcqSbEC/CdZD8hoZwtrysu/ZvNZOKchwFsiBaN47+DxK0K/fL/X8CDcG+w3iqgH/x5ipIw== + SIGNATURE] + + */ + string keyNoWS = System.Text.RegularExpressions.Regex.Replace(StringUtil.Extract(KeyText, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"); + var jKey = JObject.Parse(keyNoWS); + l.LicenseExpire = DateTime.MaxValue; + l.MaintenanceExpire = DateUtil.EpochToDateNullIsMin(jKey["Expires"].Value()); + l.FetchCode = jLicense["code"].Value(); + l.Tags.Add("v7"); + } + else + { + //RAVEN KEY + /* + {{ + "Key": { + "LicenseFormat": "8", + "Id": "1672261044", + "RegisteredTo": "PDI Technologies", + "DBID": "R6U37uNUN2hSQideG6Gg+MqoQY8vuUeyHFI6Kv7VDsE=", + "Perpetual": true, + "LicenseExpiration": "5555-01-01T00:00:00", + "MaintenanceExpiration": "2023-12-28T00:00:00", + "Features": [ + { + "Name": "ActiveInternalUsers", + "Count": 5 + } + ] + } +}} + */ + string keyNoWS = System.Text.RegularExpressions.Regex.Replace(StringUtil.Extract(KeyText, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"); + var jKey = JObject.Parse(keyNoWS); + l.DbId = jKey["DBID"].Value(); + l.LicenseExpire = DateUtil.EpochToDateNullIsMin(jKey["LicenseExpiration"].Value()); + l.MaintenanceExpire = DateUtil.EpochToDateNullIsMin(jKey["MaintenanceExpiration"].Value()); + l.Tags.Add("raven"); + } + + l.Created = (DateTime)DateUtil.EpochToDateNullIsNull(jLicense["dtCreated"].Value()); + l.FetchedOn = DateUtil.EpochToDateNullIsNull(jLicense["dtfetched"].Value()); l.FetchEmail = jLicense["email"].Value(); l.Key = jLicense["key"].Value(); - //priority to tags - if (l.FetchCode == null) - l.Tags.Add("raven"); - else - l.Tags.Add("v7"); - LicenseBiz biz = LicenseBiz.GetBiz(ct); await biz.CreateAsync(l); @@ -459,9 +540,6 @@ namespace Sockeye.Biz #endregion licenses - - - } catch (Exception ex) {