public Task UpdateShowsWithVenueLocation(string venueGuid, VenueLocation venueLocation)
 {
     foreach (var show in shows.Where(s => s.VenueGuid == venueGuid))
     {
         show.VenueLocation = DeepCopy(venueLocation);
     }
     return(Task.CompletedTask);
 }
Exemplo n.º 2
0
        public VenueLocation GetVenueLocation(int venueId)
        {
            var           eventData = _contentService.GetById(venueId);
            VenueLocation venueItem = new VenueLocation
            {
                Location = Convert.ToString(eventData.GetValue("VenueLocation")),
            };

            return(venueItem);
        }
        public async Task Handle(ShowAdded showAdded)
        {
            Console.WriteLine($"Indexing a show for {showAdded.act.description.title} at {showAdded.venue.description.name}.");
            try
            {
                string actGuid   = showAdded.act.actGuid.ToString().ToLower();
                string venueGuid = showAdded.venue.venueGuid.ToString().ToLower();

                ActDescription   actDescription   = ActDescription.FromRepresentation(showAdded.act.description);
                VenueDescription venueDescription = VenueDescription.FromRepresentation(showAdded.venue.description);
                VenueLocation    venueLocation    = VenueLocation.FromRepresentation(showAdded.venue.location);

                ActDocument act = await actUpdater.UpdateAndGetLatestAct(new ActDocument
                {
                    ActGuid     = actGuid,
                    Description = actDescription
                });

                VenueDocument venue = await venueUpdater.UpdateAndGetLatestVenue(new VenueDocument
                {
                    VenueGuid   = venueGuid,
                    Description = venueDescription,
                    Location    = venueLocation
                });

                var show = new ShowDocument
                {
                    ActGuid          = actGuid,
                    VenueGuid        = venueGuid,
                    StartTime        = showAdded.show.startTime,
                    ActDescription   = act.Description,
                    VenueDescription = venue.Description,
                    VenueLocation    = venue.Location
                };
                await repository.IndexShow(show);

                Console.WriteLine("Succeeded");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
Exemplo n.º 4
0
 public async Task UpdateShowsWithVenueLocation(string venueGuid, VenueLocation venueLocation)
 {
     await elasticClient.UpdateByQueryAsync <ShowDocument>(ubq => ubq
                                                           .Query(q => q
                                                                  .Match(m => m
                                                                         .Field(f => f.VenueGuid)
                                                                         .Query(venueGuid)
                                                                         )
                                                                  )
                                                           .Script(s => s
                                                                   .Source("ctx._source.venueLocation = params.venueLocation")
                                                                   .Params(p => p
                                                                           .Add("venueLocation", venueLocation)
                                                                           )
                                                                   )
                                                           .Conflicts(Conflicts.Proceed)
                                                           .Refresh(true)
                                                           );
 }
Exemplo n.º 5
0
        public async Task <VenueResponse> AddVenueAsync(VenueRequest venue)
        {
            LocationIqReverseResponse locationResponse = await _locationIqProvider.GetLocationDetailsAsync(venue.Postcode);

            VenueAddress venueAddress = locationResponse.MapAddressProperties(venue.BuildingNameOrNumber);

            VenueDto venueDto = venue.MapRequestToDto(Guid.Empty, venueAddress);

            Guid insertedVenueId = await _venueRepo.AddVenueAsync(venueDto);

            VenueLocation venueLocation = new VenueLocation
            {
                Location = locationResponse.MapToGeoJson(),
                VenueId  = insertedVenueId
            };

            await _locationIqProvider.AddGeoLocation(venueLocation);

            return(await GetVenueAsync(insertedVenueId));
        }
Exemplo n.º 6
0
        /// <summary>
        /// @dev Process this GeoJSON data into JSON.
        /// @notice Disclaimer Realm does not support storing of Point data structures
        ///
        /// </summary>
        private void Process()
        {
            string[]             list      = data.Data.Split('\n');
            List <VenueLocation> VenueList = new List <VenueLocation>();
            bool          readCord         = false;
            VenueLocation tempLoc          = new VenueLocation();

            for (int i = 0; i < list.Length; i++)
            {
                if (list[i].Contains("properties"))
                {
                    i++;
                    tempLoc.Name        = CommaRemover.RemoveComma(list[i++]);
                    tempLoc.Name        = QuoteRemover.removeQuote(tempLoc.Name);
                    tempLoc.Description = NameRemover.Process(list[i].Trim());
                }
                if (list[i].Contains("coordinates"))
                {
                    string removecommaLat  = CommaRemover.RemoveComma(list[++i]);
                    string removecommaLong = CommaRemover.RemoveComma(list[++i]);
                    tempLoc.Latitude  = double.Parse(removecommaLat, CultureInfo.InvariantCulture);
                    tempLoc.Longitude = double.Parse(removecommaLong, CultureInfo.InvariantCulture);
                    readCord          = true;
                    tempLoc.Latitude  = tempLoc.Latitude;
                    tempLoc.Longitude = tempLoc.Longitude;
                    continue;
                }
                else if (readCord)
                {
                    VenueList.Add(tempLoc);
                    readCord = false;
                    tempLoc  = new VenueLocation();
                }
            }

            db.StoreVenueLocations(VenueList);
        }
        public async Task Handle(VenueLocationChanged venueLocationChanged)
        {
            Console.WriteLine($"Updating index for venue location {venueLocationChanged.location.latitude}, {venueLocationChanged.location.longitude}.");
            try
            {
                string        venueGuid     = venueLocationChanged.venueGuid.ToString().ToLower();
                VenueLocation venueLocation = VenueLocation.FromRepresentation(venueLocationChanged.location);
                VenueDocument updatedVenue  = new VenueDocument
                {
                    VenueGuid = venueGuid,
                    Location  = venueLocation
                };
                VenueDocument venue = await venueUpdater.UpdateAndGetLatestVenue(updatedVenue);

                await repository.UpdateShowsWithVenueLocation(venue.VenueGuid, venue.Location);

                Console.WriteLine("Succeeded");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
Exemplo n.º 8
0
        private void ParseDummyModel()
        {
            List <Venue>        MiniVenues = App.AutoFacContainer.Resolve <VenuesRespository>().PreFilterVenues;
            FourSquareDataModel M          = new FourSquareDataModel();

            for (int i = 0; i < M.VenuesWithTips.Count; i++)
            {
                try
                {
                    if (i != 57)
                    {
                        JsonObject MainDataObject = SimpleJson.SimpleJson.DeserializeObject(M.VenuesWithTips[i]) as JsonObject;
                        JsonObject ResponseObject = MainDataObject["response"] as JsonObject;
                        JsonObject V = ResponseObject["venue"] as JsonObject;


                        int CheckinsCount = 0;
                        int UsersCount    = 0;

                        VenueLocation        JsVenueLoc        = new VenueLocation();
                        List <VenueCategory> JsVenueCategories = new List <VenueCategory>();
                        List <VenueTip>      JsVenueTips       = new List <VenueTip>();

                        if (Verifier.Verify(V, "tips"))
                        {
                            JsonObject TipsObject   = V["tips"] as JsonObject;
                            JsonArray  GroupsObject = TipsObject["groups"] as JsonArray;

                            foreach (JsonObject O in GroupsObject)
                            {
                                if (Verifier.Verify(O, "items"))
                                {
                                    JsonArray TipsItems = O["items"] as JsonArray;

                                    foreach (JsonObject T in TipsItems)
                                    {
                                        JsVenueTips.Add(new VenueTip()
                                        {
                                            TipText = T["text"] as String
                                        });
                                    }
                                }
                            }
                        }

                        if (Verifier.Verify(V, "stats"))
                        {
                            JsonObject Status = V["stats"] as JsonObject;
                            int.TryParse(Status["usersCount"] as String, out UsersCount);
                            int.TryParse(Status["checkinsCount"] as String, out CheckinsCount);
                        }

                        if (Verifier.Verify(V, "categories"))
                        {
                            JsonArray Categories = V["categories"] as JsonArray;

                            foreach (JsonObject C in Categories)
                            {
                                JsVenueCategories.Add(new VenueCategory()
                                {
                                    ID        = C["id"] as String,
                                    Name      = C["name"] as String,
                                    ShortName = C["shortName"] as String,
                                    LongName  = C["pluralName"] as String
                                });
                            }
                        }

                        if (Verifier.Verify(V, "location"))
                        {
                            JsonObject Loc = V["location"] as JsonObject;

                            if (Verifier.Verify(V, "address"))
                            {
                                JsVenueLoc.Address = Loc["address"] as String;
                            }

                            JsVenueLoc.Latitude  = (Double)Loc["lat"];
                            JsVenueLoc.Longitude = (Double)Loc["lng"];
                        }

                        Venue MV = new Venue(
                            V["id"] as String,
                            V["name"] as String,
                            UsersCount,
                            CheckinsCount,
                            JsVenueLoc,
                            JsVenueCategories,
                            JsVenueTips
                            );

                        MiniVenues.Add(MV);
                    }
                }
                catch (Exception E)
                {
                    Console.Write(E.Message);
                }
                finally
                { }
            }

            //MiniVenues = MiniVenues.Distinct(new VenuesComparer<Venue>()).ToList();
            FilterAllVenuesByTips();
        }
Exemplo n.º 9
0
        private void ParseMiniVenues(JsonArray VenuesData, List <Venue> MiniVenues)
        {
            foreach (JsonObject V in VenuesData)
            {
                int CheckinsCount = 0;
                int UsersCount    = 0;

                VenueLocation        JsVenueLoc        = new VenueLocation();
                List <VenueCategory> JsVenueCategories = new List <VenueCategory>();

                if (Verifier.Verify(V, "stats"))
                {
                    JsonObject Status = V["stats"] as JsonObject;
                    int.TryParse(Status["usersCount"] as String, out UsersCount);
                    int.TryParse(Status["checkinsCount"] as String, out CheckinsCount);
                }

                if (Verifier.Verify(V, "categories"))
                {
                    JsonArray Categories = V["categories"] as JsonArray;

                    foreach (JsonObject C in Categories)
                    {
                        JsVenueCategories.Add(new VenueCategory()
                        {
                            ID        = C["id"] as String,
                            Name      = C["name"] as String,
                            ShortName = C["shortName"] as String,
                            LongName  = C["pluralName"] as String
                        });
                    }
                }

                if (Verifier.Verify(V, "location"))
                {
                    JsonObject Loc = V["location"] as JsonObject;

                    if (Verifier.Verify(Loc, "address"))
                    {
                        JsVenueLoc.Address = Loc["address"] as String;
                    }

                    if (Verifier.Verify(Loc, "lat"))
                    {
                        JsVenueLoc.Latitude = (Double)Loc["lat"];
                    }

                    if (Verifier.Verify(Loc, "lng"))
                    {
                        JsVenueLoc.Longitude = (Double)Loc["lng"];
                    }
                }


                Venue MV = new Venue(
                    V["id"] as String,
                    V["name"] as String,
                    UsersCount,
                    CheckinsCount,
                    JsVenueLoc,
                    JsVenueCategories
                    );

                MiniVenues.Add(MV);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Reads the local file.
        /// </summary>
        /// <returns>GeoJSONData in raw format.</returns>
        public GeoJSONData ReadLocalFile()
        {
            GeoJSONData data    = new GeoJSONData();
            string      content = "";

            using (var input = context.Assets.Open(FileName))
                using (StreamReader sr = new System.IO.StreamReader(input))
                {
                    string temp = sr.ReadLine();
                    while (true)
                    {
                        if (string.IsNullOrEmpty(temp))
                        {
                            break;
                        }
                        content += temp + "\n";
                        temp     = sr.ReadLine();
                    }
                }
            var geoData = new GeoJSONData();

            geoData.Data = content;
            var tempList = new List <VenueLocation>();

            using (var input = context.Assets.Open(FileName1))
                using (StreamReader sr = new StreamReader(input))
                {
                    string temp = sr.ReadLine();
                    while (true)
                    {
                        if (string.IsNullOrEmpty(temp))
                        {
                            break;
                        }
                        var subject = "";
                        var index   = 0;
                        for (int i = 0; i < temp.Length; i++, index++)
                        {
                            if (temp[i] != '[')
                            {
                                subject += temp[i];
                            }
                            else
                            {
                                index++;                         //skip over the '['
                                break;
                            }
                        }
                        var venue = "";
                        subject = new SpaceRemover(subject).RemovedSpaces;
                        for (int a = index; a < temp.Length; a++)
                        {
                            var ch = temp[a];
                            if (temp[a] == ']')
                            {
                                break;
                            }
                            else
                            {
                                venue += temp[index++];
                            }
                        }
                        var tempVenueLoc = new VenueLocation {
                            Name = venue
                        };
                        tempList.Add(tempVenueLoc);
                        temp = sr.ReadLine();
                    }
                }
            var result = string.Join(",", tempList);

            loc = tempList;
            return(geoData);
        }
Exemplo n.º 11
0
        public async Task <VenueLocation> AddGeoLocation(VenueLocation venueLocation)
        {
            VenueLocation location = await _locationRepo.AddGeoLocation(venueLocation);

            return(location);
        }
Exemplo n.º 12
0
        public GeoJSONData Process()
        {
            var    content  = "";
            var    content2 = "";
            var    current  = Directory.GetCurrentDirectory();
            var    text     = System.IO.File.OpenText("Files/RhodesMap.geojson");
            string temp     = text.ReadLine();

            while (true)
            {
                if (string.IsNullOrEmpty(temp))
                {
                    break;
                }
                content += temp + "\n";
                temp     = text.ReadLine();
            }
            GeoJSONData geoData = new GeoJSONData {
                Data = content
            };

            text = System.IO.File.OpenText("Files/Venues.txt");
            temp = text.ReadLine();
            var tempList = new List <VenueLocation>();

            while (true)
            {
                if (string.IsNullOrEmpty(temp))
                {
                    break;
                }
                var subject = "";
                var index   = 0;
                for (int i = 0; i < temp.Length; i++, index++)
                {
                    if (temp[i] != '[')
                    {
                        subject += temp[i];
                    }
                    else
                    {
                        index++;                                 //skip over the '['
                        break;
                    }
                }
                var venue = "";
                subject = new SpaceRemover(subject).RemovedSpaces;
                for (int a = index; a < temp.Length; a++)
                {
                    if (temp[a] == ']')
                    {
                        break;
                    }
                    else
                    {
                        venue += temp[index++];
                    }
                }
                var tempVenueLoc = new VenueLocation {
                    Name = venue
                };
                tempList.Add(tempVenueLoc);
                temp = text.ReadLine();
            }
            loc = tempList;
            return(geoData);
        }
Exemplo n.º 13
0
        public async Task <VenueLocation> AddGeoLocation(VenueLocation venueLocation)
        {
            await _venueLocationCollection.InsertOneAsync(venueLocation);

            return(venueLocation);
        }