Ejemplo n.º 1
0
        public void gprs_OnDisConnect(Socket socket)
        {
            try
            {
                labelGprsCount.Text = (Int32.Parse(labelGprsCount.Text) - 1).ToString();
                TcpTerminal gc = (TcpTerminal)tcpTable[socket];
                if (gc != null)
                {
                    if (gc.Car != null)
                    {
                        gc.Car.GprsConn = null;
                    }
                    tcpTable.Remove(gc);
                }

                /*
                 * for(int i = 0; i < gprsClientList.Count; i++)
                 *  if(socket == gprsClientList[i].Socket)
                 *  {
                 *      if(gprsClientList[i].Car != null)
                 *          gprsClientList[i].Car.GprsClient = null;
                 *      gprsClientList.RemoveAt(i);
                 *      break;
                 *  }*/
            }
            catch (Exception e)
            {
                if (FormMain.LOG_ERR)
                {
                    logger.AddErr(e, "");
                }
            }
        }
Ejemplo n.º 2
0
        //gprs 接收事件
        void gprsServer_OnReceive(Socket socket, string msg)
        {
            try
            {
                TcpTerminal gc = (TcpTerminal)tcpTable[socket];
                if (gc != null)
                {
                    gc.Counter = 0;
                    //logger.AddMsg("tcp终端信息(ascii):" + msg);

                    if (msg.Substring(13, 4) == "UB00")
                    {
                        String str = "";
                        str = msg.Substring(0, 13) + "DB01" + msg.Substring(17, (msg.Length - 17));
                        gc.Send(str);
                    }

                    if (msg.Substring(13, 4) == "UB05")
                    {
                        String str = "", strt = "", sucess = "", fail = "";

                        str = msg.Substring(17, 15);
                        DBManager dbmj = DBManager.GetInstance(Config.DbHost, Config.DbName, Config.DbUser, Config.DbPw);

                        DataTable dt = dbmj.ExecuteQuery("select machineNO from tCar where machineNO=" + "'" + str + "';");
                        foreach (DataRow dr in dt.Rows)
                        {
                            strt = dr[0].ToString();
                        }

                        if (strt != "")
                        {
                            sucess = msg.Substring(0, 13) + "DX061^";
                            gc.Send(sucess);
                            sucess = "";
                            sucess = msg.Substring(0, 13) + "0014^";
                            gc.Send(sucess);
                            dbmj.Close();
                        }
                        else
                        {
                            fail = msg.Substring(0, 13) + "DX060^";
                            gc.Send(fail);
                            dbmj.Close();

                            goto kick;
                        }
                    }



                    //logger.AddMsg("tcp终端信息(hex):" + Pub.RealHexToStr(msg));

                    GPSInfo gi = new GPSInfo(msg, gc);
                    analyzer.AddInInfo(gi);
                    kick :;
                }
            }
            catch (Exception e)
            {
                if (FormMain.LOG_ERR)
                {
                    logger.AddErr(e, "");
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// TCP GPS��Ϣ
 /// </summary>
 /// <param name="s">��Ϣ����</param>
 /// <param name="tt">TCP����</param>
 public GPSInfo(String s, TcpTerminal tt)
 {
     msg = s;
     tcpConn = tt;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// TCP GPS信息
 /// </summary>
 /// <param name="s">信息内容</param>
 /// <param name="tt">TCP连接</param>
 public GPSInfo(String s, TcpTerminal tt)
 {
     msg     = s;
     tcpConn = tt;
 }