zs
2025-04-28 1f32ea02c1910c417f159cba81a296e66ae7484c
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.WmsAreas
{
    /// <summary>
    /// WmsArea种子数据提供程序
    /// </summary>
    public class WmsAreaDataSeedContributor : IDataSeedContributor, ITransientDependency
    {
        private readonly IUnitOfWorkManager _unitOfWorkManager;
        private readonly IWmsAreaRepository _wmsareaRepository;
        private readonly IGuidGenerator _guidGenerator;
 
        /// <summary>
        /// Initializes a new instance of the <see cref="WmsAreaDataSeedContributor"/> class.
        /// </summary>
        /// <param name="unitOfWorkManager">The unit of work manager.</param>
        /// <param name="guidGenerator">The unique identifier generator.</param>
        /// <param name="wmsareaRepository">The work section repository.</param>
        public WmsAreaDataSeedContributor(IUnitOfWorkManager unitOfWorkManager,  IGuidGenerator guidGenerator, IWmsAreaRepository wmsareaRepository)
        {
            _unitOfWorkManager = unitOfWorkManager;
            _wmsareaRepository = wmsareaRepository;
            _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 SeedWmsAreaDataAsync();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
 
        /// <summary>
        /// Seeds the work section data asynchronous.
        /// </summary>
        private async Task SeedWmsAreaDataAsync()
        {
           
        }
    }
}