| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using System.Diagnostics;
- using Admin.NET.Plugin.AiDOP.Entity;
- using Admin.NET.Plugin.AiDOP.Entity.S0.Manufacturing;
- using Admin.NET.Plugin.AiDOP.Entity.S0.Quality;
- using Admin.NET.Plugin.AiDOP.Entity.S0.Sales;
- using Admin.NET.Plugin.AiDOP.Entity.S0.Supply;
- using Admin.NET.Plugin.AiDOP.Entity.S8;
- using Admin.NET.Plugin.AiDOP.Order;
- using Admin.NET.Plugin.AiDOP.Infrastructure;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Hosting;
- using SqlSugar;
- namespace Admin.NET.Plugin.AiDOP;
- /// <summary>
- /// AiDOP 插件启动配置(按需扩展 DI)
- /// </summary>
- [AppStartup(900)]
- public class Startup : AppStartup
- {
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddHttpClient();
- services.AddConfigurableOptions<S8ActiveFlowWatchOptions>();
- services.AddScoped<AdoS0ExceptionFilter>();
- services.AddScoped<AdoS0ResultFilter>();
- services.Configure<MvcOptions>(options =>
- {
- options.Filters.AddService<AdoS0ExceptionFilter>();
- options.Filters.AddService<AdoS0ResultFilter>();
- });
- }
- /// <summary>
- /// 开发环境下为 Demo 表执行 CodeFirst(表已存在则跳过变更,行为取决于 SqlSugar 配置)。
- /// </summary>
- public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
- {
- try
- {
- AidopMenuLinkSync.EnsureLinked(app.ApplicationServices);
- }
- catch (Exception ex)
- {
- Trace.TraceWarning("Ai-DOP AidopMenuLinkSync: " + ex);
- }
- try
- {
- using var scopeS4 = app.ApplicationServices.CreateScope();
- var dbS4 = scopeS4.ServiceProvider.GetRequiredService<ISqlSugarClient>();
- dbS4.CodeFirst.InitTables(typeof(AdoSmartOpsLayoutItem), typeof(AdoSmartOpsHomeModule), typeof(AdoSmartOpsKpiMaster));
- AidopTenantMigration.MigrateOldTenantId(dbS4);
- AidopKpiMasterSeed.EnsureSeed(dbS4);
- AidopKpiMasterSeed.EnsureSeed(dbS4, 1300000000888);
- }
- catch (Exception ex)
- {
- Trace.TraceWarning("Ai-DOP CodeFirst/S4 seed: " + ex);
- }
- if (!env.IsDevelopment())
- return;
- // 客户/物料/优先级等;远端若已是遗留表(已有主键),CodeFirst 会报 Multiple primary key,不可让启动失败。
- try
- {
- using var scope = app.ApplicationServices.CreateScope();
- var db = scope.ServiceProvider.GetRequiredService<ISqlSugarClient>();
- db.CodeFirst.InitTables(
- typeof(AdoS0CustMaster),
- typeof(AdoS0ItemMaster),
- typeof(AdoS0ItemSubstituteDetail),
- typeof(AdoS0PriorityCode),
- typeof(AdoS0ProductStructureMaster),
- typeof(AdoS0ProductStructureOp),
- typeof(AdoS0StdOpMaster),
- typeof(AdoS0LineMaster),
- typeof(AdoS0MfgRoutingOpDetail),
- typeof(AdoS0MfgPersonSkillAssignment),
- typeof(AdoS0MfgWorkOrderControl),
- typeof(AdoS0MfgPersonSkill),
- typeof(AdoS0MfgLinePost),
- typeof(AdoS0MfgLinePostSkill),
- typeof(AdoS0MfgWorkCenter),
- typeof(AdoS0MfgLineMaterial),
- typeof(AdoS0ProcessFlowCard),
- typeof(AdoS0OrderScheduleCycle),
- typeof(AdoS0MfgElementParam),
- typeof(AdoS0MfgMaterialProcessElement),
- typeof(AdoS0MfgPreprocessElement),
- typeof(AdoS0MfgPreprocessElementParam),
- typeof(AdoS0ImageType),
- typeof(AdoS0QualitySegmentImage),
- typeof(AdoS0QmsQualityBaseType),
- typeof(AdoS0QmsFqcInspectionSpec),
- typeof(AdoS0QmsFqcInspectionSpecEntry),
- typeof(AdoS0QmsOqcInspectionSpec),
- typeof(AdoS0QmsOqcInspectionSpecEntry),
- typeof(AdoS0CategoryLeadTime),
- typeof(AdoS0MaterialPlanCycle),
- typeof(AdoS0SrmPurchase),
- typeof(AdoS8Exception),
- typeof(AdoS8ExceptionTimeline),
- typeof(AdoS8DecisionRecord),
- typeof(AdoS8Evidence),
- typeof(AdoS8SceneConfig),
- typeof(AdoS8AlertRule),
- typeof(AdoS8NotificationLayer),
- typeof(AdoS8DataSource),
- typeof(AdoS8WatchRule),
- typeof(AdoS8RolePermissionConfig),
- typeof(AdoS8NotificationLog),
- typeof(ContractReview),
- typeof(ContractReviewFlow),
- typeof(ProductDesign),
- typeof(ProductDesignBom),
- typeof(ProductDesignRouting)
- );
- }
- catch (Exception ex)
- {
- Trace.TraceWarning("Ai-DOP Development CodeFirst (S0/S8/Order demo tables): " + ex);
- }
- }
- }
|