public List <SitrackFrame> SitrackModelToFrame(SitrackReceptionModel[] positions) { var frameReport = new StringBuilder(positions.Length + " -> "); var frameList = new List <SitrackFrame>(); foreach (var position in positions) { var sitrackFrame = new SitrackFrame(); sitrackFrame.Course = position.course; sitrackFrame.DeviceId = position.device_id; sitrackFrame.EventDesc = position.event_desc; sitrackFrame.EventId = position.event_id; if (position.holder_domain != null) { sitrackFrame.HolderDomain = position.holder_domain.Replace("*", ""); } sitrackFrame.HolderId = position.holder_id; sitrackFrame.HolderName = position.holder_name; sitrackFrame.Id = position.id; sitrackFrame.Latitude = (float)position.latitude; sitrackFrame.Longitude = (float)position.longitude; sitrackFrame.Location = position.location; sitrackFrame.ReportDate = Convert.ToDateTime(position.reportDate); sitrackFrame.Speed = position.speed; sitrackFrame.InputDate = Convert.ToDateTime(position.reportDate); frameReport.AppendFormat("Course : {0}, ", sitrackFrame.Course); frameReport.AppendFormat("DeviceId : {0}, ", sitrackFrame.DeviceId); frameReport.AppendFormat("EventDesc : {0}, ", sitrackFrame.EventDesc); frameReport.AppendFormat("EventId : {0}, ", sitrackFrame.EventId); frameReport.AppendFormat("HolderDomain : {0}, ", sitrackFrame.HolderDomain); frameReport.AppendFormat("HolderId : {0}, ", sitrackFrame.HolderId); frameReport.AppendFormat("HolderName: {0}, ", sitrackFrame.HolderName); frameReport.AppendFormat("Id : {0}, ", sitrackFrame.Id); frameReport.AppendFormat("Lat: {0}, ", sitrackFrame.Latitude); frameReport.AppendFormat("Lon : {0}, ", sitrackFrame.Longitude); frameReport.AppendFormat("Location : {0}, ", sitrackFrame.Location); frameReport.AppendFormat("ReportDate : {0}, ", sitrackFrame.ReportDate); frameReport.AppendFormat("Speed : {0} ", sitrackFrame.Speed); frameReport.AppendFormat("InputDate : {0} ", sitrackFrame.InputDate); Logger.InfoFormat("[ {0} ]", frameReport); //sitrackFrame.Validity = position.validity; //sitrackFrame.InputDate = position.input_date; frameList.Add(sitrackFrame); } return(frameList); }
private IMessage Translate(SitrackFrame frame) { var deviceId = 0; if (frame.HolderDomain != null) { deviceId = FindDeviceId(frame.HolderDomain); } if (deviceId != 0 && deviceId != -1) { var pos = new GPSPoint { Lat = (float)frame.Latitude, Lon = (float)frame.Longitude, Date = frame.ReportDate.ToUniversalTime(), Speed = new Speed(frame.Speed), Course = new Course(frame.Course) }; if (frame.EventDesc != null) { var dispositivoDao = new DispositivoDAO(); var dispositivo = dispositivoDao.FindById(deviceId); var codeEvent = frame.EventId + 9000; var msgTraduccionDao = new MensajeTraducidoDAO(); var codeEventTraducido = msgTraduccionDao.GetCodigoFinal(dispositivo.Empresa.Id, codeEvent.ToString()); var evento = new Event(Convert.ToInt16(codeEventTraducido), -1, deviceId, (ulong)frame.EventId, pos, pos.GetDate(), "", null, true); return(evento); } var message = pos.ToPosition(deviceId, 0); return(message); } return(null); }