From 5ad6e67ff916c4813472d4b8fc2763333abc9c4c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 6 Feb 2023 21:45:10 +0000 Subject: [PATCH] --- .../SockBotProcessPurchasesIntoLicenses.cs | 167 +++++++++++++++--- 1 file changed, 142 insertions(+), 25 deletions(-) diff --git a/server/generator/SockBotProcessPurchasesIntoLicenses.cs b/server/generator/SockBotProcessPurchasesIntoLicenses.cs index 6fc2d43..7a5fdcb 100644 --- a/server/generator/SockBotProcessPurchasesIntoLicenses.cs +++ b/server/generator/SockBotProcessPurchasesIntoLicenses.cs @@ -139,35 +139,152 @@ namespace Sockeye.Biz //copy all the values to the new license newLicense.ExportToXLS = lastLicense.ExportToXLS; newLicense.ExportToXLSExpires = lastLicense.ExportToXLSExpires; - newLicense.ImportExportCSVDuplicate=lastLicense.ImportExportCSVDuplicate; - newLicense.ImportExportCSVDuplicateExpires=lastLicense.ImportExportCSVDuplicateExpires; - newLicense.MaintenanceExpire=lastLicense.MaintenanceExpire; - newLicense.MBI=lastLicense.MBI; - newLicense.MBIExpires=lastLicense.MBIExpires; - newLicense.OLI=lastLicense.OLI; - newLicense.OLIExpires=lastLicense.OLIExpires; - newLicense.OutlookSchedule=lastLicense.OutlookSchedule; - newLicense.OutlookScheduleExpires=lastLicense.OutlookScheduleExpires; - newLicense.PTI=lastLicense.PTI; - newLicense.PTIExpires=lastLicense.PTIExpires; - newLicense.QBI=lastLicense.QBI; - newLicense.QBIExpires=lastLicense.QBIExpires; - newLicense.QBOI=lastLicense.QBOI; - newLicense.QBOIExpires=lastLicense.QBOIExpires; - newLicense.QuickNotification=lastLicense.QuickNotification; - newLicense.QuickNotificationExpires=lastLicense.QuickNotificationExpires; - newLicense.Renewal=true; - newLicense.RI=lastLicense.RI; - newLicense.RIExpires=lastLicense.RIExpires; - newLicense.Tags=lastLicense.Tags; - newLicense.Users=lastLicense.Users; - newLicense.WBI=lastLicense.WBI; - newLicense.WBIExpires=lastLicense.WBIExpires; - newLicense.Wiki=lastLicense.Wiki; + newLicense.ImportExportCSVDuplicate = lastLicense.ImportExportCSVDuplicate; + newLicense.ImportExportCSVDuplicateExpires = lastLicense.ImportExportCSVDuplicateExpires; + newLicense.MaintenanceExpire = lastLicense.MaintenanceExpire; + newLicense.MBI = lastLicense.MBI; + newLicense.MBIExpires = lastLicense.MBIExpires; + newLicense.OLI = lastLicense.OLI; + newLicense.OLIExpires = lastLicense.OLIExpires; + newLicense.OutlookSchedule = lastLicense.OutlookSchedule; + newLicense.OutlookScheduleExpires = lastLicense.OutlookScheduleExpires; + newLicense.PTI = lastLicense.PTI; + newLicense.PTIExpires = lastLicense.PTIExpires; + newLicense.QBI = lastLicense.QBI; + newLicense.QBIExpires = lastLicense.QBIExpires; + newLicense.QBOI = lastLicense.QBOI; + newLicense.QBOIExpires = lastLicense.QBOIExpires; + newLicense.QuickNotification = lastLicense.QuickNotification; + newLicense.QuickNotificationExpires = lastLicense.QuickNotificationExpires; + newLicense.Renewal = true; + newLicense.RI = lastLicense.RI; + newLicense.RIExpires = lastLicense.RIExpires; + newLicense.Tags = lastLicense.Tags; + newLicense.Users = lastLicense.Users; + newLicense.WBI = lastLicense.WBI; + newLicense.WBIExpires = lastLicense.WBIExpires; + newLicense.Wiki = lastLicense.Wiki; } + //iterate the purchases and update / set the license foreach (var purchase in purchaseGroup) { + var product = await ct.Product.AsNoTracking().FirstOrDefaultAsync(z => z.Id == purchase.ProductId);//should *always* exist + if (product == null) + { + var err = $"SockBotProcessPurchasesIntoLicenses purchase: {purchase.Id} has un-matchable product id: {purchase.ProductId}"; + //serious issue requires immediate notification + await NotifyEventHelper.AddOpsProblemEvent(err); + log.LogError(err); + continue; + } + + /* + id name productCode price renewPrice + 1 Key administration 300093112 3500 3500 + 2 Custom work 300151145 0 0 + 3 AyaNova RI 1 year subscription license 300740314 19900 6965 + 4 Single AyaNova schedulable resource 1 year subscription license 300740315 15900 5565 + 5 Single AyaNova Lite 1 year subscription license 300740316 6900 2415 + 6 Up to 5 AyaNova schedulable resource 1 year subscription license 300740317 69500 24325 + 7 Up to 10 AyaNova schedulable resource 1 year subscription license 300740318 119000 41650 + 8 Up to 20 AyaNova schedulable resource 1 year subscription license 300740319 198000 69300 + 9 AyaNova WBI (web browser interface) 1 year subscription license 300740321 9900 3465 + 10 AyaNova MBI (minimal browser interface) 1 year subscription license 300740322 9900 3465 + 11 AyaNova QBI(QuickBooks interface) 1 year subscription license 300740323 9900 3465 + 12 AyaNova PTI(US Peachtree/Sage 50 interface) 1 year subscription license 300740324 9900 3465 + 13 AyaNova OLI(Outlook interface) 1 year subscription license 300740325 9900 3465 + 14 Plug-in Outlook Schedule Export 1 year subscription license 300740326 1900 665 + 15 Plug-in Export to XLS 1 year subscription license 300740327 1900 665 + 16 Plug-in Quick Notification 1 year subscription license 300740328 1900 665 + 17 Plug-in importexport.csv duplicate 1 year subscription license 300740329 1900 665 + 18 Up to 999 AyaNova schedulable resource 1 year subscription license 300741264 15000 5250 + 19 Up to 15 AyaNova schedulable resource 1 year subscription license 300807973 165000 57750 + 20 AyaNova QBOI(QuickBooks Online interface) 1 year subscription license 300784766 12900 4515 + 21 Single AyaNova service techncian perpetual license 301028314 135 100 + 22 Single AyaNova service techncian 1 year maintenance plan - new 301028317 135 100 + 23 Single AyaNova service techncian 1 year maintenance plan - active 301028315 100 100 + */ + var dtOneYear = DateTime.UtcNow.AddYears(1); + switch (product.VendorCode) + { + case "300740314": + newLicense.RI = true; + newLicense.RIExpires = dtOneYear; + break; + case "300740321": + newLicense.WBI = true; + newLicense.WBIExpires = dtOneYear; + break; + case "300740322": + newLicense.MBI = true; + newLicense.MBIExpires = dtOneYear; + break; + case "300740323": + newLicense.QBI = true; + newLicense.QBIExpires = dtOneYear; + break; + case "300740324": + newLicense.PTI = true; + newLicense.PTIExpires = dtOneYear; + break; + case "300740325": + newLicense.OLI = true; + newLicense.OLIExpires = dtOneYear; + break; + case "300740326": + newLicense.OutlookSchedule = true; + newLicense.OutlookScheduleExpires = dtOneYear; + break; + case "300740327": + newLicense.ExportToXLS = true; + newLicense.ExportToXLSExpires = dtOneYear; + break; + case "300740328": + newLicense.QuickNotification = true; + newLicense.QuickNotificationExpires = dtOneYear; + break; + case "300740329": + newLicense.ImportExportCSVDuplicate = true; + newLicense.ImportExportCSVDuplicateExpires = dtOneYear; + break; + case "300784766": + newLicense.QBOI = true; + newLicense.QBOIExpires = dtOneYear; + break; + //USERS + case "300740315": + newLicense.Users = 1; + newLicense.MaintenanceExpire = dtOneYear; + break; + case "300740317": + newLicense.Users = 5; + newLicense.MaintenanceExpire = dtOneYear; + break; + case "300740318": + newLicense.Users = 10; + newLicense.MaintenanceExpire = dtOneYear; + break; + case "300740319": + newLicense.Users = 20; + newLicense.MaintenanceExpire = dtOneYear; + break; + case "300741264": + newLicense.Users = 999; + newLicense.MaintenanceExpire = dtOneYear; + break; + case "300807973": + newLicense.Users = 15; + newLicense.MaintenanceExpire = dtOneYear; + break; + default: + var err = $"SockBotProcessPurchasesIntoLicenses purchase: {purchase.Id} has product not part of v7 group expected: {product.Name}-{product.VendorCode}"; + //serious issue requires immediate notification + await NotifyEventHelper.AddOpsProblemEvent(err); + log.LogError(err); + continue; + + } } }