Ejemplo n.º 1
0
        public void ArquivoTXT(string[] theLines)
        {
            progressBar1.Maximum = theLines.Count();
            progressBar1.Minimum = 0;
            for (int i = 0; i < theLines.Count(); i++)
            {
                progressBar1.Value = i;
                DtoDestino destino = new DtoDestino();
                destino.transportadora = theLines[0];
                if (theLines[i].Contains("NF:"))
                {
                    if (theLines[i].Substring(3).Length > 30)
                    {
                        destino.documento = theLines[i].Substring(3, 30);
                    }
                    else
                    {
                        destino.documento = theLines[i].Substring(3);
                    }
                    destino.nome = theLines[i + 1];
                    model   get             = new model();
                    Boolean existeDocumento = get.getDestinoDocumento(destino.documento, destino.transportadora);
                    if (!existeDocumento)
                    {
                        int    posicao      = theLines[i + 2].IndexOf("-");
                        string bairro       = theLines[i + 2].Substring(posicao + 2);
                        int    posicaofinal = bairro.IndexOf("-");
                        destino.bairro   = bairro.Substring(0, 7);
                        destino.endereco = theLines[i + 2].Replace('-', ',');

                        model      m       = new model();
                        DtoLatLong latlong = m.GetLatLongGoogle(destino.endereco);

                        try
                        {
                            destino.latitude  = double.Parse(latlong.latitude, CultureInfo.InvariantCulture);
                            destino.longitude = double.Parse(latlong.longitude, CultureInfo.InvariantCulture);
                            destino.distancia = Convert.ToDouble(latlong.distancia, CultureInfo.InvariantCulture);
                            destino.duracao   = latlong.duracao;
                        }
                        catch (Exception)
                        {
                            destino.status = "E";
                        }
                        destino.status = "I";
                        model post = new model();
                        post.set(destino);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public FrmDestino(string valor)
        {
            InitializeComponent();
            model      get = new model();
            DtoDestino d   = get.getDestinoDocumento(valor);

            textBoxID.Text             = d.id.ToString();
            textBoxNome.Text           = d.nome;
            textBoxDocumento.Text      = d.documento;
            textBoxEndereco.Text       = d.endereco;
            textBoxLatitude.Text       = d.latitude.ToString();
            textBoxLongitude.Text      = d.longitude.ToString();
            textBoxTransportadora.Text = d.transportadora;
            textBoxBairro.Text         = d.bairro;
        }
Ejemplo n.º 3
0
        private void Jadlog(string[] theLines)
        {
            try
            {
                progressBar1.Maximum = theLines.Count();
                progressBar1.Minimum = 0;

                for (int i = 0; i < theLines.Count(); i++)
                {
                    progressBar1.Value = i;
                    if (theLines[i].Contains("Nome") && theLines[i].Contains("Cep"))
                    {
                        DtoDestino destino = new DtoDestino();
                        destino.transportadora = "JADLOG";
                        if (theLines[i].Contains("NomeNome"))
                        {
                            destino.documento = theLines[i].Substring(9, 14);
                        }
                        else
                        {
                            destino.documento = theLines[i].Substring(5, 14);
                        }
                        model   get             = new model();
                        Boolean existeDocumento = get.getDestinoDocumento(destino.documento, destino.transportadora);

                        if (!existeDocumento)
                        {
                            destino.nome = theLines[i + 1].Substring(0, 29);
                            int posicao       = theLines[i + 1].IndexOf("-");
                            int posicaobairro = (theLines[i - 1].IndexOf("-")) + 1;

                            string bairro = theLines[i - 1].Substring(posicaobairro);
                            destino.bairro   = bairro;
                            destino.endereco = theLines[i + 1].Substring(posicao + 1).Replace('/', ',') + "," + bairro + ",Toledo, PR";

                            model      m       = new model();
                            DtoLatLong latlong = m.GetLatLongGoogle(destino.endereco);

                            try
                            {
                                destino.latitude  = double.Parse(latlong.latitude, CultureInfo.InvariantCulture);
                                destino.longitude = double.Parse(latlong.longitude, CultureInfo.InvariantCulture);
                                destino.distancia = Convert.ToDouble(latlong.distancia, CultureInfo.InvariantCulture);
                                destino.duracao   = latlong.duracao;
                            }
                            catch (Exception)
                            {
                                destino.status = "E";
                            }
                            destino.status = "I";
                            model post = new model();
                            post.set(destino);
                        }
                    }
                }
                CarregarDestinos();
                progressBar1.Visible = false;
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 4
0
        private void TotalExpress(string[] theLines)
        {
            try
            {
                progressBar1.Maximum = theLines.Count();
                progressBar1.Minimum = 0;
                int linha = 0;
                foreach (var l in theLines)
                {
                    linha++;
                    progressBar1.Value = linha;
                    if (linha >= 15 && linha < 48)
                    {
                        string     theLine = l.ToLower();
                        DtoDestino destino = new DtoDestino();
                        destino.transportadora = "TotalExpress";

                        string nrLinha = theLine.Substring(0, 2);
                        if (nrLinha.Trim().Length == 1)
                        {
                            destino.documento = theLine.Substring(20, 9);
                            destino.nome      = theLine.Substring(35);
                            int posicao = theLine.IndexOf("/") + 2;
                            if (theLine.Substring(posicao).Length > 30)
                            {
                                destino.bairro = theLine.Substring(posicao, 30).ToUpper();
                            }
                            else
                            {
                                destino.bairro = theLine.Substring(posicao).ToUpper();
                            }

                            model   get             = new model();
                            Boolean existeDocumento = get.getDestinoDocumento(destino.documento, destino.transportadora);

                            if (!existeDocumento)
                            {
                                if (theLine.Contains("avenida"))
                                {
                                    int posicaoAvenia = theLine.IndexOf("avenida");
                                    destino.endereco = theLine.Substring(posicaoAvenia).Replace('/', ',') + ",Toledo, PR";
                                }
                                else
                                if (theLine.Contains("rua"))
                                {
                                    int posicaoRua = theLine.IndexOf("rua");
                                    destino.endereco = theLine.Substring(posicaoRua).Replace('/', ',') + ",Toledo, PR";
                                }
                                else
                                {
                                    destino.endereco = theLine.Substring(61).Replace('/', ',') + ",Toledo, PR";
                                }
                                try
                                {
                                    model      getlatlng = new model();
                                    DtoLatLong latlong   = getlatlng.GetLatLongGoogle(destino.endereco);
                                    destino.latitude  = Convert.ToDouble(latlong.latitude, CultureInfo.InvariantCulture);
                                    destino.longitude = Convert.ToDouble(latlong.longitude, CultureInfo.InvariantCulture);
                                    destino.distancia = Convert.ToDouble(latlong.distancia, CultureInfo.InvariantCulture);
                                    destino.duracao   = latlong.duracao;
                                }
                                catch (Exception ex)
                                {
                                    destino.status = "E";
                                }
                            }
                        }
                        else
                        {
                            destino.documento = theLine.Substring(20, 9);
                            destino.nome      = theLine.Substring(36);
                            int posicao = theLine.IndexOf("/") + 2;
                            if (theLine.Substring(posicao).Length > 30)
                            {
                                destino.bairro = theLine.Substring(posicao, 30).ToUpper();
                            }

                            destino.documento = theLine.Substring(20, 9);
                            model   get             = new model();
                            Boolean existeDocumento = get.getDestinoDocumento(destino.documento, destino.transportadora);

                            if (!existeDocumento)
                            {
                                if (theLine.Contains("avenida"))
                                {
                                    int posicaoAvenia = theLine.IndexOf("avenida");
                                    destino.endereco = theLine.Substring(posicaoAvenia).Replace('/', ',') + ",Toledo, PR";
                                }
                                else
                                if (theLine.Contains("rua"))
                                {
                                    int posicaoRua = theLine.IndexOf("rua");
                                    destino.endereco = theLine.Substring(posicaoRua).Replace('/', ',') + ",Toledo, PR";
                                }
                                else if (theLine.Contains("rodovia"))
                                {
                                    int posicaoRua = theLine.IndexOf("rodovia");
                                    destino.endereco = theLine.Substring(posicaoRua).Replace('/', ',') + ",Toledo, PR";
                                }
                                else
                                {
                                    destino.endereco = theLine.Substring(61).Replace('/', ',') + ",Toledo, PR";
                                }
                                try
                                {
                                    model      getlatlng = new model();
                                    DtoLatLong latlong   = getlatlng.GetLatLongGoogle(destino.endereco);
                                    destino.latitude  = Convert.ToDouble(latlong.latitude, CultureInfo.InvariantCulture);
                                    destino.longitude = Convert.ToDouble(latlong.longitude, CultureInfo.InvariantCulture);
                                    destino.distancia = Convert.ToDouble(latlong.distancia, CultureInfo.InvariantCulture);
                                    destino.duracao   = latlong.duracao;
                                }
                                catch (Exception)
                                {
                                    destino.status = "E";
                                }
                            }
                        }

                        destino.status = "I";
                        model post = new model();
                        post.set(destino);
                    }
                }
                CarregarDestinos();
                progressBar1.Visible = false;
            }
            catch (Exception ex)
            {
                throw ex;;
            }
        }
Ejemplo n.º 5
0
        private void DIALOGO(string[] theLines)
        {
            try
            {
                progressBar1.Maximum = theLines.Count();
                progressBar1.Minimum = 0;
                for (int i = 0; i < theLines.Count(); i++)
                {
                    progressBar1.Value = i;
                    if (i >= 19)
                    {
                        DtoDestino destino = new DtoDestino();
                        destino.transportadora = "DIALOGO";
                        destino.documento      = Regex.Match(theLines[i].Substring(11, 9), @"\d+").Value;

                        if (theLines[i + 1].Contains("CENTRO"))
                        {
                            destino.bairro = "CENTRO";
                        }
                        else
                        if (theLines[i + 1].Contains("VILA INDUSTRIAL"))
                        {
                            destino.bairro = "VILA INDUSTRIAL";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PORTO ALEGRE"))
                        {
                            destino.bairro = "JARDIM PORTO ALEGRE";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM POR"))
                        {
                            destino.bairro = "JARDIM PORTO ALEGRE";
                        }
                        else
                        if (theLines[i + 1].Contains("JD PTO ALEGRE"))
                        {
                            destino.bairro = "JARDIM PORTO ALEGRE";
                        }
                        else
                        if (theLines[i + 1].Contains("JD PORTO ALEGRE"))
                        {
                            destino.bairro = "JARDIM PORTO ALEGRE";
                        }
                        else
                        if (theLines[i + 1].Contains("SANTA CLARA 4"))
                        {
                            destino.bairro = "SANTA CLARA IV";
                        }
                        else
                        if (theLines[i + 1].Contains("SANTA CLARA IV"))
                        {
                            destino.bairro = "SANTA CLARA IV";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM EUR"))
                        {
                            destino.bairro = "JARDIM EUROPA";
                        }
                        else
                        if (theLines[i + 1].Contains("JD EUROPA"))
                        {
                            destino.bairro = "JARDIM EUROPA";
                        }
                        else
                        if (theLines[i + 1].Contains("VILA PIONEIRO"))
                        {
                            destino.bairro = "VILA PIONEIRO";
                        }
                        else
                        if (theLines[i + 1].Contains("Vila Pioneiro"))
                        {
                            destino.bairro = "VILA PIONEIRO";
                        }
                        else
                        if (theLines[i + 1].Contains("VILA PIONE"))
                        {
                            destino.bairro = "VILA PIONEIRO";
                        }
                        else
                        if (theLines[i + 1].Contains("VL PIONEIRO"))
                        {
                            destino.bairro = "VILA PIONEIRO";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PAULISTA"))
                        {
                            destino.bairro = "JARDIM PAULISTA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PAU"))
                        {
                            destino.bairro = "JARDIM PAULISTA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PANORAMA"))
                        {
                            destino.bairro = "JARDIM PANORAMA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PAN"))
                        {
                            destino.bairro = "JARDIM PANORAMA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM BRESSAN"))
                        {
                            destino.bairro = "JARDIM BRESSAN";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM BRE"))
                        {
                            destino.bairro = "JARDIM BRESSAN";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM PARIZZOTTO"))
                        {
                            destino.bairro = "JARDIM PARIZZOTTO";
                        }
                        else
                        if (theLines[i + 1].Contains("SAO FRANCISCO"))
                        {
                            destino.bairro = "SAO FRANCISCO";
                        }
                        else
                        if (theLines[i + 1].Contains("SAO FRANCI"))
                        {
                            destino.bairro = "SAO FRANCISCO";
                        }
                        else
                        if (theLines[i + 1].Contains("BOA ESPERANCA"))
                        {
                            destino.bairro = "BOA ESPERANCA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM CONCORDIA"))
                        {
                            destino.bairro = "JARDIM CONCORDIA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM CON"))
                        {
                            destino.bairro = "JARDIM CONCORDIA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM COOPAGRO"))
                        {
                            destino.bairro = "JARDIM COOPAGRO";
                        }
                        else
                        if (theLines[i + 1].Contains("MARACANA"))
                        {
                            destino.bairro = "MARACANA";
                        }
                        else
                        if (theLines[i + 1].Contains("INDEPENDENCIA"))
                        {
                            destino.bairro = "INDEPENDENCIA";
                        }
                        else
                        if (theLines[i + 1].Contains("VILA OPERARIA"))
                        {
                            destino.bairro = "VILA OPERARIA";
                        }
                        else
                        if (theLines[i + 1].Contains("JARDIM GISELA"))
                        {
                            destino.bairro = "JARDIM GISELA";
                        }
                        else
                        if (theLines[i + 1].Contains("VILA NOVA"))
                        {
                            destino.bairro = "VILA NOVA";
                        }
                        else
                        {
                            destino.bairro = "Não encontrado";
                        }

                        model   get             = new model();
                        Boolean existeDocumento = get.getDestinoDocumento(destino.documento, destino.transportadora);

                        if (!existeDocumento)
                        {
                            if (theLines[i + 1].Contains("-"))
                            {
                                int posicao = theLines[i + 1].IndexOf("-") + 3;
                                destino.nome = theLines[i + 1].Substring(posicao, 25);
                            }
                            else
                            {
                                destino.nome = theLines[i + 1].Substring(0, 30);
                            }
                            int posicaoDacte = theLines[i + 2].IndexOf("DACTE") - 5;
                            destino.endereco = theLines[i + 2].Substring(3, posicaoDacte).Replace('/', ',') + ",Toledo, PR";

                            try
                            {
                                model      m       = new model();
                                DtoLatLong latlong = m.GetLatLongGoogle(destino.endereco);
                                destino.latitude  = Convert.ToDouble(latlong.latitude, CultureInfo.InvariantCulture);
                                destino.longitude = Convert.ToDouble(latlong.longitude, CultureInfo.InvariantCulture);
                                destino.distancia = Convert.ToDouble(latlong.distancia, CultureInfo.InvariantCulture);
                                destino.duracao   = latlong.duracao;
                            }
                            catch (Exception)
                            {
                                destino.status = "E";
                            }
                            destino.status = "I";
                            model post = new model();
                            post.set(destino);
                            i++;
                        }
                        i++;
                    }
                }
                CarregarDestinos();
                progressBar1.Visible = false;
            }
            catch (Exception ex)
            { }
        }