diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs index 5902cf83..1fb49eea 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs @@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Volo.Abp.Domain.Repositories; +using NUglify.Helpers; using Win.Sfs.SettleAccount.Entities.BQ.Vmi; namespace Win.Sfs.SettleAccount; @@ -19,6 +19,9 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { + AppDomain.CurrentDomain.GetAssemblies().SelectMany(o => o.GetTypes()) + .Where(o => o.IsClass && !o.IsAbstract && o.IsAssignableTo(typeof(IJobService))) + .ForEach(o => services.AddTransient(o)); services.AddScheduler(); services.AddRouting(options => options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer)); services.AddMvc(options => options.Conventions.Add(new RouteTokenTransformerConvention(new SlugifyParameterTransformer()))); @@ -41,7 +44,7 @@ public class Startup app.ApplicationServices.UseScheduler(scheduler => { using var scope = app.ApplicationServices.CreateScope(); - var jobs = scope.ServiceProvider.GetService>()?.ToList(); + var jobs = scope.ServiceProvider.GetService().Set().ToList(); jobs?.ForEach(job => { var jobId = job.Id; @@ -51,13 +54,15 @@ public class Startup { if (scope.ServiceProvider.GetService(serviceType) is IJobService jobService) { - scheduler.Schedule(() => { + scheduler.Schedule(() => + { using var scope = app.ApplicationServices.CreateScope(); - var jobItemRepository = scope.ServiceProvider.GetRequiredService>(); - var jobLogRepository = scope.ServiceProvider.GetRequiredService>(); + var db = scope.ServiceProvider.GetService(); + var jobItemRepository = db.Set(); + var jobLogRepository = db.Set(); var jobItem = jobItemRepository.FirstOrDefault(o => o.Id == jobId); jobItem.IsRunning = true; - jobItemRepository.UpdateAsync(jobItem).Wait(); + db.SaveChanges(); var jobLog = new JobLog { JobId = jobId, Start = DateTime.Now }; try { @@ -72,9 +77,9 @@ public class Startup finally { jobLog.End = DateTime.Now; - jobLogRepository.InsertAsync(jobLog).Wait(); + jobLogRepository.Add(jobLog); jobItem.IsRunning = false; - jobItemRepository.UpdateAsync(jobItem).Wait(); + db.SaveChanges(); } }).Cron(job.Cron); } diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json index 209e9758..d71a2bda 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json @@ -3,10 +3,8 @@ "CorsOrigins": "https://*.abc.com,http://localhost:9527,http://149.223.116.5:8088" }, "ConnectionStrings": { - //"Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True", - //"SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;" - "SettleAccountService": "Server=localhost;Database=BQ_SA;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True", - "Default": "Server=localhost;Database=BJABP;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True" + "Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True", + "SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;" }, "Serilog": { "Using": [], diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js index 481d2f9c..ef2dc6d7 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js @@ -33,7 +33,7 @@ export default { :hideButton="true" :isQueryForm="true" > -