using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Abp.Guids; using Volo.Abp.Uow; namespace CMS.Plugin.HIAWms.Domain.WmsMaterialInfos { /// /// WmsMaterialInfo种子数据提供程序 /// public class WmsMaterialInfoDataSeedContributor : IDataSeedContributor, ITransientDependency { private readonly IUnitOfWorkManager _unitOfWorkManager; private readonly IWmsMaterialInfoRepository _wmsmaterialinfoRepository; private readonly IGuidGenerator _guidGenerator; /// /// Initializes a new instance of the class. /// /// The unit of work manager. /// The unique identifier generator. /// The work section repository. public WmsMaterialInfoDataSeedContributor(IUnitOfWorkManager unitOfWorkManager, IGuidGenerator guidGenerator, IWmsMaterialInfoRepository wmsmaterialinfoRepository) { _unitOfWorkManager = unitOfWorkManager; _wmsmaterialinfoRepository = wmsmaterialinfoRepository; _guidGenerator = guidGenerator; } /// public async Task SeedAsync(DataSeedContext context) { if (context.Properties.ContainsKey(CMSPluginDbProperties.ConnectionStringName) && context.Properties[CMSPluginDbProperties.ConnectionStringName]?.ToString() == CMSPluginDbProperties.ConnectionStringName) { try { //using var unitofWork = _unitOfWorkManager.Begin(requiresNew: true); //await unitofWork.SaveChangesAsync(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } if (context.Properties.ContainsKey("SeedTestData") && context.Properties["SeedTestData"]?.ToString() == "SeedTestData") { try { await SeedWmsMaterialInfoDataAsync(); } catch (Exception e) { Console.WriteLine(e.Message); } } } /// /// Seeds the work section data asynchronous. /// private async Task SeedWmsMaterialInfoDataAsync() { } } }