Update_6_31.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Comal.Classes;
  2. using InABox.Core;
  3. using InABox.Database;
  4. namespace PRS.Shared;
  5. public class Update_6_31 : DatabaseUpdateScript
  6. {
  7. public override VersionNumber Version => new (6, 31);
  8. private static Dictionary<string, Tuple<string, string>> _6_31_module_map = new()
  9. {
  10. { "Assignments", new("Assignments", "Assignments") },
  11. { "Daily Report", new("Daily Report", "Assignments") },
  12. { "Delivered On Site", new("Delivered On Site", "Delivery Items") },
  13. { "Deliveries", new("Deliveries", "Deliveries") },
  14. { "Digital Forms", new("Digital Forms", "DigitalForm") },
  15. { "Employee List", new("Employees", "Employee") },
  16. { "Equipment List", new("Equipment", "Equipment") },
  17. { "Factory Floor", new("Factory", "Manufacturing Packets") },
  18. { "Incoming Consignments", new("Consignments", "Consignment") },
  19. { "Manufacturing Status", new("Manufacturing Packets", "Manufacturing Packets") },
  20. { "Product List", new("Products", "Products") },
  21. { "Projects", new("Job Details", "Job Details") },
  22. { "Purchase Orders", new("Purchase Orders", "PurchaseOrder") },
  23. { "Quotes", new("Quotes", "Quotes") },
  24. { "Rack List", new("Shipping", "Shipments") },
  25. { "Site Requisitions", new("Requisitions", "Requisition") },
  26. { "Staff TimeSheets", new("Timesheets", "TimeSheet") },
  27. { "Stock Locations", new("Stock Locations", "StockLocation") },
  28. { "Stock Movements", new("Stock Movements", "StockMovement") },
  29. { "Task List", new("Tasks By Status", "Kanban") },
  30. };
  31. public override bool Update()
  32. {
  33. var modules = DbFactory.NewProvider(Logger.Main).Query(new Filter<CustomModule>().All())
  34. .Rows.Select(x => x.ToObject<CustomModule>()).ToList();
  35. foreach(var module in modules)
  36. {
  37. if (!string.IsNullOrWhiteSpace(module.Section))
  38. {
  39. if (_6_31_module_map.TryGetValue(module.Section, out var map))
  40. {
  41. module.Section = map.Item1;
  42. module.DataModel = map.Item2;
  43. module.AllRecords = true;
  44. }
  45. else
  46. {
  47. Logger.Send(LogType.Error, "", $"Custom Module '{module.Name}' has section name '{module.Section}' and will no longer be visible!");
  48. }
  49. }
  50. }
  51. DbFactory.NewProvider(Logger.Main).Save(modules);
  52. return true;
  53. }
  54. }