Пример #1
0
       /// <summary>
        /// 回应注册协议
       /// </summary>
       /// <param name="tc"></param>
       /// <param name="ns"></param>
       /// <param name="bTerminalNo"></param>
       /// <param name="bCommand"></param>
       /// <param name="dataLen"></param>
       /// <param name="i"></param>
        private void register(TcpClient tc, NetworkStream ns, int dataLen,byte[] bb, int i)
        {
            try
            {
                bool bReRegister = false;
                string sphone = string.Format("{0:d2}{1:d2}{2:d2}{3:d2}{4:d2}{5:d2}", bb[i], bb[i + 1], bb[i + 2], bb[i + 3], bb[i + 4], bb[i + 5]);
                i = i + 6;
                bool bType = System.BitConverter.ToBoolean(bb, i++);
                string sversion = System.BitConverter.ToString(bb, i, 3).Replace('-', '.');
                if (DBHelp.Register(BTServer.Mac, out bTerminalNo, sphone, bType, sversion, out bReRegister))
                {
                    byte State = 0x00;
                    byte[] bRespose = MakeRegisterPackage(State);
                    ns.Write(bRespose, 0, bRespose.Length);
                    ns.Flush();

                    Terminal t = new Terminal(bTerminalNo, bType, sversion, sphone, 0, 0, DateTime.Now);
                    Terminal.AppTerminal(t);

                    return;
                }
            }
            catch { }

        }
Пример #2
0
 public static void AppTerminal(Terminal tt)
 {
     foreach (Terminal t in lTerminals)
     {
         if (t.Id == tt.Id)
         {
             tt.Close();
             return;
         }
     }
     lTerminals.Add(tt);
 }