Exemplo n.º 1
0
 public Forum(Forum f)
 {
     this.forumId = f.forumId;
     this.admin = new User(f.admin);
     this.subForums = null;
     this.forumName = f.forumName;
     this.members = null;
     this.registrationPolicy = f.registrationPolicy;
 }
Exemplo n.º 2
0
 public User(string userName, string password, string email, string signature, Forum forum)
 {
     this.userName = userName;
     this.password = password;
     this.email = email;
     this.friends = new List<User>();
     this.signature = signature;
     this.isLoggedIn = false;
     this.isConfirmed = false;
 }
Exemplo n.º 3
0
 public static bool checkMemberAuthorization(Forum f, string userName, string password)
 {
     User mem = f.getUser(userName);
     if (mem == null)
     {
         return false;
     }
     else if (mem.userName == userName && mem.password == password && mem.isLogged())
         return true;
     return false;
 }
Exemplo n.º 4
0
 public SubForum(string subForumTitle, Forum parentForun, ForumGeneratorContext db)
 {
     this.subForumTitle = subForumTitle;
     this.moderators = new List<Moderator>();
     this.parentForum = parentForun;
     Moderator m = new Moderator(parentForum.admin, ForumGenerator_Version2_Server.Users.Moderator.modLevel.ALL);
     this.moderators.Add(m);
     db.Moderators.Add(m);
     db.SaveChanges();
     this.discussions = new List<Discussion>();
     this.vocabulary = new HashSet<Word>();
 }
 public bool isSubForumExist(Forum forum, string subForumTitle)
 {
     bool res = false;
     foreach (SubForum sf in forum.subForums)
     {
         if (sf.subForumTitle == subForumTitle)
         {
             res = true;
             break;
         }
     }
     return res;
 }
        //public string getUniqueForumName(List<Forum> forums)
        //{
        //    Random random = new Random();
        //    string res = "forum" + random.Next(0, 9);
        //    while (isForumExist(forums, res))
        //    {
        //        res += random.Next(0, 9);
        //    }
        //    return res;
        //}
        //public string getUniqueSubForumTitle(Forum forum)
        //{
        //    Random random = new Random();
        //    string res = "subForum" + random.Next(0, 9);
        //    while (isSubForumExist(forum, res))
        //    {
        //        res += random.Next(0, 9);
        //    }
        //    return res;
        //}
        public bool isUserNameExist(Forum forum, string userName)
        {
            bool res = false;
            List<User> users = forum.members;

            foreach (User u in users)
            {
                if (u.userName.Equals(userName))
                {
                    res = true;
                    break;
                }
            }
            return res;
        }
Exemplo n.º 7
0
 public static bool checkAdminAuthorization(Forum f, string userName, string password)
 {
     if (f.admin.userName == userName && f.admin.password == password && f.admin.isLogged())
         return true;
     return false;
 }
Exemplo n.º 8
0
        private void ThreadTest2()
        {
            Console.WriteLine("creating one forum for all threads \n");

            /* creating one forum for all threads */
            Console.WriteLine("creating one forum for all threads \n");
            Unitedforum = this.bridge.createNewForum(SU_NAME, SU_PSWD, FORUM_NAME1, ADMIN_NAME, ADMIN_PSWD, Forum.RegPolicy.NONE);
            this.bridge.login(Unitedforum.forumId, ADMIN_NAME, ADMIN_PSWD);

            var list = new List<int>();
            for (int i = 0; i < numOfThreads2; i++)
            {
                list.Add(i);
                events2[i] = new ManualResetEvent(false);
                ThreadPool.QueueUserWorkItem(new WaitCallback(runAndSetScenario2), i);
            }
            WaitHandle.WaitAll(events2);
            if(!failed2)
                testsLogger.logMethodTestResults("ThreadTest2", testNum);
        }
Exemplo n.º 9
0
 internal List<User> getMutualUsers(Forum other)
 {
     List<User> mutuals = new List<User>();
     // Go all over other's members and for each one check
     // if he is a member in this forum.
     foreach (User user in other.members)
     {
         try
         {
             getUser(user.userName);
             mutuals.Add(user);
         }
         catch (UserNotFoundException) { }
     }
     return mutuals;
 }
        //creates a new forum and a new user which is the forum's administrator
        public Forum createNewForum(string userName, string password, string forumName, string adminUserName, 
                                    string adminPassword, ForumGenerator_Version2_Server.ForumData.Forum.RegPolicy registrationPolicy)
        {
            try
            {
                this.logger.logAction("performing createNewForum:  userName: "******"\tpassword: <not detailed>" +
                                                              "\tforumName: " + forumName +
                                                              "\tadminUserName: "******"\tadminPassword: "******"createNewForum: " + e.Message);
                throw e;
            }
        }