static void Main(string[] args)
        {
            var container = SimpleInjectorContainer.Initialize();

            IVenueService    venueService    = container.GetInstance <IVenueService>();
            ILocationService locationService = container.GetInstance <ILocationService>();
            InstagramScraper bot             = container.GetInstance <InstagramScraper>();

            bot.Initialize();
            bot.Login();
            var venues            = venueService.GetAll();
            var exceptionMessages = new List <string>();

            foreach (var venue in venues)
            {
                try
                {
                    venue.Location = locationService.GetByVenueId(venue.Id);
                    bot.FindVisitorByVenue(venue);
                    venueService.InsertVisitors(venue);
                }
                catch (Exception ex)
                {
                    exceptionMessages.Add(string.Format("Mensage: {0} --> InnerException: {1} --> VenueId: {2} --> VenueName: {3}", ex.Message, ex.InnerException, venue.Id, venue.Name));
                }
            }
            System.IO.File.WriteAllLines(ConfigurationManager.AppSettings.Get("FilesPath"), exceptionMessages);
            bot.Close();
        }
Example #2
0
        private void SaveUpdateValidate(Layout layout, IVenueService vs)
        {
            var vsAll = vs.GetAll();
            var all   = GetAll();

            if (!(from x in vsAll where x.Id == layout.VenueId select x).Any())
            {
                throw new Exception("No such venue");
            }
        }
        //Step 2
        //Busca todos os lugares no banco de dados
        //Compara os nomes de todos os lugares entre si para buscar similaridades (distancia de Levenshtein normalizada)
        //Insere no banco o resultado do calculo se for menor que 0.2
        private static void RemoveSimilarVenues(IVenueService venueService, ILocationService locationService)
        {
            List <Venue> venuesToRemove = new List <Venue>();
            List <Venue> venues         = venueService.GetAll().ToList();

            for (int i = 0; i < venues.Count - 1; i++)
            {
                int nextIndex = i + 1;
                venues[i].SimilarVenues = venues.GetRange(nextIndex, venues.Count - nextIndex)
                                          .Select(x => new VenueSimilarityDTO
                {
                    Venue = new Venue
                    {
                        Id   = x.Id,
                        Name = x.Name
                    }
                })
                                          .ToList();
                venues[i].CalculateNameSimilarity();
                foreach (var similar in venues[i].SimilarVenues)
                {
                    if (similar.Similarity <= (decimal)0.2)
                    {
                        venues[i].Location     = locationService.GetByVenueId(venues[i].Id);
                        similar.Venue.Location = locationService.GetByVenueId(similar.Venue.Id);
                        if (venues[i].Location.CalculateDistance(similar.Venue.Location) < 100)
                        {
                            venuesToRemove.Add(similar.Venue);
                        }
                    }
                }
            }
            foreach (var venue in venuesToRemove.Distinct())
            {
                Console.WriteLine(venue.Name);
                venueService.DeleteById(venue);
            }
        }
Example #4
0
    public ActionResult <ItemResponse <Paged <Venue> > > GetAll(string query, int type, int pageIndex, int pageSize)
    {
        try
        {
            Paged <Venue> pagedData = _venuesService.GetAll(query, type, pageIndex, pageSize);

            if (pagedData == null)
            {
                return(StatusCode(404, new ErrorResponse("Record not found.")));
            }
            else
            {
                ItemResponse <Paged <Venue> > resp = new ItemResponse <Paged <Venue> >();
                resp.Item = pagedData;
                return(Ok200(resp));
            }
        }
        catch (Exception ex)
        {
            Logger.LogError(ex.ToString());
            return(StatusCode(500, new ErrorResponse(ex.Message)));
        }
    }
        public ActionResult <IEnumerable <VenueModel> > Get()
        {
            var items = _service.GetAll();

            return(Ok(items));
        }
 public IHttpActionResult Get()
 {
     return(Ok(_venueService.GetAll()));
 }