示例#1
0
        /// <summary>
        /// 提交坐标数据
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="requestMethod">Post/Get</param>
        /// <param name="connectTimeout">连接时限</param>
        /// <param name="readWriteTimeout">读取时限</param>
        /// <returns></returns>
        public static string SubmitPos(PostionDto dto, string requestMethod = "Post", int connectTimeout = 20000, int readWriteTimeout = 20000)
        {
            var data = new Dictionary <string, string> {
                { "Sim", dto.Sim }, { "Latitude", dto.Latitude }, { "Longitude", dto.Longitude }, { "Direction", dto.Direction }, { "Speed", dto.Speed }, { "Time", dto.Time }, { "Status", dto.Status }
            };
            var dataBytes = _ConvertKeyValuePairToBytes(data);
            var result    = Send(Config.ServerUrl + "DataReceiver/Index", new Dictionary <string, string>(), dataBytes, requestMethod, connectTimeout, readWriteTimeout);

            return(GetContentString(result, Encoding.UTF8));
        }
示例#2
0
 private void SaveMsg(Message message, Express.IServer server, Express.ChannelReceiveEventArgs e, IProtocolBuffer protocolbuffer)
 {
     //SaveLogsService.WriteLog("Body类名 : " + message.Packet);
     if (message.Body is ClientRegister)
     {
         var msg = message.GetBody <ClientRegister>();
         SaveLogsService.WriteLog("省ID : " + msg.Province);
         SaveLogsService.WriteLog("市县区ID : " + msg.City);
         SaveLogsService.WriteLog("Color : " + msg.Color);
         SaveLogsService.WriteLog("终端ID : " + msg.DeviceID);
         SaveLogsService.WriteLog("终端型号 : " + msg.DeviceNo);
         SaveLogsService.WriteLog("制造商 : " + msg.Provider);
         SaveLogsService.WriteLog("车辆颜色 : " + msg.Color);
         SendBackToReg(message, server, e, protocolbuffer);
     }
     else if (message.Body is ClientSignature)
     {
         var msg = message.GetBody <ClientSignature>();
         SaveLogsService.WriteLog("Signature : " + msg.Signature);
         SendBackToReg(message, server, e, protocolbuffer, 1);
     }
     else if (message.Body is ClientResponse)
     {
         var msg = message.GetBody <ClientResponse>();
         SaveLogsService.WriteLog("BussinessNO : " + msg.BussinessNO);
         SaveLogsService.WriteLog("ResultID : " + msg.ResultID);
         SaveLogsService.WriteLog("BussinessNO : " + msg.Result);
         SendBackToReg(message, server, e, protocolbuffer, 1);
     }
     else if (message.Body is ClientPostion) //坐标上报
     {
         var postion = message.GetBody <ClientPostion>();
         SaveLogsService.WriteLog("ID : " + message.ID);
         SaveLogsService.WriteLog("SIM : " + message.SIM);
         SaveLogsService.WriteLog("Latitude : " + postion.Latitude);
         SaveLogsService.WriteLog("Longitude : " + postion.Longitude);
         SaveLogsService.WriteLog("speed : " + postion.Speed);
         SaveLogsService.WriteLog("Time : " + postion.Time.ToString("yyyy-MM-dd HH:mm:ss"));
         SaveLogsService.WriteLog("Status : " + (postion.Status.ACC ? "启动" : "关闭"));
         var dto = new PostionDto
         {
             Sim       = message.SIM,
             Latitude  = postion.Latitude.ToString(),
             Longitude = postion.Longitude.ToString(),
             Direction = postion.Direction.ToString(),
             Speed     = postion.Speed.ToString(),
             Time      = postion.Time.ToString("yyyy-MM-dd HH:mm:ss"),
             Status    = postion.Status.ACC.ToString()
         };
         var result = SendPosToServer.SubmitPos(dto);
         if (result != "0")
         {
             SaveLogsService.WriteLog("Upload : " + result);
         }
         SendBackToReg(message, server, e, protocolbuffer, 1);
     }
     else
     {
         //SendBackToReg(message, server, e, protocolbuffer, 1);
     }
 }