ningshuxia
2022-10-27 2b6eeda2c91f0e570b58b2799758475b46c1ad61
Socket/IStation.DataDockingSocket4NT/control/SendControlJobHelper.cs
@@ -1,4 +1,5 @@
using IStation.Untity;
using IStation.DataDockingSocket.MsgHandle;
using IStation.Untity;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,8 +11,11 @@
    /// <summary>
    /// 发送控制指令辅助类
    /// </summary>
    public class SendControlJobHelper
    public class SendControlJobHelper
    {
        /// <summary>
        /// 从MQ里面获取控制指令 辅助类
        /// </summary>
        private static RabbitMqExChangeHelper _queueHelper = null;
        /// <summary>
@@ -43,31 +47,39 @@
                {
                    try
                    {
                        if(paras==null)
                        if (paras == null)
                        {
                            LogHelper.Info("南通控制命令,数据序列化失败");
                            NtLogHelper.Info("南通控制命令,数据序列化失败");
                            return true;
                        }
                        var bts = BitTransfer.FromString(paras.Instruction);
                        if (session != null)
                        {
                            if (session.IsConnected)
                            {
                                session.Send(bts, 0, bts.Length);
                                LogHelper.Info(session.SessionName + ":" +paras.Instruction + ", 发送一条请求控制指令");
                            }
                        switch (paras.Type)
                        {//0代表关机 1代表开机
                            case 0:
                                ShunDownMsgHelper.StartJob(session);
                                break;//从辅助类中获取 关闭
                            case 1:
                                if (string.IsNullOrEmpty(paras.Paras))
                                    return false;
                                StartUpMsgHelper.StartJob(session);
                                break;//从辅助类中获取 开启
                            default:
                                return false;
                        }
                        return true;
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error("南通控制命令,数据消息队列出错,自动跳过", ex);
                        NtLogHelper.Error("南通控制命令,数据消息队列出错,自动跳过", ex);
                        return true;
                    }
                });
            });
        }
    }
}