private void FromBytesToFormatoPainelCfg(byte[] dados) { unsafe { fixed(byte *pSrc = dados) { FormatoRoteiros *roteiros = (FormatoRoteiros *)pSrc; this.versao = roteiros->versao; this.reservado = roteiros->reservado; this.id = roteiros->id; this.tarifa = roteiros->tarifa; // valor da tarifa multiplicado por 100 ex:11,22 é salvo como 1122 this.labelNumero = ArrayLDX2.ByteArrayToString(roteiros->labelNumero, 20); this.labelRoteiro = ArrayLDX2.ByteArrayToString(roteiros->labelRoteiro, 16); this.labelRoteiroVolta = ArrayLDX2.ByteArrayToString(roteiros->labelRoteiroVolta, 16); for (int i = 0; i < 2; i++) { this.reservado2[i] = roteiros->reservado2[i]; } this.crc = roteiros->crc; } } }
public void GerarFormatoNovo(string arquivoNome, string diretorioRaiz) { FileStream fs = File.OpenRead(arquivoNome + Util.Util.sequencial_arquivo_mensagens.ToString("X8") + Util.Util.ARQUIVO_EXT_MPT); byte[] dados = new byte[(int)fs.Length]; fs.Read(dados, 0, dados.Length); fs.Close(); unsafe { fixed(byte *pSrc = dados) { FormatoMensagemPaths *mensagemPaths = (FormatoMensagemPaths *)pSrc; this.versao = mensagemPaths->versao; this.reservado = mensagemPaths->reservado; this.idMensagem = mensagemPaths->idMensagem; for (int i = 0; i < 58; i++) { this.reservado2[i] = mensagemPaths->reservado2[i]; } this.crc = mensagemPaths->crc; this.pathVideo = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(mensagemPaths->pathVideo, 64)); } //fs = File.OpenRead(diretorioRaiz + this.pathVideo); fs = File.OpenRead(this.pathVideo); byte[] dadosVideo = new byte[(int)fs.Length]; fs.Read(dadosVideo, 0, dadosVideo.Length); fs.Close(); Array.Resize(ref dados, (dados.Length - 64) + dadosVideo.Length); Array.Copy(dadosVideo, 0, dados, 64, dadosVideo.Length); fixed(byte *pSrc = dados) { FormatoMensagemPaths *mensagemPaths = (FormatoMensagemPaths *)pSrc; mensagemPaths->crc = CalcularCRC(dados); } fs = File.Create(arquivoNome + Util.Util.sequencial_arquivo_mensagens.ToString("X8") + Util.Util.ARQUIVO_EXT_MPT); fs.Write(dados, 0, dados.Length); fs.Close(); } }
private void FromBytesToFormatoPainelCfg(byte[] dados) { unsafe { fixed(byte *pSrc = dados) { FormatoMotoristas *roteiros = (FormatoMotoristas *)pSrc; this.versao = roteiros->versao; this.id = roteiros->id; this.labelIdentificacao = ArrayLDX2.ByteArrayToString(roteiros->labelIdentificacao, 20); this.labelNome = ArrayLDX2.ByteArrayToString(roteiros->labelNome, 20); this.crc = roteiros->crc; } } }
private void FromBytesToFormatoPainelCfg(byte[] dados) { unsafe { fixed(byte *pSrc = dados) { FormatoMensagemPaths *mensagemPaths = (FormatoMensagemPaths *)pSrc; this.versao = mensagemPaths->versao; this.reservado = mensagemPaths->reservado; this.idMensagem = mensagemPaths->idMensagem; for (int i = 0; i < 58; i++) { this.reservado2[i] = mensagemPaths->reservado2[i]; } this.crc = mensagemPaths->crc; this.pathVideo = ArrayLDX2.ByteArrayToString(mensagemPaths->pathVideo, 64); } } }
private void FromBytesToFormatoPainelCfg(byte[] dados) { unsafe { fixed(byte *pSrc = dados) { FormatoMensagem *mensagem = (FormatoMensagem *)pSrc; this.versao = mensagem->versao; this.reservado = mensagem->reservado; this.id = mensagem->id; this.labelMensagem = ArrayLDX2.ByteArrayToString(mensagem->labelMensagem, 20); for (int i = 0; i < 38; i++) { this.reservado2[i] = mensagem->reservado2[i]; } this.crc = mensagem->crc; } } }
private void FromBytesToFormatoPainelCfg(byte[] dados) { unsafe { fixed(byte *pSrc = dados) { FormatoListaArquivos *listaArquivos = (FormatoListaArquivos *)pSrc; Byte[] temporario = new byte[listaArquivos->qtdArquivos]; this.versao = listaArquivos->versao; this.qtdArquivos = listaArquivos->qtdArquivos; this.crc = listaArquivos->crc; for (int i = 0; i < this.qtdArquivos; i++) { this.listaPaths.Add(string.Empty); this.listaPaths[i] = ArrayLDX2.ByteArrayToString(pSrc + sizeof(FormatoListaArquivos) + (i * Util.Util.ARQUIVO_LST_PATH_SIZE), Util.Util.ARQUIVO_LST_PATH_SIZE); } } } }
private void FromBytesToFormatoPainelCfg(byte[] dados) { unsafe { fixed(byte *pSrc = dados) { FormatoRoteiroPaths *roteiroPaths = (FormatoRoteiroPaths *)pSrc; this.versao = roteiroPaths->versao; this.reservado = roteiroPaths->reservado; this.idRoteiro = roteiroPaths->idRoteiro; for (int i = 0; i < 58; i++) { this.reservado2[i] = roteiroPaths->reservado2[i]; } this.crc = roteiroPaths->crc; this.pathExibicaoIda = ArrayLDX2.ByteArrayToString(roteiroPaths->pathExibicaoIda, 64); this.pathExibicaoVolta = ArrayLDX2.ByteArrayToString(roteiroPaths->pathExibicaoVolta, 64); this.pathNumeroRoteiro = ArrayLDX2.ByteArrayToString(roteiroPaths->pathNumeroRoteiro, 64); } } }
public void GerarFormatoNovo(string arquivoNome, string diretorioRaiz) { UInt32 offsetId = 0; UInt32 offsetNome = 0; FileStream fs = File.OpenRead(arquivoNome + Util.Util.sequencial_arquivo_motoristas.ToString("X8") + Util.Util.ARQUIVO_EXT_DPT); byte[] dados = new byte[(int)fs.Length]; fs.Read(dados, 0, dados.Length); fs.Close(); unsafe { fixed(byte *pSrc = dados) { FormatoMotoristaPaths *motoristaPaths = (FormatoMotoristaPaths *)pSrc; this.versao = motoristaPaths->versao; this.idMotorista = motoristaPaths->idMotorista; this.crc = motoristaPaths->crc; this.pathExibicaoID = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(motoristaPaths->pathExibicaoId, 64)); this.pathExibicaoNome = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(motoristaPaths->pathExibicaoNome, 64)); } if (this.pathExibicaoID.Contains(":")) { fs = File.OpenRead(this.pathExibicaoID); } else { fs = File.OpenRead(diretorioRaiz + this.pathExibicaoID); } byte[] dadosVideoId = new byte[(int)fs.Length]; fs.Read(dadosVideoId, 0, dadosVideoId.Length); fs.Close(); offsetId = 64; Array.Resize(ref dados, (dados.Length - (2 * 64)) + dadosVideoId.Length); Array.Copy(dadosVideoId, 0, dados, offsetId, dadosVideoId.Length); if (this.pathExibicaoNome.Contains(":")) { fs = File.OpenRead(this.pathExibicaoNome); } else { fs = File.OpenRead(diretorioRaiz + this.pathExibicaoNome); } byte[] dadosVideoNome = new byte[(int)fs.Length]; fs.Read(dadosVideoNome, 0, dadosVideoNome.Length); fs.Close(); offsetNome = (UInt32)(offsetId + dadosVideoId.Length); Array.Resize(ref dados, dados.Length + dadosVideoNome.Length); Array.Copy(dadosVideoNome, 0, dados, offsetNome, dadosVideoNome.Length); BitConverter.GetBytes(offsetId).CopyTo(dados, 4); BitConverter.GetBytes(offsetNome).CopyTo(dados, 8); fixed(byte *pSrc = dados) { FormatoMotoristaPaths *motoristaPaths = (FormatoMotoristaPaths *)pSrc; motoristaPaths->crc = CalcularCRC(dados); BitConverter.GetBytes(motoristaPaths->crc).CopyTo(dados, Util.Util.CRCPosition1); } fs = File.Create(arquivoNome + Util.Util.sequencial_arquivo_motoristas.ToString("X8") + Util.Util.ARQUIVO_EXT_DPT); fs.Write(dados, 0, dados.Length); fs.Close(); } }
public void GerarFormatoNovo(string arquivoNome, string diretorioRaiz) { UInt32 offsetIda = 0; UInt32 offsetVolta = 0; UInt32 offsetNumero = 0; FileStream fs = File.OpenRead(arquivoNome + Util.Util.sequencial_arquivo_roteiros.ToString("X8") + Util.Util.ARQUIVO_EXT_RPT); byte[] dados = new byte[(int)fs.Length]; fs.Read(dados, 0, dados.Length); fs.Close(); unsafe { fixed(byte *pSrc = dados) { FormatoRoteiroPaths *roteiroPaths = (FormatoRoteiroPaths *)pSrc; this.versao = roteiroPaths->versao; this.reservado = roteiroPaths->reservado; this.idRoteiro = roteiroPaths->idRoteiro; for (int i = 0; i < 58; i++) { this.reservado2[i] = roteiroPaths->reservado2[i]; } this.crc = roteiroPaths->crc; this.pathExibicaoIda = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(roteiroPaths->pathExibicaoIda, 64)); this.pathExibicaoVolta = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(roteiroPaths->pathExibicaoVolta, 64)); this.pathNumeroRoteiro = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(roteiroPaths->pathNumeroRoteiro, 64)); } if (this.pathExibicaoIda.Contains(":")) { fs = File.OpenRead(this.pathExibicaoIda); } else { fs = File.OpenRead(diretorioRaiz + this.pathExibicaoIda); } byte[] dadosVideoIda = new byte[(int)fs.Length]; fs.Read(dadosVideoIda, 0, dadosVideoIda.Length); fs.Close(); offsetIda = 64; Array.Resize(ref dados, (dados.Length - (3 * 64)) + dadosVideoIda.Length); Array.Copy(dadosVideoIda, 0, dados, offsetIda, dadosVideoIda.Length); if (this.pathExibicaoVolta.Contains(":")) { fs = File.OpenRead(this.pathExibicaoVolta); } else { fs = File.OpenRead(diretorioRaiz + this.pathExibicaoVolta); } byte[] dadosVideoVolta = new byte[(int)fs.Length]; fs.Read(dadosVideoVolta, 0, dadosVideoVolta.Length); fs.Close(); offsetVolta = (UInt32)(offsetIda + dadosVideoIda.Length); Array.Resize(ref dados, dados.Length + dadosVideoVolta.Length); Array.Copy(dadosVideoVolta, 0, dados, offsetVolta, dadosVideoVolta.Length); if (this.pathNumeroRoteiro.Contains(":")) { fs = File.OpenRead(this.pathNumeroRoteiro); } else { fs = File.OpenRead(diretorioRaiz + this.pathNumeroRoteiro); } byte[] dadosVideoNumero = new byte[(int)fs.Length]; fs.Read(dadosVideoNumero, 0, dadosVideoNumero.Length); fs.Close(); offsetNumero = (UInt32)(offsetVolta + dadosVideoVolta.Length); Array.Resize(ref dados, dados.Length + dadosVideoNumero.Length); Array.Copy(dadosVideoNumero, 0, dados, offsetNumero, dadosVideoNumero.Length); BitConverter.GetBytes(offsetIda).CopyTo(dados, 4); BitConverter.GetBytes(offsetVolta).CopyTo(dados, 8); BitConverter.GetBytes(offsetNumero).CopyTo(dados, 12); fixed(byte *pSrc = dados) { FormatoRoteiroPaths *roteiroPaths = (FormatoRoteiroPaths *)pSrc; roteiroPaths->crc = CalcularCRC(dados); BitConverter.GetBytes(roteiroPaths->crc).CopyTo(dados, Util.Util.CRCPosition1); } fs = File.Create(arquivoNome + Util.Util.sequencial_arquivo_roteiros.ToString("X8") + Util.Util.ARQUIVO_EXT_RPT); fs.Write(dados, 0, dados.Length); fs.Close(); } }