using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Uow;
namespace CMS.Plugin.HIAWms.Domain.WmsPlaces
{
///
/// WmsPlace种子数据提供程序
///
public class WmsPlaceDataSeedContributor : IDataSeedContributor, ITransientDependency
{
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IWmsPlaceRepository _wmsplaceRepository;
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 WmsPlaceDataSeedContributor(IUnitOfWorkManager unitOfWorkManager, IGuidGenerator guidGenerator, IWmsPlaceRepository wmsplaceRepository)
{
_unitOfWorkManager = unitOfWorkManager;
_wmsplaceRepository = wmsplaceRepository;
_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 SeedWmsPlaceDataAsync();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
///
/// Seeds the work section data asynchronous.
///
private async Task SeedWmsPlaceDataAsync()
{
}
}
}