schangxiang@126.com
2025-05-13 25246d39da4b74b54a844b36d8a50752917b81cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Uow;
 
namespace CMS.Plugin.HIAWms.Domain.WmsMaterialStocks
{
    /// <summary>
    /// WmsMaterialStock种子数据提供程序
    /// </summary>
    public class WmsMaterialStockDataSeedContributor : IDataSeedContributor, ITransientDependency
    {
        private readonly IUnitOfWorkManager _unitOfWorkManager;
        private readonly IWmsMaterialStockRepository _wmsmaterialstockRepository;
        private readonly IGuidGenerator _guidGenerator;
 
        /// <summary>
        /// Initializes a new instance of the <see cref="WmsMaterialStockDataSeedContributor"/> class.
        /// </summary>
        /// <param name="unitOfWorkManager">The unit of work manager.</param>
        /// <param name="guidGenerator">The unique identifier generator.</param>
        /// <param name="wmsmaterialstockRepository">The work section repository.</param>
        public WmsMaterialStockDataSeedContributor(IUnitOfWorkManager unitOfWorkManager,  IGuidGenerator guidGenerator, IWmsMaterialStockRepository wmsmaterialstockRepository)
        {
            _unitOfWorkManager = unitOfWorkManager;
            _wmsmaterialstockRepository = wmsmaterialstockRepository;
            _guidGenerator = guidGenerator;
        }
 
        /// <inheritdoc />
        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 SeedWmsMaterialStockDataAsync();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
 
        /// <summary>
        /// Seeds the work section data asynchronous.
        /// </summary>
        private async Task SeedWmsMaterialStockDataAsync()
        {
            
        }
    }
}