Files
tnb.server/WarehouseMgr/Tnb.WarehouseMgr/PcStroageService.cs

38 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using JNPF;
using JNPF.Common.Extension;
using Microsoft.Extensions.DependencyInjection;
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 Dictionary<string, BaseWareHouseService> _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<ServiceModuleAttribute>() != null)
.ToDictionary(x => x.GetCustomAttribute<ServiceModuleAttribute>().BizTypeId, x => (BaseWareHouseService)App.GetService(x));
}
public async Task Do(WareHouseUpInput input)
{
if (_serviceMap.ContainsKey(input.bizTypeId))
await _serviceMap[input.bizTypeId].ModifyAsync(input);
}
}
}