State of OMG-LEGION prior to merge

This commit is contained in:
2022-10-30 10:54:20 -04:00
parent 9924880b51
commit 48844127d7
45 changed files with 1350 additions and 868 deletions

View File

@@ -41,6 +41,8 @@ namespace PartSource.Automation.Jobs
IEnumerable<Product> products = await _shopifyClient.Products.Get(parameters);
int i = 1;
while (products != null && products.Any())
{
foreach (Product product in products)
@@ -94,45 +96,51 @@ namespace PartSource.Automation.Jobs
await SavePositionMetafield(product, vehicleIds, currentPosition);
//IList<string> notes = fitments.Select(f => f.NoteText)
IList<string> notes = fitments.Select(f => f.FitmentNoteHash)
.Distinct()
.ToList();
// .Distinct()
// .ToList();
IList<object> vehicleNotes = new List<object>();
//IList<object> vehicleNotes = new List<object>();
foreach (string noteHash in notes)
{
FitmentNote fitmentNote = await _fitmentContext.FitmentNotes.FirstOrDefaultAsync(f => f.Hash == noteHash);
//foreach (string noteText in notes)
//{
// vehicleIds = fitments.Where(f => f.NoteText == noteText)
// .Select(f => new { f.EngineConfigId, f.BaseVehicleId })
// .SelectMany(f => vehicles.Where(v => v.BaseVehicleId == f.BaseVehicleId && v.EngineConfigId == f.EngineConfigId))
// .Select(v => v.VehicleToEngineConfigId)
// .ToList();
if (fitmentNote == null)
{
continue;
}
// vehicleNotes.Add(new { noteText, vehicleIds });
//}
vehicleIds = fitments.Where(f => f.FitmentNoteHash == noteHash)
.Select(f => new { f.EngineConfigId, f.BaseVehicleId })
.SelectMany(f => vehicles.Where(v => v.BaseVehicleId == f.BaseVehicleId && v.EngineConfigId == f.EngineConfigId))
.Select(v => v.VehicleToEngineConfigId)
.ToList();
//string json = JsonConvert.SerializeObject(vehicleNotes);
//if (json.Length >= 100000)
//{
// continue;
//}
vehicleNotes.Add(new { fitmentNote.NoteText, vehicleIds });
}
//Metafield vehicleMetafield = new Metafield
//{
// Namespace = "fitment",
// Key = "note_text",
// Value = json,
// ValueType = "json_string",
// OwnerResource = "product",
// OwnerId = product.Id
//};
string json = JsonConvert.SerializeObject(vehicleNotes);
if (json.Length >= 100000)
{
continue;
}
//await _shopifyClient.Metafields.Add(vehicleMetafield);
Metafield vehicleMetafield = new Metafield
{
Namespace = "fitment",
Key = "note_text",
Value = json,
ValueType = "json_string",
OwnerResource = "product",
OwnerId = product.Id
};
//importData.UpdatedAt = DateTime.Now;
//importData.UpdateType = "Positioning";
}
await _shopifyClient.Metafields.Add(vehicleMetafield);
//importData.UpdatedAt = DateTime.Now;
//importData.UpdateType = "Positioning";
}
catch (Exception ex)
{
@@ -141,7 +149,8 @@ namespace PartSource.Automation.Jobs
}
try
{
{
Console.WriteLine(i);
products = await _shopifyClient.Products.GetNext();
}
@@ -200,7 +209,7 @@ namespace PartSource.Automation.Jobs
OwnerId = product.Id
};
System.Diagnostics.Debug.WriteLine(json);
//System.Diagnostics.Debug.WriteLine(json);
await _shopifyClient.Metafields.Add(vehicleMetafield);
}