예제 #1
0
        public void teste()
        {
            var relationshipReps = new GetRelationshipStatus();
            var userSource = new TwitterAPPUser();
            var userTarget = new TwitterAPPUser();
            var opt = new RepositoryOptions();

            var userRep = new LoadUser();

            opt.twitterUser.screen_name = "amosbatista";
            userSource = userRep.GetUser(opt);

            opt.twitterUser.screen_name = "oficial_cp";
            userTarget = userRep.GetUser(opt);

            opt.twitterUser = userSource;
            opt.twitterUser_Target = userTarget;

            var result = relationshipReps.Get(opt);
            result.ToString();
        }
예제 #2
0
        public void GenerateNetWorkStatistics(NetWorkStatisticsProperties searchProp)
        {
            // Cleaning database
            var userDB = new UserRepository();
            var followerDB = new UserRelationshipRepository();

            // Main list
            var processedUserList = new TwitterUserList(); // Used in the interaction

            // Arrays of friends and followers
            var friendsReps = new FriendsIdList();
            var followersReps = new FollowerIdList();
            var userLookUp = new UserLookUp();
            var relationshipReps = new GetRelationshipStatus();

            var followersList = new List<TwitterAPPUser>();
            var followersIdList = new UserIdList();
            var friendsList = new List<TwitterAPPUser>();
            var friendsIdList = new UserIdList();

            var opt = new RepositoryOptions();

            var newFollowersUser = new TwitterAPPUser();
            var newFriendUser = new TwitterAPPUser();
            var newUserToSave = new TwitterAPPUser();

            // Lists of FR and FF from each user
            var actualUserFriendIdList = new UserIdList();
            var actualUserFollowerIdList = new UserIdList();
            var idListToProcess = new UserIdList();
            var userListToProcess = new List<TwitterAPPUser>();

            var relationshipStatus = new RelationshipStatus_FinalResult();

            // Determine the kind of process
            if (searchProp.generateNewStatistic == true)
            {
                userDB.EraseAllData();
                followerDB.EraseAllData();

                // Setting the user for the first time
                opt.twitterUser.screen_name = searchProp.twitterName;

                // Loading me as the first user
                var twitterUserRep = new LoadUser();
                var mainUser = twitterUserRep.GetUser(opt);

                // Save the user
                userDB.SaveNewUser(mainUser);
                userDB.SetUserAsProcessed(mainUser); // To impeding the first user to be processed again

                // Generation of FR (friends) and FF (followers) list
                opt.twitterUser.id_str = mainUser.id_str;

                // Getting the friends and followers list
                followersIdList = followersReps.GetFollowers(opt);
                friendsIdList = friendsReps.GetFriends(opt);

                opt.userList = followersIdList;
                followersList = userLookUp.GetUserCompleteList(opt);

                opt.userList = friendsIdList;
                friendsList = userLookUp.GetUserCompleteList(opt);


                // Reading all followers list
                foreach (TwitterAPPUser user in followersList)
                {
                    // Save the current user
                    userDB.SaveNewUser(user);

                    // Save the relationship
                    followerDB.SaveUserFollower(mainUser, user);
                }

                // Reading all friends list
                foreach (TwitterAPPUser user in friendsList)
                {
                    // Save the current user
                    userDB.SaveNewUser(user);

                    // Save the relationship
                    followerDB.SaveUserFollower(user, mainUser);
                }

                // Combinning the 2 list
                userListToProcess.AddRange(friendsList);
                userListToProcess.AddRange(followersList);
            }
            else
            {
                // Load the list of the users
                userListToProcess = userDB.LoadUnprocessedUsers();
            }

            // Reading all this list, to get each contacts
            foreach (TwitterAPPUser userSource in userListToProcess)
            {

                foreach (TwitterAPPUser userTarget in userListToProcess)
                {
                    opt.twitterUser = userSource;
                    opt.twitterUser_Target = userTarget;

                    relationshipStatus = relationshipReps.Get(opt);

                    // Saving the user relationship, by the result response
                    if (relationshipStatus.relationship.target.following == true)
                        followerDB.SaveUserFollower(userSource, userTarget);
                    if (relationshipStatus.relationship.target.followed_by == true)
                        followerDB.SaveUserFollower(userTarget, userSource);
                }

                // After all, indicate the user was processed
                userDB.SetUserAsProcessed(userSource);
            }
        }