From 836f5f7b673f3aea9f08e65e0ddf82c0c92383e9 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 28 Dec 2022 00:42:33 +0000 Subject: [PATCH] --- server/biz/GlobalBizSettingsBiz.cs | 11 ++++++++--- server/util/AySchema.cs | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/server/biz/GlobalBizSettingsBiz.cs b/server/biz/GlobalBizSettingsBiz.cs index c73762e..410fa05 100644 --- a/server/biz/GlobalBizSettingsBiz.cs +++ b/server/biz/GlobalBizSettingsBiz.cs @@ -263,15 +263,20 @@ namespace Sockeye.Biz //create product if not exist then import //Get product id if exists var ProductName = jPurchase["name"].Value(); - ProductName = ProductName.Replace("- Renewal", "").Replace(" Renewal", "").Replace(" RENEWAL", "").Replace("CANCELLED ", ""); - var p = await ct.Product.AsNoTracking().FirstOrDefaultAsync(z => z.Name == ProductName); + 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()); + + if (p == null) { + //Create it here p = new Product(); - p.Name = jPurchase["name"].Value(); + p.Name = ProductName; p.VendorId = 1; p.OurCode = p.VendorCode = jPurchase["productCode"].Value(); + + //log.LogInformation($"Importing new product name:{p.Name} - code:{p.VendorCode}"); ProductBiz biz = ProductBiz.GetBiz(ct); p = await biz.CreateAsync(p); } diff --git a/server/util/AySchema.cs b/server/util/AySchema.cs index b341f31..e7c051c 100644 --- a/server/util/AySchema.cs +++ b/server/util/AySchema.cs @@ -23,7 +23,7 @@ namespace Sockeye.Util private const int DESIRED_SCHEMA_LEVEL = 16; internal const long EXPECTED_COLUMN_COUNT = 497; - internal const long EXPECTED_INDEX_COUNT = 71; + internal const long EXPECTED_INDEX_COUNT = 74; internal const long EXPECTED_CHECK_CONSTRAINTS = 238; internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 32; internal const long EXPECTED_VIEWS = 0; @@ -31,7 +31,7 @@ namespace Sockeye.Util //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!! - ///////////////////////////////////////// (C495:I71:CC237:FC32:V0:R2) + ///////////////////////////////////////// (C497:I74:CC238:FC32:V0:R2) /* @@ -892,8 +892,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); + "wiki TEXT, tags VARCHAR(255) ARRAY, customerid BIGINT REFERENCES acustomer(id) )"); - await ExecQueryAsync("CREATE TABLE aproduct (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL, active BOOL NOT NULL DEFAULT true, " - + "vendorid BIGINT NOT NULL REFERENCES avendor(id), licenseinterval INTERVAL, maintinterval INTERVAL, vendorcode TEXT NOT NULL, ourcode TEXT NOT NULL, " + await ExecQueryAsync("CREATE TABLE aproduct (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL UNIQUE, active BOOL NOT NULL DEFAULT true, " + + "vendorid BIGINT NOT NULL REFERENCES avendor(id), licenseinterval INTERVAL, maintinterval INTERVAL, vendorcode TEXT NOT NULL UNIQUE, ourcode TEXT NOT NULL UNIQUE, " + "wiki TEXT, tags VARCHAR(255) ARRAY )");