Files
tnb.server/WarehouseMgr/Tnb.WarehouseMgr/PdaStroageService.cs
2023-06-19 15:01:37 +08:00

41 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using JNPF;
using JNPF.Common.Extension;
using Tnb.WarehouseMgr.Entities.Attributes;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
{
[Caller("app")]
public class PdaStroageService : IWHStorageService
{
private static Dictionary<string, BaseWareHouseService> _serviceMap = new Dictionary<string, BaseWareHouseService>(StringComparer.OrdinalIgnoreCase);
static PdaStroageService()
{
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(IPdaStroage).IsAssignableFrom(u) && u.IsSubclassOf(typeof(BaseWareHouseService))).ToList();
foreach (var serviceType in serviceTypes)
{
var bizTypeId = serviceType.GetCustomAttribute<ServiceModuleAttribute>()?.BizTypeId;
if (!bizTypeId.IsNullOrEmpty())
{
_serviceMap[bizTypeId!] = (BaseWareHouseService)App.GetService(serviceType)!;
}
}
}
public async Task Do(WareHouseUpInput input)
{
if (_serviceMap.ContainsKey(input.bizTypeId))
{
await _serviceMap[input.bizTypeId].ModifyAsync(input);
}
}
}
}