Exemple #1
0
        static void Main(string[] args)
        {
            SPOService       spoM     = new SPOService();
            var              image    = spoM.GetPhotoInfo("Noticias", "1");
            CelebrityService cService = new CelebrityService();
            var              celebriy = cService.MakeAnalysisCelebrity(image);

            Console.WriteLine(cService.GetCelebrity(celebriy));
        }
Exemple #2
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            // parse query parameter
            dynamic data = await req.Content.ReadAsAsync <object>();

            log.Info("Data:" + data.Lista + data.Id + data.site);
            // Set name to query string or body data
            string lista = data?.Lista;
            string id    = data?.Id;
            string site  = data?.site;



            if (lista != null && id != null)
            {
                log.Info("Lista " + lista + " id " + id + " site " + site);

                SPOService       spoM          = new SPOService(site);
                var              image         = spoM.GetPhotoInfo(lista, id);
                CelebrityService cService      = new CelebrityService();
                var              content       = cService.MakeAnalysisCelebrity(image);
                var              celebrityName = cService.GetCelebrity(content.celebrity);

                log.Info("Obteniendo el celebrity");

                var azureSearch  = new AzureSearchService();
                var indexCreate  = azureSearch.CreateIndexAsync <AzureSearchModel>("newsindex", false, null).Result;
                var contentIndex = new AzureSearchModel()
                {
                    IdSharepoint = id, Name = celebrityName, Tags = content.tags, Id = id
                };
                var uploadDocument = azureSearch.UploadDocuments <AzureSearchModel>("newsindex", new List <AzureSearchModel>()
                {
                    contentIndex
                }.ToArray());

                log.Info("Creado el search");
                spoM.SetResultNews(lista, id, JsonConvert.SerializeObject(content.tags));
                return(req.CreateResponse(HttpStatusCode.OK, "Noticia categorizada"));
            }

            else
            {
                return(req.CreateResponse(HttpStatusCode.BadRequest, "Faltan parametros"));
            }
        }