Exemplo n.º 1
0
        public List <PontoEntregaMapa> CoordenadasPontoEntregaOrdem(string NumeroOrdem)
        {
            List <PontoEntregaMapa> coordenadas = new List <PontoEntregaMapa>();

            OrdemDeServico ordem = UnitOfWork.OrdemDeServicoRepository.Get(o => o.NumeroOS == NumeroOrdem, includeProperties: "Cidade").FirstOrDefault();

            Cidade cidade = ordem.Cidade;

            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(cidade.Datum, cidade.NorteOuSul, cidade.Zona);

            List <Poste> postes_ordem = UnitOfWork.PosteRepository.Get(p => p.IdOrdemDeServico == ordem.IdOrdemDeServico && p.DataExclusao == null, includeProperties: "PontoDeEntrega").ToList();

            foreach (Poste poste in postes_ordem)
            {
                foreach (PontoEntrega ponto_entrega in poste.PontoDeEntrega)
                {
                    LatLon LatLonPoste        = converter.Convert(poste.X, poste.Y);
                    LatLon LatLonPontoEntrega = converter.Convert(ponto_entrega.X, ponto_entrega.Y);

                    coordenadas.Add(new PontoEntregaMapa
                    {
                        IdPontoEntrega          = ponto_entrega.IdPontoEntrega.ToString(),
                        ponto_entrega_latitude  = LatLonPontoEntrega.Lat,
                        ponto_entrega_longitude = LatLonPontoEntrega.Lon,
                        poste_latitude          = LatLonPoste.Lat,
                        poste_longitude         = LatLonPoste.Lon,
                        Image = ImagePontoEntrega(ponto_entrega.ClasseSocial)
                    });
                }
            }

            return(coordenadas);
        }
Exemplo n.º 2
0
        public List <PontoEntregaMapa> CoordenadasPontoEntrega(long IdCidade)
        {
            List <PontoEntregaMapa> coordenadas = new List <PontoEntregaMapa>();

            Cidade cidade = UnitOfWork.CidadeRepository.Get(c => c.IdCidade == IdCidade).FirstOrDefault();

            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(cidade.Datum, cidade.NorteOuSul, cidade.Zona);

            List <Poste> postes = UnitOfWork.PosteRepository.Get(p => p.IdCidade == IdCidade && p.DataExclusao == null, includeProperties: "PontoDeEntrega").ToList();

            foreach (Poste poste in postes)
            {
                foreach (PontoEntrega ponto_entrega in poste.PontoDeEntrega)
                {
                    LatLon LatLonPoste        = converter.Convert(poste.X, poste.Y);
                    LatLon LatLonPontoEntrega = converter.Convert(ponto_entrega.X, ponto_entrega.Y);

                    coordenadas.Add(new PontoEntregaMapa {
                        IdPontoEntrega          = ponto_entrega.IdPontoEntrega.ToString(),
                        ponto_entrega_latitude  = LatLonPontoEntrega.Lat,
                        ponto_entrega_longitude = LatLonPontoEntrega.Lon,
                        poste_latitude          = LatLonPoste.Lat,
                        poste_longitude         = LatLonPoste.Lon,
                        Image = ImagePontoEntrega(ponto_entrega.ClasseSocial)
                    });
                }
            }

            return(coordenadas);
        }
Exemplo n.º 3
0
        public List <LimitesCidadeView> LimitesByOS(OrdemDeServico ordem_servico)
        {
            List <LimitesCidadeView> retorno = new List <LimitesCidadeView>();

            if (ordem_servico != null)
            {
                if (ordem_servico.PoligonosOS.Count > 0)
                {
                    foreach (PoligonoOS poligono in ordem_servico.PoligonosOS)
                    {
                        ConverterUtmToLatLon converter = new ConverterUtmToLatLon(ordem_servico.Cidade.Datum, ordem_servico.Cidade.NorteOuSul, ordem_servico.Cidade.Zona);

                        retorno.Add(new LimitesCidadeView
                        {
                            LatitudeA  = converter.Convert(poligono.X1, poligono.Y1).Lat,
                            LongitudeA = converter.Convert(poligono.X1, poligono.Y1).Lon,
                            LatitudeB  = converter.Convert(poligono.X2, poligono.Y2).Lat,
                            LongitudeB = converter.Convert(poligono.X2, poligono.Y2).Lon,
                        });
                    }
                }
            }

            return(retorno);
        }
Exemplo n.º 4
0
        public List <VaoView> VaosToVaosViewByCidade(List <OrdemDeServico> Ordens)
        {
            List <VaoView> retorno = new List <VaoView>();

            foreach (OrdemDeServico os_corrrente in Ordens)
            {
                List <VaoPrimario> VaosOs = UnitOfWork.VaoPrimarioRepository.Get(v => v.IdOrdemDeServico == os_corrrente.IdOrdemDeServico).ToList();

                if (VaosOs != null && VaosOs.Count > 0)
                {
                    foreach (VaoPrimario vao in VaosOs)
                    {
                        ConverterUtmToLatLon converter = new ConverterUtmToLatLon(os_corrrente.Cidade.Datum, os_corrrente.Cidade.NorteOuSul, os_corrrente.Cidade.Zona);

                        retorno.Add(new VaoView
                        {
                            IdVaoPrimario = vao.IdVaoPrimario,
                            LatitudeA     = converter.Convert(vao.X1, vao.Y1).Lat,
                            LongitudeA    = converter.Convert(vao.X1, vao.Y1).Lon,
                            LatitudeB     = converter.Convert(vao.X2, vao.Y2).Lat,
                            LongitudeB    = converter.Convert(vao.X2, vao.Y2).Lon,
                        });
                    }
                }
            }

            return(retorno);
        }
Exemplo n.º 5
0
        public ActionResult GetPontoEntregaById(long idPontoEntrega)
        {
            PontoEntrega     pontoEntrega = UnitOfWork.PontoEntregaRepository.Get(p => p.IdPontoEntrega == idPontoEntrega && p.DataExclusao == null, includeProperties: "Cidade").FirstOrDefault();
            FotoPontoEntrega foto         = UnitOfWork.FotoPontoEntregaRepository.Get(f => f.IdPontoEntrega == idPontoEntrega && f.DataExclusao == null).FirstOrDefault();

            PontoEntregaView pontoEntregaView = new MetodosPontoEntregaView().PontoEntregaToPontoEntregaView(pontoEntrega);

            LatLon LatLong = new ConverterUtmToLatLon(pontoEntrega.Cidade.Datum, pontoEntrega.Cidade.NorteOuSul, pontoEntrega.Cidade.Zona).Convert(pontoEntrega.X, pontoEntrega.Y);

            //Object poste_return = new
            //{
            //    IdPoste = poste.IdPoste,
            //    Latitude = LatLong.Lat,
            //    Longitude = LatLong.Lon,
            //    //Img = poste.Finalizado == true ? "03" : "08",
            //    Img = poste.Finalizado == true ? "10" : "08",
            //    IdCidade = poste.IdCidade,
            //    CodGeo = poste.CodigoGeo,
            //    Altura = poste.Altura,
            //    TipoPoste = poste.TipoPoste,
            //    Esforco = poste.Esforco,
            //    Descricao = poste.Descricao
            //};

            return(Json(pontoEntregaView, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        //
        // GET: /Anotacoes/
        public ActionResult GetAnotacaoByOs(string codOs)
        {
            List <Anotacao> Anotacaos = new List <Anotacao>();
            var             anotacoes = UnitOfWork.AnotacaoRepository.Get(a => a.OrdemDeServico.NumeroOS == codOs && a.DataExclusao == null, includeProperties: "OrdemDeServico, Cidade").ToList();

            foreach (var item in anotacoes)
            {
                if (converter == null)
                {
                    converter = new ConverterUtmToLatLon(item.OrdemDeServico.Cidade.Datum, item.OrdemDeServico.Cidade.NorteOuSul, item.OrdemDeServico.Cidade.Zona);
                }
                if (IdCidade == -1)
                {
                    IdCidade = item.OrdemDeServico.IdCidade;
                }
                if (NomeCidade == string.Empty)
                {
                    NomeCidade = item.OrdemDeServico.Cidade.Nome;
                }

                LatLon LatiLong1 = converter.Convert(item.X, item.Y);
                Anotacaos.Add(new Anotacao()
                {
                    Descricao        = item.Descricao,
                    IdAnotacao       = item.IdAnotacao,
                    IdOrdemDeServico = item.IdOrdemDeServico,
                    X = LatiLong1.Lat,
                    Y = LatiLong1.Lon
                });
            }
            return(Json(new ResponseView()
            {
                Status = Status.OK, Result = Anotacaos
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
        public ActionResult GetQuadrasByCidade(long IdCidade)
        {
            Cidade cidade = UnitOfWork.CidadeRepository.Get(c => c.IdCidade == IdCidade).FirstOrDefault();

            List <Quadra> quadras = UnitOfWork.QuadrasRepository.Get(q => q.IdCidade == IdCidade).ToList();

            List <object> quadrasRetorno = new List <object>();

            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(cidade.Datum, cidade.NorteOuSul, cidade.Zona);

            foreach (Quadra quadraBD in quadras)
            {
                LatLon LatiLongA = converter.Convert(quadraBD.X1, quadraBD.Y1);
                LatLon LatiLongB = converter.Convert(quadraBD.X2, quadraBD.Y2);

                quadrasRetorno.Add(new
                {
                    ID         = quadraBD.ID,
                    LatitudeA  = LatiLongA.Lat,
                    LongitudeA = LatiLongA.Lon,
                    LatitudeB  = LatiLongB.Lat,
                    LongitudeB = LatiLongB.Lon,
                });
            }

            return(Json(new ResponseView()
            {
                Status = Status.OK, Result = quadrasRetorno
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        public ActionResult GetQuadrasByOs(string OrdemServico)
        {
            OrdemDeServico os = UnitOfWork.OrdemDeServicoRepository.Get(o => o.NumeroOS == OrdemServico, includeProperties: "Cidade").FirstOrDefault();

            List <Quadra> quadras = UnitOfWork.QuadrasRepository.Get(q => q.IdOrdemDeServico == os.IdOrdemDeServico).ToList();

            List <object> quadrasRetorno = new List <object>();

            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(os.Cidade.Datum, os.Cidade.NorteOuSul, os.Cidade.Zona);

            foreach (Quadra quadraBD in quadras)
            {
                LatLon LatiLongA = converter.Convert(quadraBD.X1, quadraBD.Y1);
                LatLon LatiLongB = converter.Convert(quadraBD.X2, quadraBD.Y2);

                quadrasRetorno.Add(new
                {
                    ID         = quadraBD.ID,
                    LatitudeA  = LatiLongA.Lat,
                    LongitudeA = LatiLongA.Lon,
                    LatitudeB  = LatiLongB.Lat,
                    LongitudeB = LatiLongB.Lon,
                });
            }

            return(Json(new ResponseView()
            {
                Status = Status.OK, Result = quadrasRetorno
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Método responsável por criar a estrutura de dados necessária para ser
        /// plotado no mapa do Google Maps.
        /// </summary>
        /// <param name="OrdensDaCidade"></param>
        /// <returns></returns>
        public List <OrdemServicoView> GenerateOSObjects(List <OrdemDeServico> OrdensDaCidade)
        {
            if (OrdensDaCidade == null)
            {
                throw new ArgumentException("o paramêtro 'OrdensDaCidade' não ser null.");
            }

            List <OrdemServicoView> result = new List <OrdemServicoView>();

            #region Criando o Objeto para a plotagem das Ordens de Servico no Mapa

            foreach (OrdemDeServico ordemDeServico in OrdensDaCidade)
            {
                ConverterUtmToLatLon converter = new ConverterUtmToLatLon(ordemDeServico.Cidade.Datum, ordemDeServico.Cidade.NorteOuSul, ordemDeServico.Cidade.Zona);
                OrdemServicoView     OSView    = new OrdemServicoView();
                OSView.NumeroOrdemServico = ordemDeServico.NumeroOS;
                OSView.Situacao           = ordemDeServico.Situacao;
                OSView.Colaborador        = ordemDeServico.Usuario != null?ordemDeServico.Usuario.UserName.ToUpper() : "SEM COLABORADOR";

                foreach (PoligonoOS p in ordemDeServico.PoligonosOS.OrderBy(o => o.Ordem))
                {
                    OSView.PontosPoligono.Add(converter.Convert(p.X1, p.Y1));
                    OSView.PontosPoligono.Add(converter.Convert(p.X2, p.Y2));
                }

                result.Add(OSView);
            }

            #endregion

            List <object> coordenadas = new List <object>();

            return(result);
        }
Exemplo n.º 10
0
        public HttpResponseMessage GetByOS(long IdOrdemDeServico)
        {
            IEnumerable <Poste> PostesDB = UnitOfWork.PosteRepository.Get(p => p.IdOrdemDeServico == IdOrdemDeServico && p.DataExclusao == null, includeProperties: "Cidade,Fotos");

            if (PostesDB != null)
            {
                List <object>        Postes    = new List <object>();
                ConverterUtmToLatLon converter = null;

                foreach (Poste p in PostesDB)
                {
                    if (converter == null)
                    {
                        converter = new ConverterUtmToLatLon(p.Cidade.Datum, p.Cidade.NorteOuSul, p.Cidade.Zona);
                    }

                    List <FotoAPI> FotosApi = new List <FotoAPI>();

                    foreach (FotoPoste foto in p.Fotos.Where(f => f.DataExclusao == null))
                    {
                        FotoAPI ft = new FotoAPI();
                        ft.NumeroFoto = foto.NumeroFoto;
                        ft.DataFoto   = foto.DataFoto.ToString("dd-MM-yyyy HH:MM:SS"); //ConvertDate.DateTimeToUnixTimestamp(foto.DataFoto);
                        FotosApi.Add(ft);
                    }

                    Postes.Add(new
                    {
                        IdPoste          = p.IdPoste,
                        Posicao          = converter.Convert(p.X, p.Y),
                        DataCadastro     = p.DataCadastro,
                        DataExclusao     = p.DataExclusao,
                        Finalizado       = p.Finalizado,
                        CodigoGeo        = p.CodigoGeo,
                        IdLogradouro     = p.IdLogradouro,
                        IdCidade         = p.Cidade.IdCidade,
                        IdOrdemDeServico = p.IdOrdemDeServico,
                        Fotos            = FotosApi,
                        Altura           = p.Altura,
                        TipoPoste        = p.TipoPoste,
                        Esforco          = p.Esforco,
                        Descricao        = p.Descricao
                    });
                }

                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                {
                    Status = Status.OK, Results = Postes
                }));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                {
                    Status = Status.NOK, Message = Resources.Messages.Not_Register_Data_Base
                }));
            }
        }
Exemplo n.º 11
0
        public PosteView NovoPoste(Poste poste)
        {
            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(poste.Cidade.Datum, poste.Cidade.NorteOuSul, poste.Cidade.Zona);
            LatLon LatiLong = converter.Convert(poste.X, poste.Y);

            return(new PosteView {
                IdPoste = poste.IdPoste, Latitude = LatiLong.Lat, Longitude = LatiLong.Lon, CodGeo = poste.CodigoGeo
            });
        }
Exemplo n.º 12
0
        public HttpResponseMessage Get(long IdPoste)
        {
            Poste PostesDB = UnitOfWork.PosteRepository.Get(p => p.IdPoste == IdPoste && p.DataExclusao == null, includeProperties: "Cidade,Fotos").FirstOrDefault();

            if (PostesDB != null)
            {
                object Poste = new object();
                ConverterUtmToLatLon converter = null;

                if (converter == null)
                {
                    converter = new ConverterUtmToLatLon(PostesDB.Cidade.Datum, PostesDB.Cidade.NorteOuSul, PostesDB.Cidade.Zona);
                }

                List <FotoAPI> FotosApi = new List <FotoAPI>();

                foreach (FotoPoste foto in PostesDB.Fotos.Where(f => f.DataExclusao == null))
                {
                    FotoAPI ft = new FotoAPI();
                    ft.NumeroFoto = foto.NumeroFoto;
                    ft.DataFoto   = foto.DataFoto.ToString("dd-MM-yyyy hh:mm:ss"); //ConvertDate.DateTimeToUnixTimestamp(foto.DataFoto);
                    FotosApi.Add(ft);
                }

                Poste = new
                {
                    IdPoste          = PostesDB.IdPoste,
                    Posicao          = converter.Convert(PostesDB.X, PostesDB.Y),
                    DataCadastro     = PostesDB.DataCadastro,
                    DataExclusao     = PostesDB.DataExclusao,
                    Finalizado       = PostesDB.Finalizado,
                    CodigoGeo        = PostesDB.CodigoGeo,
                    IdLogradouro     = PostesDB.IdLogradouro,
                    IdCidade         = PostesDB.Cidade.IdCidade,
                    IdOrdemDeServico = PostesDB.IdOrdemDeServico,
                    Fotos            = FotosApi,
                    Altura           = PostesDB.Altura,
                    TipoPoste        = PostesDB.TipoPoste,
                    Esforco          = PostesDB.Esforco,
                    Descricao        = PostesDB.Descricao
                };

                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                {
                    Status = Status.OK, Results = Poste
                }));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                {
                    Status = Status.NOK, Message = Resources.Messages.Not_Register_Data_Base
                }));
            }
        }
Exemplo n.º 13
0
        public VaosDemandasView VaoToVaoView(VaosDemandaPoste vaos_bd)
        {
            //Poste poste = UnitOfWork.PosteRepository.Get(p => p.IdPoste == vaos_bd.IdPoste).FirstOrDefault();
            Cidade cidade = UnitOfWork.CidadeRepository.Get(c => c.IdCidade == vaos_bd.IdCidade).FirstOrDefault();

            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(cidade.Datum, cidade.NorteOuSul, cidade.Zona);
            LatLon LatiLong1 = converter.Convert(vaos_bd.X1, vaos_bd.Y1);
            LatLon LatiLong2 = converter.Convert(vaos_bd.X2, vaos_bd.Y2);

            VaosDemandasView vaos = new VaosDemandasView();

            vaos.X1 = LatiLong1.Lat;
            vaos.Y1 = LatiLong1.Lon;
            vaos.X2 = LatiLong2.Lat;
            vaos.Y2 = LatiLong2.Lon;

            return(vaos);
        }
Exemplo n.º 14
0
        public ActionResult GetArvoresById(long IdArvore)
        {
            //Lista de Arvores do Banco de Dados.
            //Tranforma a lista de arvores retornadas do banco para um objeto que javascript entende.
            //envia a lista de arvores para a javascript
            Arvore     arvore     = UnitOfWork.ArvoreRepository.Get(a => a.IdArvore == IdArvore && a.DataExclusao == null, includeProperties: "Cidade").FirstOrDefault();
            ArvoreView arvoreview = new ArvoreView();

            if (arvore != null)
            {
                arvoreview.IdArvore = arvore.IdArvore;
                arvoreview.Porte    = arvore.Porte;

                ConverterUtmToLatLon converter = new ConverterUtmToLatLon(arvore.Cidade.Datum, arvore.Cidade.NorteOuSul, arvore.Cidade.Zona);
                LatLon _coor = converter.Convert(arvore.X, arvore.Y);
                if (arvore.Latitude == 0 && arvore.Longitude == 0)
                {
                    arvoreview.Latitude  = _coor.Lat;
                    arvoreview.Longitude = _coor.Lon;
                }
                else
                {
                    arvoreview.Latitude  = arvore.Latitude;
                    arvoreview.Longitude = arvore.Longitude;
                }


                foreach (FotoArvore foto_corrente in UnitOfWork.FotoArvoreRepository.Get(f => f.IdArvore == arvore.IdArvore && f.DataExclusao == null).ToList())
                {
                    arvoreview.Fotos.Add(new FotoArvoreView()
                    {
                        DataFoto     = string.Format("{0:yyyy-MM-dd}", foto_corrente.DataFoto),
                        IdFotoArvore = foto_corrente.IdFotoArvore,
                        NumeroFoto   = foto_corrente.NumeroFoto
                    });
                }
            }

            return(Json(new ResponseView()
            {
                Status = Status.OK, Result = arvoreview
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 15
0
        public AnotacaoView AnotacaToAnotacaoView(Anotacao anotacao)
        {
            if (anotacao == null)
            {
                throw new ArgumentException("o paramêtro 'Poste' não pode ser null.");
            }

            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(anotacao.Cidade.Datum, anotacao.Cidade.NorteOuSul, anotacao.Cidade.Zona);
            LatLon       LatiLong          = converter.Convert(anotacao.X, anotacao.Y);
            AnotacaoView anotacaoView      = new AnotacaoView();

            anotacaoView.IdAnotacao = anotacao.IdAnotacao;
            anotacaoView.Descricao  = anotacao.Descricao;
            anotacaoView.X          = LatiLong.Lat;
            anotacaoView.Y          = LatiLong.Lon;
            anotacaoView.IdCidade   = anotacao.IdCidade;

            return(anotacaoView);
        }
Exemplo n.º 16
0
        public ActionResult NovoNoMaps([System.Web.Http.FromBody] DemandaStrandView demandaStrandView)
        {
            Cidade cidade = UnitOfWork.CidadeRepository.Get(c => c.IdCidade == demandaStrandView.IdCidade).FirstOrDefault();
            ConverterLatLonToUtm converter = null;

            if (cidade != null)
            {
                converter = new ConverterLatLonToUtm(cidade.Datum, cidade.NorteOuSul, cidade.Zona);


                OrdemDeServico ordemDeServico = UnitOfWork.OrdemDeServicoRepository.Get(or => or.NumeroOS == demandaStrandView.NumeroOs).FirstOrDefault();

                double x1 = Double.Parse(demandaStrandView.X1Texto, System.Globalization.CultureInfo.InvariantCulture);
                double y1 = Double.Parse(demandaStrandView.Y1Texto, System.Globalization.CultureInfo.InvariantCulture);
                double x2 = Double.Parse(demandaStrandView.X2Texto, System.Globalization.CultureInfo.InvariantCulture);
                double y2 = Double.Parse(demandaStrandView.Y2Texto, System.Globalization.CultureInfo.InvariantCulture);

                UTM utm1 = converter.Convert(x1, y1);
                UTM utm2 = converter.Convert(x2, y2);

                DemandaStrand demandaStrand = new DemandaStrand
                {
                    IdCidade         = demandaStrandView.IdCidade,
                    IdOrdemDeServico = ordemDeServico.IdOrdemDeServico,
                    X1           = utm1.X,
                    Y1           = utm1.Y,
                    X2           = utm2.X,
                    Y2           = utm2.Y,
                    DataInclusao = DateTime.Now
                };

                UnitOfWork.DemandaStrandRepository.Insert(demandaStrand);
                UnitOfWork.Save();

                DemandaStrand strand = UnitOfWork.DemandaStrandRepository.Get(d => d.ID == demandaStrand.ID).FirstOrDefault();

                return(Json(StrandPaginadoView.GenerateUnico(strand), JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { Status = Status.NotFound, Result = "Cidade nao encontrada!" }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 17
0
        public PosteView PostetoPosteViewFiltroLampada(Poste poste)
        {
            if (poste == null)
            {
                throw new ArgumentException("o paramêtro 'Poste' não pode ser null.");
            }

            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(poste.Cidade.Datum, poste.Cidade.NorteOuSul, poste.Cidade.Zona);
            LatLon    LatiLong             = converter.Convert(poste.X, poste.Y);
            PosteView posteView            = new PosteView();

            posteView.IdPoste   = poste.IdPoste;
            posteView.Latitude  = LatiLong.Lat;
            posteView.Longitude = LatiLong.Lon;
            posteView.Img       = IdentificaCorPosteLampada(poste);
            posteView.IdCidade  = poste.Cidade.IdCidade;
            posteView.CodGeo    = poste.CodigoGeo;

            return(posteView);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Lista De Pontos de Entrega View para o java script
        /// </summary>
        /// <param name="pontos_bd"></param>
        /// <returns></returns>
        public List <PontoEntregaView> ListaPontoEntrega(List <PontoEntrega> pontos_bd, long IdPoste)
        {
            List <PontoEntregaView> pontos_entrega = new List <PontoEntregaView>();

            Poste  poste  = UnitOfWork.PosteRepository.Get(p => p.IdPoste == IdPoste).FirstOrDefault();
            Cidade cidade = UnitOfWork.CidadeRepository.Get(c => c.IdCidade == poste.IdCidade).FirstOrDefault();

            foreach (PontoEntrega ponto_corrente in pontos_bd)
            {
                ConverterUtmToLatLon converter = new ConverterUtmToLatLon(cidade.Datum, cidade.NorteOuSul, cidade.Zona);
                LatLon LatiLong = converter.Convert(ponto_corrente.X, ponto_corrente.Y);

                PontoEntregaView ponto_view = new PontoEntregaView();

                ponto_view.IdPontoEntrega            = ponto_corrente.IdPontoEntrega;
                ponto_view.IdPoste                   = ponto_corrente.IdPoste;
                ponto_view.CodigoGeoBD               = ponto_corrente.CodigoGeoBD;
                ponto_view.IdOrdemServico            = ponto_corrente.IdOrdemDeServico;
                ponto_view.Classificacao             = ponto_corrente.Classificacao;
                ponto_view.TipoImovel                = ponto_corrente.TipoImovel;
                ponto_view.NumeroAndaresEdificio     = ponto_corrente.NumeroAndaresEdificio;
                ponto_view.TotalApartamentosEdificio = ponto_corrente.TotalApartamentosEdificio;
                ponto_view.NomeEdificio              = ponto_corrente.NomeEdificio;
                // ponto_view.Status = ponto_corrente.Status;
                //ponto_view.ClasseAtendimento = ponto_corrente.ClasseAtendimento;
                //ponto_view.TipoConstrucao = ponto_corrente.TipoConstrucao;
                ponto_view.Numero       = ponto_corrente.Numero;
                ponto_view.ClasseSocial = ponto_corrente.ClasseSocial;
                //ponto_view.Logradouro = ponto_corrente.Logradouro;
                //ponto_view.EtLigacao = ponto_corrente.EtLigacao;
                //ponto_view.Observacao = ponto_corrente.Observacao;
                ponto_view.Latitude  = LatiLong.Lat;
                ponto_view.Longitude = LatiLong.Lon;
                //ponto_view.QuantidadeMedidores = ponto_corrente.Medidor.Count;
                //ponto_view.Fase = ponto_corrente.Fase;

                pontos_entrega.Add(ponto_view);
            }

            return(pontos_entrega);
        }
Exemplo n.º 19
0
        public ActionResult Novo(DemandaStrandView demandaStrandView)
        {
            Cidade cidade = UnitOfWork.CidadeRepository.Get(c => c.IdCidade == demandaStrandView.IdCidade).FirstOrDefault();
            ConverterLatLonToUtm converter = null;

            if (cidade != null)
            {
                converter = new ConverterLatLonToUtm(cidade.Datum, cidade.NorteOuSul, cidade.Zona);

                Poste poste1 = UnitOfWork.PosteRepository.Get(p1 => p1.IdPoste == demandaStrandView.IdPoste1).FirstOrDefault();
                Poste poste2 = UnitOfWork.PosteRepository.Get(p2 => p2.IdPoste == demandaStrandView.IdPoste2).FirstOrDefault();

                OrdemDeServico ordemDeServico = UnitOfWork.OrdemDeServicoRepository.Get(or => or.NumeroOS == demandaStrandView.NumeroOs).FirstOrDefault();

                /* UTM utm1 = converter.Convert(demandaStrandView.X1, demandaStrandView.Y1);
                 * UTM utm2 = converter.Convert(demandaStrandView.X2, demandaStrandView.Y2);*/

                DemandaStrand demandaStrand = new DemandaStrand
                {
                    IdCidade         = demandaStrandView.IdCidade,
                    IdOrdemDeServico = ordemDeServico.IdOrdemDeServico,
                    X1           = poste1.X,
                    Y1           = poste1.Y,
                    X2           = poste2.X,
                    Y2           = poste2.Y,
                    DataInclusao = DateTime.Now
                };

                UnitOfWork.DemandaStrandRepository.Insert(demandaStrand);
                UnitOfWork.Save();

                DemandaStrand strand = UnitOfWork.DemandaStrandRepository.Get(d => d.ID == demandaStrand.ID).FirstOrDefault();

                return(Json(StrandPaginadoView.GenerateUnico(strand), JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { Status = Status.NotFound, Result = "Cidade nao encontrada!" }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 20
0
        public List <LimitesCidadeView> LimitesByCidade(List <LimiteCidade> Limites)
        {
            List <LimitesCidadeView> retorno = new List <LimitesCidadeView>();

            if (Limites != null && Limites.Count > 0)
            {
                foreach (LimiteCidade Limite in Limites)
                {
                    ConverterUtmToLatLon converter = new ConverterUtmToLatLon(Limite.Cidade.Datum, Limite.Cidade.NorteOuSul, Limite.Cidade.Zona);

                    retorno.Add(new LimitesCidadeView
                    {
                        LatitudeA  = converter.Convert(Limite.X1, Limite.Y1).Lat,
                        LongitudeA = converter.Convert(Limite.X1, Limite.Y1).Lon,
                        LatitudeB  = converter.Convert(Limite.X2, Limite.Y2).Lat,
                        LongitudeB = converter.Convert(Limite.X2, Limite.Y2).Lon,
                    });
                }
            }

            return(retorno);
        }
Exemplo n.º 21
0
        //
        // GET: /Strands/
        public ActionResult GetStrandsByOs(string codOs)
        {
            var ordemServico = UnitOfWork.OrdemDeServicoRepository.Get(nu => nu.NumeroOS == codOs).FirstOrDefault();

            List <DemandaStrand> DemandaStrands = new List <DemandaStrand>();
            var listaDemandaStrand = UnitOfWork.DemandaStrandRepository.Get(a => a.IdOrdemDeServico == ordemServico.IdOrdemDeServico && a.DataExclusao == null, includeProperties: "OrdemDeServico, Cidade").ToList();

            foreach (var item in listaDemandaStrand)
            {
                if (converter == null)
                {
                    converter = new ConverterUtmToLatLon(item.OrdemDeServico.Cidade.Datum, item.OrdemDeServico.Cidade.NorteOuSul, item.OrdemDeServico.Cidade.Zona);
                }
                if (IdCidade == -1)
                {
                    IdCidade = item.OrdemDeServico.IdCidade;
                }
                if (NomeCidade == string.Empty)
                {
                    NomeCidade = item.OrdemDeServico.Cidade.Nome;
                }

                LatLon LatiLong1 = converter.Convert(item.X1, item.Y1);
                LatLon LatiLong2 = converter.Convert(item.X2, item.Y2);
                DemandaStrands.Add(new DemandaStrand()
                {
                    ID = item.ID,
                    X1 = LatiLong1.Lat,
                    Y1 = LatiLong1.Lon,
                    X2 = LatiLong2.Lat,
                    Y2 = LatiLong2.Lon,
                });
            }
            return(Json(new ResponseView()
            {
                Status = Status.OK, Result = DemandaStrands
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 22
0
        public List <VaoView> VaosToVaosViewByOs(List <VaoPrimario> Vaos, OrdemDeServico Os)
        {
            List <VaoView> retorno = new List <VaoView>();

            if (Vaos != null && Vaos.Count > 0)
            {
                foreach (VaoPrimario vao in Vaos)
                {
                    ConverterUtmToLatLon converter = new ConverterUtmToLatLon(Os.Cidade.Datum, Os.Cidade.NorteOuSul, Os.Cidade.Zona);

                    retorno.Add(new VaoView
                    {
                        IdVaoPrimario = vao.IdVaoPrimario,
                        LatitudeA     = converter.Convert(vao.X1, vao.Y1).Lat,
                        LongitudeA    = converter.Convert(vao.X1, vao.Y1).Lon,
                        LatitudeB     = converter.Convert(vao.X2, vao.Y2).Lat,
                        LongitudeB    = converter.Convert(vao.X2, vao.Y2).Lon,
                    });
                }
            }

            return(retorno);
        }
Exemplo n.º 23
0
        public ActionResult GetArvoresByCidade(long IdCidade)
        {
            Cidade cidade_corrente         = UnitOfWork.CidadeRepository.Get(c => c.IdCidade == IdCidade).FirstOrDefault();
            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(cidade_corrente.Datum, cidade_corrente.NorteOuSul, cidade_corrente.Zona);

            //Lista de Arvores do Banco de Dados.
            //Tranforma a lista de arvores retornadas do banco para um objeto que javascript entende.
            //envia a lista de arvores para a javascript
            List <Arvore> arvores = new List <Arvore>();

            List <ArvoreView> _arvoresView = new List <ArvoreView>();

            /*
             * arvores = UnitOfWork.ArvoreRepository.Get(a => a.IdCidade == IdCidade && a.DataExclusao == null).ToList();
             *
             * LatLon _coor = null;
             * foreach (var arvore_corrente in arvores)
             * {
             *  if (arvore_corrente.Latitude == 0 && arvore_corrente.Longitude == 0)
             *  {
             *      _coor = converter.Convert(arvore_corrente.X, arvore_corrente.Y);
             *      arvore_corrente.Latitude = _coor.Lat;
             *      arvore_corrente.Longitude = _coor.Lon;
             *  }
             *
             *  _arvoresView.Add(new ArvoreView()
             *  {
             *      Fotos = new List<FotoArvoreView>(),
             *      IdArvore = arvore_corrente.IdArvore,
             *      Latitude = arvore_corrente.Latitude,
             *      Longitude = arvore_corrente.Longitude,
             *      Porte = arvore_corrente.Porte
             *  });
             * }
             */
            return(SendBigJson(_arvoresView, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 24
0
        public HttpResponseMessage GetByCidade(long idCidade)
        {
            IEnumerable <OrdemDeServico> OrdensDeServico = UnitOfWork.OrdemDeServicoRepository.Get(os => os.IdUsuario == IdUsuario && os.Cidade.IdCidade == idCidade, includeProperties: "Cidade,PoligonosOS");

            if (OrdensDeServico != null && OrdensDeServico.Count() > 0)
            {
                /// Criando a lista de Ordem de Servico para o Mobile
                ConverterUtmToLatLon converter          = null;
                List <object>        jsonOrdemDeServico = new List <object>();
                foreach (OrdemDeServico OS in OrdensDeServico)
                {
                    if (converter == null)
                    {
                        converter = new ConverterUtmToLatLon(OS.Cidade.Datum, OS.Cidade.NorteOuSul, OS.Cidade.Zona);
                    }

                    /// Pontos do poligono
                    List <LatLon> PoligonosOs = OS.PoligonosOS.OrderBy(o => o.Ordem).Select(os => converter.Convert(os.X1, os.Y1)).ToList();

                    /// Objeto que será serializado para json
                    jsonOrdemDeServico.Add(new { IdOrdemDeServico = OS.IdOrdemDeServico, NumeroOS = OS.NumeroOS, PoligonosOS = PoligonosOs, Status = CalculaStatusOs.Calcular(OS) });
                }

                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                {
                    Status = Status.Found, Message = Resources.Messages.Found_Register, Results = jsonOrdemDeServico
                }));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                {
                    Status = Status.NotFound, Message = Resources.Messages.Not_Register_Data_Base
                }));
            }
        }
Exemplo n.º 25
0
        public HttpResponseMessage Add(PosteEditAPI Poste)
        {
            /// Validando o Poste
            ICollection <ValidationResult> results;

            if (Poste.TryValidate(out results))
            {
                OrdemDeServico OSBD = UnitOfWork.OrdemDeServicoRepository.Get(os => os.IdOrdemDeServico == Poste.IdOrdemDeServico, includeProperties: "Cidade").FirstOrDefault();
                if (OSBD != null)
                {
                    ConverterLatLonToUtm converter = new ConverterLatLonToUtm(OSBD.Cidade.Datum, OSBD.Cidade.NorteOuSul, OSBD.Cidade.Zona);
                    UTM utmPoste = converter.Convert(Poste.Lat, Poste.Lon);

                    // Salvando a posição do Mobile no momento da Edição do poste
                    UTM posicaoAtualizacao = converter.Convert(Poste.LatAtualizacao, Poste.LonAtualizacao);

                    Poste posteAux = new Poste()
                    {
                        X              = utmPoste.X,
                        Y              = utmPoste.Y,
                        XAtualizacao   = posicaoAtualizacao.X,
                        YAtualizacao   = posicaoAtualizacao.Y,
                        OrdemDeServico = OSBD,
                        DataCadastro   = DateTime.Now,
                        Cidade         = OSBD.Cidade,
                        Altura         = Poste.Altura,
                        TipoPoste      = Poste.TipoPoste,
                        Esforco        = Poste.Esforco,
                        Descricao      = Poste.Descricao
                    };

                    UnitOfWork.PosteRepository.Insert(posteAux);

                    /// usuario
                    Usuario User = UnitOfWork.UsuarioRepository.Get(u => u.IdUsuario == IdUsuario).FirstOrDefault();

                    if (Poste.Fotos != null && Poste.Fotos.Count > 0)
                    {
                        foreach (FotoAPI foto in Poste.Fotos)
                        {
                            if (foto != null)
                            {
                                DateTime DataDiretorio = Convert.ToDateTime(foto.DataFoto); //ConvertDate.UnixTimestampToDateTime(foto.DataFoto);
                                String   Data          = DataDiretorio.ToString("dd-MM-yyyy hh:mm:ss");

                                UnitOfWork.FotoPosteRepository.Insert(new FotoPoste
                                {
                                    CodigoGeoBD = -1,
                                    IdPoste     = posteAux.IdPoste,
                                    NumeroFoto  = foto.NumeroFoto.Trim(),
                                    DataFoto    = DataDiretorio,
                                    Path        = string.Format(ConfigurationManager.AppSettings["NewPathFotos"], OSBD.Cidade.CidadeDiretorio, Data, User.UserName.ToUpper(), foto.NumeroFoto.Trim())
                                });
                            }
                        }
                    }

                    UnitOfWork.Save();

                    List <FotoAPI> FotosApi = new List <FotoAPI>();

                    foreach (FotoPoste foto in posteAux.Fotos.Where(f => f.DataExclusao == null))
                    {
                        FotoAPI ft = new FotoAPI();
                        ft.NumeroFoto = foto.NumeroFoto;
                        ft.DataFoto   = foto.DataFoto.ToString("dd-MM-yyyy hh:mm:ss"); //ConvertDate.DateTimeToUnixTimestamp(foto.DataFoto);
                        FotosApi.Add(ft);
                    }

                    ConverterUtmToLatLon converterToLatLong = new ConverterUtmToLatLon(posteAux.Cidade.Datum, posteAux.Cidade.NorteOuSul, posteAux.Cidade.Zona);
                    return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                    {
                        Status = Status.OK,
                        Message = Resources.Messages.Save_OK,
                        Results = new
                        {
                            IdPoste = posteAux.IdPoste,
                            Posicao = converterToLatLong.Convert(posteAux.X, posteAux.Y),
                            DataCadastro = posteAux.DataCadastro,
                            DataExclusao = posteAux.DataExclusao,
                            Finalizado = posteAux.Finalizado,
                            CodigoGeo = posteAux.CodigoGeo,
                            IdLogradouro = posteAux.IdLogradouro,
                            IdCidade = posteAux.Cidade.IdCidade,
                            IdOrdemDeServico = posteAux.IdOrdemDeServico,
                            Fotos = FotosApi,
                            Altura = posteAux.Altura,
                            TipoPoste = posteAux.TipoPoste,
                            Esforco = posteAux.Esforco,
                            Descricao = posteAux.Descricao
                        }
                    }));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                    {
                        Status = Status.NOK, Message = Resources.Messages.OS_Not_Found
                    }));
                }
            }
            else
            {
                string MessageValidate = string.Empty;
                foreach (var validationResult in results)
                {
                    MessageValidate += validationResult.ErrorMessage;
                }
                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                {
                    Status = Status.NOK, Message = MessageValidate
                }));
            }
        }
Exemplo n.º 26
0
        public HttpResponseMessage Edit(PosteEditAPI Poste)
        {
            /// Validando o Poste
            ICollection <ValidationResult> results;

            if (Poste.TryValidate(out results))
            {
                Poste posteBD = UnitOfWork.PosteRepository.Get(p => p.IdPoste == Poste.IdPoste && p.DataExclusao == null, includeProperties: "Cidade,Fotos,OrdemDeServico").FirstOrDefault();
                if (posteBD != null)
                {
                    ConverterLatLonToUtm converter = new ConverterLatLonToUtm(posteBD.Cidade.Datum, posteBD.Cidade.NorteOuSul, posteBD.Cidade.Zona);
                    UTM utmPoste = converter.Convert(Poste.Lat, Poste.Lon);

                    //Atribuindo os novos valores da Edicao
                    posteBD.X          = utmPoste.X;
                    posteBD.Y          = utmPoste.Y;
                    posteBD.Finalizado = Poste.Finalizado;
                    posteBD.Altura     = Poste.Altura;
                    posteBD.TipoPoste  = Poste.TipoPoste;
                    posteBD.Esforco    = Poste.Esforco != null ? Poste.Esforco : 0;
                    posteBD.Descricao  = Poste.Descricao != null?Poste.Descricao.ToUpper() : "";

                    posteBD.DataCadastro = ConvertDate.UnixTimestampToDateTime(Poste.DataAtualizacao);

                    // Salvando a posição do Mobile no momento da Edição do poste
                    UTM posicaoAtualizacao = converter.Convert(Poste.LatAtualizacao, Poste.LonAtualizacao);
                    posteBD.XAtualizacao = posicaoAtualizacao.X;
                    posteBD.YAtualizacao = posicaoAtualizacao.Y;

                    UnitOfWork.PosteRepository.Update(posteBD);

                    /// Setando DataDeExclusao em todas as fotos
                    foreach (FotoPoste f in posteBD.Fotos)
                    {
                        f.DataExclusao = DateTime.Now;
                        UnitOfWork.FotoPosteRepository.Update(f);
                    }

                    /// usuario
                    Usuario User = UnitOfWork.UsuarioRepository.Get(u => u.IdUsuario == IdUsuario).FirstOrDefault();

                    // Verificando as alterações das fotos
                    if (Poste.Fotos != null && Poste.Fotos.Count > 0)
                    {
                        foreach (FotoAPI foto in Poste.Fotos)
                        {
                            if (foto != null)
                            {
                                DateTime DataDiretorio = Convert.ToDateTime(foto.DataFoto);  //ConvertDate.UnixTimestampToDateTime(foto.DataFoto);
                                String   Data          = DataDiretorio.ToString("dd-MM-yyyy hh:mm:ss");

                                FotoPoste f = UnitOfWork.FotoPosteRepository.Get(fto => fto.IdPoste == posteBD.IdPoste && fto.NumeroFoto.Trim() == foto.NumeroFoto.Trim()).FirstOrDefault();
                                if (f != null)
                                {
                                    f.DataExclusao = null;
                                    f.DataFoto     = DataDiretorio;
                                    f.Path         = string.Format(ConfigurationManager.AppSettings["NewPathFotos"], posteBD.Cidade.CidadeDiretorio, Data, User.UserName.ToUpper(), foto.NumeroFoto.Trim());
                                    UnitOfWork.FotoPosteRepository.Update(f);
                                }
                                else
                                {
                                    FotoPoste fAux = new FotoPoste
                                    {
                                        CodigoGeoBD = -1,
                                        IdPoste     = posteBD.IdPoste,
                                        NumeroFoto  = foto.NumeroFoto.Trim(),
                                        DataFoto    = DataDiretorio,
                                        Path        = string.Format(ConfigurationManager.AppSettings["NewPathFotos"], posteBD.Cidade.CidadeDiretorio, Data, User.UserName.ToUpper(), foto.NumeroFoto.Trim())
                                    };

                                    UnitOfWork.FotoPosteRepository.Insert(fAux);
                                }
                            }
                        }
                    }

                    UnitOfWork.Save(); //Commit

                    List <FotoAPI> FotosApi = new List <FotoAPI>();

                    foreach (FotoPoste foto in posteBD.Fotos.Where(f => f.DataExclusao == null))
                    {
                        FotoAPI ft = new FotoAPI();
                        ft.NumeroFoto = foto.NumeroFoto;
                        ft.DataFoto   = foto.DataFoto.ToString("dd-MM-yyyy hh:mm:ss"); //ConvertDate.DateTimeToUnixTimestamp(foto.DataFoto);
                        FotosApi.Add(ft);
                    }

                    ConverterUtmToLatLon converterToLatLong = new ConverterUtmToLatLon(posteBD.Cidade.Datum, posteBD.Cidade.NorteOuSul, posteBD.Cidade.Zona);
                    return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                    {
                        Status = Status.OK,
                        Message = Resources.Messages.Save_OK,
                        Results = new
                        {
                            IdPoste = posteBD.IdPoste,
                            Posicao = converterToLatLong.Convert(posteBD.X, posteBD.Y),
                            DataCadastro = posteBD.DataCadastro,
                            DataExclusao = posteBD.DataExclusao,
                            Finalizado = posteBD.Finalizado,
                            CodigoGeo = posteBD.CodigoGeo,
                            IdLogradouro = posteBD.IdLogradouro,
                            IdCidade = posteBD.Cidade.IdCidade,
                            IdOrdemDeServico = posteBD.IdOrdemDeServico,
                            Fotos = FotosApi,
                            Altura = posteBD.Altura,
                            TipoPoste = posteBD.TipoPoste,
                            Esforco = posteBD.Esforco,
                            Descricao = posteBD.Descricao
                        }
                    }));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                    {
                        Status = Status.NOK, Message = Resources.Messages.Poste_Not_Found
                    }));
                }
            }
            else
            {
                string MessageValidate = string.Empty;
                foreach (var validationResult in results)
                {
                    MessageValidate += validationResult.ErrorMessage + "-";
                }
                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseApi()
                {
                    Status = Status.NOK, Message = MessageValidate.Remove(MessageValidate.Length - 1)
                }));
            }
        }
Exemplo n.º 27
0
        public static object GenerateByOsNaSa(IEnumerable <Poste> postesOs)
        {
            if (postesOs == null)
            {
                throw new ArgumentException("o paramêtro 'postesOs' não pode ser null.");
            }

            long IdCidade = -1;
            ConverterUtmToLatLon converter = null;
            List <object>        postes    = new List <object>();
            LatLon centro;
            double x = 0, y = 0, z = 0;
            int    total      = 0;
            string NomeCidade = string.Empty;

            foreach (Poste poste in postesOs)
            {
                if (converter == null)
                {
                    converter = new ConverterUtmToLatLon(poste.Cidade.Datum, poste.Cidade.NorteOuSul, poste.Cidade.Zona);
                }
                if (IdCidade == -1)
                {
                    IdCidade = poste.IdCidade;
                }
                if (NomeCidade == string.Empty)
                {
                    NomeCidade = poste.Cidade.Nome;
                }

                LatLon LatiLong = converter.Convert(poste.X, poste.Y);

                //Calculando o Centro do conjunto dos postes
                double latitude  = LatiLong.Lat * Math.PI / 180;
                double longitude = LatiLong.Lon * Math.PI / 180;

                x += Math.Cos(latitude) * Math.Cos(longitude);
                y += Math.Cos(latitude) * Math.Sin(longitude);
                z += Math.Sin(latitude);
                total++;

                postes.Add(new PosteView
                {
                    IdPoste   = poste.IdPoste,
                    Latitude  = LatiLong.Lat,
                    Longitude = LatiLong.Lon,
                    CodGeo    = poste.CodigoGeo,
                    Img       = new MetodosPosteView().IdentificaCorPosteNaSa(poste)
                });
            }

            x = x / total;
            y = y / total;
            z = z / total;

            double centralLongitude  = Math.Atan2(y, x);
            double centralSquareRoot = Math.Sqrt(x * x + y * y);
            double centralLatitude   = Math.Atan2(z, centralSquareRoot);

            centro = new LatLon()
            {
                Lat = centralLatitude * 180 / Math.PI, Lon = centralLongitude * 180 / Math.PI
            };

            return(new { IdCidade = IdCidade, NomeCidade = NomeCidade, Postes = postes, Centro = centro });
        }
Exemplo n.º 28
0
        public static object GenerateByOs(IEnumerable <VaosDemandaPoste> postesOs)
        {
            if (postesOs == null)
            {
                throw new ArgumentException("o paramêtro 'postesOs' não pode ser null.");
            }

            long IdCidade = -1;
            ConverterUtmToLatLon converter    = null;
            List <object>        vaosdemandas = new List <object>();
            // LatLon centro;
            // double x = 0, y = 0, z = 0;
            // int total = 0;
            string NomeCidade = string.Empty;

            foreach (VaosDemandaPoste vao in postesOs)
            {
                if (converter == null)
                {
                    converter = new ConverterUtmToLatLon(vao.Cidade.Datum, vao.Cidade.NorteOuSul, vao.Cidade.Zona);
                }
                if (IdCidade == -1)
                {
                    IdCidade = vao.IdCidade;
                }
                if (NomeCidade == string.Empty)
                {
                    NomeCidade = vao.Cidade.Nome;
                }

                LatLon LatiLong1 = converter.Convert(vao.X1, vao.Y1);
                LatLon LatiLong2 = converter.Convert(vao.X2, vao.Y2);

                //Calculando o Centro do conjunto dos postes

                /*double latitude = LatiLong.Lat * Math.PI / 180;
                 * double longitude = LatiLong.Lon * Math.PI / 180;*/

                /*x += Math.Cos(latitude) * Math.Cos(longitude);
                 * y += Math.Cos(latitude) * Math.Sin(longitude);
                 * z += Math.Sin(latitude);
                 * total++; */

                vaosdemandas.Add(new VaosDemandasView
                {
                    ID = vao.IdPontoEntrega,
                    X1 = LatiLong1.Lat,
                    Y1 = LatiLong1.Lon,
                    X2 = LatiLong2.Lat,
                    Y2 = LatiLong2.Lon

                         /*IdPontoEntrega = poste.IdPontoEntrega,
                          * Latitude = LatiLong.Lat,
                          * Longitude = LatiLong.Lon,
                          * //CodGeo = poste.CodigoGeo,
                          * //NumeroPosteNaOS = poste.NumeroPosteNaOS,
                          * Img = ImgAux*/
                });
            }

            /* x = x / total;
             * y = y / total;
             * z = z / total;
             *
             * double centralLongitude = Math.Atan2(y, x);
             * double centralSquareRoot = Math.Sqrt(x * x + y * y);
             * double centralLatitude = Math.Atan2(z, centralSquareRoot);*/

            // centro = new LatLon() { Lat = centralLatitude * 180 / Math.PI, Lon = centralLongitude * 180 / Math.PI };

            return(new { VaosDemandas = vaosdemandas });
        }
Exemplo n.º 29
0
        public static object GenerateByOs(IEnumerable <PontoEntrega> postesOs)
        {
            if (postesOs == null)
            {
                throw new ArgumentException("o paramêtro 'postesOs' não pode ser null.");
            }

            long IdCidade = -1;
            ConverterUtmToLatLon converter = null;
            List <object>        postes    = new List <object>();
            LatLon centro;
            double x = 0, y = 0, z = 0;
            int    total      = 0;
            string NomeCidade = string.Empty;

            foreach (PontoEntrega poste in postesOs)
            {
                if (converter == null)
                {
                    converter = new ConverterUtmToLatLon(poste.Cidade.Datum, poste.Cidade.NorteOuSul, poste.Cidade.Zona);
                }
                if (IdCidade == -1)
                {
                    IdCidade = poste.IdCidade;
                }
                if (NomeCidade == string.Empty)
                {
                    NomeCidade = poste.Cidade.Nome;
                }

                LatLon LatiLong = converter.Convert(poste.X, poste.Y);

                //Calculando o Centro do conjunto dos postes
                double latitude  = LatiLong.Lat * Math.PI / 180;
                double longitude = LatiLong.Lon * Math.PI / 180;

                x += Math.Cos(latitude) * Math.Cos(longitude);
                y += Math.Cos(latitude) * Math.Sin(longitude);
                z += Math.Sin(latitude);
                total++;

                // Nova regra de Status do poste para a View
                string ImgAux = string.Empty;
                if (poste.ClasseSocial == BLL.Enums.ClasseSocial.COMERCIAL_P || poste.ClasseSocial == BLL.Enums.ClasseSocial.COMERCIAL_M || poste.ClasseSocial == BLL.Enums.ClasseSocial.COMERCIAL_G)
                {
                    ImgAux = "comercio";
                }
                else if (poste.ClasseSocial == BLL.Enums.ClasseSocial.EDIFÍCIO_RES || poste.ClasseSocial == BLL.Enums.ClasseSocial.EDIFICIO_EMPRESA || poste.ClasseSocial == BLL.Enums.ClasseSocial.EDIFICIO_COM || poste.ClasseSocial == BLL.Enums.ClasseSocial.EDIFÍCIO_CONSTRUCAO)
                {
                    ImgAux = "predio";
                }
                else if (poste.ClasseSocial == BLL.Enums.ClasseSocial.RESIDENCIAL)
                {
                    ImgAux = "casa";
                }
                else if (poste.ClasseSocial == BLL.Enums.ClasseSocial.TERRENO)
                {
                    ImgAux = "terreno";
                }
                else if (poste.ClasseSocial == BLL.Enums.ClasseSocial.COMERCIO_RESIDENCIA)
                {
                    ImgAux = "misto";
                }
                else if (poste.ClasseSocial == BLL.Enums.ClasseSocial.VILA)
                {
                    ImgAux = "vila";
                }
                else
                {
                    ImgAux = "duvida";
                }

                postes.Add(new PontoEntregaView
                {
                    IdPontoEntrega = poste.IdPontoEntrega,
                    Latitude       = LatiLong.Lat,
                    Longitude      = LatiLong.Lon,
                    Numero         = poste.Numero,
                    ClasseSocial   = poste.ClasseSocial,
                    //CodGeo = poste.CodigoGeo,
                    //NumeroPosteNaOS = poste.NumeroPosteNaOS,
                    Img = ImgAux
                });
            }

            x = x / total;
            y = y / total;
            z = z / total;

            double centralLongitude  = Math.Atan2(y, x);
            double centralSquareRoot = Math.Sqrt(x * x + y * y);
            double centralLatitude   = Math.Atan2(z, centralSquareRoot);

            centro = new LatLon()
            {
                Lat = centralLatitude * 180 / Math.PI, Lon = centralLongitude * 180 / Math.PI
            };

            return(new { IdCidade = IdCidade, NomeCidade = NomeCidade, PontoEntregas = postes, Centro = centro });
        }
Exemplo n.º 30
0
        public PosteView PostetoPosteView(Poste poste)
        {
            if (poste == null)
            {
                throw new ArgumentException("o paramêtro 'Poste' não pode ser null.");
            }

            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(poste.Cidade.Datum, poste.Cidade.NorteOuSul, poste.Cidade.Zona);
            LatLon    LatiLong             = converter.Convert(poste.X, poste.Y);
            PosteView posteView            = new PosteView();

            posteView.IdPoste   = poste.IdPoste;
            posteView.Latitude  = LatiLong.Lat;
            posteView.Longitude = LatiLong.Lon;
            posteView.IdCidade  = poste.Cidade.IdCidade;
            posteView.CodGeo    = poste.CodigoGeo;

            if (poste.Finalizado)
            {
                posteView.Img = "03";
            }
            else
            {
                posteView.Img = "08";
            }
            posteView.Altura    = poste.Altura;
            posteView.TipoPoste = poste.TipoPoste;
            posteView.Esforco   = poste.Esforco;

            posteView.EncontradoPoste           = poste.encontrado;
            posteView.BarramentoPoste           = poste.barramento;
            posteView.PararioPoste              = poste.para_raio;
            posteView.AterramentoPoste          = poste.aterramento;
            posteView.EstruturaPrimariaPoste    = poste.estrutura_primaria;
            posteView.EstruturaSecundaria_poste = poste.estrutura_secundaria;

            posteView.QuantidadeEstai   = poste.qtd_estai;
            posteView.AnoPoste          = poste.ano;
            posteView.SituacaoPoste     = poste.situacao;
            posteView.EquipamentoPoste  = poste.equipamento1;
            posteView.MuflaPoste        = poste.mufla;
            posteView.RedePrimarioPoste = poste.rede_primaria;
            posteView.DefeitoPoste      = poste.defeito;

            /*foreach (var itemIP in poste.IP)
             * {
             *  posteView.NumeroPrefeitura += itemIP.NumeroPrefeitura + " / ";
             * }*/

            if (posteView.NumeroPrefeitura != null && posteView.NumeroPrefeitura != string.Empty)
            {
                posteView.NumeroPrefeitura = posteView.NumeroPrefeitura.Remove(posteView.NumeroPrefeitura.Length - 3);

                posteView.Descricao = poste.Descricao + " Numero(s) da Prefeitura: " + posteView.NumeroPrefeitura;
            }
            else
            {
                posteView.Descricao = poste.Descricao;
            }

            return(posteView);
        }