Пример #1
0
        public void CalcularMelhorVoltaDeCadaPiloto(Dictionary <int, DadosCorridaPiloto> pDadosVoltaPilotos)
        {
            var melhorVoltaByPilotoRelatorio = new StringBuilder();

            var formatString = "|{0,-35}|{1,-35}|{2,-35}|";

            melhorVoltaByPilotoRelatorio.AppendLine()
            .AppendFormat(Culture, formatString, "Código Piloto", "Nome Piloto", "Melhor Volta")
            .AppendLine();

            string primeiraLinha = CriarLinhaFormatadoraColunasTabelas(melhorVoltaByPilotoRelatorio);

            melhorVoltaByPilotoRelatorio.Insert(0, primeiraLinha);
            melhorVoltaByPilotoRelatorio.Append(primeiraLinha).AppendLine();

            // constrói  relatório da melhor Volta De Cada Piloto
            pDadosVoltaPilotos.ToList().ForEach(elem =>
            {
                int codigoPiloto     = elem.Key;
                String nomePiloto    = elem.Value.Piloto.NomePiloto;
                TimeSpan melhorVolta = elem.Value.MelhorVolta;

                melhorVoltaByPilotoRelatorio.AppendFormat(Culture, formatString, codigoPiloto.ToString("D4"), nomePiloto, melhorVolta.ToString(@"hh\:mm\:ss\:fff")).AppendLine();
            });

            //acrescenta no relatório Final título como: [ MELHOR VOLTA POR PILOTO ]
            RelatorioFinal.AppendLine().AppendLine().Append("-> [ MELHOR VOLTA POR PILOTO ]").AppendLine().AppendLine();
            //append no relatório Final dados sobre MELHOR VOLTA POR PILOTO
            RelatorioFinal.Append(melhorVoltaByPilotoRelatorio.ToString());
        }
Пример #2
0
        public void CalcularMelhorVoltaDaCorrida(Dictionary <int, DadosCorridaPiloto> pDadosVoltaPilotos)
        {
            StringBuilder melhorVoltaDaCorrida = new StringBuilder();

            var formatString = "|{0,-35}|{1,-35}|{2,-35}|";

            melhorVoltaDaCorrida.AppendLine()
            .AppendFormat(Culture, formatString, "Código Piloto", "Nome Piloto", "Tempo da Volta")
            .AppendLine();

            String primeiraLinha = CriarLinhaFormatadoraColunasTabelas(melhorVoltaDaCorrida);

            melhorVoltaDaCorrida.Insert(0, primeiraLinha);
            melhorVoltaDaCorrida.Append(primeiraLinha).AppendLine();


            //hashmap que sera retornado. OBS é um LinkedHashMap pois ele sempre preserva a ordem de insercão
            //pilotos ordenados pelo menor tempo de volta
            var pilotosOrdenadosByMenorTempoVolta = new Dictionary <int, DadosCorridaPiloto>();

            //ordena o dicionário pelo menor tempo de volta de cada piloto
            pDadosVoltaPilotos.ToList().OrderBy(x => x.Value.MelhorVolta).ToList()
            .ForEach(x => pilotosOrdenadosByMenorTempoVolta.Add(x.Key, x.Value));

            DadosCorridaPiloto dadosMelhorPiloto = pilotosOrdenadosByMenorTempoVolta.FirstOrDefault().Value;

            int      codigoPiloto = dadosMelhorPiloto.Piloto.Codigo;
            String   nomePiloto   = dadosMelhorPiloto.Piloto.NomePiloto;
            TimeSpan melhorVolta  = dadosMelhorPiloto.MelhorVolta;

            melhorVoltaDaCorrida.AppendFormat(Culture, formatString, codigoPiloto.ToString("D3"), nomePiloto, melhorVolta.ToString(@"hh\:mm\:ss\:fff")).AppendLine();

            //acrescenta no relatorio Final título seção MELHOR VOLTA POR PILOTO
            RelatorioFinal.AppendLine().AppendLine().Append("-> [ MELHOR VOLTA DA CORRIDA ]").AppendLine().AppendLine();
            //append no relatorio Final dados sobre MELHOR VOLTA POR PILOTO
            RelatorioFinal.Append(melhorVoltaDaCorrida.ToString());
        }