using System.Reflection; using JNPF; using Tnb.WarehouseMgr.Entities.Attributes; using Tnb.WarehouseMgr.Entities.Dto; using Tnb.WarehouseMgr.Interfaces; namespace Tnb.WarehouseMgr { [Caller("web")] public class PcStroageService : IWHStorageService { private static readonly Dictionary _serviceMap = new(StringComparer.OrdinalIgnoreCase); static PcStroageService() { _serviceMap = App.EffectiveTypes.AsParallel().Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && !typeof(IPdaStroage).IsAssignableFrom(u) && u.IsSubclassOf(typeof(BaseWareHouseService)) && u.GetCustomAttribute() != null) .ToDictionary(x => x.GetCustomAttribute().BizTypeId, x => (BaseWareHouseService)App.GetService(x)); } public async Task Do(WareHouseUpInput input) { if (string.IsNullOrEmpty(input.bizTypeId)) return; if (_serviceMap.ContainsKey(input.bizTypeId)) { await _serviceMap[input.bizTypeId].ModifyAsync(input); } else { foreach (var key in _serviceMap.Keys) { if (key.Contains(input.bizTypeId)) { await _serviceMap[key].ModifyAsync(input); } } } } } }