Startup.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System.Diagnostics;
  2. using Admin.NET.Plugin.AiDOP.Entity;
  3. using Admin.NET.Plugin.AiDOP.Entity.S0.Manufacturing;
  4. using Admin.NET.Plugin.AiDOP.Entity.S0.Sales;
  5. using Admin.NET.Plugin.AiDOP.Entity.S0.Supply;
  6. using Admin.NET.Plugin.AiDOP.Infrastructure;
  7. using Microsoft.AspNetCore.Builder;
  8. using Microsoft.AspNetCore.Hosting;
  9. using Microsoft.AspNetCore.Mvc;
  10. using Microsoft.Extensions.DependencyInjection;
  11. using Microsoft.Extensions.Hosting;
  12. using SqlSugar;
  13. namespace Admin.NET.Plugin.AiDOP;
  14. /// <summary>
  15. /// AiDOP 插件启动配置(按需扩展 DI)
  16. /// </summary>
  17. [AppStartup(900)]
  18. public class Startup : AppStartup
  19. {
  20. public void ConfigureServices(IServiceCollection services)
  21. {
  22. services.AddScoped<AdoS0ExceptionFilter>();
  23. services.AddScoped<AdoS0ResultFilter>();
  24. services.Configure<MvcOptions>(options =>
  25. {
  26. options.Filters.AddService<AdoS0ExceptionFilter>();
  27. options.Filters.AddService<AdoS0ResultFilter>();
  28. });
  29. }
  30. /// <summary>
  31. /// 开发环境下为 Demo 表执行 CodeFirst(表已存在则跳过变更,行为取决于 SqlSugar 配置)。
  32. /// </summary>
  33. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  34. {
  35. try
  36. {
  37. AidopMenuLinkSync.EnsureLinked(app.ApplicationServices);
  38. }
  39. catch (Exception ex)
  40. {
  41. Trace.TraceWarning("Ai-DOP AidopMenuLinkSync: " + ex);
  42. }
  43. if (!env.IsDevelopment())
  44. return;
  45. // 客户/物料/优先级:ado_s0_sales_cust_master、ado_s0_sales_item_master、ado_s0_sales_priority_code(旧表可 DROP 后重启)。
  46. using var scope = app.ApplicationServices.CreateScope();
  47. var db = scope.ServiceProvider.GetRequiredService<ISqlSugarClient>();
  48. db.CodeFirst.InitTables(
  49. typeof(AdoOrder),
  50. typeof(AdoPlan),
  51. typeof(AdoWorkOrder),
  52. typeof(AdoS0CustMaster),
  53. typeof(AdoS0ItemMaster),
  54. typeof(AdoS0ItemSubstituteDetail),
  55. typeof(AdoS0PriorityCode),
  56. typeof(AdoS0ProductStructureMaster),
  57. typeof(AdoS0ProductStructureOp),
  58. typeof(AdoS0StdOpMaster),
  59. typeof(AdoS0LineMaster),
  60. typeof(AdoS0MfgRoutingOpDetail),
  61. typeof(AdoS0MfgPersonSkillAssignment),
  62. typeof(AdoS0MfgWorkOrderControl),
  63. typeof(AdoS0MfgPersonSkill),
  64. typeof(AdoS0MfgLinePost),
  65. typeof(AdoS0MfgLinePostSkill),
  66. typeof(AdoS0MfgWorkCenter),
  67. typeof(AdoS0MfgLineMaterial),
  68. typeof(AdoS0MfgElementParam),
  69. typeof(AdoS0MfgMaterialProcessElement),
  70. typeof(AdoS0MfgPreprocessElement),
  71. typeof(AdoS0MfgPreprocessElementParam),
  72. typeof(AdoS0ImageType),
  73. typeof(AdoS0QualitySegmentImage),
  74. typeof(AdoS0SrmPurchase)
  75. );
  76. }
  77. }