private List <VkCommands.Data.IData> searchPeople(ISearchProfile sProfile,
                                                          int currentDepth, ISearchSubscriber subscriber)
        {
            List <IData> tergetUsers = new List <IData>();
            Friends      friends     = FriendsHelper.getFriends(CoreId);
            User         user        = null;
            bool         isTarget    = true;

            if (OnFirstStep)
            {
                for (int i = 0; i < friends.Users.Count; i++)
                {
                    if (isStopped)
                    {
                        return(tergetUsers);
                    }

                    user     = friends.Users[i];
                    isTarget = detectTargetUser(sProfile, user);
                    if (isTarget)
                    {
                        if (sProfile.CheckFriends)
                        {
                            if (!FriendsHelper.areFriends(user.Id,
                                                          AuthFactory.getCurrentAuth().InitialUser).GetAreFriends)
                            {
                                tergetUsers.Add(user);
                                subscriber.onItemFoundEvent(new ItemUpdatedEvent(user.Id));
                            }
                        }
                        else
                        {
                            tergetUsers.Add(user);
                            subscriber.onItemFoundEvent(new ItemUpdatedEvent(user.Id));
                        }
                    }
                    if (currentDepth < Depth)
                    {
                        //if (sProfile.Criteria[NextIterationCriteria].Equals(user.NextIterationCriteria))
                        //{
                        CoreId = user.Id;
                        tergetUsers.AddRange(searchPeople(sProfile, currentDepth + 1, subscriber));
                        //}
                    }
                }
            }
            return(tergetUsers);
        }
Beispiel #2
0
        public static void generateData(ISearchSubscriber subscriber)
        {
            subscriber.onSearchStarted();
            Random rnd = new Random();

            for (int i = 0; i < COUNT; i++)
            {
                if (isStopped)
                {
                    isStopped = false;
                    subscriber.onSearchFinished();
                    break;
                }

                Thread.Sleep(200);
                subscriber.onItemFoundEvent(new ItemUpdatedEvent("TEST ITEM " + rnd.Next(1, 50000)));
            }
            subscriber.onSearchFinished();
        }
 public override List <VkCommands.Data.IData> search(ISearchProfile sProfile, ISearchSubscriber subscriber)
 {
     isStopped = false;
     subscriber.onSearchStarted();
     if (sProfile.GetType() == typeof(PeopleSearchProfile))
     {
         List <IData> data = searchPeople(sProfile, 0, subscriber);
         subscriber.onSearchFinished();
         return(data);
     }
     else if (sProfile.GetType() == typeof(GroupSearchProfile))
     {
         return(searchGroup(sProfile, 0));
     }
     else
     {
         return(null);
     }
 }
Beispiel #4
0
 public abstract List <IData> search(ISearchProfile sProfile, ISearchSubscriber subscriber);
Beispiel #5
0
        public static List <User> performeTreesSearchForPeople(string coreId, int depth,
                                                               Dictionary <string, string> criteria, ISearchSubscriber subscriber, bool checkFriends)
        {
            ISearchProfile sProfile = SearchProfileFactory.createSearchProfile(SearchType.People);

            strategy =
                SearchStrategyFactory.createTreeSearchStrategy(SearchStrategyType.BalancedTrees);

            strategy.CoreId       = coreId;
            strategy.OnFirstStep  = true;
            strategy.Depth        = depth;
            sProfile.Criteria     = criteria;
            sProfile.CheckFriends = checkFriends;
            List <IData> targets = strategy.search(sProfile, subscriber);

            return(targets.Cast <User>().ToList());
        }