public async Task <List <ArloRegistration> > GetAllEventRegistrations(ArloEvent ev, bool forceRefresh) { var cache = await GetEntity <List <ArloRegistration> >(Constants.Cache.AllRegistrationsComplete); if (cache != null && !forceRefresh) { return(cache); } var links = await RecurseGetLinks <EventRegistrationList>(ev, Constants.Cache.AllRegistrations, Constants.Rel.Registrations, true, forceRefresh); var registrants = await _getRegistrationLinks(links, forceRefresh); var taskListUpdateCache = new List <Task>(); foreach (var r in registrants) { if (r.Contact == null) { continue; } taskListUpdateCache.Add(SetEntity(string.Format(Constants.Cache.Contact, r.Contact.ContactID), r)); taskListUpdateCache.Add(SetEntity(string.Format(Constants.Cache.Registration, r.RegistrationID), r)); } await Task.WhenAll(taskListUpdateCache); await SetEntity(Constants.Cache.AllRegistrationsComplete, registrants); return(registrants); }
public async Task <List <ArloContact> > GetAllEventRegistrationContacts(ArloEvent ev, bool forceRefresh) { var cache = await GetEntity <List <ArloContact> >(Constants.Cache.AllRegistrationContactsComplete); if (cache != null && !forceRefresh) { return(cache); } var links = await RecurseGetLinks <EventRegistrationList>(ev, Constants.Cache.AllRegistrations, Constants.Rel.Registrations, true, forceRefresh); var registrants = await LoadLinkEntities <ArloRegistration>(links, Constants.Cache.AllRegistrationList, Constants.Rel.Registration, forceRefresh); var contacts = await LoadLinkEntitiesFromList <ArloContact, ArloRegistration>(registrants, Constants.Cache.AllRegistrationContacts, Constants.Rel.RelatedContact, forceRefresh); if (contacts == null) { _logService.TrackTrace("NullContacts!", XSeverityLevel.Critical); return(null); } await SetEntity(Constants.Cache.AllRegistrationContactsComplete, contacts); if (forceRefresh) { _logService.TrackMetric("EventRegistrations", contacts.Count); } return(contacts); }
public async Task <ArloRegistration> MapContactIdToRegistration(ArloEvent ev, string contactId) { var cache = await GetEntity <ArloRegistration>(string.Format(Constants.Cache.Contact, contactId)); if (cache != null) { return(cache); } //this guy is not present so need to resolve it using search var searchRego = await _registrationSearch.Search(ev, contactId); if (searchRego == null) { return(null); } var registrants = await LoadLinkEntities <ArloRegistration>(searchRego, Constants.Cache.AllRegistrationList + $".{contactId}", Constants.Rel.Registration, true); var registrant = registrants.FirstOrDefault(); var link = registrant.FindLink(Constants.Rel.RelatedContact); if (link == null) { return(null); } registrant.Contact = await LoadEntity <ArloContact>(link, link); await SetEntity(string.Format(Constants.Cache.Contact, contactId), registrant); return(registrant); }
public async Task <List <string> > GetAllPresenters(ArloEvent ev) { var cache = await GetEntity <List <string> >(Constants.Cache.AllPresenters); if (cache != null) { return(cache); } var eventSession = await GetEventSessions(false); var allPresenters = new List <string>(); foreach (var session in eventSession) { foreach (var presenter in session.Presenters) { var fullName = presenter.FullName; if (!allPresenters.Contains(fullName)) { allPresenters.Add(fullName); } } } await SetEntity(Constants.Cache.AllPresenters, allPresenters); return(allPresenters); }
public async Task SimpleCacheTest() { var cache = Resolve <IRedisEntityCache>(); await cache.Delete <ArloEvent>("test"); var d = await cache.GetEntity <ArloEvent>("test"); Assert.IsNull(d); var arloItem = new ArloEvent { Description = "test" }; var write = await cache.SetEntity("test", arloItem); d = await cache.GetEntity <ArloEvent>("test"); Assert.IsNotNull(d); await cache.Delete <ArloEvent>("test"); d = await cache.GetEntity <ArloEvent>("test"); Assert.IsNull(d); }
public async Task <SessionList> GetAllEventSessionLinks(ArloEvent ev, bool doNext, bool forceRefresh) { var sessionList = await RecurseGetLinks <SessionList>(ev, _getEventSessionsKey(ev), Constants.Rel.Sessions, true, forceRefresh); return(sessionList); }
public async Task <EventRegistrationList> Search(ArloEvent ev, string contactId) { var baseUrl = new Uri(ev.FindLink(Constants.Rel.Registrations)); var actualUrl = new Uri(baseUrl, $"?filter=Contact/ContactId eq {contactId}"); return(await Get(actualUrl.ToString())); }
public async Task <List <string> > GetAllTopics(ArloEvent ev) { var cache = await GetEntity <List <string> >(Constants.Cache.AllTopics); if (cache != null) { return(cache); } var eventSession = await GetEventSessions(false); var overallList = new List <string>(); foreach (var sess in eventSession) { if (sess?.CustomFields?.Field == null) { continue; } foreach (var f in sess.CustomFields.Field) { if (string.IsNullOrWhiteSpace(f?.Value?.String)) { continue; } if (overallList.Contains(f.Value.String)) { continue; } if (//f.Name == Constants.Fields.PrimaryProductFocus || //f.Name == Constants.Fields.Theme || f.Name == Constants.Fields.Track) { overallList.Add(f.Value.String); } } } await SetEntity(Constants.Cache.AllTopics, overallList); return(overallList); }
public async Task <ArloEvent> GetEventById(string id, bool forceRefresh) { if (!forceRefresh) { ArloEvent evt = null; evt = await GetEntity <ArloEvent>(_eventKey(id)); if (evt != null) { return(evt); } } var evFromServer = await _arloEventRepo.GetById(id); await SetEntity(_eventKey(id), evFromServer, Constants.Cache.DefaultTimespan); return(evFromServer); }
public async Task <List <string> > GetTopicsByDateTime(ArloEvent ev, DateTime date, string time) { var eventSessions = await GetEventSessions(false); var filteredSessions = eventSessions.Where( s => FilterSessionByDayAndTime(s, date, time) ).ToList(); var topics = new List <string>(); foreach (var session in filteredSessions) { if (session?.CustomFields?.Field == null) { continue; } foreach (var f in session.CustomFields.Field) { if (string.IsNullOrWhiteSpace(f?.Value?.String)) { continue; } if (topics.Contains(f.Value.String)) { continue; } if (f.Name == Constants.Fields.Track) { topics.Add(f.Value.String); } } } return(topics); }
string _getEventSessionsKey(ArloEvent ev) { return($"sessions.{ev.EventID}"); }
public async Task <List <ArloSession> > GetEventSessionsAsync(ArloEvent ev, bool forceRefresh) { var sessionList = await GetAllEventSessionLinks(ev, true, false); return(await GetEventSessions(sessionList.Link, forceRefresh)); }
public async Task <ArloEvent> GetCurrentEvent() { return(_currentEvent ?? (_currentEvent = await GetEventById("1881", false))); }