This commit is contained in:
2023-01-23 22:25:54 +00:00
parent 09f2f3be2f
commit ffdf5070b4
4 changed files with 365 additions and 327 deletions

View File

@@ -666,8 +666,7 @@ namespace Sockeye
if (ServerBootConfig.SOCKEYE_PERMANENTLY_ERASE_DATABASE)
{
_newLog.LogWarning("SOCKEYE_PERMANENTLY_ERASE_DATABASE has been set - IMPORTING ROCKFISH");
GlobalBizSettingsBiz biz = GlobalBizSettingsBiz.GetBiz(dbContext);
biz.ImportRockfish(dbContext, _newLog).Wait();
GlobalBizSettingsBiz.ImportRockfish(_newLog).Wait();
_newLog.LogInformation("IMPORT COMPLETED");
}
}

View File

@@ -129,7 +129,7 @@ namespace Sockeye.Biz
//IMPORT FROM ROCKFISH
public async Task ImportRockfish(AyContext ct, ILogger log)
public static async Task ImportRockfish(ILogger log)
{
log.LogInformation("Start import from rockfish, authenticating");
ApiServerState apiServerState = (ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(ApiServerState));
@@ -193,49 +193,53 @@ namespace Sockeye.Biz
foreach (JObject jSite in jaSiteList)
{
var CustomerName = jCustomer["name"].Value<string>();
if (multiSite)
{
CustomerName += " - " + jSite["name"].Value<string>();
log.LogInformation($"RFImport MULTISITE CUSTOMER: {CustomerName}");
}
long CurrentCustomerId = 0;
//Create customer if we don't have one already
if (await ct.Customer.AnyAsync(z => z.Name == CustomerName))
continue;//already have this one so no need to process it again
using (AyContext ct = ServiceProviderProvider.DBContext)
{
//CREATE CUSTOMER
Customer c = new Customer();
c.Active = jCustomerListItem["active"].Value<bool>();
c.Name = CustomerName;
c.Country = jSite["country"].Value<string>();
c.Region = jSite["stateProvince"].Value<string>();
c.DoNotContact = jCustomer["doNotContact"].Value<bool>();
c.Notes = jCustomer["notes"].Value<string>();
c.DbId = jSite["dbId"].Value<string>();
if (c.DbId == "v7_no_dbid")
var CustomerName = jCustomer["name"].Value<string>();
if (multiSite)
{
c.DbId = null;
c.Tags.Add("v7");
CustomerName += " - " + jSite["name"].Value<string>();
log.LogInformation($"RFImport MULTISITE CUSTOMER: {CustomerName}");
}
else
c.Tags.Add("raven");
if (jSite["hosted"].Value<bool>() == true)
c.Tags.Add("hosted");
//In rockfish there were support emails that were people allowed to be contacting us on behalf of the customer
var supportEmail = jCustomer["supportEmail"].Value<string>();
if (!string.IsNullOrWhiteSpace(supportEmail))
c.Notes += "\nSupport Emails: " + supportEmail;
//in Rockfish the admin email is the main license related contact and technically the only person responsible to contact us
//usually the same as the purchase email
c.EmailAddress = jCustomer["adminEmail"].Value<string>();
CustomerBiz biz = CustomerBiz.GetBiz(ct);
var NewObject = await biz.CreateAsync(c);
CurrentCustomerId = NewObject.Id;
}//customer creation
//Create customer if we don't have one already
if (await ct.Customer.AnyAsync(z => z.Name == CustomerName))
continue;//already have this one so no need to process it again
{
//CREATE CUSTOMER
Customer c = new Customer();
c.Active = jCustomerListItem["active"].Value<bool>();
c.Name = CustomerName;
c.Country = jSite["country"].Value<string>();
c.Region = jSite["stateProvince"].Value<string>();
c.DoNotContact = jCustomer["doNotContact"].Value<bool>();
c.Notes = jCustomer["notes"].Value<string>();
c.DbId = jSite["dbId"].Value<string>();
if (c.DbId == "v7_no_dbid")
{
c.DbId = null;
c.Tags.Add("v7");
}
else
c.Tags.Add("raven");
if (jSite["hosted"].Value<bool>() == true)
c.Tags.Add("hosted");
//In rockfish there were support emails that were people allowed to be contacting us on behalf of the customer
var supportEmail = jCustomer["supportEmail"].Value<string>();
if (!string.IsNullOrWhiteSpace(supportEmail))
c.Notes += "\nSupport Emails: " + supportEmail;
//in Rockfish the admin email is the main license related contact and technically the only person responsible to contact us
//usually the same as the purchase email
c.EmailAddress = jCustomer["adminEmail"].Value<string>();
CustomerBiz biz = CustomerBiz.GetBiz(ct);
var NewObject = await biz.CreateAsync(c);
CurrentCustomerId = NewObject.Id;
}//customer creation
}//context
//SITE PURCHASES
@@ -244,63 +248,65 @@ namespace Sockeye.Biz
foreach (JObject jPurchase in jaPurchaseList)
{
//create product if not exist then import
//Get product id if exists
var ProductName = jPurchase["name"].Value<string>();
ProductName = ProductName.Replace("- Renewal", "").Replace(" Renewal", "").Replace(" RENEWAL", "").Replace("CANCELLED ", "").Replace("CANCELED ", "");
var p = await ct.Product.AsNoTracking().FirstOrDefaultAsync(z => z.VendorCode == jPurchase["productCode"].Value<string>());
if (p == null)
using (AyContext ct = ServiceProviderProvider.DBContext)
{
//create product if not exist then import
//Get product id if exists
var ProductName = jPurchase["name"].Value<string>();
ProductName = ProductName.Replace("- Renewal", "").Replace(" Renewal", "").Replace(" RENEWAL", "").Replace("CANCELLED ", "").Replace("CANCELED ", "");
var p = await ct.Product.AsNoTracking().FirstOrDefaultAsync(z => z.VendorCode == jPurchase["productCode"].Value<string>());
//Create it here
p = new Product();
p.Name = ProductName;
p.Active = true;//not entirely true but we can always deactivate there aren't many products
p.VendorId = 1;
p.OurCode = p.VendorCode = jPurchase["productCode"].Value<string>();
p.PGroup = ProductBiz.ProductGroupFromProductCode(p.OurCode);
if (p.VendorCode == "301028468")//subscription yearly
if (p == null)
{
p.LicenseInterval = new TimeSpan(365, 0, 0, 0); //actual length, in license is where I pad to cover them
//Create it here
p = new Product();
p.Name = ProductName;
p.Active = true;//not entirely true but we can always deactivate there aren't many products
p.VendorId = 1;
p.OurCode = p.VendorCode = jPurchase["productCode"].Value<string>();
p.PGroup = ProductBiz.ProductGroupFromProductCode(p.OurCode);
if (p.VendorCode == "301028468")//subscription yearly
{
p.LicenseInterval = new TimeSpan(365, 0, 0, 0); //actual length, in license is where I pad to cover them
}
if (p.VendorCode == "301028467")//subscription monthly
{
p.LicenseInterval = new TimeSpan(31, 0, 0, 0);//there is no concept beyond days for timespan so a month is 31 days max
p.MaintInterval = new TimeSpan(31, 0, 0, 0);//the only product less than one year of maintenance save the ones with no maintenance which can be edited manually later as there are so few of them
}
else
p.MaintInterval = new TimeSpan(365, 0, 0, 0);
ProductBiz biz = ProductBiz.GetBiz(ct);
p = await biz.CreateAsync(p);
}
if (p.VendorCode == "301028467")//subscription monthly
//Now we can add the sale that we have the product
if (!await ct.Purchase.AnyAsync(z => z.SalesOrderNumber == jPurchase["salesOrderNumber"].Value<string>()))
{
p.LicenseInterval = new TimeSpan(31, 0, 0, 0);//there is no concept beyond days for timespan so a month is 31 days max
p.MaintInterval = new TimeSpan(31, 0, 0, 0);//the only product less than one year of maintenance save the ones with no maintenance which can be edited manually later as there are so few of them
var s = new Purchase();
s.VendorId = 1;
s.ProductId = p.Id;
s.PGroup = p.PGroup;
s.CustomerId = CurrentCustomerId;
s.CancelDate = DateUtil.EpochToDateNullIsNull(jPurchase["cancelDate"].Value<long?>());
s.CouponCode = jPurchase["couponCode"].Value<string>();
s.ExpireDate = DateUtil.EpochToDateNullIsNull(jPurchase["expireDate"].Value<long?>());
s.Name = p.Name;
s.Processed = true;
s.PurchaseDate = DateUtil.EpochToDateNullIsMin(jPurchase["purchaseDate"].Value<long?>());
s.Quantity = jPurchase["quantity"].Value<int>();
s.RenewNoticeSent = jPurchase["renewNoticeSent"].Value<bool>();
s.SalesOrderNumber = jPurchase["salesOrderNumber"].Value<string>();
s.Notes = jPurchase["notes"].Value<string>();
PurchaseBiz biz = PurchaseBiz.GetBiz(ct);
await biz.CreateAsync(s);
}
else
p.MaintInterval = new TimeSpan(365, 0, 0, 0);
ProductBiz biz = ProductBiz.GetBiz(ct);
p = await biz.CreateAsync(p);
}
//Now we can add the sale that we have the product
if (!await ct.Purchase.AnyAsync(z => z.SalesOrderNumber == jPurchase["salesOrderNumber"].Value<string>()))
{
var s = new Purchase();
s.VendorId = 1;
s.ProductId = p.Id;
s.PGroup = p.PGroup;
s.CustomerId = CurrentCustomerId;
s.CancelDate = DateUtil.EpochToDateNullIsNull(jPurchase["cancelDate"].Value<long?>());
s.CouponCode = jPurchase["couponCode"].Value<string>();
s.ExpireDate = DateUtil.EpochToDateNullIsNull(jPurchase["expireDate"].Value<long?>());
s.Name = p.Name;
s.Processed = true;
s.PurchaseDate = DateUtil.EpochToDateNullIsMin(jPurchase["purchaseDate"].Value<long?>());
s.Quantity = jPurchase["quantity"].Value<int>();
s.RenewNoticeSent = jPurchase["renewNoticeSent"].Value<bool>();
s.SalesOrderNumber = jPurchase["salesOrderNumber"].Value<string>();
s.Notes = jPurchase["notes"].Value<string>();
PurchaseBiz biz = PurchaseBiz.GetBiz(ct);
await biz.CreateAsync(s);
}
}//context
}
@@ -341,21 +347,23 @@ namespace Sockeye.Biz
"processed": false
},
*/
using (AyContext ct = ServiceProviderProvider.DBContext)
{
var vn = new VendorNotification();
vn.Created = DateUtil.EpochToDateNullIsMin(jVendorNotificationItem["dtCreated"].Value<long>());
vn.VendorId = 1;
vn.VendorData = jVendorNotificationItem["data"].Value<string>();
vn.Processed = vn.Created;//indicate it's been processed
await ct.SaveChangesAsync();
var vn = new VendorNotification();
vn.Created = DateUtil.EpochToDateNullIsMin(jVendorNotificationItem["dtCreated"].Value<long>());
vn.VendorId = 1;
vn.VendorData = jVendorNotificationItem["data"].Value<string>();
vn.Processed = vn.Created;//indicate it's been processed
await ct.SaveChangesAsync();
#if (DEBUG)
//Test dev stuff
//Test dev stuff
#warning DEV TEST ORDER PROCESSING REMOVE THIS WHEN DONE
if (!string.IsNullOrWhiteSpace(vn.VendorData))
await SockBotProcessVendorNotifications.ParseVendorNotificationData(vn, ct, log);
if (!string.IsNullOrWhiteSpace(vn.VendorData))
await SockBotProcessVendorNotifications.ParseVendorNotificationData(vn, ct, log);
#endif
}
}// all vendor notifications loop
}
@@ -379,6 +387,8 @@ namespace Sockeye.Biz
// }
// {
// using (AyContext ct = ServiceProviderProvider.DBContext)
// {
// res = await client.GetAsync($"{URL_ROCKFISH}api/rfcase/list");
// responseText = await res.Content.ReadAsStringAsync();
// var jaRFCaseList = JArray.Parse(responseText);
@@ -387,6 +397,7 @@ namespace Sockeye.Biz
// foreach (JObject jRFCase in jaRFCaseList.Reverse())
// {
// var g = new GZCase();
// g.CaseId = jRFCase["id"].Value<long>();
// g.Closed = DateUtil.EpochToDateNullIsNull(jRFCase["dtClosed"].Value<long?>());
@@ -462,6 +473,7 @@ namespace Sockeye.Biz
// await command.ExecuteNonQueryAsync();
// await ct.Database.CloseConnectionAsync();
// }
// }//end of context
// }
#endregion cases
@@ -477,166 +489,168 @@ namespace Sockeye.Biz
DateTime dtTempCreated = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
foreach (JObject jLicenseListItem in jaLicenseList.Reverse())
{
res = await client.GetAsync($"{URL_ROCKFISH}api/license/{jLicenseListItem["id"].Value<long>()}");
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"
}
*/
var l = new License();
l.Active = true;
l.RegTo = jLicense["regTo"].Value<string>();
//try to match customer; rockfish didn't track customer id in the license so this is a bit wishy washy
Customer cust = null;
cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.Name == jLicense["customerName"].Value<string>());
if (cust == null)//email?
cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.EmailAddress.Contains(jLicense["email"].Value<string>()));
if (cust != null)
l.CustomerId = cust.Id;
var KeyText = jLicense["key"].Value<string>();
l.Key = KeyText;
LicenseBiz.ParseKeySetDTOFields(l);
if (KeyText.Contains("AyaNovaLicenseKey"))
using (AyContext ct = ServiceProviderProvider.DBContext)
{
//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]
res = await client.GetAsync($"{URL_ROCKFISH}api/license/{jLicenseListItem["id"].Value<long>()}");
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"
}
*/
var l = new License();
l.Active = true;
l.RegTo = jLicense["regTo"].Value<string>();
//try to match customer; rockfish didn't track customer id in the license so this is a bit wishy washy
Customer cust = null;
cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.Name == jLicense["customerName"].Value<string>());
if (cust == null)//email?
cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.EmailAddress.Contains(jLicense["email"].Value<string>()));
if (cust != null)
l.CustomerId = cust.Id;
var KeyText = jLicense["key"].Value<string>();
l.Key = KeyText;
LicenseBiz.ParseKeySetDTOFields(l);
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);
//In v7 the license expires is an optional property set called "LockDate"
l.LicenseExpire = null;
if (jKey["AyaNovaLicenseKey"]["LockDate"] != null)
l.LicenseExpire = jKey["AyaNovaLicenseKey"]["LockDate"].Value<DateTime>().ToUniversalTime();
l.MaintenanceExpire = jKey["AyaNovaLicenseKey"]["Expires"].Value<DateTime>().ToUniversalTime();
//l.Users=jKey["AyaNovaLicenseKey"]["TotalScheduleableUsers"].Value<int>();
l.PGroup = ProductGroup.AyaNova7;
l.FetchCode = jLicense["code"].Value<string>();
}
else if (KeyText.Contains("AyaNovaLiteLicenseKey"))
{
/*
"[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);
string keyNoWS = System.Text.RegularExpressions.Regex.Replace(StringUtil.Extract(KeyText, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1");
var jKey = JObject.Parse(keyNoWS);
//In v7 the license expires is an optional property set called "LockDate"
l.LicenseExpire = null;
if (jKey["AyaNovaLiteLicenseKey"]["LockDate"] != null)
l.LicenseExpire = jKey["AyaNovaLiteLicenseKey"]["LockDate"].Value<DateTime>().ToUniversalTime();
//In v7 the license expires is an optional property set called "LockDate"
l.LicenseExpire = null;
if (jKey["AyaNovaLicenseKey"]["LockDate"] != null)
l.LicenseExpire = jKey["AyaNovaLicenseKey"]["LockDate"].Value<DateTime>().ToUniversalTime();
l.MaintenanceExpire = jKey["AyaNovaLiteLicenseKey"]["Expires"].Value<DateTime>().ToUniversalTime();
l.MaintenanceExpire = jKey["AyaNovaLicenseKey"]["Expires"].Value<DateTime>().ToUniversalTime();
//l.Users=jKey["AyaNovaLicenseKey"]["TotalScheduleableUsers"].Value<int>();
l.PGroup = ProductGroup.AyaNova7;
l.FetchCode = jLicense["code"].Value<string>();
l.PGroup = ProductGroup.AyaNova7;
l.FetchCode = jLicense["code"].Value<string>();
}
else if (KeyText.Contains("AyaNovaLiteLicenseKey"))
{
/*
"[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);
//In v7 the license expires is an optional property set called "LockDate"
l.LicenseExpire = null;
if (jKey["AyaNovaLiteLicenseKey"]["LockDate"] != null)
l.LicenseExpire = jKey["AyaNovaLiteLicenseKey"]["LockDate"].Value<DateTime>().ToUniversalTime();
l.MaintenanceExpire = jKey["AyaNovaLiteLicenseKey"]["Expires"].Value<DateTime>().ToUniversalTime();
l.PGroup = ProductGroup.AyaNova7;
l.FetchCode = jLicense["code"].Value<string>();
l.Tags.Add("lite");
}
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["Key"]["DBID"].Value<string>();
l.LicenseExpire = jKey["Key"]["LicenseExpiration"].Value<DateTime>().ToUniversalTime();
//if (jKey["Key"]["Perpetual"].Value<bool>())
if ((bool?)jKey["Key"]["Perpetual"] ?? true)
l.PGroup = ProductGroup.RavenPerpetual;
l.Tags.Add("lite");
}
else
l.PGroup = ProductGroup.RavenSubscription;
l.MaintenanceExpire = jKey["Key"]["MaintenanceExpiration"].Value<DateTime>().ToUniversalTime();
}
{
//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["Key"]["DBID"].Value<string>();
l.LicenseExpire = jKey["Key"]["LicenseExpiration"].Value<DateTime>().ToUniversalTime();
//if (jKey["Key"]["Perpetual"].Value<bool>())
if ((bool?)jKey["Key"]["Perpetual"] ?? true)
l.PGroup = ProductGroup.RavenPerpetual;
else
l.PGroup = ProductGroup.RavenSubscription;
l.MaintenanceExpire = jKey["Key"]["MaintenanceExpiration"].Value<DateTime>().ToUniversalTime();
}
l.Created = (DateTime)DateUtil.EpochToDateNullIsNull(jLicense["dtcreated"].Value<long>());
l.FetchedOn = DateUtil.EpochToDateNullIsNull(jLicense["dtfetched"].Value<long?>());
l.FetchEmail = jLicense["email"].Value<string>();
// l.Key = jLicense["key"].Value<string>();
l.Created = (DateTime)DateUtil.EpochToDateNullIsNull(jLicense["dtcreated"].Value<long>());
l.FetchedOn = DateUtil.EpochToDateNullIsNull(jLicense["dtfetched"].Value<long?>());
l.FetchEmail = jLicense["email"].Value<string>();
// l.Key = jLicense["key"].Value<string>();
l.Active = true;//active here means it's been fully prepared and is viable for use, all prior licenses fit this description so all are active
l.NotificationSent = true;
LicenseBiz biz = LicenseBiz.GetBiz(ct);
await biz.CreateAsync(l, true);
l.Active = true;//active here means it's been fully prepared and is viable for use, all prior licenses fit this description so all are active
l.NotificationSent = true;
LicenseBiz biz = LicenseBiz.GetBiz(ct);
await biz.CreateAsync(l, true);
}//context
}// all licenses loop
@@ -676,96 +690,97 @@ namespace Sockeye.Biz
},
*/
//Save Key first then can set keyid on tlr
long? TrialKeyId = null;
using (AyContext ct = ServiceProviderProvider.DBContext)
{
string sKey = jTrialRequestItem["key"].Value<string>();
if (!string.IsNullOrWhiteSpace(sKey))
//Save Key first then can set keyid on tlr
long? TrialKeyId = null;
{
License l = new License();
l.TrialMode = true;
l.Key = sKey;
//get number of users count and features etc
LicenseBiz.ParseKeySetDTOFields(l);
//Parse key as we need the expiry dates and they are only stored in the key not the trial request
string keyNoWS = System.Text.RegularExpressions.Regex.Replace(StringUtil.Extract(l.Key, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1");
var jKey = JObject.Parse(keyNoWS);
l.RegTo = jKey["Key"]["RegisteredTo"].Value<string>();
//try to match customer; rockfish didn't track customer id in the license so this is a bit wishy washy
Customer cust = null;
cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.Name == l.RegTo);
if (cust == null)//email?
cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.EmailAddress.Contains(jTrialRequestItem["email"].Value<string>()));
if (cust != null)
l.CustomerId = cust.Id;
l.DbId = jKey["Key"]["DBID"].Value<string>();
l.LicenseExpire = jKey["Key"]["LicenseExpiration"].Value<DateTime>().ToUniversalTime();
if ((bool?)jKey["Key"]["Perpetual"] ?? true)
l.PGroup = ProductGroup.RavenPerpetual;
else
l.PGroup = ProductGroup.RavenSubscription;
l.MaintenanceExpire = jKey["Key"]["MaintenanceExpiration"].Value<DateTime>().ToUniversalTime();
l.Created = DateUtil.EpochToDateNullIsMin(jTrialRequestItem["dtProcessed"].Value<long>());
l.FetchedOn = DateUtil.EpochToDateNullIsNull(jTrialRequestItem["dtFetched"].Value<long?>());
l.FetchEmail = jTrialRequestItem["email"].Value<string>();
l.Active = true;//active here means it's been fully prepared and is viable for use, all prior licenses fit this description so all are active
l.NotificationSent = true;
//workaround sketchy old testing licenses
if (l.PGroup == ProductGroup.RavenSubscription)
string sKey = jTrialRequestItem["key"].Value<string>();
if (!string.IsNullOrWhiteSpace(sKey))
{
if (l.MaxDataGB == null || l.MaxDataGB == 0)
l.MaxDataGB = 20;
License l = new License();
l.TrialMode = true;
if (l.CustomerUsers == null || l.CustomerUsers == 0)
l.CustomerUsers = 250;
l.Key = sKey;
//get number of users count and features etc
LicenseBiz.ParseKeySetDTOFields(l);
//Parse key as we need the expiry dates and they are only stored in the key not the trial request
string keyNoWS = System.Text.RegularExpressions.Regex.Replace(StringUtil.Extract(l.Key, "[KEY", "KEY]").Trim(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1");
var jKey = JObject.Parse(keyNoWS);
}
l.RegTo = jKey["Key"]["RegisteredTo"].Value<string>();
//try to match customer; rockfish didn't track customer id in the license so this is a bit wishy washy
Customer cust = null;
cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.Name == l.RegTo);
if (cust == null)//email?
cust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.EmailAddress.Contains(jTrialRequestItem["email"].Value<string>()));
if (cust != null)
l.CustomerId = cust.Id;
l.DbId = jKey["Key"]["DBID"].Value<string>();
l.LicenseExpire = jKey["Key"]["LicenseExpiration"].Value<DateTime>().ToUniversalTime();
if ((bool?)jKey["Key"]["Perpetual"] ?? true)
l.PGroup = ProductGroup.RavenPerpetual;
else
l.PGroup = ProductGroup.RavenSubscription;
l.MaintenanceExpire = jKey["Key"]["MaintenanceExpiration"].Value<DateTime>().ToUniversalTime();
l.Created = DateUtil.EpochToDateNullIsMin(jTrialRequestItem["dtProcessed"].Value<long>());
l.FetchedOn = DateUtil.EpochToDateNullIsNull(jTrialRequestItem["dtFetched"].Value<long?>());
l.FetchEmail = jTrialRequestItem["email"].Value<string>();
l.Active = true;//active here means it's been fully prepared and is viable for use, all prior licenses fit this description so all are active
l.NotificationSent = true;
//workaround sketchy old testing licenses
if (l.PGroup == ProductGroup.RavenSubscription)
{
if (l.MaxDataGB == null || l.MaxDataGB == 0)
l.MaxDataGB = 20;
if (l.CustomerUsers == null || l.CustomerUsers == 0)
l.CustomerUsers = 250;
}
LicenseBiz lbiz = LicenseBiz.GetBiz(ct);
var newLicenseObject = await lbiz.CreateAsync(l, true);
LicenseBiz lbiz = LicenseBiz.GetBiz(ct);
var newLicenseObject = await lbiz.CreateAsync(l, true);
#if (DEBUG)
if (newLicenseObject == null)
{
System.Diagnostics.Debugger.Break();
}
if (newLicenseObject == null)
{
System.Diagnostics.Debugger.Break();
}
#endif
TrialKeyId = newLicenseObject.Id;
TrialKeyId = newLicenseObject.Id;
}
}
}
{
var tlr = new TrialLicenseRequest();
tlr.DbId = jTrialRequestItem["dbId"].Value<string>();
tlr.PGroup = (jTrialRequestItem["perpetual"].Value<bool>() ? ProductGroup.RavenPerpetual : ProductGroup.RavenSubscription);
tlr.CompanyName = jTrialRequestItem["companyName"].Value<string>();
tlr.ContactName = jTrialRequestItem["contactName"].Value<string>();
tlr.Email = jTrialRequestItem["email"].Value<string>();
tlr.EmailConfirmCode = jTrialRequestItem["emailConfirmCode"].Value<string>();
tlr.EmailValidated = jTrialRequestItem["emailValidated"].Value<bool>();
tlr.Requested = (DateTime)DateUtil.EpochToDateNullIsNull(jTrialRequestItem["dtRequested"].Value<long>());
tlr.Processed = DateUtil.EpochToDateNullIsNull(jTrialRequestItem["dtProcessed"].Value<long?>());
tlr.Status = (TrialRequestStatus)jTrialRequestItem["status"].Value<int>();
tlr.RejectReason = jTrialRequestItem["rejectReason"].Value<string>();
tlr.LicenseId = TrialKeyId;
var biz = TrialLicenseRequestBiz.GetBiz(ct);
await biz.CreateAsync(tlr, true);
}
{
var tlr = new TrialLicenseRequest();
tlr.DbId = jTrialRequestItem["dbId"].Value<string>();
tlr.PGroup = (jTrialRequestItem["perpetual"].Value<bool>() ? ProductGroup.RavenPerpetual : ProductGroup.RavenSubscription);
tlr.CompanyName = jTrialRequestItem["companyName"].Value<string>();
tlr.ContactName = jTrialRequestItem["contactName"].Value<string>();
tlr.Email = jTrialRequestItem["email"].Value<string>();
tlr.EmailConfirmCode = jTrialRequestItem["emailConfirmCode"].Value<string>();
tlr.EmailValidated = jTrialRequestItem["emailValidated"].Value<bool>();
tlr.Requested = (DateTime)DateUtil.EpochToDateNullIsNull(jTrialRequestItem["dtRequested"].Value<long>());
tlr.Processed = DateUtil.EpochToDateNullIsNull(jTrialRequestItem["dtProcessed"].Value<long?>());
tlr.Status = (TrialRequestStatus)jTrialRequestItem["status"].Value<int>();
tlr.RejectReason = jTrialRequestItem["rejectReason"].Value<string>();
tlr.LicenseId = TrialKeyId;
var biz = TrialLicenseRequestBiz.GetBiz(ct);
await biz.CreateAsync(tlr, true);
}
}//context
}// all trial requests loop

View File

@@ -105,7 +105,7 @@ namespace Sockeye.Biz
if (jData["order_notification"]["purchase"]["is_test"] != null && jData["order_notification"]["purchase"]["is_test"].Value<bool>() == true)
{
//during debugging allow it to process as a test but normally test orders should stop here
//during debugging allow it to process as a test but normally test orders should stop here
#if (!DEBUG)
return true;
#endif
@@ -123,14 +123,18 @@ namespace Sockeye.Biz
#region CUSTOMER MAKE OR LOCATED
///////////////////////////////////////////////////////////////////////////////////////////
var jCustomerName = jData["order_notification"]["purchase"]["customer_data"]["reg_name"].Value<string>() ?? throw new System.FormatException($"Vendor data empty reg_name:{vn.VendorData}");
var jCustomerEmail = jData["order_notification"]["purchase"]["customer_data"]["delivery_contact"]["email"].Value<string>() ?? throw new System.FormatException($"Vendor data empty email:{vn.VendorData}");
if (jData["order_notification"]["purchase"]["customer_data"]["delivery_contact"]["email"] == null)//we can't process orders with no email at all hard no
throw new System.FormatException($"Vendor data empty email:{vn.VendorData}");
var jCustomerEmail = jData["order_notification"]["purchase"]["customer_data"]["delivery_contact"]["email"].Value<string>();
var jCustomerAccountNumber = jData["order_notification"]["purchase"]["customer_data"]["shopper_id"].Value<string>();//appears to be mycommerce customer id number hopefully static between orders
var customerBiz = CustomerBiz.GetBiz(ct);
//attempt to match to existing customer
//account number is most ideal match, name second but could be multiple in sockeye from rockfish sites so name will start the same, finally email if nothing else
Customer customer = await ct.Customer.FirstOrDefaultAsync(z => z.AccountNumber == jCustomerAccountNumber) ?? await ct.Customer.FirstOrDefaultAsync(z => z.Name.StartsWith(jCustomerName)) ?? await ct.Customer.FirstOrDefaultAsync(z => z.EmailAddress == jCustomerEmail);
Customer customer = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.AccountNumber == jCustomerAccountNumber)
?? await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.Name.StartsWith(jCustomerName))
?? await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z => z.EmailAddress == jCustomerEmail);
if (customer == null)
{
//New customer

View File

@@ -6,6 +6,26 @@ TODO:
- if v7 needs to account for there being a delay sometimes in order completeness
maybe just keep adding to the order and refreshing
2023-01-23 12:07:29.9706|INFO|SERVER|RFImport MULTISITE CUSTOMER: AAA TEST DEVELOPMENT - TEMPORARY-HPE d.o.o.
2023-01-23 12:07:30.0367|INFO|SERVER|RFImport MULTISITE CUSTOMER: AAA TEST DEVELOPMENT - TestEvalMartinParsons
2023-01-23 12:07:30.1134|INFO|SERVER|RFImport MULTISITE CUSTOMER: AAA TEST DEVELOPMENT - test.onayanova.com
2023-01-23 12:07:30.1817|INFO|SERVER|RFImport MULTISITE CUSTOMER: AAA TEST DEVELOPMENT - development laptop debug mode
2023-01-23 12:07:30.2467|INFO|SERVER|RFImport MULTISITE CUSTOMER: AAA TEST DEVELOPMENT - test.helloayanova.com
2023-01-23 12:07:30.3152|INFO|SERVER|RFImport MULTISITE CUSTOMER: AAA TEST DEVELOPMENT - main
2023-01-23 12:07:41.4818|INFO|SERVER|RFImport MULTISITE CUSTOMER: Concept Machine Tool - Concept Machine Tool WI
2023-01-23 12:07:42.7496|INFO|SERVER|RFImport MULTISITE CUSTOMER: Concept Machine Tool - Concept Machine Tool Sales
2023-01-23 12:08:12.2217|INFO|SERVER|RFImport MULTISITE CUSTOMER: Morrow Service, Inc. - TestV8TrialExtension
2023-01-23 12:08:12.3234|INFO|SERVER|RFImport MULTISITE CUSTOMER: Morrow Service, Inc. - Morrow Service, Inc.
2023-01-23 12:08:24.8012|INFO|SERVER|RFImport MULTISITE CUSTOMER: Repairtek Technical Services Inc CANCELLED May 2017 - Repairtek Technical Services Inc - Project CPC
2023-01-23 12:08:24.9617|INFO|SERVER|RFImport MULTISITE CUSTOMER: Repairtek Technical Services Inc CANCELLED May 2017 - CANCELED Repairtek Technical Services Inc
2023-01-23 12:08:41.3152|INFO|SERVER|RFImport MULTISITE CUSTOMER: WE Technology Solutions, INC. - main-raven
2023-01-23 12:08:41.4872|INFO|SERVER|RFImport MULTISITE CUSTOMER: WE Technology Solutions, INC. - Main
2023-01-23 12:08:42.2448|INFO|SERVER|RFImport MULTISITE CUSTOMER: Yamaha Music Malaysia May 2017 - Yamaha Music Malaysia Sdn Bhd - ASC2
2023-01-23 12:08:42.3657|INFO|SERVER|RFImport MULTISITE CUSTOMER: Yamaha Music Malaysia May 2017 - Yamaha Music Malaysia Sdn Bhd - ASC1
2023-01-23 12:08:42.4901|INFO|SERVER|RFImport MULTISITE CUSTOMER: Yamaha Music Malaysia May 2017 - Yamaha Music Malaysia ASC3
2023-01-23 12:08:42.6139|INFO|SERVER|RFImport MULTISITE CUSTOMER: Yamaha Music Malaysia May 2017 - Yamaha Music Malaysia ASC4
- JOB: make a license from purchases but not active ready to send / in waiting only for approval
- if v7 needs to account for there being a delay sometimes in order completeness
maybe just keep adding to the order and refreshing