Esempio n. 1
0
        public UserState GetGlobalState()
        {
            var global = new UserState(MyFilms.GlobalUsername)
            { WatchedCount = 0, UserRating = NoRating, WatchedDate = NoWatchedDate };

              foreach (UserState userState in this.MultiUserStates.FindAll(x => x.UserName != MyFilms.GlobalUsername))
              {
            global.WatchedCount += userState.WatchedCount;
            if (userState.WatchedDate > global.WatchedDate) global.WatchedDate = userState.WatchedDate;
            if (userState.UserRating > global.UserRating) global.UserRating = userState.UserRating;
              }
              global.Watched = global.WatchedCount > 0;
              return global;
        }
Esempio n. 2
0
 public UserState GetUserState(string username)
 {
     UserState userstate;
       if (MultiUserStates.Count(userState => userState.UserName == username) == 0)
       {
     userstate = new UserState(username);
     MultiUserStates.Add(userstate);
       }
       userstate = MultiUserStates.First(userState => userState.UserName == username);
       return userstate;
 }
Esempio n. 3
0
 private void LoadUserStates()
 {
     if (MultiUserStates == null) MultiUserStates = new List<UserState>();
       MultiUserStates.Clear();
       string[] split = MultiUserStatesValue.Split(new Char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
       foreach (string s in split)
       {
     if (s.Contains(":"))
     {
       UserState userstate = new UserState((string) EnhancedWatchedValue(s, Type.Username))
       {
     UserRating = (decimal) EnhancedWatchedValue(s, Type.Rating),
     WatchedCount = (int) EnhancedWatchedValue(s, Type.Count),
     Watched = (int) EnhancedWatchedValue(s, Type.Count) > 0,
     WatchedDate = (DateTime) (EnhancedWatchedValue(s, Type.Datewatched)),
     ResumeData = (int) (EnhancedWatchedValue(s, Type.Resume))
       };
       MultiUserStates.Add(userstate);
       // LogMyFilms.Debug("LoadUserStates() - loading state for user '" + userstate.UserName + "', rating = '" + userstate.UserRating + "', count = '" + userstate.WatchedCount + "', watched = '" + userstate.Watched + "', watcheddate = '" + userstate.WatchedDate + "'");
     }
       }
 }