private SI_CUSTO_ADICIONAL_FRETE_OUTRequest ConverterObjetoRequisicaoWS(Integracao integracao)
        {
            int count = 0;
            SI_CUSTO_ADICIONAL_FRETE_OUTRequest objRequest = new SI_CUSTO_ADICIONAL_FRETE_OUTRequest();

            var ocorrenciasWS = new DT_CUSTO_ADICIONAL_FRETE_HBSIS_RequestIntegracaoOcorrencia[integracao.Ocorrencias.Where(x => x.ExibirOcorrenciaNoXml()).Count()];

            foreach (var ocorrencia in integracao.Ocorrencias.Where(x => x.ExibirOcorrenciaNoXml()))
            {
                var ocorrenciaWS = InicializaOcorrencia();

                if (ocorrencia.GetType() == typeof(DivergenciaDiaria))
                {
                    DivergenciaDiariaOcorrenciaWS(ocorrencia, ocorrenciaWS);
                }

                else if (ocorrencia.GetType() == typeof(DivergenciaPernoite))
                {
                    DivergenciaPernoiteOcorrenciaWS(ocorrencia, ocorrenciaWS);
                }

                else if (ocorrencia.GetType() == typeof(DivergenciaKm))
                {
                    DivergenciaKmOcorrenciaWS(ocorrencia, ocorrenciaWS);
                }

                else if (ocorrencia.GetType() == typeof(CustoDescarga))
                {
                    CustoDescargaOcorrenciaWS(ocorrencia, ocorrenciaWS);
                }

                else if (ocorrencia.GetType() == typeof(DevolucaoTransportador))
                {
                    DevolucaoTransportadorOcorrenciaWS(ocorrencia, ocorrenciaWS);
                }

                else if (ocorrencia.GetType() == typeof(DiariaCliente))
                {
                    DIariaClienteOcorrenciaWS(ocorrencia, ocorrenciaWS);
                }

                else if (ocorrencia.GetType() == typeof(Reentrega))
                {
                    ReentregaOcorrenciaWS(ocorrencia, ocorrenciaWS);
                }

                else if (ocorrencia.GetType() == typeof(AdicionalBalsa))
                {
                    AdicionalBalsaOcorrenciaWS(ocorrencia, ocorrenciaWS);
                }

                else if (ocorrencia.GetType() == typeof(AdicionalMeiaPernoite))
                {
                    AdicionalMeiaPernoiteOcorrenciaWS(ocorrencia, ocorrenciaWS);
                }

                ocorrenciasWS[count++] = ocorrenciaWS;
            }

            objRequest.MT_CUSTO_ADICIONAL_FRETE_HBSIS_Request = new DT_CUSTO_ADICIONAL_FRETE_HBSIS_Request()
            {
                Integracao = new DT_CUSTO_ADICIONAL_FRETE_HBSIS_RequestIntegracao()
                {
                    CnpjTransportador = integracao.CnpjTransportador,
                    Data            = integracao.GetDtData(),
                    DataSpecified   = true,
                    CpfMotorista    = integracao.CpfMotorista,
                    MultiTransporte = integracao.MultiTransporte?.NumeroRota?.ConvertAll(x => x.ToString()).ToArray() ?? null,
                    NumeroRota      = integracao.NumeroRota.ToString(),
                    Placa           = integracao.Placa,
                    UnidadeNegocio  = integracao.UnidadeNegocio,
                    Ocorrencias     = ocorrenciasWS
                }
            };

            return(objRequest);
        }
Exemple #2
0
 public void Enviar(SI_CUSTO_ADICIONAL_FRETE_OUTRequest request)
 {
     Wrapper.SendSync(request);
 }