using CMS.Plugin.WareCmsUtilityApi.Abstractions; using CMS.Plugin.WareCmsUtilityApi.Domain.Samples; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using SYC.Flow.Kernel; using Volo.Abp.DependencyInjection; using Volo.Abp.Uow; namespace CMS.Plugin.WareCmsUtilityApi.Services { /// public class WareCmsUtilityApiFlowService : IWareCmsUtilityApiFlowService, ITransientDependency { private readonly ILogger _logger; private readonly IServiceProvider _serviceProvider; /// /// Initializes a new instance of the class. /// /// The logger. public WareCmsUtilityApiFlowService(ILogger logger, IServiceProvider serviceProvider) { _logger = logger; _serviceProvider = serviceProvider; } /// public async Task ProcessAsync(ProcessflowEventArgs args) { using var scope = _serviceProvider.CreateScope(); var unitOfWorkManager = scope.ServiceProvider.GetRequiredService(); using var uow = unitOfWorkManager.Begin(requiresNew: true); var sampleRepository = scope.ServiceProvider.GetRequiredService(); var count = await sampleRepository.GetCountAsync(); // 如果有更新数据库操作,需提交保存 // await uow.SaveChangesAsync(); // 输出日志 _logger.LogInformation($"WareCmsUtilityApiFlowService:ProcessAsync()"); } } }