public ZonedEvent(string title, string url, string source, bool allday, string lat, string lon, string categories, DateTimeWithZone dtstart, DateTimeWithZone dtend, string description, string location) : base(title, url, source, allday, lat, lon, categories, description, location) { this.dtstart = dtstart; this.dtend = dtend; }
public void TagsAndUrlsAreCoalesced() // 3 events with same title + start should coalesce tags and urls { DeleteZonedObjects(keene_test_hub); var dtstart = new DateTimeWithZone(DateTime.Now, calinfo_keene.tzinfo); var dtend = new DateTimeWithZone(dtstart.LocalTime + TimeSpan.FromHours(1), calinfo_keene.tzinfo); var es1 = new ZonedEventStore(calinfo_keene, SourceType.ical); es1.AddEvent( "event", "http://1", "source1", dtstart, dtend, "1", "1", false, "cat1", "first event", "first location" ); es1.Serialize(); Assert.IsTrue(calinfo_keene.eventful); var es2 = new ZonedEventStore(calinfo_keene, SourceType.eventful); es2.AddEvent( "event", "http://2", "source2", dtstart, dtend, "2", "2", false, "cat2,cat2a", "second event", "second location" ); es2.Serialize(); EventStore.CombineZonedEventStoresToZonelessEventStore(keene_test_hub, settings); var es = new ZonelessEventStore(calinfo_keene).Deserialize(); Assert.That(es.events.Count == 1); var evt = es.events.Find(e => e.title == "event"); Assert.That(evt.categories == "cat1,cat2,cat2a"); Assert.That(evt.urls_and_sources.Keys.Count == 2); Assert.That(evt.urls_and_sources["http://1"] == "source1"); Assert.That(evt.urls_and_sources["http://2"] == "source2"); }
public void AddEvent(string title, string url, string source, DateTimeWithZone dtstart, DateTimeWithZone dtend, string lat, string lon, bool allday, string categories, string description, string location) { title = title.StripHtmlTags(); if (location != null) { location = location.StripHtmlTags(); } if (description != null) { description = description.StripHtmlTags(); } ZonedEvent evt = new ZonedEvent(title: title, url: url, source: source, dtstart: dtstart, dtend: dtend, lat: lat, lon: lon, allday: allday, categories: categories, description: description, location: location); events.Add(evt); }
public void UpcomingUrlsAreNormalized() { DeleteZonedObjects(keene_test_hub); var dtstart = new DateTimeWithZone(DateTime.Now, calinfo_keene.tzinfo); var dtend = new DateTimeWithZone(dtstart.LocalTime + TimeSpan.FromHours(1), calinfo_keene.tzinfo); var es1 = new ZonedEventStore(calinfo_keene, SourceType.ical); es1.AddEvent( "event", "http://upcoming.yahoo.com/event/8504144/", "Comedy Showcase", dtstart, dtend, "1", "1", false, "comedy", "first event", "first location" ); es1.Serialize(); var es2 = new ZonedEventStore(calinfo_keene, SourceType.upcoming); es2.AddEvent( "event", "http://upcoming.yahoo.com/event/8504144", "Ann Arbor Comedy Showcase", dtstart, dtend, "1", "1", false, "upcoming", "first event", "first location" ); es2.Serialize(); EventStore.CombineZonedEventStoresToZonelessEventStore(keene_test_hub, settings); var es = new ZonelessEventStore(calinfo_keene).Deserialize(); Assert.That(es.events.Count == 1); var evt = es.events.Find(e => e.title == "event"); var categories = evt.categories.Split(',').ToList(); categories.Sort(); Assert.That(categories.SequenceEqual(new List<string>() { "comedy", "upcoming" })); Assert.That(evt.urls_and_sources.Keys.Count == 1); }
public void TagsAndUrlsAreCoalesced() { DeleteZonedObjects(keene_test_hub); var dtstart = new DateTimeWithZone(DateTime.Now, calinfo_keene.tzinfo); var dtend = new DateTimeWithZone(dtstart.LocalTime + TimeSpan.FromHours(1), calinfo_keene.tzinfo); var es1 = new ZonedEventStore(calinfo_keene, SourceType.ical); es1.AddEvent( "event", "http://1", "source1", dtstart, dtend, "1", "1", false, "cat1", "first event", "first location" ); es1.Serialize(); Assert.IsTrue(calinfo_keene.eventful); var es2 = new ZonedEventStore(calinfo_keene, SourceType.eventful); es2.AddEvent( "event", "http://2", "source2", dtstart, dtend, "2", "2", false, "cat2,cat2a", "second event", "second location" ); es2.Serialize(); Assert.IsTrue(calinfo_keene.upcoming); var es3 = new ZonedEventStore(calinfo_keene, SourceType.upcoming); es3.AddEvent( "event", "http://3", "source3", dtstart, dtend, "3", "3", false, "cat3,cat3a", "third event", "third location" ); es3.AddEvent( "another event", "http://4", "source4", dtstart, dtend, "4", "4", false, "cat4,cat4a", "fourth event", "fourth location" ); es3.Serialize(); EventStore.CombineZonedEventStoresToZonelessEventStore(keene_test_hub, settings); var es = new ZonelessEventStore(calinfo_keene).Deserialize(); Assert.That(es.events.Count == 2); var evt = es.events.Find(e => e.title == "event"); Assert.That(evt.categories == "cat1,cat2,cat2a,cat3,cat3a"); Assert.That(evt.urls_and_sources.Keys.Count == 3); Assert.That(evt.urls_and_sources["http://1"] == "source1"); Assert.That(evt.urls_and_sources["http://2"] == "source2"); Assert.That(evt.urls_and_sources["http://3"] == "source3"); //Assert.That(evt.list_of_urls_and_sources[0][0] == "http://1" && evt.list_of_urls_and_sources[0][1] == "source1"); //Assert.That(evt.list_of_urls_and_sources[1][0] == "http://2" && evt.list_of_urls_and_sources[1][1] == "source2"); //Assert.That(evt.list_of_urls_and_sources[2][0] == "http://3" && evt.list_of_urls_and_sources[2][1] == "source3"); }
public void EventfulUrlsAreNormalized() { DeleteZonedObjects(keene_test_hub); var dtstart = new DateTimeWithZone(DateTime.Now, calinfo_keene.tzinfo); var dtend = new DateTimeWithZone(dtstart.LocalTime + TimeSpan.FromHours(1), calinfo_keene.tzinfo); var es1 = new ZonedEventStore(calinfo_keene, SourceType.ical); es1.AddEvent( "event", "http://eventful.com/E0-001-039987477-3", "The Blind Pig", dtstart, dtend, "1", "1", false, "music", "first event", "first location" ); es1.Serialize(); var es2 = new ZonedEventStore(calinfo_keene, SourceType.eventful); es2.AddEvent( "event", "http://eventful.com/events/E0-001-039987477-3", "Blind Pig", dtstart, dtend, "1", "1", false, "eventful", "first event", "first location" ); es2.Serialize(); EventStore.CombineZonedEventStoresToZonelessEventStore(keene_test_hub, settings); var es = new ZonelessEventStore(calinfo_keene).Deserialize(); Assert.That(es.events.Count == 1); var evt = es.events.Find(e => e.title == "event"); var categories = evt.categories.Split(',').ToList(); categories.Sort(); Assert.That(categories.SequenceEqual(new List<string>() { "eventful", "music" })); Assert.That(evt.urls_and_sources.Keys.Count == 1); }
public void CollectFacebook(ZonedEventStore es, bool test) { using (facebook_ical) { var args = string.Format("q={0}&since=yesterday&limit=1000", this.calinfo.where); var method = "search"; var msg = string.Format("{0}: loading facebook events", this.id); GenUtils.LogMsg("info", msg, null); var uniques = new Dictionary<string, FacebookEvent>(); // dedupe by title + start foreach (var fb_event in FacebookIterator(method, args)) uniques.AddOrUpdateDictionary<string, FacebookEvent>(fb_event.name + fb_event.dt.ToString(), fb_event); foreach (FacebookEvent fb_event in uniques.Values) { var dtstart_with_zone = new DateTimeWithZone(fb_event.dt, this.calinfo.tzinfo); if (dtstart_with_zone.UniversalTime < Utils.MidnightInTz(this.calinfo.tzinfo).UniversalTime) continue; AddFacebookEvent(es, fb_event, dtstart_with_zone); } fbstats.whenchecked = DateTime.Now.ToUniversalTime(); SerializeStatsAndIntermediateOutputs(es, facebook_ical, fbstats, SourceType.facebook); } }
// put the event into a) the eventstore, and b) the per-type intermediate icalendar object public void AddIcalEvent(DDay.iCal.Event evt, FeedRegistry fr, ZonedEventStore es, string feedurl, string source) { try { evt = NormalizeIcalEvt(evt, feedurl, source); DateTimeWithZone dtstart; DateTimeWithZone dtend; var tzinfo = this.calinfo.tzinfo; //dtstart = Utils.DtWithZoneFromICalDateTime(evt.Start.Value, tzinfo); //dtend = (evt.DTEnd == null) ? new Utils.DateTimeWithZone(DateTime.MinValue, tzinfo) : Utils.DtWithZoneFromICalDateTime(evt.End.Value, tzinfo); //dtstart = new Utils.DateTimeWithZone(evt.Start.Value,tzinfo); //dtend = new Utils.DateTimeWithZone(evt.End.Value,tzinfo); var localstart = evt.DTStart.IsUniversalTime ? TimeZoneInfo.ConvertTimeFromUtc(evt.Start.UTC, tzinfo) : evt.Start.Local; dtstart = new DateTimeWithZone(localstart, tzinfo); var localend = evt.DTEnd.IsUniversalTime ? TimeZoneInfo.ConvertTimeFromUtc(evt.End.UTC, tzinfo) : evt.End.Local; dtend = new DateTimeWithZone(localend, tzinfo); MakeGeo(this.calinfo, evt, this.calinfo.lat, this.calinfo.lon); string categories = null; if (evt.Categories != null && evt.Categories.Count() > 0) categories = string.Join(",", evt.Categories.ToList().Select(cat => cat.ToString().ToLower())); string description = this.calinfo.has_descriptions ? evt.Description : null; string location = this.calinfo.has_locations ? evt.Location : null; es.AddEvent(title: evt.Summary, url: evt.Url.ToString(), source: source, dtstart: dtstart, dtend: dtend, lat: this.calinfo.lat, lon: this.calinfo.lon, allday: evt.IsAllDay, categories: categories, description: description, location: location); var evt_tmp = MakeTmpEvt(this.calinfo, dtstart: dtstart, dtend: dtend, title: evt.Summary, url: evt.Url.ToString(), location: evt.Location, description: source, lat: this.calinfo.lat, lon: this.calinfo.lon, allday: evt.IsAllDay); AddEventToDDayIcal(ical_ical, evt_tmp); if ( fr.stats.ContainsKey(feedurl) ) // won't be true when adding to the per-feed obj cache fr.stats[feedurl].loaded++; // and this will have already been counted by the all-feeds AddIcalEvent } catch (Exception e) { GenUtils.PriorityLogMsg("exception", "AddIcalEvent", source + ": " + e.Message + ": " + evt.Summary); } }
public void AddFacebookEvent(ZonedEventStore es, FacebookEvent fb_event, DateTimeWithZone dtstart) { var title = fb_event.name; var event_url = "http://www.facebook.com/event.php?eid=" + fb_event.id; var source = "facebook"; var location = fb_event.location; var all_day = false; fbstats.eventcount++; var evt_tmp = MakeTmpEvt(this.calinfo, dtstart, DateTimeWithZone.MinValue(this.calinfo.tzinfo), title, url: event_url, location: location, description: source, lat: this.calinfo.lat, lon: this.calinfo.lon, allday: all_day); AddEventToDDayIcal(facebook_ical, evt_tmp); var min = DateTimeWithZone.MinValue(this.calinfo.tzinfo); es.AddEvent(title: title, url: event_url, source: source, dtstart: dtstart, dtend: min, lat: null, lon: null, allday: all_day, categories: "facebook", description: null, location: location); }
public void AddEventfulEvent(ZonedEventStore es, string venue_name, XElement evt) { var str_dtstart = XmlUtils.GetXeltValue(evt, ElmcityUtils.Configurator.no_ns, "start_time"); DateTime dtstart = Utils.LocalDateTimeFromLocalDateStr(str_dtstart); var dtstart_with_tz = new DateTimeWithZone(dtstart, this.calinfo.tzinfo); if (dtstart_with_tz.UniversalTime < Utils.MidnightInTz(this.calinfo.tzinfo).UniversalTime) return; var no_ns = ElmcityUtils.Configurator.no_ns; var event_id = evt.Attribute("id").Value; var event_owner = XmlUtils.GetXeltValue(evt, no_ns, "owner"); var title = XmlUtils.GetXeltValue(evt, no_ns, "title"); var venue_url = XmlUtils.GetXeltValue(evt, no_ns, "venue_url"); var all_day = XmlUtils.GetXeltValue(evt, no_ns, "all_day") == "1"; var venue_address = XmlUtils.GetXeltValue(evt, no_ns, "venue_address"); string lat = this.calinfo.lat; // default to hub lat/lon string lon = this.calinfo.lon; lat = XmlUtils.GetXeltValue(evt, no_ns, "latitude"); lon = XmlUtils.GetXeltValue(evt, no_ns, "longitude"); if (lat == null || lon == null) { GenUtils.LogMsg("warning", "AddEventfulEvent", "no lat/lon"); } var category = XmlUtils.GetXeltValue(evt, ElmcityUtils.Configurator.no_ns, "category"); if (String.IsNullOrWhiteSpace(category)) category = SourceType.eventful.ToString(); else category = SourceType.eventful.ToString() + "," + category; string event_url = "http://eventful.com/events/" + event_id; string source = venue_name; if (String.IsNullOrEmpty(source)) source = "Unnamed Eventful Venue"; string location; if (!String.IsNullOrEmpty(source)) { location = venue_name; if (!String.IsNullOrEmpty(venue_address)) location += ", " + venue_address; } else { location = event_url; } estats.eventcount++; var evt_tmp = MakeTmpEvt(this.calinfo, dtstart_with_tz, DateTimeWithZone.MinValue(this.calinfo.tzinfo), title, url: event_url, location: location, description: source, lat: lat, lon: lon, allday: all_day); AddEventToDDayIcal(eventful_ical, evt_tmp); var min = DateTimeWithZone.MinValue(this.calinfo.tzinfo); // suppress description to minimize amount of eventful info carried in the event packet // allow location but it is subject to the per-hub locations setting (calinfo.has_locations) es.AddEvent(title: title, url: event_url, source: source, dtstart: dtstart_with_tz, dtend: min, lat: lat, lon: lon, allday: all_day, categories: category, description: null, location: location); }
public void AddEventBriteEvent(ZonedEventStore es, XElement evt, DateTimeWithZone dtstart, DateTimeWithZone dtend) { string title; string event_url; string source; bool all_day; string categories; var evt_tmp = MakeDDayEventFromEventBriteEvent(evt, out title, out event_url, out source, out all_day, out categories); AddEventToDDayIcal(eventbrite_ical, evt_tmp); var min = DateTimeWithZone.MinValue(this.calinfo.tzinfo); // todo: dig out location from http://developer.eventbrite.com/doc/events/event_search/ es.AddEvent(title: title, url: event_url, source: source, dtstart: dtstart, dtend: dtend, lat: null, lon: null, allday: all_day, categories: categories, description: null, location: null); }
public static DDay.iCal.Event MakeTmpEvt(TimeZoneInfo tzinfo, DateTimeWithZone dtstart, DateTimeWithZone dtend, string title, string url, string location, string description, string lat, string lon, bool allday) { var calinfo = new Calinfo(tzinfo); return MakeTmpEvt(calinfo, dtstart, dtend, title, url, location, description, lat, lon, allday); }
public static DDay.iCal.Event MakeTmpEvt(Calinfo calinfo, DateTimeWithZone dtstart, DateTimeWithZone dtend, string title, string url, string location, string description, string lat, string lon, bool allday) { DDay.iCal.Event evt = new DDay.iCal.Event(); // for export to the intermediate ics file evt.Summary = title; evt.Url = new Uri(url); if (location != null) evt.Location = location; if (description != null) evt.Description = description; else evt.Description = url; if ( calinfo == null ) MakeGeo(calinfo, evt, lat, lon); else MakeGeo(evt, lat, lon); evt.Start = new iCalDateTime(dtstart.LocalTime); // always local because the final ics file will use vtimezone evt.Start.TZID = calinfo.tzinfo.Id; if (!dtend.Equals(DateTimeWithZone.MinValue(calinfo.tzinfo))) { evt.End = new iCalDateTime(dtend.LocalTime); evt.End.TZID = calinfo.tzinfo.Id; } evt.IsAllDay = allday; evt.UID = Event.MakeEventUid(evt); return evt; }
private DateTimeWithZone DateTimeWithZoneFromUpcomingXEvent(XElement evt, ref bool allday) { string str_date = ""; string str_time = ""; try { str_date = evt.Attribute("start_date").Value; str_time = evt.Attribute("start_time").Value; if (str_time == "") { str_time = "00:00:00"; allday = true; } var str_dtstart = str_date + " " + str_time; var _dtstart = Utils.LocalDateTimeFromLocalDateStr(str_dtstart); var dtstart = new DateTimeWithZone(_dtstart, this.calinfo.tzinfo); return dtstart; } catch (Exception e) { GenUtils.PriorityLogMsg("exception", "DateTimeWithZoneFromUpcomingXEvent: " + string.Format("date[{0}] time[{1}]", str_date, str_time), e.Message + e.StackTrace); return new DateTimeWithZone(DateTime.MinValue, this.calinfo.tzinfo); } }
public void AddEvent(string title, string url, string source, DateTimeWithZone dtstart, DateTimeWithZone dtend, string lat, string lon, bool allday, string categories, string description, string location) { title = title.StripHtmlTags(); if ( location != null ) location = location.StripHtmlTags(); if ( description != null ) description = description.StripHtmlTags(); ZonedEvent evt = new ZonedEvent(title: title, url: url, source: source, dtstart: dtstart, dtend: dtend, lat: lat, lon: lon, allday: allday, categories: categories, description: description, location: location); events.Add(evt); }
public ZonedEvent(string title, string url, string source, bool allday, string lat, string lon, string categories, DateTimeWithZone dtstart, DateTimeWithZone dtend, string description, string location) : base(title, url, source, allday, lat, lon, categories, description, location) { this.dtstart = dtstart; this.dtend = dtend; }