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) if (ServerBootConfig.SOCKEYE_PERMANENTLY_ERASE_DATABASE)
{ {
_newLog.LogWarning("SOCKEYE_PERMANENTLY_ERASE_DATABASE has been set - IMPORTING ROCKFISH"); _newLog.LogWarning("SOCKEYE_PERMANENTLY_ERASE_DATABASE has been set - IMPORTING ROCKFISH");
GlobalBizSettingsBiz biz = GlobalBizSettingsBiz.GetBiz(dbContext); GlobalBizSettingsBiz.ImportRockfish(_newLog).Wait();
biz.ImportRockfish(dbContext, _newLog).Wait();
_newLog.LogInformation("IMPORT COMPLETED"); _newLog.LogInformation("IMPORT COMPLETED");
} }
} }

View File

@@ -129,7 +129,7 @@ namespace Sockeye.Biz
//IMPORT FROM ROCKFISH //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"); log.LogInformation("Start import from rockfish, authenticating");
ApiServerState apiServerState = (ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(ApiServerState)); ApiServerState apiServerState = (ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(ApiServerState));
@@ -192,6 +192,9 @@ namespace Sockeye.Biz
bool multiSite = jaSiteList.Count() > 1; bool multiSite = jaSiteList.Count() > 1;
foreach (JObject jSite in jaSiteList) foreach (JObject jSite in jaSiteList)
{
long CurrentCustomerId = 0;
using (AyContext ct = ServiceProviderProvider.DBContext)
{ {
var CustomerName = jCustomer["name"].Value<string>(); var CustomerName = jCustomer["name"].Value<string>();
if (multiSite) if (multiSite)
@@ -199,7 +202,7 @@ namespace Sockeye.Biz
CustomerName += " - " + jSite["name"].Value<string>(); CustomerName += " - " + jSite["name"].Value<string>();
log.LogInformation($"RFImport MULTISITE CUSTOMER: {CustomerName}"); log.LogInformation($"RFImport MULTISITE CUSTOMER: {CustomerName}");
} }
long CurrentCustomerId = 0;
//Create customer if we don't have one already //Create customer if we don't have one already
if (await ct.Customer.AnyAsync(z => z.Name == CustomerName)) if (await ct.Customer.AnyAsync(z => z.Name == CustomerName))
@@ -236,6 +239,7 @@ namespace Sockeye.Biz
var NewObject = await biz.CreateAsync(c); var NewObject = await biz.CreateAsync(c);
CurrentCustomerId = NewObject.Id; CurrentCustomerId = NewObject.Id;
}//customer creation }//customer creation
}//context
//SITE PURCHASES //SITE PURCHASES
@@ -243,6 +247,8 @@ namespace Sockeye.Biz
var jaPurchaseList = JArray.Parse(await res.Content.ReadAsStringAsync()); var jaPurchaseList = JArray.Parse(await res.Content.ReadAsStringAsync());
foreach (JObject jPurchase in jaPurchaseList) foreach (JObject jPurchase in jaPurchaseList)
{
using (AyContext ct = ServiceProviderProvider.DBContext)
{ {
//create product if not exist then import //create product if not exist then import
//Get product id if exists //Get product id if exists
@@ -300,7 +306,7 @@ namespace Sockeye.Biz
PurchaseBiz biz = PurchaseBiz.GetBiz(ct); PurchaseBiz biz = PurchaseBiz.GetBiz(ct);
await biz.CreateAsync(s); await biz.CreateAsync(s);
} }
}//context
} }
@@ -341,7 +347,8 @@ namespace Sockeye.Biz
"processed": false "processed": false
}, },
*/ */
using (AyContext ct = ServiceProviderProvider.DBContext)
{
var vn = new VendorNotification(); var vn = new VendorNotification();
vn.Created = DateUtil.EpochToDateNullIsMin(jVendorNotificationItem["dtCreated"].Value<long>()); vn.Created = DateUtil.EpochToDateNullIsMin(jVendorNotificationItem["dtCreated"].Value<long>());
vn.VendorId = 1; vn.VendorId = 1;
@@ -349,13 +356,14 @@ namespace Sockeye.Biz
vn.Processed = vn.Created;//indicate it's been processed vn.Processed = vn.Created;//indicate it's been processed
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
#if (DEBUG) #if (DEBUG)
//Test dev stuff //Test dev stuff
#warning DEV TEST ORDER PROCESSING REMOVE THIS WHEN DONE #warning DEV TEST ORDER PROCESSING REMOVE THIS WHEN DONE
if (!string.IsNullOrWhiteSpace(vn.VendorData)) if (!string.IsNullOrWhiteSpace(vn.VendorData))
await SockBotProcessVendorNotifications.ParseVendorNotificationData(vn, ct, log); await SockBotProcessVendorNotifications.ParseVendorNotificationData(vn, ct, log);
#endif #endif
}
}// all vendor notifications loop }// 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"); // res = await client.GetAsync($"{URL_ROCKFISH}api/rfcase/list");
// responseText = await res.Content.ReadAsStringAsync(); // responseText = await res.Content.ReadAsStringAsync();
// var jaRFCaseList = JArray.Parse(responseText); // var jaRFCaseList = JArray.Parse(responseText);
@@ -387,6 +397,7 @@ namespace Sockeye.Biz
// foreach (JObject jRFCase in jaRFCaseList.Reverse()) // foreach (JObject jRFCase in jaRFCaseList.Reverse())
// { // {
// var g = new GZCase(); // var g = new GZCase();
// g.CaseId = jRFCase["id"].Value<long>(); // g.CaseId = jRFCase["id"].Value<long>();
// g.Closed = DateUtil.EpochToDateNullIsNull(jRFCase["dtClosed"].Value<long?>()); // g.Closed = DateUtil.EpochToDateNullIsNull(jRFCase["dtClosed"].Value<long?>());
@@ -462,6 +473,7 @@ namespace Sockeye.Biz
// await command.ExecuteNonQueryAsync(); // await command.ExecuteNonQueryAsync();
// await ct.Database.CloseConnectionAsync(); // await ct.Database.CloseConnectionAsync();
// } // }
// }//end of context
// } // }
#endregion cases #endregion cases
@@ -477,7 +489,8 @@ namespace Sockeye.Biz
DateTime dtTempCreated = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc); DateTime dtTempCreated = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
foreach (JObject jLicenseListItem in jaLicenseList.Reverse()) foreach (JObject jLicenseListItem in jaLicenseList.Reverse())
{ {
using (AyContext ct = ServiceProviderProvider.DBContext)
{
res = await client.GetAsync($"{URL_ROCKFISH}api/license/{jLicenseListItem["id"].Value<long>()}"); res = await client.GetAsync($"{URL_ROCKFISH}api/license/{jLicenseListItem["id"].Value<long>()}");
responseText = await res.Content.ReadAsStringAsync(); responseText = await res.Content.ReadAsStringAsync();
var jLicense = JObject.Parse(responseText); var jLicense = JObject.Parse(responseText);
@@ -637,6 +650,7 @@ namespace Sockeye.Biz
l.NotificationSent = true; l.NotificationSent = true;
LicenseBiz biz = LicenseBiz.GetBiz(ct); LicenseBiz biz = LicenseBiz.GetBiz(ct);
await biz.CreateAsync(l, true); await biz.CreateAsync(l, true);
}//context
}// all licenses loop }// all licenses loop
@@ -676,7 +690,8 @@ namespace Sockeye.Biz
}, },
*/ */
using (AyContext ct = ServiceProviderProvider.DBContext)
{
//Save Key first then can set keyid on tlr //Save Key first then can set keyid on tlr
long? TrialKeyId = null; long? TrialKeyId = null;
{ {
@@ -765,7 +780,7 @@ namespace Sockeye.Biz
await biz.CreateAsync(tlr, true); await biz.CreateAsync(tlr, true);
} }
}//context
}// all trial requests loop }// all trial requests loop

View File

@@ -123,14 +123,18 @@ namespace Sockeye.Biz
#region CUSTOMER MAKE OR LOCATED #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 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 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); var customerBiz = CustomerBiz.GetBiz(ct);
//attempt to match to existing customer //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 //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) if (customer == null)
{ {
//New customer //New customer

View File

@@ -6,6 +6,26 @@ TODO:
- if v7 needs to account for there being a delay sometimes in order completeness - if v7 needs to account for there being a delay sometimes in order completeness
maybe just keep adding to the order and refreshing 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 - 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 - if v7 needs to account for there being a delay sometimes in order completeness
maybe just keep adding to the order and refreshing maybe just keep adding to the order and refreshing