Пример #1
0
        public CombosIndexPromocaoNoticia GetCombos()
        {
            var RNPromocoesNoticias = new ZAdmin_RN.Promocao.PromocaoNoticia(Configuracoes.ServidorElastic, Configuracoes.IndexElastic);

            var combos = new CombosIndexPromocaoNoticia();

            combos.empresas = RNPromocoesNoticias.RetornaEmpresaNoticias();

            return(combos);
        }
Пример #2
0
        public IndexPromocaoNoticia retornaNoticiasPromocao(int idPromocao, int pagina, int quantidade)
        {
            var PromocoesRN = new ZAdmin_RN.Promocao.PromocaoNoticia(Configuracoes.ServidorElastic, Configuracoes.IndexElastic);

            var indexPromocaoNoticia = new IndexPromocaoNoticia();

            indexPromocaoNoticia.noticias      = PromocoesRN.retornaNoticiasPromocao(idPromocao, pagina, quantidade);
            indexPromocaoNoticia.totalNoticias = PromocoesRN.totalNoticias;

            return(indexPromocaoNoticia);
        }
Пример #3
0
        public IndexPromocaoNoticia noticias(filtroPromocaoNoticia filtro)
        {
            var PromocoesRN = new ZAdmin_RN.Promocao.PromocaoNoticia(Configuracoes.ServidorElastic, Configuracoes.IndexElastic);

            var indexPromocaoNoticia = new IndexPromocaoNoticia();

            indexPromocaoNoticia.noticias      = PromocoesRN.RetornaNoticias(filtro);
            indexPromocaoNoticia.totalNoticias = PromocoesRN.totalNoticias;

            return(indexPromocaoNoticia);
        }
Пример #4
0
        private int CadastroSalvarPromocaoMySQL(Promocao dados)
        {
            var db = new ZAdmin_DB.Model.zeengEntities();

            var promoDB = new ZAdmin_DB.Model.promo_promocoes();

            promoDB.idorgaoregulador       = dados.idOrgaoregulador != null ? dados.idOrgaoregulador : null;
            promoDB.idmodalidade           = dados.idModalidade != null ? dados.idModalidade : 1; //1 - outros
            promoDB.nome                   = dados.nome;
            promoDB.certificadoautorizacao = dados.certificadoAutorizacao;
            promoDB.outrosinteressados     = dados.outrosInteressados;
            promoDB.abrangencianacional    = dados.abrangenciaNacional;
            promoDB.dtcadastro             = DateTime.Now;
            promoDB.dtvigenciaini          = dados.dtVigenciaIni != null ? dados.dtVigenciaIni : null;
            promoDB.dtvigenciafim          = dados.dtVigenciaFim != null ? dados.dtVigenciaFim : null;
            promoDB.valorpremios           = dados.valorPremio;
            promoDB.linksitepromocao       = dados.linkSitePromocao;
            promoDB.linkfacebook           = dados.linkFacebook;
            promoDB.linkinstagram          = dados.linkInstagram;
            promoDB.linktwitter            = dados.linkTwitter;
            promoDB.linkyoutube            = dados.linkYoutube;
            promoDB.mecanicapromo          = dados.mecanicaPromo;
            promoDB.produtosparticipantes  = dados.produtosParticipantes;
            promoDB.premiospromo           = dados.premiosPromo;
            promoDB.linkregulamento        = dados.linkRegulamento;
            promoDB.textoregulamento       = dados.textoRegulamento;
            promoDB.excluido               = false;

            db.promo_promocoes.Add(promoDB);
            db.SaveChanges();

            // Caso o cadastro esteja sendo feito a partir de notícia
            if (dados.idNoticia > 0)
            {
                var rnPromocaoNoticia = new PromocaoNoticia(_server, _indexElastic);
                rnPromocaoNoticia.AssociaPromocaoNoticia(promoDB.idpromocao, dados.idNoticia, dados.fontePesquisa);
            }

            // Caso o cadastro esteja sendo feito a partir de um post
            if (dados.idRedeSocial > 0)
            {
                var rnPromocaoRedesSociais = new PromocaoRedesSociais.PromocaoRedesSociais(_server, _indexElastic);
                rnPromocaoRedesSociais.associarPromocaoPost(promoDB.idpromocao, dados.idRedeSocial, dados.nomeRedeSocial);
            }

            //var dadosProc = db.seae_processos.Where(x => x.idprocesso == dados.idProcesso).FirstOrDefault();
            return(promoDB.idpromocao);
        }
Пример #5
0
        public void DesassociarPromocaoNoticia(ZAdmin_RN.Promocao.TagPromocao tag)
        {
            var RN = new ZAdmin_RN.Promocao.PromocaoNoticia(Configuracoes.ServidorElastic, Configuracoes.IndexElastic);

            RN.DesassociarPromocaoNoticia(tag);
        }
Пример #6
0
        public Mensagem atualizaPromocaoNoticia(int idPromocao, int idFontePesquisa, int idNoticia)
        {
            var RNPromoNoticias = new ZAdmin_RN.Promocao.PromocaoNoticia(Configuracoes.ServidorElastic, Configuracoes.IndexElastic);

            return(RNPromoNoticias.AssociaPromocaoNoticia(idPromocao, idNoticia, idFontePesquisa));
        }
Пример #7
0
        private void CadastroSalvarPromocaoElasticSearch(int idpromocao, Promocao dados)
        {
            var orgao = db.promo_orgaosreguladores.Where(x => x.idorgao == dados.idOrgaoregulador).FirstOrDefault();

            ZAdmin_RN.Promocao.PromocaoElastic promoElastic = new PromocaoElastic()
            {
                idpromocao         = idpromocao,
                idorgaoregulador   = dados.idOrgaoregulador,
                nomeorgaoregulador = orgao.nome,
                nome = dados.nome,
                certificadoautorizacao = dados.certificadoAutorizacao,
                dtcadastro             = DateTime.Now.ToString("yyyy-MM-dd")
            };

            if (dados.idNoticia > 0)
            {
                var noticiadb = (dados.fontePesquisa == 1) ? db.noticias.Where(x => x.idnoticia_knewin == dados.idNoticia).FirstOrDefault() :
                                db.noticias.Where(x => x.idnoticia == dados.idNoticia).FirstOrDefault();

                promoElastic.noticias = new List <Noticia>();

                Noticia noticia = new Noticia()
                {
                    idnoticia                                      = noticiadb.idnoticia,
                    autor                                          = noticiadb.autor,
                    conteudo                                       = noticiadb.conteudo,
                    titulo                                         = noticiadb.titulo,
                    datapublicacao                                 = noticiadb.datapublicacao != null?noticiadb.datapublicacao.Value.ToString("yyyy-MM-dd") : null,
                                                         url       = noticiadb.url,
                                                         nomefonte = db.fontes_noticias.Where(x => x.idfonte == noticiadb.idfonte).FirstOrDefault().nome
                };
                promoElastic.noticias.Add(noticia);
            }

            if (dados.idRedeSocial > 0)
            {
                switch (dados.nomeRedeSocial)
                {
                case "facebook":
                {
                    var postdb = db.fb_posts.Where(x => x.idpost == dados.idRedeSocial).FirstOrDefault();

                    promoElastic.postsfacebook = new List <FacePost>();

                    FacePost post = new FacePost()
                    {
                        idpost            = (int)postdb.idpost,
                        compartilhamentos = (int)postdb.compartilhamentos,
                        curtidas          = postdb.reacoes,
                        datahora          = postdb.datahora.ToString("dd/MM/yyyy HH:mm:ss"),
                        postagem          = postdb.postagem,
                        nomeimagem        = postdb.nomeimagem,
                        qtdcomentarios    = (int)postdb.comentarios
                    };

                    promoElastic.postsfacebook.Add(post);

                    break;
                }

                case "twitter":
                {
                    var postdb = db.tw_posts.Where(x => x.idpost == dados.idRedeSocial).FirstOrDefault();

                    promoElastic.poststwitter = new List <TwPost>();

                    TwPost post = new TwPost()
                    {
                        idpost     = postdb.idpost,
                        curtidas   = (int)postdb.qtdfavoritado,
                        retweets   = (int)postdb.qtdretweets,
                        datahora   = postdb.datahora.Value.ToString("dd/MM/yyyy HH:mm:ss"),
                        nomeimagem = postdb.nomeimagem,
                        postagem   = postdb.postagem
                    };

                    promoElastic.poststwitter.Add(post);
                    break;
                }

                case "instagram":
                {
                    var postdb = db.insta_posts.Where(x => x.idpost == dados.idRedeSocial).FirstOrDefault();

                    promoElastic.postsinstagram = new List <InstaPost>();

                    InstaPost post = new InstaPost()
                    {
                        idpost         = postdb.idpost,
                        curtidas       = (int)postdb.qtdcurtidas,
                        datahora       = postdb.datahora.Value.ToString("dd/MM/yyyy HH:mm:ss"),
                        nomeimagem     = postdb.nomeimagem,
                        postagem       = postdb.postagem,
                        qtdcomentarios = (int)postdb.qtdcomentarios
                    };

                    promoElastic.postsinstagram.Add(post);
                    break;
                }

                case "youtube":
                {
                    var postdb = db.yt_videos.Where(x => x.idvideo == dados.idRedeSocial).FirstOrDefault();

                    promoElastic.videosyoutube = new List <VideoYt>();

                    VideoYt post = new VideoYt()
                    {
                        idvideo        = postdb.idvideo,
                        curtidas       = postdb.qtdcurtidas,
                        datahora       = postdb.datahora.ToString("dd/MM/yyyy HH:mm:ss"),
                        nomeimagem     = postdb.nomeimagem,
                        descricao      = postdb.descricao,
                        qtdcomentarios = postdb.qtdcomentarios,
                        visualizacoes  = postdb.qtdvisualizacoes,
                        descurtidas    = postdb.qtddescurtidas
                    };

                    promoElastic.videosyoutube.Add(post);
                    break;
                }
                }
            }

            var node     = new Uri(_server);
            var settings = new ConnectionSettings(node);

            settings.DisableDirectStreaming(true);
            settings.DefaultIndex(_indexElastic + "promocoes");

            var client = new ElasticClient(settings);

            var resposta = client.Index(promoElastic, i => i.Type("promocao").Id(promoElastic.idpromocao));

            var promoNoticia = new PromocaoNoticia(_server, _indexElastic);

            promoNoticia.atualizaPromocaoNoticiaElasticSearch(dados.idNoticia);
        }