Example #1
0
        public int CompareTo(object o)
        {
            IEMember a = this;
            IEMember b = (IEMember)o;

            return(string.Compare(a.Username, b.Username));
        }
Example #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);
        }
Example #3
0
        public async void SaveMember(IEMember member)
        {
            _logger.LogInfo("Saving member " + member.Id + " profile=" + member.Username + " Status=" + member.Status);

            if (member.Id == 0)
            {
                IEMember newMember = await _externalDb.AddNewMember(Settings.UserName, member);

                if (newMember != null)
                {
                    member.Id = newMember.Id;
                    Members.Add(member.ProfileId, member);
                }
            }
            else
            {
                IEMember newMember = await _externalDb.ModifyMember(Settings.UserName, member);

                if (Members.TryGetValue(member.ProfileId, out IEMember prevMember))
                {
                    Members.Remove(member.ProfileId);
                }
                Members.Add(member.ProfileId, member);
            }

            /*
             * if ( member.Id == 0 )
             * {
             *  _database.InsertAsync(member).Wait();
             *  Members.Add(member.ProfileId, member);
             * }
             * else
             * {
             *  _database.UpdateAsync(member).Wait();
             *  if ( Members.TryGetValue(member.ProfileId, out IEMember prevMember)) {
             *      Members.Remove(member.ProfileId);
             *  }
             *  Members.Add(member.ProfileId, member);
             * }
             */
        }
Example #4
0
        private async Task <TimeSpan> InternalDoNameSearch(string username)
        {
            if (Settings.LoginDetailsSupplied())
            {
                // Not logged in currently - we should try to login now....
                bool state = await _session.Login(Settings.UserName, Settings.Password);

                if (state)
                {
                    SearchResults.Clear();
                    List <IEProfile> profiles = await _session.SearchByName(Settings.SearchForFemales, username, Settings.FetchCount);

                    _logger.LogInfo("Found " + profiles.Count() + " results for search of " + username);
                    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
                            };
                        }
                        member.Username       = profile.Name;
                        member.Age            = profile.Age;
                        member.ThumbnailUrl   = profile.ThumbnailUrl;
                        member.PartialSummary = profile.PartialSummary;
                        SearchResults.Add(member);
                    }
                    await _session.Logout();

                    SearchResults.Sort();
                }
            }
            return(TimeScheduler.STOP_TIMER);                           // This stops us being re-scheduled
        }
Example #5
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);
        }
Example #6
0
        private async Task <TimeSpan> InternalGetMemberProfile(IEMember member)
        {
            if ((member.FetchedExtraData == null) || ((DateTime.Now - member.FetchedExtraData).TotalDays > 500))
            //if (member.FetchedExtraData == null)
            {
                // Never got extra profile data - need to fetch it...or it was over 10 days ago...
                if (Settings.LoginDetailsSupplied())
                {
                    // Not logged in currently - we should try to login now....
                    bool state = await _session.Login(Settings.UserName, Settings.Password);

                    if (state)
                    {
                        await _session.GetProfile(member);

                        await _session.Logout();

                        SaveMember(member);                                     // Remember the changes
                        member.FirePropertyChangeEvent();                       // Tell anyone who cares
                    }
                }
            }
            return(TimeScheduler.STOP_TIMER);                // This stops us being re-scheduled
        }
Example #7
0
 public void GetMemberProfile(IEMember member)
 {
     TimeScheduler.GetTimeScheduler().AddTask(DS_TASK_NAME + member.ProfileId, TimeSpan.FromSeconds(0), () => InternalGetMemberProfile(member));
 }
Example #8
0
        public async Task <bool> GetProfile(IEMember member)
        {
            var reply = await _httpClient.GetAsync(PROFILE_URL + member.ProfileId);

            if (reply.StatusCode == HttpStatusCode.OK)
            {
                var replyPage = await reply.Content.ReadAsStringAsync();

                HtmlDocument htmlDoc = new HtmlDocument();
                htmlDoc.LoadHtml(replyPage);

                var tables = htmlDoc.DocumentNode.Descendants("table").ToList();

                //
                // Table 1 holds info including 'Race', 'Location' and 'Marital Status'
                //
                if ((tables != null) && (tables.Count() > 5))
                {
                    var tds = tables[1].Descendants("td").ToList();
                    if ((tds != null) && (tds.Count() > 16))
                    {
                        int fieldOffset = 14;
                        if (tds.Count() > 19)
                        {
                            // This means we have a 'Message History' shown as well...we need to step over it...
                            fieldOffset += 2;               // Message History adds 2 new fields before the ones we want.
                        }
                        _logger.LogInfo("Found " + tds.Count() + " tds");
                        var race    = tds[fieldOffset++].InnerText.Split(':')[1].Trim();     //
                        var loc     = tds[fieldOffset++].InnerText.Split(':')[1].Trim();;    // Location (often includes town)
                        var mStatus = tds[fieldOffset++].InnerText.Split(':')[1].Trim();;    // Marital Status

                        _logger.LogInfo("Race = " + race);
                        _logger.LogInfo("Location = " + loc);
                        _logger.LogInfo("Marital Status = " + mStatus);

                        member.Race          = race;
                        member.Region        = loc;
                        member.MaritalStatus = mStatus;
                    }
                    //
                    // Table 3 holds 'Personal Info' such as Religion, Eye Colour, Hair colour etc
                    //
                    tds = tables[3].Descendants("td").ToList();
                    if ((tds != null) && (tds.Count() > 22))
                    {
                        var religion   = tds[2].InnerText.Trim();
                        var eyeColour  = tds[4].InnerText.Trim();
                        var drinking   = tds[6].InnerText.Trim();
                        var hairColour = tds[8].InnerText.Trim();
                        var smoking    = tds[10].InnerText.Trim();
                        var build      = tds[12].InnerText.Trim();
                        var height     = tds[14].InnerText.Trim();
                        var education  = tds[16].InnerText.Trim();
                        var job        = tds[18].InnerText.Trim();
                        var interests  = tds[22].InnerText.Trim();

                        var subInterests = interests.Split(',');
                        interests = "";
                        foreach (var sub in subInterests)
                        {
                            if (interests.Length > 0)
                            {
                                interests += ",";
                            }
                            interests += sub.Trim();
                        }

                        _logger.LogInfo("religon = " + religion);
                        _logger.LogInfo("eyeColour = " + eyeColour);
                        _logger.LogInfo("drinking = " + drinking);
                        _logger.LogInfo("hairColour = " + hairColour);
                        _logger.LogInfo("smoking = " + smoking);
                        _logger.LogInfo("build = " + build);
                        _logger.LogInfo("height = " + height);
                        _logger.LogInfo("education = " + education);
                        _logger.LogInfo("job = " + job);
                        _logger.LogInfo("interests = " + interests);

                        member.Religion   = religion;
                        member.EyeColour  = eyeColour;
                        member.Drinking   = drinking;
                        member.Smoking    = smoking;
                        member.HairColour = hairColour;
                        member.Build      = build;
                        member.Height     = height;
                        member.Education  = education;
                        member.Occupation = job;
                        member.Interests  = interests;
                    }
                    //
                    // Table 4 is the 'Ideal partner' info.
                    //

                    tds = tables[4].Descendants("td").ToList();
                    if ((tds != null) && (tds.Count() > 3))
                    {
                        var lookingFor       = tds[1].InnerText.Trim();
                        var ideal            = tds[2].InnerText.Trim();
                        var relationshipType = tds[3].InnerText.Trim();

                        _logger.LogInfo("orig-relationshipType = '" + relationshipType + "'");

                        const string RELATION_TYPE = "Type of Relationship";
                        if (relationshipType.StartsWith(RELATION_TYPE, StringComparison.CurrentCulture))
                        {
                            relationshipType = relationshipType.Substring(RELATION_TYPE.Length).Trim();
                        }

                        var relationShipSub = relationshipType.Split(',');

                        if (relationShipSub.Count() > 0)
                        {
                            relationshipType = "";
                            foreach (var sub in relationShipSub)
                            {
                                if (relationshipType.Length > 0)
                                {
                                    relationshipType += ",";
                                }
                                relationshipType += sub.Trim();
                            }
                        }

                        const string LOOKING_FOR = "I'm looking for someone who is:";
                        if (lookingFor.StartsWith(LOOKING_FOR, StringComparison.CurrentCulture))
                        {
                            lookingFor = lookingFor.Substring(LOOKING_FOR.Length).Trim();
                        }

                        _logger.LogInfo("lookingFor = " + lookingFor);
                        _logger.LogInfo("ideal = " + ideal);
                        _logger.LogInfo("relationshipType = " + relationshipType);

                        member.LookingFor       = lookingFor;
                        member.IdealPartner     = ideal;
                        member.RelationshipType = relationshipType;
                    }
                    //
                    // Table 5 is the About me info
                    //
                    tds = tables[5].Descendants("td").ToList();
                    if ((tds != null) && (tds.Count() > 2))
                    {
                        var about = tds[1].InnerText.Trim();

                        _logger.LogInfo("about = " + about);
                        member.About = about;
                    }
                    member.FetchedExtraData = DateTime.Now;
                }

                return(true);
            }

            return(false);
        }