示例#1
0
        /// <summary>
        /// Retrieves a list of flight Trechos
        /// </summary>
        /// <param name="route2">class UberAir</param>
        /// <param name="route1">class UberAir </param>
        /// <param name="uberFlightD">class UberAir </param>
        /// <returns>Return with List of flight Trechos</returns>
        internal List <Trechos> FillStretchUberPlanes(UberAir route2, UberAir route1, UberAir uberFlightD)
        {
            Logger?.LogDebug("'{0}' has been invoked", nameof(FillStretchUberPlanes));

            Trechos        trechos;
            List <Trechos> listTrechos;

            try
            {
                listTrechos = new List <Trechos>();
                if (route2 != null)
                {
                    trechos           = new Trechos();
                    trechos.origem    = route2.aeroporto_origem;
                    trechos.destino   = route2.aeroporto_destino;
                    trechos.saida     = route2.data.AddTicks(route2.horario_saida.Ticks);
                    trechos.chegada   = route2.data.AddTicks(route2.horario_chegada.Ticks);
                    trechos.operadora = "UberAir";
                    trechos.preco     = route2.preco;
                    listTrechos.Add(trechos);
                }

                if (route1 != null)
                {
                    trechos           = new Trechos();
                    trechos.origem    = route1.aeroporto_origem;
                    trechos.destino   = route1.aeroporto_destino;
                    trechos.saida     = route1.data.AddTicks(route1.horario_saida.Ticks);
                    trechos.chegada   = route1.data.AddTicks(route1.horario_chegada.Ticks);
                    trechos.operadora = "UberAir";
                    trechos.preco     = route1.preco;
                    listTrechos.Add(trechos);
                }

                if (uberFlightD != null)
                {
                    trechos           = new Trechos();
                    trechos.origem    = uberFlightD.aeroporto_origem;
                    trechos.destino   = uberFlightD.aeroporto_destino;
                    trechos.saida     = uberFlightD.data.AddTicks(uberFlightD.horario_saida.Ticks);
                    trechos.chegada   = uberFlightD.data.AddTicks(uberFlightD.horario_chegada.Ticks);
                    trechos.operadora = "UberAir";
                    trechos.preco     = uberFlightD.preco;
                    listTrechos.Add(trechos);
                }

                return(listTrechos);
            }
            catch (Exception ex)
            {
                Logger?.LogCritical("There was an error on '{0}' invocation: {1}", nameof(FillStretchUberPlanes), ex.Message);
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// Retrieves a list of UberAir flight
        /// </summary>
        /// <returns>Return with List of UberAir Flights</returns>
        internal List <UberAir> ReadUberAir()
        {
            Logger?.LogDebug("'{0}' has been invoked", nameof(ReadUberAir));

            List <UberAir> ListUberAir = new List <UberAir>();

            try
            {
                //read csv file
                var lines = System.IO.File.ReadAllLines(@".\\Files\\uberair.csv");
                int count = 0;

                //get line by line
                foreach (var line in lines)
                {
                    //put line in and array
                    string[] words = line.Split(',');

                    //jump frist line name of collumn
                    if (count == 0)
                    {
                        count++;
                        continue;
                    }

                    UberAir uberItem = new UberAir();

                    uberItem.numero_voo        = words[0].ToString();
                    uberItem.aeroporto_origem  = words[1].ToString();
                    uberItem.aeroporto_destino = words[2].ToString();
                    uberItem.data            = Convert.ToDateTime(words[3].ToString());
                    uberItem.horario_saida   = TimeSpan.Parse(words[4].ToString());
                    uberItem.horario_chegada = TimeSpan.Parse(words[5].ToString());
                    uberItem.preco           = Decimal.Parse(words[6]);

                    ListUberAir.Add(uberItem);

                    count++;
                }

                return(ListUberAir);
            }
            catch (Exception ex)
            {
                Logger?.LogCritical("There was an error on '{0}' invocation: {1}", nameof(ReadUberAir), ex.Message);
                return(null);
            }
        }