예제 #1
0
 public static void AddWatchedHistory(DBTrackInfo MusicVideo, DBUser user)
 {
     DBWatchedHistory history = new DBWatchedHistory();
       history.DateWatched = DateTime.Now;
       history.Movie = MusicVideo;
       history.User = user;
       history.Commit();
       MusicVideo.Commit();
 }
예제 #2
0
        public static void AddWatchedHistory(DBTrackInfo MusicVideo, DBUser user)
        {
            DBWatchedHistory history = new DBWatchedHistory();

            history.DateWatched = DateTime.Now;
            history.Movie       = MusicVideo;
            history.User        = user;
            history.Commit();
            MusicVideo.Commit();
        }
        // Loops through all mvCentral in the system to verify them
        public static void VerifyMusicVideoInformation()
        {
            logger.Info("Updating MusicVideo Information...");

            float count              = 0;
            List <DBTrackInfo> mvs   = DBTrackInfo.GetAll();
            List <DBUser>      users = DBUser.GetAll();
            float total              = mvs.Count;

            int removed  = 0;
            int settings = 0;

            foreach (DBTrackInfo mv in mvs)
            {
                if (MaintenanceProgress != null)
                {
                    MaintenanceProgress("", (int)(count * 100 / total));
                }
                count++;

                // Skip uncommited files
                if (mv.ID == null)
                {
                    continue;
                }

                #region Remove MusicVideo without attached local media

                // Remove mvCentral with no files
                if (mv.LocalMedia.Count == 0)
                {
                    logger.Info("'{0}' was removed from the system because it had no local media.", mv.Track);
                    mv.Delete();
                    removed++;
                    continue;
                }

                #endregion

                #region Add missing user settings

                if (mv.UserSettings.Count == 0)
                {
                    logger.Info("'{0}' was missing UserMovingSettings, adding now.", mv.Track);
                    foreach (DBUser currUser in users)
                    {
                        DBUserMusicVideoSettings userSettings = new DBUserMusicVideoSettings();
                        userSettings.User = currUser;
                        userSettings.Commit();
                        mv.UserSettings.Add(userSettings);
                        userSettings.CommitNeeded = false;
                    }
//                    lock (mv)
                    {
                        mv.Commit();
                    }
                    settings++;
                }

                #endregion
            }

            logger.Info("Removed {0} MusicVideo entries.", removed.ToString());
            logger.Info("Updated {0} MusicVideo entries with default user setting.", settings.ToString());
            if (MaintenanceProgress != null)
            {
                MaintenanceProgress("", 100);
            }
        }
예제 #4
0
        // Initializes the database connection to the Music video Plugin database
        private static void initDB()
        {
            if (_databaseManager != null)
            return;

              string fullDBFileName = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, dbFileName);
              _databaseManager = new DatabaseManager(fullDBFileName);

              // check that we at least have a default user
              List<DBUser> users = DBUser.GetAll();
              if (users.Count == 0)
              {
            DBUser defaultUser = new DBUser();
            defaultUser.Name = "Default User";
            defaultUser.Commit();
              }

              // add all filter helpers
              //           _databaseManager.AddFilterHelper<DBMovieInfo>(new FilterHelperDBMovieInfo());
        }