Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
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));
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
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));
        }
Exemple #8
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));
        }
Exemple #9
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
            });
        }
Exemple #10
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);
        }
Exemple #11
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));
            }
        }
Exemple #12
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);
        }
Exemple #13
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));
        }
Exemple #14
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);
        }
Exemple #15
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));
        }
Exemple #16
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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #19
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
                }));
            }
        }
Exemple #20
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)
                }));
            }
        }
Exemple #21
0
        public PontoEntregaView PontoEntregaToPontoEntregaView(PontoEntrega ponto_entrega_bd)
        {
            // Poste poste = UnitOfWork.PosteRepository.Get(p => p.IdPoste == ponto_entrega_bd.IdPoste).FirstOrDefault();
            Cidade cidade = UnitOfWork.CidadeRepository.Get(c => c.IdCidade == ponto_entrega_bd.IdCidade).FirstOrDefault();

            ConverterUtmToLatLon converter = new ConverterUtmToLatLon(cidade.Datum, cidade.NorteOuSul, cidade.Zona);
            LatLon LatiLong = converter.Convert(ponto_entrega_bd.X, ponto_entrega_bd.Y);

            PontoEntregaView ponto_view = new PontoEntregaView();

            ponto_view.IdPontoEntrega = ponto_entrega_bd.IdPontoEntrega;
            ponto_view.IdPoste        = ponto_entrega_bd.IdPoste;
            ponto_view.CodigoGeoBD    = ponto_entrega_bd.CodigoGeoBD;
            ponto_view.Complemento1   = ponto_entrega_bd.Complemento1;
            ponto_view.Complemento2   = ponto_entrega_bd.Complemento2;
            //ponto_view.Status = ponto_entrega_bd.Status;
            //ponto_view.ClasseAtendimento = ponto_entrega_bd.ClasseAtendimento;
            //ponto_view.TipoConstrucao = ponto_entrega_bd.TipoConstrucao;
            ponto_view.Numero       = ponto_entrega_bd.Numero;
            ponto_view.ClasseSocial = ponto_entrega_bd.ClasseSocial;
            //ponto_view.Logradouro = ponto_entrega_bd.Logradouro;
            //ponto_view.Fase = ponto_entrega_bd.Fase;
            //ponto_view.EtLigacao = ponto_entrega_bd.EtLigacao;
            //ponto_view.Observacao = ponto_entrega_bd.Observacao;
            ponto_view.Latitude                  = LatiLong.Lat;
            ponto_view.Longitude                 = LatiLong.Lon;
            ponto_view.Classificacao             = ponto_entrega_bd.Classificacao;
            ponto_view.ClassificacaoComercio     = ponto_entrega_bd.TipoComercio;
            ponto_view.NomeEdificio              = ponto_entrega_bd.NomeEdificio;
            ponto_view.NumeroAndaresEdificio     = ponto_entrega_bd.NumeroAndaresEdificio;
            ponto_view.Ocorrencia                = ponto_entrega_bd.Ocorrencia;
            ponto_view.QtdBlocos                 = ponto_entrega_bd.QtdBlocos;
            ponto_view.QtdDomicilio              = ponto_entrega_bd.QtdDomicilio;
            ponto_view.QtdDomicilioComercio      = ponto_entrega_bd.QtdSalas;
            ponto_view.TotalApartamentosEdificio = ponto_entrega_bd.TotalApartamentosEdificio;

            // Nova regra de Status do poste para a View
            string ImgAux = string.Empty;

            if (ponto_view.ClasseSocial == BLL.Enums.ClasseSocial.COMERCIAL_P || ponto_view.ClasseSocial == BLL.Enums.ClasseSocial.COMERCIAL_M || ponto_view.ClasseSocial == BLL.Enums.ClasseSocial.COMERCIAL_G)
            {
                ImgAux = "comercio";
            }
            else if (ponto_view.ClasseSocial == BLL.Enums.ClasseSocial.EDIFÍCIO_RES || ponto_view.ClasseSocial == BLL.Enums.ClasseSocial.EDIFICIO_EMPRESA || ponto_view.ClasseSocial == BLL.Enums.ClasseSocial.EDIFICIO_COM || ponto_view.ClasseSocial == BLL.Enums.ClasseSocial.EDIFÍCIO_CONSTRUCAO)
            {
                ImgAux = "predio";
            }
            else if (ponto_view.ClasseSocial == BLL.Enums.ClasseSocial.RESIDENCIAL)
            {
                ImgAux = "casa";
            }
            else if (ponto_view.ClasseSocial == BLL.Enums.ClasseSocial.TERRENO)
            {
                ImgAux = "terreno";
            }
            else if (ponto_view.ClasseSocial == BLL.Enums.ClasseSocial.COMERCIO_RESIDENCIA)
            {
                ImgAux = "misto";
            }
            else if (ponto_view.ClasseSocial == BLL.Enums.ClasseSocial.VILA)
            {
                ImgAux = "vila";
            }
            else
            {
                ImgAux = "duvida";
            }
            ponto_view.Img = ImgAux;

            return(ponto_view);
        }
Exemple #22
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);
        }