Example #1
0
        public void GetEventsFromMeetUp(bool force = false)
        {
            if (!_serviceUtils.ShouldUpdate(force, DateTime.Now.AddHours(-3), ApiType.MeetUpEvents, null))
            {
                return;
            }

            var wrapper = _eventsProxy.GetMeetupEvents();

            if (wrapper.IsGood)
            {
                var meetupEvents = wrapper.Data.results.ToList();
                _occasionFactory.MapOccasions(meetupEvents);
                // add runner and time
                _serviceUtils.UpdateLastRun(ApiType.MeetUpEvents, null);
            }
            else
            {
                Log.Error(wrapper.Error, wrapper.ErrorException);
            }
        }
        public void GetMembersFromMeetUp(bool force, DateTime dt)
        {
            if (!_serviceUtils.ShouldUpdate(force, Convert.ToDateTime(dt).AddHours(-4), ApiType.MeetupMembers, null))
            {
                return;
            }

            // can get a max of 200 members at a time so run in a loop and to reduce memory handle as a set of 200 instead of getting all.
            var i = 0;
            List <MeetupMember> members;

            do
            {
                members = new List <MeetupMember>(); // reset from last loop

                try
                {
                    var wrapper = _memberProxy.GetMeetupMembers(i);
                    i++;
                    if (wrapper.IsGood)
                    {
                        members = wrapper.Data.results.ToList();
                        _userFactory.MapUsers(members);
                    }
                    else
                    {
                        Log.Error(wrapper.Error, wrapper.ErrorException);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message, ex);
                }
            } while (members.Count == 200);

            _serviceUtils.UpdateLastRun(ApiType.MeetupMembers, null);
        }