Esempio n. 1
0
        void gsm_OnReceivedData(object sender, GsmService.ReceivedDataEventArgs e)
        {
            GsmServer gsm = sender as GsmServer;

            lock (gsm)
            {
                string ss = "Index:" + e.Decodedmessage.SmsIndex + "\r\n 短信中心:" + e.Decodedmessage.ServiceCenterAddress + "\r\n" + "手机号码:" + e.Decodedmessage.PhoneNumber + "\r\n" +
                            "短信内容:" + e.Decodedmessage.SmsContent + "\r\n" + "发送时间:" + e.Decodedmessage.SendTime;

                gsm.TrySmsContent = e.Decodedmessage.TrySmsContent;//中文短信解码方式

                //写入接收数据队列
                byte[] bt = null;
                if (wrx.XMLObj.HEXOrASC == "HEX")
                {
                    bt = EnCoder.HexStrToByteArray(e.Decodedmessage.SmsContent);
                }
                else
                {
                    bt = Encoding.UTF8.GetBytes(e.Decodedmessage.SmsContent);
                }
                GsmBussiness.WriteGrdQ(gsm, e.Decodedmessage.PhoneNumber, e.Decodedmessage.SendTime, bt);

                //写入透传列表
                ServiceBussiness.WriteQDM(bt);
                //写入日志
                LogInfoToTxt(ServiceEnum.NFOINDEX.GSM, e.Decodedmessage.PhoneNumber, bt);

                //解析数据包(更新手机号列表)
                GsmBussiness.ResolvePacket(gsm);
            }
        }
Esempio n. 2
0
 public static void LogInfoToTxt(Service.ServiceEnum.NFOINDEX nfoindex, string NFOINDEXinfo, byte[] bt, string HEXOrASC)
 {
     if (HEXOrASC == "HEX")
     {
         log.Info(nfoindex + "|" + NFOINDEXinfo + "|" + DateTime.Now.ToString("yyyyMMddHHmmss") + "|" + EnCoder.ByteArrayToHexStr(bt));
     }
     else
     {
         log.Info(nfoindex + "|" + NFOINDEXinfo + "|" + DateTime.Now.ToString("yyyyMMddHHmmss") + "|" + Encoding.ASCII.GetString(bt));
     }
 }
Esempio n. 3
0
 public void ToQxsd(ServiceEnum.NFOINDEX NFOINDEX)
 {
     if (ServiceEnum.NFOINDEX.TCP == NFOINDEX)
     {
         var            cmds = from cmd in ServiceControl.LC where cmd.SERVICETYPE == "TCP" select cmd;
         List <Command> CMDS = cmds.ToList <Command>();
         foreach (var t in ServiceControl.tcp)
         {
             foreach (var item in CMDS)
             {
                 #region 编码
                 byte[] EncoderData = null;
                 if (wrx.XMLObj.HEXOrASC == "HEX")
                 {
                     EncoderData = EnCoder.HexStrToByteArray(item.Data);
                 }
                 if (wrx.XMLObj.HEXOrASC == "ASC")
                 {
                     EncoderData = Encoding.ASCII.GetBytes(item.Data);
                 }
                 #endregion
                 TcpService.TcpBussiness.WriteTsdQ(t, item.STCD, EncoderData, item.CommandID);
             }
         }
     }
     else if (ServiceEnum.NFOINDEX.UDP == NFOINDEX)
     {
         var            cmds = from cmd in ServiceControl.LC where cmd.SERVICETYPE == "UDP" select cmd;
         List <Command> CMDS = cmds.ToList <Command>();
         foreach (var u in ServiceControl.udp)
         {
             foreach (var item in CMDS)
             {
                 #region 编码
                 byte[] EncoderData = null;
                 if (wrx.XMLObj.HEXOrASC == "HEX")
                 {
                     EncoderData = EnCoder.HexStrToByteArray(item.Data);
                 }
                 if (wrx.XMLObj.HEXOrASC == "ASC")
                 {
                     EncoderData = Encoding.ASCII.GetBytes(item.Data);
                 }
                 #endregion
                 UdpService.UdpBussiness.WriteUsdQ(u, item.STCD, EncoderData, item.CommandID);
             }
         }
     }
     else if (ServiceEnum.NFOINDEX.GSM == NFOINDEX)
     {
         var            cmds = from cmd in ServiceControl.LC where cmd.SERVICETYPE == "GSM" select cmd;
         List <Command> CMDS = cmds.ToList <Command>();
         foreach (var g in ServiceControl.gsm)
         {
             foreach (var item in CMDS)
             {
                 #region 编码
                 byte[] EncoderData = null;
                 if (wrx.XMLObj.HEXOrASC == "HEX")
                 {
                     EncoderData = EnCoder.HexStrToByteArray(item.Data);
                 }
                 if (wrx.XMLObj.HEXOrASC == "ASC")
                 {
                     EncoderData = Encoding.ASCII.GetBytes(item.Data);
                 }
                 #endregion
                 GsmService.GsmBussiness.WriteGsdQ(g, item.STCD, EncoderData, item.CommandID);
             }
         }
     }
     else if (ServiceEnum.NFOINDEX.COM == NFOINDEX)
     {
         var            cmds = from cmd in ServiceControl.LC where cmd.SERVICETYPE == "COM" select cmd;
         List <Command> CMDS = cmds.ToList <Command>();
         foreach (var c in ServiceControl.com)
         {
             foreach (var item in CMDS)
             {
                 #region 编码
                 byte[] EncoderData = null;
                 if (wrx.XMLObj.HEXOrASC == "HEX")
                 {
                     EncoderData = EnCoder.HexStrToByteArray(item.Data);
                 }
                 if (wrx.XMLObj.HEXOrASC == "ASC")
                 {
                     EncoderData = Encoding.ASCII.GetBytes(item.Data);
                 }
                 #endregion
                 ComService.ComBussiness.WriteCsdQ(c, item.STCD, EncoderData, item.CommandID);
             }
         }
     }
 }