天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB

using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QM.Exchange.Interface;
namespace QM.Exchange.Core.ProcessProgram
{
/// <summary>
/// 数据处理程序执行者
/// </summary>
public class CommandExecutor
{
private List<DataCommand> _commands = new List<DataCommand>();
/// <summary>
/// 设置处理程序
/// </summary>
/// <param name="command"></param>
public void SetCommand(DataCommand command)
{
_commands.Add(command);
}
/// <summary>
/// 执行处理程序
/// </summary>
public void Execute()
{
Parallel.ForEach(_commands, command =>
{
try
{
IExChangeContext context = new ExChangeContext();
command.Execute(context, command.Message);
}
catch (Exception ex)
{
QMFrameWork.Log.LogManager.LogHelper.Error(
new QMFrameWork.Log.LogInfo { ClientIP = "", UserName = "", Info = command.GetType().ToString(), ErrorInfo = ex });
}
});
}
}
}