Пример #1
0
        public static List<TaggableSource> GetEventBriteOrganizers(Calinfo calinfo, Dictionary<string, string> settings)
        {
            var organizers = new List<TaggableSource>();
            var name_and_pk = "eventbritesources";
            var collector = new Collector(calinfo, settings);
            string method = "event_search";
            string args = collector.MakeEventBriteArgs();
            int page_count = collector.GetEventBritePageCount(method, args);

            var results = from evt in collector.EventBriteIterator(page_count, method, args)
                          select new
                          {
                              id = evt.Descendants("organizer").Descendants("id").FirstOrDefault().Value,
                              name = evt.Descendants("organizer").Descendants("name").FirstOrDefault().Value,
                              city = evt.Descendants("venue").Descendants("city").FirstOrDefault().Value.ToLower()
                          };

            results = results.Distinct();

            Parallel.ForEach(source: results, body: (id_name_city) =>
            {
                if (id_name_city.city != calinfo.City)
                    return;
                var organizer_id = id_name_city.id;
                var name = id_name_city.name;
                var home_url = "http://www.eventbrite.com/org/" + organizer_id;
                var escaped_name = Uri.EscapeDataString(name);
                var ical_url = string.Format("http://elmcity.cloudapp.net/ics_from_eventbrite_organizer?organizer={0}&elmcity_id={1}", escaped_name, calinfo.id);
                var taggable = new TaggableSource(name, calinfo.id, home_url, ical_url, id_name_city.city);
                RememberTaggable(name_and_pk, organizer_id, taggable);
                organizers.Add(taggable);
            });

            return organizers;
        }
Пример #2
0
        public void EventbriteQueryReturnsPageCountOrMinusOne()
        {
            var collector = new Collector(test_calinfo, settings);

            string method = "event_search";
            string args = collector.MakeEventBriteArgs(2, null);
            int count = collector.GetEventBritePageCount(method, args);
            Assert.That(count == -1 || count >= 1);
            if (count >= 1 && settings["eventbrite_quota_reached"] == "True")
            {
                GenUtils.PriorityLogMsg("info", "GetEventBritePageCount", "resetting quota marker");
                var dict = new Dictionary<string, object>() { { "value", false } };
                TableStorage.UpmergeDictToTableStore(dict, "settings", "settings", "eventbrite_quota_reached");
            }
        }