53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using JSMachine.WMS.Common;
|
|||
|
|
using JSMachine.WMS.Common.Cache.Model;
|
||
|
|
using JSMachine.WMS.Common.Cache;
|
||
|
|
using JSMachine.WMS.Common.Dto.Http.In;
|
||
|
|
using JSMachine.WMS.Netty.NettyAsServer.Command;
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using Microsoft.Extensions.Caching.Memory;
|
||
|
|
|
||
|
|
namespace JSMachine.WMS.Netty.NettyAsServer.CommandHandler
|
||
|
|
{
|
||
|
|
public class BarCodeCmdHandlerL : BaseCmdhandler
|
||
|
|
{
|
||
|
|
public async override Task<bool> Handle(BaseCmd msg)
|
||
|
|
{
|
||
|
|
return await Task.Run(() =>
|
||
|
|
{
|
||
|
|
if (msg is BarCodeUploadCmd barCodeUploadCmd)
|
||
|
|
{
|
||
|
|
GlobalMemoryCache.AddCach<string, BarCodeInfo>(
|
||
|
|
RemoteIPInfo.IP,
|
||
|
|
new BarCodeInfo
|
||
|
|
{
|
||
|
|
AddTime = DateTime.Now,
|
||
|
|
BarCode = barCodeUploadCmd.Msg,
|
||
|
|
IP = RemoteIPInfo.IP
|
||
|
|
},
|
||
|
|
new MemoryCacheEntryOptions
|
||
|
|
{
|
||
|
|
AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(2),
|
||
|
|
SlidingExpiration = TimeSpan.FromSeconds(1)
|
||
|
|
});
|
||
|
|
|
||
|
|
//bool? exist = Global.AppSettings.PaperFeedConfig.CodeScannerConfig?.Any(p => p.IP == RemoteIPInfo.IP);
|
||
|
|
|
||
|
|
//IEventAggregator.GetEvent<UploadBarCodeEvent>().Publish(new BarCodeUploadParam
|
||
|
|
//{
|
||
|
|
// BarCode = barCodeUploadCmd.Msg,
|
||
|
|
// BusinessType = exist != null && exist.Value ? "0" : "1"
|
||
|
|
//});
|
||
|
|
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
return false;
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|