コード例 #1
0
        private async Task <TimeSpan> LoadFromExternalDatabase()
        {
            var table = await _externalDb.FetchAllMembers(Settings.UserName);

            _logger.LogInfo("Found " + table.Count + " members in databse");
            foreach (var member in table)
            {
                Members.Add(member.ProfileId, member);
                switch (member.Status)
                {
                case IEMember.MEMBER_NEW:
                    NewItems.Add(member);
                    break;

                case IEMember.MEMBER_REJECTED:
                    RejectedItems.Add(member);
                    break;

                default:
                    ActiveItems.Add(member);
                    break;
                }
            }

            NewItems.Sort();
            RejectedItems.Sort();
            ActiveItems.Sort();

            TimeScheduler.GetTimeScheduler().AddTask(DS_TASK_NAME, TimeSpan.FromSeconds(INITIAL_DELAY), () => OnTimedEvent());
            return(TimeScheduler.STOP_TIMER);                           // This stops us being re-scheduled
        }
コード例 #2
0
        /*
         * This method is used to search for users who are currently logged in
         */
        private async Task <bool> DoMatchFinder(bool byLogin)
        {
            List <IEProfile> profiles;
            bool             newMemberFound = false;

            if (byLogin)
            {
                profiles = await _session.OnLine(Settings.SearchForFemales, Settings.MinAge, Settings.MinAge, Settings.Regions, Settings.FetchCount);
            }
            else
            {
                profiles = await _session.MatchFinder(Settings.SearchForFemales, Settings.MinAge, Settings.MaxAge, Settings.Regions, Settings.FetchCount);
            }
            if (profiles != null)
            {
                foreach (var profile in profiles)
                {
                    // Do we know this profile already?
                    IEMember member = GetMember(profile.ProfileId);
                    if (member == null)
                    {
                        // We should add them....
                        member = new IEMember()
                        {
                            ProfileId = profile.ProfileId,
                            Region    = profile.Location,
                            Status    = IEMember.MEMBER_NEW
                        };
                        NewItems.Add(member);
                        NewItems.Sort();
                        newMemberFound = true;
                    }
                    member.Username       = profile.Name;
                    member.Age            = profile.Age;
                    member.ThumbnailUrl   = profile.ThumbnailUrl;
                    member.PartialSummary = profile.PartialSummary;
                    SaveMember(member);
                }

                if (newMemberFound && OnNewMembersFound != null)
                {
                    OnNewMembersFound();
                }
            }

            return(newMemberFound);
        }
コード例 #3
0
        public void ChangeMemberStatus(IEMember member, int newStatus)
        {
            switch (member.Status)
            {
            case IEMember.MEMBER_NEW:
                NewItems.Remove(member);
                break;

            case IEMember.MEMBER_REJECTED:
                RejectedItems.Remove(member);
                break;

            default:
                ActiveItems.Remove(member);
                break;
            }
            member.Status = newStatus;

            switch (member.Status)
            {
            case IEMember.MEMBER_NEW:
                NewItems.Add(member);
                break;

            case IEMember.MEMBER_REJECTED:
                RejectedItems.Add(member);
                break;

            default:
                ActiveItems.Add(member);
                break;
            }

            NewItems.Sort();
            RejectedItems.Sort();
            ActiveItems.Sort();

            SaveMember(member);
        }