示例#1
0
 public static void SubscriptionsCountFilter(FollowerState followerState, uint?minValue, uint?maxValue)
 {
     followerState.LeaveInList =
         (followerState.FollowerObject.SubscriptionsCount >= minValue) &&
         (followerState.FollowerObject.SubscriptionsCount <= maxValue);
 }
示例#2
0
 public static void AvatarFilter(FollowerState followerState)
 {
     followerState.LeaveInList = followerState.FollowerObject.AvatarEnable;
 }
示例#3
0
        public void FilteringProccess(ref FiltersStatus filtersStatus,
                                      string baseToFilterFilepath, string baseFilepathAfterFiltering,
                                      FilteringParameters filteringParameters)
        {
            StreamWriter streamWriter = new StreamWriter("temp.txt");
            //сообщить о получении базы
            List <FollowerState> followersList = new List <FollowerState>();

            foreach (var followerNickname in Parsers.ReadListOfStringFromFile(baseToFilterFilepath))
            {
                if (!string.IsNullOrEmpty(followerNickname))
                {
                    FollowerState followerState = GetFollowerState(followerNickname, ref filtersStatus);
                    followersList.Add(followerState);
                    if (!followerState.LeaveInList)
                    {
                        streamWriter.WriteLine(followerNickname + "\t\tEmpty page\n");
                    }
                }
            }
            followersList = (from follower in followersList where follower.LeaveInList select follower).ToList();//removing empty links
            if (filtersStatus.AvatarEnableFilter)
            {
                foreach (var followerState in followersList)
                {
                    Filters.AvatarFilter(followerState);
                }
                foreach (var followerNickname in (from follower in followersList where !follower.LeaveInList select follower.FollowerObject.Nickname).ToList())
                {
                    streamWriter.WriteLine(followerNickname + "\t\tNo avatar\n");
                }
                followersList = (from follower in followersList where follower.LeaveInList select follower).ToList();
            }
            if (filtersStatus.FollowersCountFilter)
            {
                foreach (var followerState in followersList)
                {
                    Filters.FollowersCountFilter(followerState,
                                                 filteringParameters.FollowersMinCount, filteringParameters.FollowersMaxCount);
                }
                foreach (var followerNickname in (from follower in followersList where !follower.LeaveInList select follower.FollowerObject.Nickname).ToList())
                {
                    streamWriter.WriteLine(followerNickname + "\t\tFollowers count\n");
                }
                followersList = (from follower in followersList where follower.LeaveInList select follower).ToList();
            }
            if (filtersStatus.PostsCountFilter)
            {
                foreach (var followerState in followersList)
                {
                    Filters.PostsCountFilter(followerState, filteringParameters.PostsMinCount, filteringParameters.PostsMaxCount);
                }
                foreach (var followerNickname in (from follower in followersList where !follower.LeaveInList select follower.FollowerObject.Nickname).ToList())
                {
                    streamWriter.WriteLine(followerNickname + "\t\tPosts count\n");
                }
                followersList = (from follower in followersList where follower.LeaveInList select follower).ToList();
            }
            if (filtersStatus.SubscriptionsCountFilter)
            {
                foreach (var followerState in followersList)
                {
                    Filters.SubscriptionsCountFilter(followerState, filteringParameters.SubscriptionsMinCount, filteringParameters.SubscriptionsMaxCount);
                }
                foreach (var followerNickname in (from follower in followersList where !follower.LeaveInList select follower.FollowerObject.Nickname).ToList())
                {
                    streamWriter.WriteLine(followerNickname + "\t\tSubscriptopns count\n");
                }
                followersList = (from follower in followersList where follower.LeaveInList select follower).ToList();
            }
            streamWriter.Close();
            List <string> followers = (from folwer in followersList select folwer.FollowerObject.Nickname).ToList();//ответ на один из методов выше

            Parsers.WriteListOfStringToFile(followers, baseFilepathAfterFiltering);
        }