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