public static void Finalize(Calinfo calinfo, ZonelessEventStore es_zoneless) { es_zoneless.events = EventStore.UniqueByTitleAndStart(calinfo.id, es_zoneless.events, save_tag_sources: true); // deduplicate es_zoneless.ExcludePastEvents(); // the EventCollector should already have done this, but in case not... es_zoneless.SortEventList(); // order by dtstart Utils.BuildTagStructures(es_zoneless, calinfo); // build structures used to generate tag picklists var i = 0; foreach (var evt in es_zoneless.events) { var str = evt.dtstart.ToString() + evt.title.ToString() + evt.source.ToString() + evt.url; var hash = HttpUtils.GetMd5Hash(Encoding.UTF8.GetBytes(str)); evt.uid = i; i++; evt.hash = hash; } es_zoneless.PopulateDaysAndCounts(); // do this here for a) renderer efficiency, b) renderer simplification // (it only updates these structures for category views) es_zoneless.when_finalized = DateTime.UtcNow; es_zoneless.Serialize(); }
public void SerializeAndDeserializeZonelessEventStoreYieldsExpectedEvents() { var es = new ZonelessEventStore(calinfo); es.AddEvent(title: title1, url: "http://foo", source: source1, lat: null, lon: null, dtstart: dt1, dtend: min, allday: false, categories: test_category, description: test_description, location: test_location); var evt1 = es.events.Find(e => e.title == title1); evt1.urls_and_sources = new Dictionary <string, string>() { { "http://foo", source1 } }; es.AddEvent(title: title2, url: "http://bar", source: source2, lat: null, lon: null, dtstart: dt2, dtend: min, allday: false, categories: null, description: test_description, location: test_location); var evt2 = es.events.Find(e => e.title == title2); evt2.urls_and_sources = new Dictionary <string, string>() { { "http://bar", source2 } }; var response = es.Serialize(); Assert.AreEqual(HttpStatusCode.Created, response.HttpResponse.status); var es2 = new ZonelessEventStore(calinfo).Deserialize(); es2.SortEventList(); Assert.That(es2.events.Count == 2); evt1 = es2.events[0]; evt2 = es2.events[1]; Assert.AreEqual(evt1.dtstart, dt1); Assert.AreEqual(evt2.dtstart, dt2); Assert.AreEqual(evt1.title, title1); Assert.AreEqual(evt2.title, title2); }
public void SerializeAndDeserializeZonelessEventStoreYieldsExpectedEvents() { var es = new ZonelessEventStore(calinfo); es.AddEvent(title:title1, url:"http://foo", source:source1, lat: null, lon: null, dtstart: dt1, dtend: min, allday: false, categories: test_category, description: test_description, location: test_location); var evt1 = es.events.Find(e => e.title == title1); evt1.urls_and_sources = new Dictionary<string, string>() { { "http://foo", source1 } }; //var item1 = new List<string>() { "http://foo", source1 }; //evt1.list_of_urls_and_sources = new List<List<string>>() { item1 }; es.AddEvent(title:title2, url:"http://bar", source:source2, lat: null, lon: null, dtstart: dt2, dtend: min, allday: false, categories:null, description: test_description, location: test_location); var evt2 = es.events.Find(e => e.title == title2); evt2.urls_and_sources = new Dictionary<string, string>() { { "http://bar", source2 } }; //var item2 = new List<string>() { "http://foo", source2 }; //evt2.list_of_urls_and_sources = new List<List<string>>() { item2 }; es.Serialize(); var es2 = new ZonelessEventStore(calinfo).Deserialize(); CalendarRenderer.OrganizeByDate(es2); Assert.That(es2.event_dict.Keys.Count == 2); var list1 = es2.event_dict[es2.event_dict.Keys.First()]; var list2 = es2.event_dict[es2.event_dict.Keys.Last()]; evt1 = list1.First(); evt2 = list2.First(); Assert.AreEqual(evt1.dtstart, dt1); Assert.AreEqual(evt2.dtstart, dt2); Assert.AreEqual(evt1.title, title1); Assert.AreEqual(evt2.title, title2); evt1 = es2.events.First(); evt2 = es2.events.Last(); Assert.AreEqual(evt1.dtstart, dt1); Assert.AreEqual(evt2.dtstart, dt2); Assert.AreEqual(evt1.title, title1); Assert.AreEqual(evt2.title, title2); }
public void SerializeAndDeserializeZonelessEventStoreYieldsExpectedEvents() { var es = new ZonelessEventStore(calinfo); es.AddEvent(title:title1, url:"http://foo", source:source1, lat: null, lon: null, dtstart: dt1, dtend: min, allday: false, categories: test_category, description: test_description, location: test_location); var evt1 = es.events.Find(e => e.title == title1); evt1.urls_and_sources = new Dictionary<string, string>() { { "http://foo", source1 } }; es.AddEvent(title:title2, url:"http://bar", source:source2, lat: null, lon: null, dtstart: dt2, dtend: min, allday: false, categories:null, description: test_description, location: test_location); var evt2 = es.events.Find(e => e.title == title2); evt2.urls_and_sources = new Dictionary<string, string>() { { "http://bar", source2 } }; var response = es.Serialize(); Assert.AreEqual(HttpStatusCode.Created, response.HttpResponse.status); var es2 = new ZonelessEventStore(calinfo).Deserialize(); es2.SortEventList(); Assert.That(es2.events.Count == 2); evt1 = es2.events[0]; evt2 = es2.events[1]; Assert.AreEqual(evt1.dtstart, dt1); Assert.AreEqual(evt2.dtstart, dt2); Assert.AreEqual(evt1.title, title1); Assert.AreEqual(evt2.title, title2); }
public static void UniqueFilterSortSerialize(string id, ZonelessEventStore es_zoneless) { es_zoneless.events = EventStore.UniqueByTitleAndStart(id, es_zoneless.events, save_tag_sources:true); // deduplicate es_zoneless.ExcludePastEvents(); // the EventCollector should already have done this, but in case not... es_zoneless.SortEventList(); // order by dtstart es_zoneless.Serialize(); }