调整PC端调用业务回更代码
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Dynamic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -15,25 +17,20 @@ namespace Tnb.WarehouseMgr
|
|||||||
[Caller("web")]
|
[Caller("web")]
|
||||||
public class PcStroageService : IWHStorageService
|
public class PcStroageService : IWHStorageService
|
||||||
{
|
{
|
||||||
private static Dictionary<string, BaseWareHouseService> _serviceMap = new Dictionary<string, BaseWareHouseService>(StringComparer.OrdinalIgnoreCase);
|
private static Dictionary<string, Func<WareHouseUpInput, Task>> _serviceCallbackMap = new(StringComparer.OrdinalIgnoreCase);
|
||||||
static PcStroageService()
|
static PcStroageService()
|
||||||
{
|
{
|
||||||
var serviceTypes = App.EffectiveTypes.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && !typeof(IPdaStroage).IsAssignableFrom(u) && u.IsSubclassOf(typeof(BaseWareHouseService))).ToList();
|
_serviceCallbackMap = App.EffectiveTypes.AsParallel().Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && !typeof(IPdaStroage).IsAssignableFrom(u)
|
||||||
foreach (var serviceType in serviceTypes)
|
&& u.IsSubclassOf(typeof(BaseWareHouseService)) && u.GetCustomAttribute<ServiceModuleAttribute>() != null)
|
||||||
{
|
.ToDictionary(x => x.GetCustomAttribute<ServiceModuleAttribute>().BizTypeId,
|
||||||
var bizTypeId = serviceType.GetCustomAttribute<ServiceModuleAttribute>()?.BizTypeId;
|
x => (Func<WareHouseUpInput, Task>)Delegate.CreateDelegate(typeof(Func<WareHouseUpInput, Task>), App.GetService(x), x.GetMethod(nameof(WareHouseService.ModifyAsync))));
|
||||||
if (!bizTypeId.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
_serviceMap[bizTypeId!] = (BaseWareHouseService)App.GetService(serviceType)!;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Do(WareHouseUpInput input)
|
public async Task Do(WareHouseUpInput input)
|
||||||
{
|
{
|
||||||
if (_serviceMap.ContainsKey(input.bizTypeId))
|
if (_serviceCallbackMap.ContainsKey(input.bizTypeId))
|
||||||
{
|
{
|
||||||
await _serviceMap[input.bizTypeId].ModifyAsync(input);
|
await _serviceCallbackMap[input.bizTypeId].Invoke(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user