diff --git a/apps/vue/src/views/task-management/background-jobs/components/BackgroundJobInfoTable.vue b/apps/vue/src/views/task-management/background-jobs/components/BackgroundJobInfoTable.vue index 7adfd49f9..c9467fc15 100644 --- a/apps/vue/src/views/task-management/background-jobs/components/BackgroundJobInfoTable.vue +++ b/apps/vue/src/views/task-management/background-jobs/components/BackgroundJobInfoTable.vue @@ -192,7 +192,7 @@ content: L('MultipleSelectJobsWillBeDeletedMessage'), okCancel: true, onOk: () => { - deleteById(record).then(() => { + deleteById(record.id).then(() => { reload(); }); }, diff --git a/aspnet-core/Directory.Build.props b/aspnet-core/Directory.Build.props index 0fcd0e7ea..914113047 100644 --- a/aspnet-core/Directory.Build.props +++ b/aspnet-core/Directory.Build.props @@ -1,7 +1,7 @@  - 5.0.0 - 5.0.0 + 5.1.1 + 5.1.1 1.5.0 1.0.1 5.2.0 @@ -10,7 +10,7 @@ 3.0.434 1.2.1.5 2.0.3 - 1.7.27 + 1.7.28 7.15.1 3.3.3 2.0.593 diff --git a/aspnet-core/LINGYUN.MicroService.Startup.sln b/aspnet-core/LINGYUN.MicroService.Startup.sln index 52a3bb1e0..7d255ef92 100644 --- a/aspnet-core/LINGYUN.MicroService.Startup.sln +++ b/aspnet-core/LINGYUN.MicroService.Startup.sln @@ -33,6 +33,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "task-management", "task-man EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.TaskManagement.HttpApi.Host", "services\LY.MicroService.TaskManagement.HttpApi.Host\LY.MicroService.TaskManagement.HttpApi.Host.csproj", "{EDE83705-EFEA-46DC-A8EE-68A5D8159B84}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LY.MicroService.WorkflowManagement.HttpApi.Host", "services\LY.MicroService.WorkflowManagement.HttpApi.Host\LY.MicroService.WorkflowManagement.HttpApi.Host.csproj", "{48F376EC-B951-4123-AF33-54217AD00B96}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -67,6 +69,10 @@ Global {EDE83705-EFEA-46DC-A8EE-68A5D8159B84}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDE83705-EFEA-46DC-A8EE-68A5D8159B84}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDE83705-EFEA-46DC-A8EE-68A5D8159B84}.Release|Any CPU.Build.0 = Release|Any CPU + {48F376EC-B951-4123-AF33-54217AD00B96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {48F376EC-B951-4123-AF33-54217AD00B96}.Debug|Any CPU.Build.0 = Debug|Any CPU + {48F376EC-B951-4123-AF33-54217AD00B96}.Release|Any CPU.ActiveCfg = Release|Any CPU + {48F376EC-B951-4123-AF33-54217AD00B96}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -79,6 +85,7 @@ Global {0DBBB371-B1FC-421E-A4FB-900B016AFE6A} = {A3275CEC-C5CB-4F22-875A-8270B5F4D698} {03A07A13-D9F3-4E70-B4D2-57BA2CF1E8DB} = {099F0FD1-645D-4029-8149-46523AD34933} {EDE83705-EFEA-46DC-A8EE-68A5D8159B84} = {3F453010-BA07-471D-87E5-B12346ED81EF} + {48F376EC-B951-4123-AF33-54217AD00B96} = {E47CDAF7-1046-4886-A0CB-ADF9650F8318} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A3905D9F-6EF7-4BFD-80B3-E0DD6AA82228} diff --git a/aspnet-core/common.props b/aspnet-core/common.props index 0c5bb2b25..cf133343e 100644 --- a/aspnet-core/common.props +++ b/aspnet-core/common.props @@ -1,7 +1,7 @@ latest - 5.0.0 + 5.1.1 colin $(NoWarn);CS1591;CS0436 https://github.com/colinin/abp-vue-admin-element-typescript/ diff --git a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj index 232bf7fbb..01bcb617f 100644 --- a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj +++ b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj @@ -5,7 +5,7 @@ Exe net6.0 - 5.0.1 + 5.1.1 colin Use LINGYUN.MicroService.Templates command line true diff --git a/aspnet-core/modules/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/LINGYUN/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs b/aspnet-core/modules/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/LINGYUN/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs index b43e4c50b..17375b1a0 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/LINGYUN/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/LINGYUN/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs @@ -20,15 +20,15 @@ namespace LINGYUN.Abp.BackgroundWorkers.Hangfire ServiceProvider = serviceProvider; } - public void Add(IBackgroundWorker worker) + public Task AddAsync(IBackgroundWorker worker) { var timer = worker.GetType() .GetProperty("Timer", BindingFlags.NonPublic | BindingFlags.Instance)? .GetValue(worker); if (timer == null) - { - return; + { + return Task.CompletedTask; } var period = timer.GetType() @@ -38,7 +38,7 @@ namespace LINGYUN.Abp.BackgroundWorkers.Hangfire if (!period.HasValue) { - return; + return Task.CompletedTask; } var adapterType = typeof(HangfireBackgroundWorkerAdapter<>).MakeGenericType(worker.GetType()); @@ -47,7 +47,9 @@ namespace LINGYUN.Abp.BackgroundWorkers.Hangfire RecurringJob.AddOrUpdate( recurringJobId: worker.GetType().FullName, methodCall: () => workerAdapter.ExecuteAsync(), - cronExpression: CronGenerator.FormMilliseconds(period.Value)); + cronExpression: CronGenerator.FormMilliseconds(period.Value)); + + return Task.CompletedTask; } public Task StartAsync(CancellationToken cancellationToken = default) diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml index 5c139a103..d80ca3a8b 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml @@ -209,7 +209,7 @@ 取消令牌 - + constructor @@ -225,6 +225,7 @@ + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/CAPDistributedEventBus.cs b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/CAPDistributedEventBus.cs index c2af2ea61..3f4d8fa7e 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/CAPDistributedEventBus.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN/Abp/EventBus/CAP/CAPDistributedEventBus.cs @@ -76,6 +76,7 @@ namespace LINGYUN.Abp.EventBus.CAP /// /// /// + /// public CAPDistributedEventBus(IServiceScopeFactory serviceScopeFactory, IOptions distributedEventBusOptions, ICapPublisher capPublisher, @@ -87,14 +88,16 @@ namespace LINGYUN.Abp.EventBus.CAP IGuidGenerator guidGenerator, IClock clock, ICancellationTokenProvider cancellationTokenProvider, - ICustomDistributedEventSubscriber customDistributedEventSubscriber) + ICustomDistributedEventSubscriber customDistributedEventSubscriber, + IEventHandlerInvoker eventHandlerInvoker) : base( serviceScopeFactory, currentTenant, unitOfWorkManager, distributedEventBusOptions, guidGenerator, - clock) + clock, + eventHandlerInvoker) { CapPublisher = capPublisher; CurrentUser = currentUser; @@ -157,6 +160,7 @@ namespace LINGYUN.Abp.EventBus.CAP var eventName = EventNameAttribute.GetNameOrDefault(eventType); await PublishAsync(eventName, eventData); } + /// /// 获取事件处理器工厂列表 /// diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml index 5c139a103..d80ca3a8b 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.xml @@ -209,7 +209,7 @@ 取消令牌 - + constructor @@ -225,6 +225,7 @@ + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs index e5c92e07c..508cf8756 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationModule.cs @@ -5,11 +5,13 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; +using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.BackgroundJobs; using Volo.Abp.BackgroundWorkers; using Volo.Abp.Json; using Volo.Abp.Modularity; +using Volo.Abp.Threading; namespace LINGYUN.Abp.Notifications { @@ -28,14 +30,19 @@ namespace LINGYUN.Abp.Notifications AutoAddDefinitionProviders(context.Services); } - public override void OnPostApplicationInitialization(ApplicationInitializationContext context) + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + AsyncHelper.RunSync(() => OnApplicationInitializationAsync(context)); + } + + public override async Task OnApplicationInitializationAsync(ApplicationInitializationContext context) { var options = context.ServiceProvider.GetRequiredService>().Value; if (options.IsEnabled) { - context.ServiceProvider + await context.ServiceProvider .GetRequiredService() - .Add( + .AddAsync( context.ServiceProvider .GetRequiredService() ); diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Abstractions/LINGYUN/Abp/BackgroundTasks/JobEventData.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Abstractions/LINGYUN/Abp/BackgroundTasks/JobEventData.cs index fc1852921..a36fa6e46 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Abstractions/LINGYUN/Abp/BackgroundTasks/JobEventData.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Abstractions/LINGYUN/Abp/BackgroundTasks/JobEventData.cs @@ -19,7 +19,7 @@ public class JobEventData /// /// 任务标识 /// - public Guid Key { get; } + public string Key { get; } /// /// 任务状态 /// @@ -75,7 +75,7 @@ public class JobEventData /// public bool IsAbandoned { get; set; } public JobEventData( - Guid key, + string key, Type type, string group, string name, diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Abstractions/LINGYUN/Abp/BackgroundTasks/JobInfo.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Abstractions/LINGYUN/Abp/BackgroundTasks/JobInfo.cs index 0d1b58358..34639be5b 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Abstractions/LINGYUN/Abp/BackgroundTasks/JobInfo.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Abstractions/LINGYUN/Abp/BackgroundTasks/JobInfo.cs @@ -8,7 +8,7 @@ public class JobInfo /// /// 任务标识 /// - public Guid Id { get; set; } + public string Id { get; set; } /// /// 租户标识 /// diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs index 6ed7e81c8..2a6807c0d 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs @@ -49,45 +49,46 @@ public class QuartzJobListener : JobListenerSupport, ISingletonDependency public override async Task JobToBeExecuted(IJobExecutionContext context, CancellationToken cancellationToken = default) { - var jobId = context.GetString(nameof(JobInfo.Id)); - if (Guid.TryParse(jobId, out var jobUUId)) + try { - try + var jobId = context.GetString(nameof(JobInfo.Id)); + if (jobId.IsNullOrWhiteSpace()) { - var jobEventList = EventProvider.GetAll(); - if (!jobEventList.Any()) - { - return; - } - - using var scope = ServiceProvider.CreateScope(); - var jobEventData = new JobEventData( - jobUUId, - context.JobDetail.JobType, - context.JobDetail.Key.Group, - context.JobDetail.Key.Name) - { - Result = context.Result?.ToString() - }; - - var eventContext = new JobEventContext( - scope.ServiceProvider, - jobEventData); - - var index = 0; - var taskList = new Task[jobEventList.Count]; - foreach (var jobEvent in jobEventList) - { - taskList[index] = jobEvent.OnJobBeforeExecuted(eventContext); - index++; - } - - await Task.WhenAll(taskList); + return; } - catch (Exception ex) + var jobEventList = EventProvider.GetAll(); + if (!jobEventList.Any()) { - Logger.LogError($"The event before the task execution is abnormal:{ex}"); + return; } + + using var scope = ServiceProvider.CreateScope(); + var jobEventData = new JobEventData( + jobId, + context.JobDetail.JobType, + context.JobDetail.Key.Group, + context.JobDetail.Key.Name) + { + Result = context.Result?.ToString() + }; + + var eventContext = new JobEventContext( + scope.ServiceProvider, + jobEventData); + + var index = 0; + var taskList = new Task[jobEventList.Count]; + foreach (var jobEvent in jobEventList) + { + taskList[index] = jobEvent.OnJobBeforeExecuted(eventContext); + index++; + } + + await Task.WhenAll(taskList); + } + catch (Exception ex) + { + Logger.LogError($"The event before the task execution is abnormal:{ex}"); } } @@ -95,6 +96,12 @@ public class QuartzJobListener : JobListenerSupport, ISingletonDependency { try { + var jobId = context.GetString(nameof(JobInfo.Id)); + if (jobId.IsNullOrWhiteSpace()) + { + return; + } + var jobEventList = EventProvider.GetAll(); if (!jobEventList.Any()) { @@ -102,58 +109,54 @@ public class QuartzJobListener : JobListenerSupport, ISingletonDependency } using var scope = ServiceProvider.CreateScope(); - var jobId = context.GetString(nameof(JobInfo.Id)); - if (Guid.TryParse(jobId, out var jobUUId)) + var jobType = context.JobDetail.JobType; + if (jobType.IsGenericType) + { + jobType = jobType.GetGenericArguments()[0]; + } + + var jobEventData = new JobEventData( + jobId, + jobType, + context.JobDetail.Key.Group, + context.JobDetail.Key.Name, + jobException) + { + Status = JobStatus.Running + }; + + if (context.Trigger is ISimpleTrigger simpleTrigger) { - var jobType = context.JobDetail.JobType; - if (jobType.IsGenericType) - { - jobType = jobType.GetGenericArguments()[0]; - } - - var jobEventData = new JobEventData( - jobUUId, - jobType, - context.JobDetail.Key.Group, - context.JobDetail.Key.Name, - jobException) - { - Status = JobStatus.Running - }; - - if (context.Trigger is ISimpleTrigger simpleTrigger) - { - jobEventData.Triggered = simpleTrigger.TimesTriggered; - jobEventData.RepeatCount = simpleTrigger.RepeatCount; - } - jobEventData.Description = context.JobDetail.Description; - jobEventData.RunTime = Clock.Now; - jobEventData.LastRunTime = context.PreviousFireTimeUtc?.LocalDateTime; - jobEventData.NextRunTime = context.NextFireTimeUtc?.LocalDateTime; - if (context.Result != null) - { - jobEventData.Result = context.Result?.ToString(); - } - var tenantIdString = context.GetString(nameof(IMultiTenant.TenantId)); - if (Guid.TryParse(tenantIdString, out var tenantId)) - { - jobEventData.TenantId = tenantId; - } - - var eventContext = new JobEventContext( - scope.ServiceProvider, - jobEventData); - - var index = 0; - var taskList = new Task[jobEventList.Count]; - foreach (var jobEvent in jobEventList) - { - taskList[index] = jobEvent.OnJobAfterExecuted(eventContext); - index++; - } - - await Task.WhenAll(taskList); + jobEventData.Triggered = simpleTrigger.TimesTriggered; + jobEventData.RepeatCount = simpleTrigger.RepeatCount; } + jobEventData.Description = context.JobDetail.Description; + jobEventData.RunTime = Clock.Now; + jobEventData.LastRunTime = context.PreviousFireTimeUtc?.LocalDateTime; + jobEventData.NextRunTime = context.NextFireTimeUtc?.LocalDateTime; + if (context.Result != null) + { + jobEventData.Result = context.Result?.ToString(); + } + var tenantIdString = context.GetString(nameof(IMultiTenant.TenantId)); + if (Guid.TryParse(tenantIdString, out var tenantId)) + { + jobEventData.TenantId = tenantId; + } + + var eventContext = new JobEventContext( + scope.ServiceProvider, + jobEventData); + + var index = 0; + var taskList = new Task[jobEventList.Count]; + foreach (var jobEvent in jobEventList) + { + taskList[index] = jobEvent.OnJobAfterExecuted(eventContext); + index++; + } + + await Task.WhenAll(taskList); } catch (Exception ex) { diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzKeyBuilder.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzKeyBuilder.cs index 57d685f2e..4877b292f 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzKeyBuilder.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzKeyBuilder.cs @@ -15,7 +15,7 @@ public class QuartzKeyBuilder : IQuartzKeyBuilder, ISingletonDependency public JobKey CreateJobKey(JobInfo jobInfo) { - var name = jobInfo.Id.ToString(); + var name = jobInfo.Id; var group = CurrentTenant.IsAvailable ? $"{CurrentTenant.Id}:{jobInfo.Group}" : $"Default:{jobInfo.Group}"; @@ -25,7 +25,7 @@ public class QuartzKeyBuilder : IQuartzKeyBuilder, ISingletonDependency public TriggerKey CreateTriggerKey(JobInfo jobInfo) { - var name = jobInfo.Id.ToString(); + var name = jobInfo.Id; var group = CurrentTenant.IsAvailable ? $"{CurrentTenant.Id}:{jobInfo.Group}" : $"Default:{jobInfo.Group}"; diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN.Abp.BackgroundTasks.csproj b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN.Abp.BackgroundTasks.csproj index b49f1e324..8f121281f 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN.Abp.BackgroundTasks.csproj +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN.Abp.BackgroundTasks.csproj @@ -11,6 +11,7 @@ + diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/AbpBackgroundTasksModule.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/AbpBackgroundTasksModule.cs index 644cf3c30..b4c0718a6 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/AbpBackgroundTasksModule.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/AbpBackgroundTasksModule.cs @@ -3,6 +3,7 @@ using LINGYUN.Abp.BackgroundTasks.Localization; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Auditing; using Volo.Abp.BackgroundJobs; +using Volo.Abp.BackgroundWorkers; using Volo.Abp.DistributedLocking; using Volo.Abp.Guids; using Volo.Abp.Localization; @@ -15,6 +16,7 @@ namespace LINGYUN.Abp.BackgroundTasks; [DependsOn(typeof(AbpLocalizationModule))] [DependsOn(typeof(AbpBackgroundTasksAbstractionsModule))] [DependsOn(typeof(AbpBackgroundJobsAbstractionsModule))] +[DependsOn(typeof(AbpBackgroundWorkersModule))] [DependsOn(typeof(AbpDistributedLockingAbstractionsModule))] [DependsOn(typeof(AbpGuidsModule))] public class AbpBackgroundTasksModule : AbpModule @@ -22,6 +24,8 @@ public class AbpBackgroundTasksModule : AbpModule public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddTransient(typeof(BackgroundJobAdapter<>)); + context.Services.AddSingleton(typeof(BackgroundWorkerAdapter<>)); + context.Services.AddHostedService(); Configure(options => diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobManager.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobManager.cs index 6b205e86d..e36d1576d 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobManager.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundJobManager.cs @@ -60,7 +60,7 @@ public class BackgroundJobManager : IBackgroundJobManager, ITransientDependency }; var jobInfo = new JobInfo { - Id = jobId, + Id = jobId.ToString(), TenantId = CurrentTenant.Id, Name = jobId.ToString(), Group = "BackgroundJobs", @@ -82,7 +82,7 @@ public class BackgroundJobManager : IBackgroundJobManager, ITransientDependency // 手动入队 await JobScheduler.QueueAsync(jobInfo); - return jobId.ToString(); + return jobInfo.Id; } private JobPriority ConverForm(BackgroundJobPriority priority) diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundWorkerAdapter.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundWorkerAdapter.cs new file mode 100644 index 000000000..ab41106bb --- /dev/null +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundWorkerAdapter.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Threading.Tasks; +using Volo.Abp.BackgroundWorkers; +using Volo.Abp.DynamicProxy; +using Volo.Abp.MultiTenancy; +using Volo.Abp.Threading; +using Volo.Abp.Timing; + +namespace LINGYUN.Abp.BackgroundTasks; + +public class BackgroundWorkerAdapter : BackgroundWorkerBase, IBackgroundWorkerRunnable + where TWorker : IBackgroundWorker +{ + protected IClock Clock => LazyServiceProvider.LazyGetRequiredService(); + protected IJobStore JobStore => LazyServiceProvider.LazyGetRequiredService(); + protected IJobScheduler JobScheduler => LazyServiceProvider.LazyGetRequiredService(); + protected ICurrentTenant CurrentTenant => LazyServiceProvider.LazyGetRequiredService(); + + private readonly MethodInfo _doWorkAsyncMethod; + private readonly MethodInfo _doWorkMethod; + + public BackgroundWorkerAdapter() + { + _doWorkAsyncMethod = typeof(TWorker).GetMethod("DoWorkAsync", BindingFlags.Instance | BindingFlags.NonPublic); + _doWorkMethod = typeof(TWorker).GetMethod("DoWork", BindingFlags.Instance | BindingFlags.NonPublic); + } + +#nullable enable + public JobInfo? BuildWorker(IBackgroundWorker worker) + { + int? period; + var workerType = ProxyHelper.GetUnProxiedType(worker); + + if (worker is AsyncPeriodicBackgroundWorkerBase or PeriodicBackgroundWorkerBase) + { + if (typeof(TWorker) != workerType) + { + throw new ArgumentException($"{nameof(worker)} type is different from the generic type"); + } + + var timer = workerType.GetProperty("Timer", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(worker); + if (timer == null) + { + return null; + } + + if (worker is AsyncPeriodicBackgroundWorkerBase) + { + period = ((AbpAsyncTimer)timer)?.Period; + } + else + { + period = ((AbpTimer)timer)?.Period; + } + } + else + { + return null; + } + + if (period == null) + { + return null; + } + + var jobArgs = new Dictionary + { + { "JobType", workerType.AssemblyQualifiedName }, + }; + return new JobInfo + { + Id = workerType.FullName, + TenantId = CurrentTenant.Id, + Name = workerType.FullName, + Group = "BackgroundWorkers", + Priority = JobPriority.Normal, + BeginTime = Clock.Now, + Args = jobArgs, + Description = "From the framework background workers", + JobType = JobType.Persistent, + Interval = period.Value / 1000, + MaxCount = 0, + // TODO: 可配置 + MaxTryCount = 10, + CreationTime = Clock.Now, + // 确保不会被轮询入队 + Status = JobStatus.None, + Type = typeof(BackgroundWorkerAdapter).AssemblyQualifiedName, + }; + } +#nullable disable + + public async Task ExecuteAsync(JobRunnableContext context) + { + var worker = (IBackgroundWorker)ServiceProvider.GetService(typeof(TWorker)); + var workerContext = new PeriodicBackgroundWorkerContext(ServiceProvider); + + switch (worker) + { + case AsyncPeriodicBackgroundWorkerBase asyncWorker: + { + if (_doWorkAsyncMethod != null) + { + await(Task) _doWorkAsyncMethod.Invoke(asyncWorker, new object[] { workerContext }); + } + + break; + } + case PeriodicBackgroundWorkerBase syncWorker: + { + _doWorkMethod?.Invoke(syncWorker, new object[] { workerContext }); + + break; + } + } + } +} diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundWorkerManager.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundWorkerManager.cs new file mode 100644 index 000000000..9ad7bf37a --- /dev/null +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/BackgroundWorkerManager.cs @@ -0,0 +1,55 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.BackgroundWorkers; +using Volo.Abp.DependencyInjection; +using Volo.Abp.DynamicProxy; + +namespace LINGYUN.Abp.BackgroundTasks; + +[Dependency(ReplaceServices = true)] +public class BackgroundWorkerManager : IBackgroundWorkerManager, ISingletonDependency +{ + protected IJobStore JobStore { get; } + protected IJobScheduler JobScheduler { get; } + protected IServiceProvider ServiceProvider { get; } + + public BackgroundWorkerManager( + IJobStore jobStore, + IJobScheduler jobScheduler, + IServiceProvider serviceProvider) + { + JobStore = jobStore; + JobScheduler = jobScheduler; + ServiceProvider = serviceProvider; + } + + public async Task AddAsync(IBackgroundWorker worker) + { + var adapterType = typeof(BackgroundWorkerAdapter<>).MakeGenericType(ProxyHelper.GetUnProxiedType(worker)); + + var workerAdapter = ServiceProvider.GetService(adapterType) as IBackgroundWorkerRunnable; + + var jobInfo = workerAdapter?.BuildWorker(worker); + if (jobInfo == null) + { + return; + } + + // 存储状态 + await JobStore.StoreAsync(jobInfo); + + // 手动入队 + await JobScheduler.QueueAsync(jobInfo); + } + + public Task StartAsync(CancellationToken cancellationToken = default) + { + return Task.CompletedTask; + } + + public Task StopAsync(CancellationToken cancellationToken = default) + { + return Task.CompletedTask; + } +} diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/IBackgroundWorkerRunnable.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/IBackgroundWorkerRunnable.cs new file mode 100644 index 000000000..69cc69cf4 --- /dev/null +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/IBackgroundWorkerRunnable.cs @@ -0,0 +1,10 @@ +using Volo.Abp.BackgroundWorkers; + +namespace LINGYUN.Abp.BackgroundTasks; + +public interface IBackgroundWorkerRunnable : IJobRunnable +{ +#nullable enable + JobInfo? BuildWorker(IBackgroundWorker worker); +#nullable disable +} diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/IJobStore.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/IJobStore.cs index 9dd69ca0c..880fd52bf 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/IJobStore.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/IJobStore.cs @@ -14,7 +14,7 @@ public interface IJobStore Task> GetAllPeriodTasksAsync( CancellationToken cancellationToken = default); - Task FindAsync(Guid jobId); + Task FindAsync(string jobId); Task StoreAsync(JobInfo jobInfo); diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/DefaultBackgroundWorker.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/DefaultBackgroundWorker.cs index 51b74a9e7..7317666c1 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/DefaultBackgroundWorker.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/DefaultBackgroundWorker.cs @@ -55,7 +55,7 @@ internal class DefaultBackgroundWorker : BackgroundService { return new JobInfo { - Id = Guid.Parse("8F50C5D9-5691-4B99-A52B-CABD91D93C89"), + Id = "KeepAlive", Name = nameof(BackgroundKeepAliveJob), Group = "KeepAlive", Description = "Add periodic tasks", @@ -75,7 +75,7 @@ internal class DefaultBackgroundWorker : BackgroundService { return new JobInfo { - Id = Guid.Parse("C51152E9-F0B8-4252-8352-283BE46083CC"), + Id = "Polling", Name = nameof(BackgroundPollingJob), Group = "Polling", Description = "Polling tasks to be executed", @@ -95,7 +95,7 @@ internal class DefaultBackgroundWorker : BackgroundService { return new JobInfo { - Id = Guid.Parse("AAAF8783-FA06-4CF9-BDCA-11140FB2478F"), + Id = "Cleaning", Name = nameof(BackgroundCleaningJob), Group = "Cleaning", Description = "Cleaning tasks to be executed", diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/InMemoryJobStore.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/InMemoryJobStore.cs index b6c654ebc..5d42369e8 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/InMemoryJobStore.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/LINGYUN/Abp/BackgroundTasks/Internal/InMemoryJobStore.cs @@ -41,7 +41,7 @@ internal class InMemoryJobStore : IJobStore, ISingletonDependency return Task.FromResult(jobs); } - public Task FindAsync(Guid jobId) + public Task FindAsync(string jobId) { var job = _memoryJobStore.FirstOrDefault(x => x.Id.Equals(jobId)); return Task.FromResult(job); diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/README.md b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/README.md index b3a9bee08..498f3cf75 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/README.md +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks/README.md @@ -97,6 +97,11 @@ public class DemoClass }, BackgroundJobPriority.High, TimeSpan.FromSeconds(10)); + + // 同样可以把框架后台工作者添加到作业调度器中, 不需要更改使用习惯 + var backgroundWorkManager = ServiceProvider.GetRequiredService(); + // 每20秒控制台输出 + await backgroundWorkManager.AddAsync(ServiceProvider.GetRequiredService()); } } @@ -115,4 +120,19 @@ public class SmsJob : AsyncBackgroundJob, ITransientDependency return Task.CompletedTask; } } + +public class ConsoleWorker : AsyncPeriodicBackgroundWorkerBase, ISingletonDependency +{ + public ConsoleWorker(AbpAsyncTimer timer, IServiceScopeFactory serviceScopeFactory) + : base(timer, serviceScopeFactory) + { + timer.Period = 20000; + } + + protected override Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) + { + Console.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] - ConsoleWorker Do Wrok."); + return Task.CompletedTask; + } +} ``` diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobInfoBatchInput.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobInfoBatchInput.cs index 91d0ee5ce..657b44794 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobInfoBatchInput.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobInfoBatchInput.cs @@ -5,5 +5,5 @@ namespace LINGYUN.Abp.TaskManagement; public class BackgroundJobInfoBatchInput { - public List JobIds { get; set; } = new List(); + public List JobIds { get; set; } = new List(); } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobInfoDto.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobInfoDto.cs index 8958aaa09..b9317e687 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobInfoDto.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobInfoDto.cs @@ -6,7 +6,7 @@ using Volo.Abp.Domain.Entities; namespace LINGYUN.Abp.TaskManagement; -public class BackgroundJobInfoDto : ExtensibleAuditedEntityDto, IHasConcurrencyStamp +public class BackgroundJobInfoDto : ExtensibleAuditedEntityDto, IHasConcurrencyStamp { public string ConcurrencyStamp { get; set; } /// diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobLogGetListInput.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobLogGetListInput.cs index 2c8ee69c9..aef36dcf7 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobLogGetListInput.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/BackgroundJobLogGetListInput.cs @@ -5,7 +5,7 @@ namespace LINGYUN.Abp.TaskManagement; public class BackgroundJobLogGetListInput : PagedAndSortedResultRequestDto { - public Guid? JobId { get; set; } + public string JobId { get; set; } /// /// 其他过滤条件 /// diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoAppService.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoAppService.cs index e318d2962..2ec0a4f22 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoAppService.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoAppService.cs @@ -7,20 +7,20 @@ namespace LINGYUN.Abp.TaskManagement; public interface IBackgroundJobInfoAppService : ICrudAppService< BackgroundJobInfoDto, - Guid, + string, BackgroundJobInfoGetListInput, BackgroundJobInfoCreateDto, BackgroundJobInfoUpdateDto> { - Task TriggerAsync(Guid id); + Task TriggerAsync(string id); - Task PauseAsync(Guid id); + Task PauseAsync(string id); - Task ResumeAsync(Guid id); + Task ResumeAsync(string id); - Task StopAsync(Guid id); + Task StopAsync(string id); - Task StartAsync(Guid id); + Task StartAsync(string id); Task BulkDeleteAsync(BackgroundJobInfoBatchInput input); diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobInfoAppService.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobInfoAppService.cs index e1e8249c9..735b6dd22 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobInfoAppService.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobInfoAppService.cs @@ -35,8 +35,9 @@ public class BackgroundJobInfoAppService : TaskManagementApplicationService, IBa .WithData("Name", input.Name); } + var jobId = GuidGenerator.Create(); var backgroundJobInfo = new BackgroundJobInfo( - GuidGenerator.Create(), + jobId.ToString(), input.Name, input.Group, input.Type, @@ -61,14 +62,14 @@ public class BackgroundJobInfoAppService : TaskManagementApplicationService, IBa } [Authorize(TaskManagementPermissions.BackgroundJobs.Delete)] - public virtual async Task DeleteAsync(Guid id) + public virtual async Task DeleteAsync(string id) { var backgroundJobInfo = await BackgroundJobInfoRepository.GetAsync(id); await BackgroundJobManager.DeleteAsync(backgroundJobInfo); } - public virtual async Task GetAsync(Guid id) + public virtual async Task GetAsync(string id) { var backgroundJobInfo = await BackgroundJobInfoRepository.GetAsync(id); @@ -103,7 +104,7 @@ public class BackgroundJobInfoAppService : TaskManagementApplicationService, IBa } [Authorize(TaskManagementPermissions.BackgroundJobs.Pause)] - public virtual async Task PauseAsync(Guid id) + public virtual async Task PauseAsync(string id) { var backgroundJobInfo = await BackgroundJobInfoRepository.GetAsync(id); @@ -111,7 +112,7 @@ public class BackgroundJobInfoAppService : TaskManagementApplicationService, IBa } [Authorize(TaskManagementPermissions.BackgroundJobs.Resume)] - public virtual async Task ResumeAsync(Guid id) + public virtual async Task ResumeAsync(string id) { var backgroundJobInfo = await BackgroundJobInfoRepository.GetAsync(id); @@ -119,7 +120,7 @@ public class BackgroundJobInfoAppService : TaskManagementApplicationService, IBa } [Authorize(TaskManagementPermissions.BackgroundJobs.Trigger)] - public virtual async Task TriggerAsync(Guid id) + public virtual async Task TriggerAsync(string id) { var backgroundJobInfo = await BackgroundJobInfoRepository.GetAsync(id); @@ -127,7 +128,7 @@ public class BackgroundJobInfoAppService : TaskManagementApplicationService, IBa } [Authorize(TaskManagementPermissions.BackgroundJobs.Stop)] - public virtual async Task StopAsync(Guid id) + public virtual async Task StopAsync(string id) { var backgroundJobInfo = await BackgroundJobInfoRepository.GetAsync(id); @@ -135,7 +136,7 @@ public class BackgroundJobInfoAppService : TaskManagementApplicationService, IBa } [Authorize(TaskManagementPermissions.BackgroundJobs.Start)] - public virtual async Task StartAsync(Guid id) + public virtual async Task StartAsync(string id) { var backgroundJobInfo = await BackgroundJobInfoRepository.GetAsync(id); @@ -143,7 +144,7 @@ public class BackgroundJobInfoAppService : TaskManagementApplicationService, IBa } [Authorize(TaskManagementPermissions.BackgroundJobs.Update)] - public virtual async Task UpdateAsync(Guid id, BackgroundJobInfoUpdateDto input) + public virtual async Task UpdateAsync(string id, BackgroundJobInfoUpdateDto input) { var backgroundJobInfo = await BackgroundJobInfoRepository.GetAsync(id); diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain.Shared/LINGYUN/Abp/TaskManagement/BackgroundJobLogConsts.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain.Shared/LINGYUN/Abp/TaskManagement/BackgroundJobLogConsts.cs index 618438e20..78217d4b1 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain.Shared/LINGYUN/Abp/TaskManagement/BackgroundJobLogConsts.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain.Shared/LINGYUN/Abp/TaskManagement/BackgroundJobLogConsts.cs @@ -2,6 +2,7 @@ public static class BackgroundJobLogConsts { + public static int MaxJobIdLength { get; set; } = 255; public static int MaxMessageLength { get; set; } = 1000; public static int MaxExceptionLength { get; set; } = 2000; } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobInfo.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobInfo.cs index 64d7dd693..dd0dc07c5 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobInfo.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobInfo.cs @@ -8,7 +8,7 @@ using Volo.Abp.MultiTenancy; namespace LINGYUN.Abp.TaskManagement; -public class BackgroundJobInfo : AuditedAggregateRoot, IMultiTenant +public class BackgroundJobInfo : AuditedAggregateRoot, IMultiTenant { public virtual Guid? TenantId { get; protected set; } /// @@ -107,7 +107,7 @@ public class BackgroundJobInfo : AuditedAggregateRoot, IMultiTenant protected BackgroundJobInfo() { } public BackgroundJobInfo( - Guid id, + string id, string name, string group, string type, diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobLog.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobLog.cs index 58d0de49f..7f0dcca03 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobLog.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobLog.cs @@ -8,7 +8,7 @@ namespace LINGYUN.Abp.TaskManagement; public class BackgroundJobLog : Entity, IMultiTenant { public virtual Guid? TenantId { get; protected set; } - public virtual Guid? JobId { get; set; } + public virtual string JobId { get; set; } public virtual string JobName { get; protected set; } public virtual string JobGroup { get; protected set; } public virtual string JobType { get; protected set; } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobStore.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobStore.cs index 280dc48d7..7dda6ada1 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobStore.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/BackgroundJobStore.cs @@ -44,7 +44,7 @@ public class BackgroundJobStore : IJobStore, ITransientDependency return ObjectMapper.Map, List>(jobInfos); } - public async virtual Task FindAsync(Guid jobId) + public async virtual Task FindAsync(string jobId) { var jobInfo = await JobInfoRepository.FindAsync(jobId); diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoRepository.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoRepository.cs index bffca21b9..767115c45 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoRepository.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoRepository.cs @@ -6,7 +6,7 @@ using Volo.Abp.Domain.Repositories; namespace LINGYUN.Abp.TaskManagement; -public interface IBackgroundJobInfoRepository : IRepository +public interface IBackgroundJobInfoRepository : IRepository { Task CheckNameAsync( string group, diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobLogRepository.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobLogRepository.cs index e9036a51a..bc11de3cf 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobLogRepository.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Domain/LINGYUN/Abp/TaskManagement/IBackgroundJobLogRepository.cs @@ -17,7 +17,7 @@ public interface IBackgroundJobLogRepository : IRepository Task GetCountAsync( BackgroundJobLogFilter filter, - Guid? jobId = null, + string jobId = null, CancellationToken cancellationToken = default); /// /// 获取过滤后的任务日志列表 @@ -31,7 +31,7 @@ public interface IBackgroundJobLogRepository : IRepository Task> GetListAsync( BackgroundJobLogFilter filter, - Guid? jobId = null, + string jobId = null, string sorting = nameof(BackgroundJobLog.RunTime), int maxResultCount = 10, int skipCount = 0, diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobInfoRepository.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobInfoRepository.cs index b7ac636f3..f7efe16ab 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobInfoRepository.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobInfoRepository.cs @@ -13,7 +13,7 @@ using Volo.Abp.Timing; namespace LINGYUN.Abp.TaskManagement.EntityFrameworkCore; public class EfCoreBackgroundJobInfoRepository : - EfCoreRepository, + EfCoreRepository, IBackgroundJobInfoRepository { protected IClock Clock { get; } @@ -60,6 +60,7 @@ public class EfCoreBackgroundJobInfoRepository : .Where(x => x.JobType == JobType.Period && status.Contains(x.Status)) .Where(x => (x.MaxCount == 0 || x.TriggerCount < x.MaxCount) || (x.MaxTryCount == 0 || x.TryCount < x.MaxTryCount)) .OrderByDescending(x => x.Priority) + .AsNoTracking() .ToListAsync(GetCancellationToken(cancellationToken)); } @@ -120,6 +121,7 @@ public class EfCoreBackgroundJobInfoRepository : .ThenBy(x => x.TryCount) .ThenBy(x => x.NextRunTime) .Take(maxResultCount) + .AsNoTracking() .ToListAsync(GetCancellationToken(cancellationToken)); } } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobLogRepository.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobLogRepository.cs index 4508de1a0..63339b51e 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobLogRepository.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/EfCoreBackgroundJobLogRepository.cs @@ -22,11 +22,11 @@ public class EfCoreBackgroundJobLogRepository : public virtual async Task GetCountAsync( BackgroundJobLogFilter filter, - Guid? jobId = null, + string jobId = null, CancellationToken cancellationToken = default) { return await (await GetDbSetAsync()) - .WhereIf(jobId.HasValue, x => x.JobId.Equals(jobId)) + .WhereIf(!jobId.IsNullOrWhiteSpace(), x => x.JobId.Equals(jobId)) .WhereIf(!filter.Type.IsNullOrWhiteSpace(), x => x.JobType.Contains(filter.Type)) .WhereIf(!filter.Group.IsNullOrWhiteSpace(), x => x.JobGroup.Equals(filter.Group)) .WhereIf(!filter.Name.IsNullOrWhiteSpace(), x => x.JobName.Equals(filter.Name)) @@ -40,14 +40,14 @@ public class EfCoreBackgroundJobLogRepository : public virtual async Task> GetListAsync( BackgroundJobLogFilter filter, - Guid? jobId = null, + string jobId = null, string sorting = nameof(BackgroundJobLog.RunTime), int maxResultCount = 10, int skipCount = 0, CancellationToken cancellationToken = default) { return await (await GetDbSetAsync()) - .WhereIf(jobId.HasValue, x => x.JobId.Equals(jobId)) + .WhereIf(!jobId.IsNullOrWhiteSpace(), x => x.JobId.Equals(jobId)) .WhereIf(!filter.Type.IsNullOrWhiteSpace(), x => x.JobType.Contains(filter.Type)) .WhereIf(!filter.Group.IsNullOrWhiteSpace(), x => x.JobGroup.Equals(filter.Group)) .WhereIf(!filter.Name.IsNullOrWhiteSpace(), x => x.JobName.Equals(filter.Name)) diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/TaskManagementDbContextModelCreatingExtensions.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/TaskManagementDbContextModelCreatingExtensions.cs index e85773fb2..21e455585 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/TaskManagementDbContextModelCreatingExtensions.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/TaskManagementDbContextModelCreatingExtensions.cs @@ -60,6 +60,9 @@ public static class TaskManagementDbContextModelCreatingExtensions { b.ToTable(options.TablePrefix + "BackgroundJobLogs", options.Schema); + b.Property(p => p.JobId) + .HasColumnName(nameof(BackgroundJobLog.JobId)) + .HasMaxLength(BackgroundJobLogConsts.MaxJobIdLength); b.Property(p => p.JobName) .HasColumnName(nameof(BackgroundJobLog.JobName)) .HasMaxLength(BackgroundJobInfoConsts.MaxNameLength); diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/BackgroundJobInfoController.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/BackgroundJobInfoController.cs index bfce5a205..f8b8a9605 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/BackgroundJobInfoController.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/BackgroundJobInfoController.cs @@ -32,14 +32,14 @@ public class BackgroundJobInfoController : TaskManagementController, IBackground [HttpDelete] [Route("{id}")] [Authorize(TaskManagementPermissions.BackgroundJobs.Delete)] - public Task DeleteAsync(Guid id) + public Task DeleteAsync(string id) { return BackgroundJobInfoAppService.DeleteAsync(id); } [HttpGet] [Route("{id}")] - public Task GetAsync(Guid id) + public Task GetAsync(string id) { return BackgroundJobInfoAppService.GetAsync(id); } @@ -53,7 +53,7 @@ public class BackgroundJobInfoController : TaskManagementController, IBackground [HttpPut] [Route("{id}/pause")] [Authorize(TaskManagementPermissions.BackgroundJobs.Pause)] - public Task PauseAsync(Guid id) + public Task PauseAsync(string id) { return BackgroundJobInfoAppService.PauseAsync(id); } @@ -61,7 +61,7 @@ public class BackgroundJobInfoController : TaskManagementController, IBackground [HttpPut] [Route("{id}/resume")] [Authorize(TaskManagementPermissions.BackgroundJobs.Resume)] - public Task ResumeAsync(Guid id) + public Task ResumeAsync(string id) { return BackgroundJobInfoAppService.ResumeAsync(id); } @@ -69,7 +69,7 @@ public class BackgroundJobInfoController : TaskManagementController, IBackground [HttpPut] [Route("{id}/trigger")] [Authorize(TaskManagementPermissions.BackgroundJobs.Trigger)] - public Task TriggerAsync(Guid id) + public Task TriggerAsync(string id) { return BackgroundJobInfoAppService.TriggerAsync(id); } @@ -77,7 +77,7 @@ public class BackgroundJobInfoController : TaskManagementController, IBackground [HttpPut] [Route("{id}/stop")] [Authorize(TaskManagementPermissions.BackgroundJobs.Stop)] - public Task StopAsync(Guid id) + public Task StopAsync(string id) { return BackgroundJobInfoAppService.StopAsync(id); } @@ -85,7 +85,7 @@ public class BackgroundJobInfoController : TaskManagementController, IBackground [HttpPut] [Route("{id}")] [Authorize(TaskManagementPermissions.BackgroundJobs.Update)] - public Task UpdateAsync(Guid id, BackgroundJobInfoUpdateDto input) + public Task UpdateAsync(string id, BackgroundJobInfoUpdateDto input) { return BackgroundJobInfoAppService.UpdateAsync(id, input); } @@ -93,7 +93,7 @@ public class BackgroundJobInfoController : TaskManagementController, IBackground [HttpPut] [Route("{id}/start")] [Authorize(TaskManagementPermissions.BackgroundJobs.Start)] - public Task StartAsync(Guid id) + public Task StartAsync(string id) { return BackgroundJobInfoAppService.StartAsync(id); } diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs index 5bfbc2cc7..7701e7c19 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Program.cs @@ -1,19 +1,54 @@ -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; using System; +using System.IO; +using System.Threading.Tasks; +using Volo.Abp.IO; +using Volo.Abp.Modularity.PlugIns; namespace LY.MicroService.BackendAdmin; public class Program { - public static int Main(string[] args) + public async static Task Main(string[] args) { try { Log.Information("Starting BackendAdmin.Host."); - CreateHostBuilder(args).Build().Run(); + + var builder = WebApplication.CreateBuilder(args); + builder.Host.AddAppSettingsSecretsJson() + .UseAutofac() + .ConfigureAppConfiguration((context, config) => + { + var configuration = config.Build(); + if (configuration.GetSection("AgileConfig").Exists()) + { + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + } + }) + .UseSerilog((context, provider, config) => + { + config.ReadFrom.Configuration(context.Configuration); + }); + await builder.AddApplicationAsync(options => + { + // 搜索 Modules 目录下所有文件作为插件 + // 取消显示引用所有其他项目的模块,改为通过插件的形式引用 + var pluginFolder = Path.Combine( + Directory.GetCurrentDirectory(), "Modules"); + DirectoryHelper.CreateIfNotExists(pluginFolder); + options.PlugInSources.AddFolder( + pluginFolder, + SearchOption.AllDirectories); + }); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); return 0; } catch (Exception ex) @@ -26,24 +61,4 @@ public class Program Log.CloseAndFlush(); } } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .ConfigureAppConfiguration((context, config) => - { - var configuration = config.Build(); - if (configuration.GetSection("AgileConfig").Exists()) - { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); - } - }) - .UseSerilog((context, provider, config) => - { - config.ReadFrom.Configuration(context.Configuration); - }) - .UseAutofac(); } diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Startup.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Startup.cs deleted file mode 100644 index f77d4c6f7..000000000 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Startup.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using System.IO; -using Volo.Abp.IO; -using Volo.Abp.Modularity.PlugIns; - -namespace LY.MicroService.BackendAdmin; - -public class Startup -{ - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(options => - { - // 搜索 Modules 目录下所有文件作为插件 - // 取消显示引用所有其他项目的模块,改为通过插件的形式引用 - var pluginFolder = Path.Combine( - Directory.GetCurrentDirectory(), "Modules"); - DirectoryHelper.CreateIfNotExists(pluginFolder); - options.PlugInSources.AddFolder( - pluginFolder, - SearchOption.AllDirectories); - }); - } - - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } -} diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs index 94b7b2ed1..f95eed159 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Program.cs @@ -1,21 +1,54 @@ +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; using System; +using System.IO; +using System.Threading.Tasks; +using Volo.Abp.IO; +using Volo.Abp.Modularity.PlugIns; namespace LY.MicroService.LocalizationManagement; public class Program { - public static int Main(string[] args) + public async static Task Main(string[] args) { try { - var hostBuilder = CreateHostBuilder(args).Build(); - Log.Information("Starting LocalizationManagement.Host."); - hostBuilder.Run(); + Log.Information("Starting LocalizationManagement.HttpApi.Host."); + var builder = WebApplication.CreateBuilder(args); + builder.Host.AddAppSettingsSecretsJson() + .UseAutofac() + .ConfigureAppConfiguration((context, config) => + { + var configuration = config.Build(); + if (configuration.GetSection("AgileConfig").Exists()) + { + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + } + }) + .UseSerilog((context, provider, config) => + { + config.ReadFrom.Configuration(context.Configuration); + }); + await builder.AddApplicationAsync(options => + { + // Modules Ŀ¼ļΪ + // ȡʾĿģ飬Ϊͨʽ + var pluginFolder = Path.Combine( + Directory.GetCurrentDirectory(), "Modules"); + DirectoryHelper.CreateIfNotExists(pluginFolder); + options.PlugInSources.AddFolder( + pluginFolder, + SearchOption.AllDirectories); + }); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); return 0; } catch (Exception ex) @@ -28,24 +61,4 @@ public class Program Log.CloseAndFlush(); } } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .ConfigureAppConfiguration((context, config) => - { - var configuration = config.Build(); - if (configuration.GetSection("AgileConfig").Exists()) - { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); - } - }) - .UseSerilog((context, provider, config) => - { - config.ReadFrom.Configuration(context.Configuration); - }) - .UseAutofac(); } diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Startup.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Startup.cs deleted file mode 100644 index 846c96880..000000000 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/Startup.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using System.IO; -using Volo.Abp.IO; -using Volo.Abp.Modularity.PlugIns; - -namespace LY.MicroService.LocalizationManagement; - -public class Startup -{ - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(options => - { - // Modules Ŀ¼ļΪ - // ȡʾĿģ飬Ϊͨʽ - var pluginFolder = Path.Combine( - Directory.GetCurrentDirectory(), "Modules"); - DirectoryHelper.CreateIfNotExists(pluginFolder); - options.PlugInSources.AddFolder( - pluginFolder, - SearchOption.AllDirectories); - }); - } - - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } -} diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs index 5bf4cde1f..a4f3d9e66 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Program.cs @@ -1,22 +1,54 @@ +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; using System; using System.IO; +using System.Threading.Tasks; +using Volo.Abp.IO; +using Volo.Abp.Modularity.PlugIns; namespace LY.MicroService.PlatformManagement; public class Program { - public static int Main(string[] args) + public async static Task Main(string[] args) { try { - var hostBuilder = CreateHostBuilder(args).Build(); - Log.Information("Starting Platform.Host."); - hostBuilder.Run(); + Log.Information("Starting PlatformManagement.HttpApi.Host."); + var builder = WebApplication.CreateBuilder(args); + builder.Host.AddAppSettingsSecretsJson() + .UseAutofac() + .ConfigureAppConfiguration((context, config) => + { + var configuration = config.Build(); + if (configuration.GetSection("AgileConfig").Exists()) + { + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + } + }) + .UseSerilog((context, provider, config) => + { + config.ReadFrom.Configuration(context.Configuration); + }); + await builder.AddApplicationAsync(options => + { + // Modules Ŀ¼ļΪ + // ȡʾĿģ飬Ϊͨʽ + var pluginFolder = Path.Combine( + Directory.GetCurrentDirectory(), "Modules"); + DirectoryHelper.CreateIfNotExists(pluginFolder); + options.PlugInSources.AddFolder( + pluginFolder, + SearchOption.AllDirectories); + }); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); return 0; } catch (Exception ex) @@ -29,24 +61,4 @@ public class Program Log.CloseAndFlush(); } } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .ConfigureAppConfiguration((context, config) => - { - var configuration = config.Build(); - if (configuration.GetSection("AgileConfig").Exists()) - { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); - } - }) - .UseSerilog((context, provider, config) => - { - config.ReadFrom.Configuration(context.Configuration); - }) - .UseAutofac(); } diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Startup.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Startup.cs deleted file mode 100644 index 90413aff0..000000000 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/Startup.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using System.IO; -using Volo.Abp.IO; -using Volo.Abp.Modularity.PlugIns; - -namespace LY.MicroService.PlatformManagement; - -public class Startup -{ - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(options => - { - // Modules Ŀ¼ļΪ - // ȡʾĿģ飬Ϊͨʽ - var pluginFolder = Path.Combine( - Directory.GetCurrentDirectory(), "Modules"); - DirectoryHelper.CreateIfNotExists(pluginFolder); - options.PlugInSources.AddFolder( - pluginFolder, - SearchOption.AllDirectories); - }); - } - - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } -} diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs index 6e0a837d5..e86bcff5b 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Program.cs @@ -1,22 +1,54 @@ +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; using System; using System.IO; +using System.Threading.Tasks; +using Volo.Abp.IO; +using Volo.Abp.Modularity.PlugIns; namespace LY.MicroService.RealtimeMessage; public class Program { - public static int Main(string[] args) + public async static Task Main(string[] args) { try { - var hostBuilder = CreateHostBuilder(args).Build(); - Log.Information("Starting MessageService.Host."); - hostBuilder.Run(); + Log.Information("Starting RealtimeMessage.HttpApi.Host."); + var builder = WebApplication.CreateBuilder(args); + builder.Host.AddAppSettingsSecretsJson() + .UseAutofac() + .ConfigureAppConfiguration((context, config) => + { + var configuration = config.Build(); + if (configuration.GetSection("AgileConfig").Exists()) + { + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + } + }) + .UseSerilog((context, provider, config) => + { + config.ReadFrom.Configuration(context.Configuration); + }); + await builder.AddApplicationAsync(options => + { + // Modules Ŀ¼ļΪ + // ȡʾĿģ飬Ϊͨʽ + var pluginFolder = Path.Combine( + Directory.GetCurrentDirectory(), "Modules"); + DirectoryHelper.CreateIfNotExists(pluginFolder); + options.PlugInSources.AddFolder( + pluginFolder, + SearchOption.AllDirectories); + }); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); return 0; } catch (Exception ex) @@ -29,24 +61,4 @@ public class Program Log.CloseAndFlush(); } } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .ConfigureAppConfiguration((context, config) => - { - var configuration = config.Build(); - if (configuration.GetSection("AgileConfig").Exists()) - { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); - } - }) - .UseSerilog((context, provider, config) => - { - config.ReadFrom.Configuration(context.Configuration); - }) - .UseAutofac(); } diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Startup.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Startup.cs deleted file mode 100644 index 953e89da4..000000000 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Startup.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using System.IO; -using Volo.Abp.IO; -using Volo.Abp.Modularity.PlugIns; - -namespace LY.MicroService.RealtimeMessage; - -public class Startup -{ - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(options => - { - // Modules Ŀ¼ļΪ - // ȡʾĿģ飬Ϊͨʽ - var pluginFolder = Path.Combine( - Directory.GetCurrentDirectory(), "Modules"); - DirectoryHelper.CreateIfNotExists(pluginFolder); - options.PlugInSources.AddFolder( - pluginFolder, - SearchOption.AllDirectories); - }); - } - - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } -} diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs index ffce4bc69..4d883dd11 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/EventBus/Handlers/TenantSynchronizer.cs @@ -100,7 +100,7 @@ namespace LY.MicroService.TaskManagement.EventBus.Handlers { return new JobInfo { - Id = tenantId, + Id = tenantId.ToString(), Name = nameof(BackgroundPollingJob), Group = "Polling", Description = "Polling tasks to be executed", @@ -121,7 +121,7 @@ namespace LY.MicroService.TaskManagement.EventBus.Handlers { return new JobInfo { - Id = tenantId, + Id = tenantId.ToString(), Name = nameof(BackgroundCleaningJob), Group = "Cleaning", Description = "Cleaning tasks to be executed", diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Migrations/20220113113020_Change-Background-Job-Info-Key-To-String.Designer.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Migrations/20220113113020_Change-Background-Job-Info-Key-To-String.Designer.cs new file mode 100644 index 000000000..11e48a54a --- /dev/null +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Migrations/20220113113020_Change-Background-Job-Info-Key-To-String.Designer.cs @@ -0,0 +1,202 @@ +// +using System; +using LY.MicroService.TaskManagement.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.TaskManagement.Migrations +{ + [DbContext(typeof(TaskManagementMigrationsDbContext))] + [Migration("20220113113020_Change-Background-Job-Info-Key-To-String")] + partial class ChangeBackgroundJobInfoKeyToString + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.TaskManagement.BackgroundJobInfo", b => + { + b.Property("Id") + .HasColumnType("varchar(255)"); + + b.Property("Args") + .HasColumnType("longtext") + .HasColumnName("Args"); + + b.Property("BeginTime") + .HasColumnType("datetime(6)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Cron") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Cron"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("Description"); + + b.Property("EndTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Group") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("Group"); + + b.Property("Interval") + .HasColumnType("int"); + + b.Property("IsAbandoned") + .HasColumnType("tinyint(1)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("JobType") + .HasColumnType("int"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LastRunTime") + .HasColumnType("datetime(6)"); + + b.Property("LockTimeOut") + .HasColumnType("int"); + + b.Property("MaxCount") + .HasColumnType("int"); + + b.Property("MaxTryCount") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("Name"); + + b.Property("NextRunTime") + .HasColumnType("datetime(6)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("Result") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("Result"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("TriggerCount") + .HasColumnType("int"); + + b.Property("TryCount") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("Type"); + + b.HasKey("Id"); + + b.HasIndex("Name", "Group"); + + b.ToTable("TK_BackgroundJobs", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.TaskManagement.BackgroundJobLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Exception") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)") + .HasColumnName("Exception"); + + b.Property("JobGroup") + .HasMaxLength(50) + .HasColumnType("varchar(50)") + .HasColumnName("JobGroup"); + + b.Property("JobId") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("JobId"); + + b.Property("JobName") + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("JobName"); + + b.Property("JobType") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("JobType"); + + b.Property("Message") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)") + .HasColumnName("Message"); + + b.Property("RunTime") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("JobGroup", "JobName"); + + b.ToTable("TK_BackgroundJobLogs", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Migrations/20220113113020_Change-Background-Job-Info-Key-To-String.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Migrations/20220113113020_Change-Background-Job-Info-Key-To-String.cs new file mode 100644 index 000000000..9cf9799a4 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Migrations/20220113113020_Change-Background-Job-Info-Key-To-String.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.TaskManagement.Migrations +{ + public partial class ChangeBackgroundJobInfoKeyToString : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Id", + table: "TK_BackgroundJobs", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(Guid), + oldType: "char(36)") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("Relational:Collation", "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "JobId", + table: "TK_BackgroundJobLogs", + type: "varchar(255)", + maxLength: 255, + nullable: true, + oldClrType: typeof(Guid), + oldType: "char(36)", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("Relational:Collation", "ascii_general_ci"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Id", + table: "TK_BackgroundJobs", + type: "char(36)", + nullable: false, + collation: "ascii_general_ci", + oldClrType: typeof(string), + oldType: "varchar(255)") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "JobId", + table: "TK_BackgroundJobLogs", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci", + oldClrType: typeof(string), + oldType: "varchar(255)", + oldMaxLength: 255, + oldNullable: true) + .OldAnnotation("MySql:CharSet", "utf8mb4"); + } + } +} diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Migrations/TaskManagementMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Migrations/TaskManagementMigrationsDbContextModelSnapshot.cs index d34ad29bf..aba69c5a2 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Migrations/TaskManagementMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Migrations/TaskManagementMigrationsDbContextModelSnapshot.cs @@ -23,9 +23,8 @@ namespace LY.MicroService.TaskManagement.Migrations modelBuilder.Entity("LINGYUN.Abp.TaskManagement.BackgroundJobInfo", b => { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("char(36)"); + b.Property("Id") + .HasColumnType("varchar(255)"); b.Property("Args") .HasColumnType("longtext") @@ -162,8 +161,10 @@ namespace LY.MicroService.TaskManagement.Migrations .HasColumnType("varchar(50)") .HasColumnName("JobGroup"); - b.Property("JobId") - .HasColumnType("char(36)"); + b.Property("JobId") + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("JobId"); b.Property("JobName") .HasMaxLength(100) diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs index 013d47509..971d2ee84 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs @@ -1,19 +1,53 @@ -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; +using System.IO; +using System.Threading.Tasks; +using Volo.Abp.IO; +using Volo.Abp.Modularity.PlugIns; namespace LY.MicroService.TaskManagement; public class Program { - public static int Main(string[] args) + public async static Task Main(string[] args) { try { - var host = CreateHostBuilder(args).Build(); - Log.Information("Starting web host."); - host.Run(); + Log.Information("Starting TaskManagement.HttpApi.Host."); + + var builder = WebApplication.CreateBuilder(args); + builder.Host.AddAppSettingsSecretsJson() + .UseAutofac() + .ConfigureAppConfiguration((context, config) => + { + var configuration = config.Build(); + if (configuration.GetSection("AgileConfig").Exists()) + { + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + } + }) + .UseSerilog((context, provider, config) => + { + config.ReadFrom.Configuration(context.Configuration); + }); + await builder.AddApplicationAsync(options => + { + // 搜索 Modules 目录下所有文件作为插件 + // 取消显示引用所有其他项目的模块,改为通过插件的形式引用 + var pluginFolder = Path.Combine( + Directory.GetCurrentDirectory(), "Modules"); + DirectoryHelper.CreateIfNotExists(pluginFolder); + options.PlugInSources.AddFolder( + pluginFolder, + SearchOption.AllDirectories); + }); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); return 0; } finally @@ -21,24 +55,4 @@ public class Program Log.CloseAndFlush(); } } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .ConfigureAppConfiguration((context, config) => - { - var configuration = config.Build(); - if (configuration.GetSection("AgileConfig").Exists()) - { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); - } - }) - .UseSerilog((context, config) => - { - config.ReadFrom.Configuration(context.Configuration); - }) - .UseAutofac(); } diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Startup.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Startup.cs deleted file mode 100644 index 35612530f..000000000 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Startup.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using System.IO; -using Volo.Abp.IO; -using Volo.Abp.Modularity.PlugIns; - -namespace LY.MicroService.TaskManagement; - -public class Startup -{ - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(options => - { - // 搜索 Modules 目录下所有文件作为插件 - // 取消显示引用所有其他项目的模块,改为通过插件的形式引用 - var pluginFolder = Path.Combine( - Directory.GetCurrentDirectory(), "Modules"); - DirectoryHelper.CreateIfNotExists(pluginFolder); - options.PlugInSources.AddFolder( - pluginFolder, - SearchOption.AllDirectories); - }); - } - - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } -} diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Dockerfile b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Dockerfile index 9fe768091..e11e9264f 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Dockerfile +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/aspnet:5.0 +FROM mcr.microsoft.com/dotnet/aspnet:6.0 LABEL maintainer="colin.in@foxmail.com" WORKDIR /app diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs index 0ce7dd299..00a463993 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Program.cs @@ -1,19 +1,53 @@ -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; +using System.IO; +using System.Threading.Tasks; +using Volo.Abp.IO; +using Volo.Abp.Modularity.PlugIns; namespace LY.MicroService.WorkflowManagement; public class Program { - public static int Main(string[] args) + public async static Task Main(string[] args) { try { - var host = CreateHostBuilder(args).Build(); - Log.Information("Starting web host."); - host.Run(); + Log.Information("Starting WorkflowManagement.HttpApi.Host."); + + var builder = WebApplication.CreateBuilder(args); + builder.Host.AddAppSettingsSecretsJson() + .UseAutofac() + .ConfigureAppConfiguration((context, config) => + { + var configuration = config.Build(); + if (configuration.GetSection("AgileConfig").Exists()) + { + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + } + }) + .UseSerilog((context, provider, config) => + { + config.ReadFrom.Configuration(context.Configuration); + }); + await builder.AddApplicationAsync(options => + { + // 搜索 Modules 目录下所有文件作为插件 + // 取消显示引用所有其他项目的模块,改为通过插件的形式引用 + var pluginFolder = Path.Combine( + Directory.GetCurrentDirectory(), "Modules"); + DirectoryHelper.CreateIfNotExists(pluginFolder); + options.PlugInSources.AddFolder( + pluginFolder, + SearchOption.AllDirectories); + }); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); return 0; } finally @@ -21,24 +55,4 @@ public class Program Log.CloseAndFlush(); } } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .ConfigureAppConfiguration((context, config) => - { - var configuration = config.Build(); - if (configuration.GetSection("AgileConfig").Exists()) - { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); - } - }) - .UseSerilog((context, config) => - { - config.ReadFrom.Configuration(context.Configuration); - }) - .UseAutofac(); } diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Startup.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Startup.cs deleted file mode 100644 index cc0619d01..000000000 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Startup.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using System.IO; -using Volo.Abp.IO; -using Volo.Abp.Modularity.PlugIns; - -namespace LY.MicroService.WorkflowManagement; - -public class Startup -{ - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(options => - { - // 搜索 Modules 目录下所有文件作为插件 - // 取消显示引用所有其他项目的模块,改为通过插件的形式引用 - var pluginFolder = Path.Combine( - Directory.GetCurrentDirectory(), "Modules"); - DirectoryHelper.CreateIfNotExists(pluginFolder); - options.PlugInSources.AddFolder( - pluginFolder, - SearchOption.AllDirectories); - }); - } - - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } -} diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Program.cs b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Program.cs index 11e11824a..d08309c96 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Program.cs +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Program.cs @@ -1,22 +1,54 @@ +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; using System; using System.IO; +using System.Threading.Tasks; +using Volo.Abp.IO; +using Volo.Abp.Modularity.PlugIns; namespace LY.MicroService.IdentityServer; public class Program { - public static int Main(string[] args) + public async static Task Main(string[] args) { try { - var hostBuilder = CreateHostBuilder(args).Build(); - Log.Information("Starting IdentityServer4Admin.Host."); - hostBuilder.Run(); + Log.Information("Starting IdentityServer.HttpApi.Host."); + var builder = WebApplication.CreateBuilder(args); + builder.Host.AddAppSettingsSecretsJson() + .UseAutofac() + .ConfigureAppConfiguration((context, config) => + { + var configuration = config.Build(); + if (configuration.GetSection("AgileConfig").Exists()) + { + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + } + }) + .UseSerilog((context, provider, config) => + { + config.ReadFrom.Configuration(context.Configuration); + }); + await builder.AddApplicationAsync(options => + { + // Modules Ŀ¼ļΪ + // ȡʾĿģ飬Ϊͨʽ + var pluginFolder = Path.Combine( + Directory.GetCurrentDirectory(), "Modules"); + DirectoryHelper.CreateIfNotExists(pluginFolder); + options.PlugInSources.AddFolder( + pluginFolder, + SearchOption.AllDirectories); + }); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); return 0; } catch (Exception ex) @@ -29,24 +61,4 @@ public class Program Log.CloseAndFlush(); } } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .ConfigureAppConfiguration((context, config) => - { - var configuration = config.Build(); - if (configuration.GetSection("AgileConfig").Exists()) - { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); - } - }) - .UseSerilog((context, provider, config) => - { - config.ReadFrom.Configuration(context.Configuration); - }) - .UseAutofac(); } \ No newline at end of file diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Startup.cs b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Startup.cs deleted file mode 100644 index 6d22b56e9..000000000 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Startup.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using System.IO; -using Volo.Abp.IO; -using Volo.Abp.Modularity.PlugIns; - -namespace LY.MicroService.IdentityServer; - -public class Startup -{ - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(options => - { - // Modules Ŀ¼ļΪ - // ȡʾĿģ飬Ϊͨʽ - var pluginFolder = Path.Combine( - Directory.GetCurrentDirectory(), "Modules"); - DirectoryHelper.CreateIfNotExists(pluginFolder); - options.PlugInSources.AddFolder( - pluginFolder, - SearchOption.AllDirectories); - }); - } - - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } -} \ No newline at end of file diff --git a/aspnet-core/services/LY.MicroService.identityServer/Program.cs b/aspnet-core/services/LY.MicroService.identityServer/Program.cs index e51ef8bd3..4e1978cd7 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/Program.cs +++ b/aspnet-core/services/LY.MicroService.identityServer/Program.cs @@ -1,19 +1,54 @@ -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; using System; +using System.IO; +using System.Threading.Tasks; +using Volo.Abp.IO; +using Volo.Abp.Modularity.PlugIns; namespace LY.MicroService.IdentityServer; public class Program { - public static int Main(string[] args) + public async static Task Main(string[] args) { try { - Log.Information("Starting AuthServer.Host."); - CreateHostBuilder(args).Build().Run(); + Log.Information("Starting IdentityServer."); + + var builder = WebApplication.CreateBuilder(args); + builder.Host.AddAppSettingsSecretsJson() + .UseAutofac() + .ConfigureAppConfiguration((context, config) => + { + var configuration = config.Build(); + if (configuration.GetSection("AgileConfig").Exists()) + { + config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); + } + }) + .UseSerilog((context, provider, config) => + { + config.ReadFrom.Configuration(context.Configuration); + }); + await builder.AddApplicationAsync(options => + { + // 搜索 Modules 目录下所有文件作为插件 + // 取消显示引用所有其他项目的模块,改为通过插件的形式引用 + var pluginFolder = Path.Combine( + Directory.GetCurrentDirectory(), "Modules"); + DirectoryHelper.CreateIfNotExists(pluginFolder); + options.PlugInSources.AddFolder( + pluginFolder, + SearchOption.AllDirectories); + }); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); return 0; } catch (Exception ex) @@ -26,25 +61,5 @@ public class Program Log.CloseAndFlush(); } } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .ConfigureAppConfiguration((context, config) => - { - var configuration = config.Build(); - if (configuration.GetSection("AgileConfig").Exists()) - { - config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); - } - }) - .UseSerilog((context, provider, config) => - { - config.ReadFrom.Configuration(context.Configuration); - }) - .UseAutofac(); } diff --git a/aspnet-core/services/LY.MicroService.identityServer/Startup.cs b/aspnet-core/services/LY.MicroService.identityServer/Startup.cs deleted file mode 100644 index 479ed511f..000000000 --- a/aspnet-core/services/LY.MicroService.identityServer/Startup.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using System.IO; -using Volo.Abp.IO; -using Volo.Abp.Modularity.PlugIns; - -namespace LY.MicroService.IdentityServer; - -public class Startup -{ - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(options => - { - // 搜索 Modules 目录下所有文件作为插件 - // 取消显示引用所有其他项目的模块,改为通过插件的形式引用 - var pluginFolder = Path.Combine( - Directory.GetCurrentDirectory(), "Modules"); - DirectoryHelper.CreateIfNotExists(pluginFolder); - options.PlugInSources.AddFolder( - pluginFolder, - SearchOption.AllDirectories); - }); - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } -} diff --git a/aspnet-core/services/LY.MicroService.identityServer/package.json b/aspnet-core/services/LY.MicroService.identityServer/package.json index c28a580a2..05e35b057 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/package.json +++ b/aspnet-core/services/LY.MicroService.identityServer/package.json @@ -3,6 +3,6 @@ "name": "my-app-identityserver", "private": true, "dependencies": { - "@abp/aspnetcore.mvc.ui.theme.basic": "^5.0.0-rc.1" + "@abp/aspnetcore.mvc.ui.theme.basic": "5.1.1" } } \ No newline at end of file diff --git a/common.props b/common.props index a2a83560a..8ce651936 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ latest - 5.0.0 + 5.1.1 LINGYUN $(NoWarn);CS1591;CS0436 https://github.com/colinin/abp-vue-admin-element-typescript/ diff --git a/gateways/Directory.Build.props b/gateways/Directory.Build.props index d285ba05c..40ea61b92 100644 --- a/gateways/Directory.Build.props +++ b/gateways/Directory.Build.props @@ -1,7 +1,7 @@  - 5.0.0 - 5.0.0 + 5.1.1 + 5.1.1 1.5.0 5.2.0 1.5.10 diff --git a/gateways/common.props b/gateways/common.props index 163e03e5a..ff91bb0ff 100644 --- a/gateways/common.props +++ b/gateways/common.props @@ -1,7 +1,7 @@ latest - 5.0.0 + 5.1.1 $(NoWarn);CS1591;CS0436 \ No newline at end of file