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 _serviceMap = new Dictionary(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()?.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); } } } }