using Comal.Classes; using InABox.Core; using InABox.Database; namespace PRS.Shared; public class Update_6_31 : DatabaseUpdateScript { public override VersionNumber Version => new (6, 31); private static Dictionary> _6_31_module_map = new() { { "Assignments", new("Assignments", "Assignments") }, { "Daily Report", new("Daily Report", "Assignments") }, { "Delivered On Site", new("Delivered On Site", "Delivery Items") }, { "Deliveries", new("Deliveries", "Deliveries") }, { "Digital Forms", new("Digital Forms", "DigitalForm") }, { "Employee List", new("Employees", "Employee") }, { "Equipment List", new("Equipment", "Equipment") }, { "Factory Floor", new("Factory", "Manufacturing Packets") }, { "Incoming Consignments", new("Consignments", "Consignment") }, { "Manufacturing Status", new("Manufacturing Packets", "Manufacturing Packets") }, { "Product List", new("Products", "Products") }, { "Projects", new("Job Details", "Job Details") }, { "Purchase Orders", new("Purchase Orders", "PurchaseOrder") }, { "Quotes", new("Quotes", "Quotes") }, { "Rack List", new("Shipping", "Shipments") }, { "Site Requisitions", new("Requisitions", "Requisition") }, { "Staff TimeSheets", new("Timesheets", "TimeSheet") }, { "Stock Locations", new("Stock Locations", "StockLocation") }, { "Stock Movements", new("Stock Movements", "StockMovement") }, { "Task List", new("Tasks By Status", "Kanban") }, }; public override bool Update() { var modules = DbFactory.NewProvider(Logger.Main).Query(new Filter().All()) .Rows.Select(x => x.ToObject()).ToList(); foreach(var module in modules) { if (!string.IsNullOrWhiteSpace(module.Section)) { if (_6_31_module_map.TryGetValue(module.Section, out var map)) { module.Section = map.Item1; module.DataModel = map.Item2; module.AllRecords = true; } else { Logger.Send(LogType.Error, "", $"Custom Module '{module.Name}' has section name '{module.Section}' and will no longer be visible!"); } } } DbFactory.NewProvider(Logger.Main).Save(modules); return true; } }