Exemple #1
0
        /// <summary>
        /// 在监听端口上循环读取消息(采用的是阻塞式的接收方式)
        /// </summary>
        private void ReceiveMessages()
        {
            do
            {
                //本地取消命令发生时,终止循环监听(目前还不能通过远程服务器的消息指令来终止循环)
                if (this._connectionClosed == true)
                {
                    break;
                }

                byte[] oBuffer        = new byte[10240];
                int    iMessageLength = this._socket.Receive(oBuffer);
                CommnicationMessage.GPSTrackingMessage oMessage = (CommnicationMessage.GPSTrackingMessage)CommnicationMessage.ObjectSerialize.DeserializeBytesToObject(oBuffer, iMessageLength, CommnicationMessage.ObjectSerialize.SeralizeFormatType.BinaryFormat);

                this.OnProcessMessage(new MessageArguments(oMessage));
            }while (true);
        }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="carCommInfos"></param>
 /// <param name="carRowInfos"></param>
 public static void CommInfosToDataRow(CommnicationMessage.GPSTrackingMessage carCommInfos, ref System.Data.DataRow carRowInfos)
 {
     try
     {
         carRowInfos["GeoId"]       = carCommInfos.GeoId;
         carRowInfos["CarNumber"]   = carCommInfos.CarNumber;
         carRowInfos["Phone"]       = carCommInfos.Phone;
         carRowInfos["X"]           = carCommInfos.X;
         carRowInfos["Y"]           = carCommInfos.Y;
         carRowInfos["Direction"]   = carCommInfos.Direction;
         carRowInfos["CurrentTime"] = carCommInfos.TimeStamp.ToString() + "." + carCommInfos.TimeStamp.Millisecond.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #3
0
        public static void SaveToDB(Queue <CommnicationMessage.GPSTrackingMessage> carInfosQueue)
        {
            DataTable       dtResult   = new TrackingDataTableStruct();
            OleDbConnection oConn      = BaseHandler.DatabaseManager.GetOleDbConnection(GlobeVariables.HistoryPointsDBPath);
            string          sTableName = "historyTracking";

            while (carInfosQueue.Count != 0)
            {
                DataRow dr = dtResult.NewRow();

                CommnicationMessage.GPSTrackingMessage oCarInfos = carInfosQueue.Dequeue();
                HistoryTrackings.DataStructConverter.CommInfosToDataRow(oCarInfos, ref dr);

                dtResult.Rows.Add(dr);
            }

            SavePointsToDB.LoadPointsToDB(oConn, sTableName, dtResult);
        }
Exemple #4
0
        /// <summary>
        /// 在监听端口上循环读取消息
        /// </summary>
        private void ReceiveMessages()
        {
            //do
            //{
            //    byte[] oBuffer = new byte[10240];
            //    int iMessageLength = this._socket.Receive(oBuffer);
            //    CommnicationMessage.GPSTrackingMessage oMessage = (CommnicationMessage.GPSTrackingMessage)CommnicationMessage.ObjectSerialize.DeserializeBytesToObject(oBuffer, iMessageLength, CommnicationMessage.ObjectSerialize.SeralizeFormatType.BinaryFormat);

            //    this.OnProcessMessage(new MessageArguments(oMessage));
            //    //this._messageCollection.Enqueue(oMessage);


            //    if (this._messageCollection.Count == this._queueMaxCount)
            //        HistoryTrakings.SavePointsToDB.SaveToDB(this._messageCollection);

            //    //if (this._messageCollection.Count == this._queueMaxCount)
            //    //    HistoryTrakings.SavePointsToDB.SaveToDB(this._messageCollection);

            //}
            //while (true);

            do
            {
                //本地取消命令发生时,终止循环监听(目前还不能通过远程服务器的消息指令来终止循环)
                if (this._connectionClosed == true)
                {
                    break;
                }

                byte[] oBuffer        = new byte[10240];
                int    iMessageLength = this._socket.Receive(oBuffer);
                CommnicationMessage.GPSTrackingMessage oMessage = (CommnicationMessage.GPSTrackingMessage)CommnicationMessage.ObjectSerialize.DeserializeBytesToObject(oBuffer, iMessageLength, CommnicationMessage.ObjectSerialize.SeralizeFormatType.BinaryFormat);

                this.OnProcessMessage(new MessageArguments(oMessage));
                this._messageCollection.Enqueue(oMessage);

                if (this._messageCollection.Count == this._queueMaxCount)
                {
                    HistoryTrackings.SavePointsToDB.SaveToDB(this._messageCollection);
                }
            }while (true);
        }
Exemple #5
0
        public static CommnicationMessage.GPSTrackingMessage DataRowToCommInfos(System.Data.DataRow carRowInfos)
        {
            CommnicationMessage.GPSTrackingMessage oCommInfos = new CommnicationMessage.GPSTrackingMessage();

            try
            {
                oCommInfos.GeoId = carRowInfos["GeoId"].ToString();
                oCommInfos.CarNumber = carRowInfos["CarNumber"].ToString();
                oCommInfos.Phone = carRowInfos["Phone"].ToString();
                oCommInfos.X = Convert.ToDouble(carRowInfos["X"]);
                oCommInfos.Y = Convert.ToDouble(carRowInfos["Y"]);
                oCommInfos.Direction = Convert.ToDouble(carRowInfos["Direction"]);
                oCommInfos.TimeStamp = Convert.ToDateTime(carRowInfos["CurrentTime"]);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return oCommInfos;
        }
Exemple #6
0
        public static CommnicationMessage.GPSTrackingMessage DataRowToCommInfos(System.Data.DataRow carRowInfos)
        {
            CommnicationMessage.GPSTrackingMessage oCommInfos = new CommnicationMessage.GPSTrackingMessage();

            try
            {
                oCommInfos.GeoId     = carRowInfos["GeoId"].ToString();
                oCommInfos.CarNumber = carRowInfos["CarNumber"].ToString();
                oCommInfos.Phone     = carRowInfos["phone"].ToString();
                oCommInfos.X         = Convert.ToDouble(carRowInfos["X"]);
                oCommInfos.Y         = Convert.ToDouble(carRowInfos["Y"]);
                oCommInfos.Direction = Convert.ToDouble(carRowInfos["Direction"]);
                oCommInfos.TimeStamp = Convert.ToDateTime(carRowInfos["CurrentTime"]);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(oCommInfos);
        }
Exemple #7
0
        /// <summary>
        /// 在监听端口上循环读取消息(采用的是阻塞式的接收方式)
        /// </summary>
        private void ReceiveMessages()
        {
            do
            {
                //本地取消命令发生时,终止循环监听(目前还不能通过远程服务器的消息指令来终止循环)
                if (this._connectionClosed == true)
                {
                    break;
                }

                byte[] oBuffer        = new byte[10240];
                int    iMessageLength = this._socket.Receive(oBuffer);
                CommnicationMessage.GPSTrackingMessage oMessage = (CommnicationMessage.GPSTrackingMessage)CommnicationMessage.ObjectSerialize.DeserializeBytesToObject(oBuffer, iMessageLength, CommnicationMessage.ObjectSerialize.SeralizeFormatType.BinaryFormat);

                if (GlobeVariables.MessagesCache.ContainsKey(oMessage.CarNumber))
                {
                    GlobeVariables.MessagesCache.Remove(oMessage.CarNumber);
                }

                GlobeVariables.MessagesCache.Add(oMessage.CarNumber, oMessage);
            }while (true);
        }
Exemple #8
0
 public MessageArguments(CommnicationMessage.GPSTrackingMessage message)
 {
     this._message = message;
 }
Exemple #9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="message"></param>
 public MessageArguments(CommnicationMessage.GPSTrackingMessage message)
 {
     this._message = message;
 }