Exemplo n.º 1
0
 public void saveToDB()
 {
     m_toUpdateForConfig[DBView.cIndex]           = m_uniqueID;
     m_toUpdateForConfig[DBView.cEnabled]         = m_Enabled;
     m_toUpdateForConfig[DBView.cTransToken]      = m_name;
     m_toUpdateForConfig[DBView.cPrettyName]      = m_prettyName != Translation.GetByName(m_name) ? prettyName : string.Empty;
     m_toUpdateForConfig[DBView.cParentalControl] = ParentalControl;
     m_toUpdateForConfig.Commit();
 }
Exemplo n.º 2
0
        public static void AddView(int index, string name, string prettyname, string config, bool tagview)
        {
            DBView view = new DBView();

            view[cIndex]           = index;
            view[cEnabled]         = "1";
            view[cSort]            = index + 1;
            view[cTransToken]      = name;
            view[cPrettyName]      = prettyname;
            view[cViewConfig]      = config;
            view[cTaggedView]      = tagview;
            view[cParentalControl] = "0";
            view.Commit();
            return;
        }
Exemplo n.º 3
0
        private void btnRemoveView_Click(object sender, EventArgs e) {
            if (availViews.Count == 0)
                return;
            
            // Get Selected View from list
            selectedView = Helper.getElementFromList<logicalView, string>((string)_availViews.SelectedItem, "Name", 0, availViews);
            
            // Confirm Delete
            string message = string.Format("Are you sure you want to delete view \"{0}\"?",selectedView.prettyName);
            DialogResult result = MessageBox.Show(message, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

			if (result == DialogResult.No)
				return;

            // if view is a tagged view, remove series attached to view
            if (selectedView.IsTaggedView)
            {
                // Get list of series in view
                SQLCondition conditions = new SQLCondition();
                conditions.Add(new DBOnlineSeries(), DBOnlineSeries.cViewTags, selectedView.Name, SQLConditionType.Like);
                List<DBSeries> series = DBSeries.Get(conditions);

                foreach (DBSeries s in series)
                {
                    s[DBOnlineSeries.cViewTags] = Helper.GetSeriesViewTags(s, false, selectedView.Name);
                    s.Commit();

                    // Remove from online database
                    if (selectedView.Name == DBView.cTranslateTokenOnlineFavourite)
                        Online_Parsing_Classes.OnlineAPI.ConfigureFavourites(false, DBOption.GetOptions(DBOption.cOnlineUserID), s[DBOnlineSeries.cID]);                    
                }
            }

            // Get All current Views
            DBView[] views = DBView.getAll(true);

            // Remove all Rows from Database
            DBView.ClearAll();

            int index = 0;

            // Add Rows back excluding deleted one
            foreach (DBView view in views) {
                if (view[DBView.cIndex] != int.Parse(selectedView.m_uniqueID)) {
                    DBView newView = new DBView();

                    newView[DBView.cIndex] = index;
                    newView[DBView.cEnabled] = view[DBView.cEnabled];
                    newView[DBView.cSort] = view[DBView.cSort];
                    newView[DBView.cTransToken] = view[DBView.cTransToken];
                    newView[DBView.cPrettyName] = view[DBView.cPrettyName];
                    newView[DBView.cViewConfig] = view[DBView.cViewConfig];
                    newView[DBView.cTaggedView] = view[DBView.cTaggedView];
					newView[DBView.cParentalControl] = view[DBView.cParentalControl];
                    newView.Commit();
                    index++;
                }
            }
            
            // Reload List and available Views
            LoadViews();
            
			// Select First Item in list
			if (_availViews.Items.Count > 0)
				_availViews.SelectedIndex = 0;
        }
Exemplo n.º 4
0
        public static void fillDefaults()
        {
            DBView dummy = new DBView();

            DBView[] views = DBView.getAll(true);
            if (views == null || views.Length == 0)
            {
                // no views in the db => put the default ones
                DBView view = new DBView();
                view[cIndex]      = "0";
                view[cEnabled]    = "1";
                view[cSort]       = "1";
                view[cTransToken] = cTranslateTokenAll;
                view[cPrettyName] = "";
                view[cViewConfig] = @"series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view                   = new DBView();
                view[cIndex]           = "1";
                view[cEnabled]         = "1";
                view[cSort]            = "2";
                view[cTransToken]      = cTranslateTokenFavourite;
                view[cPrettyName]      = "";
                view[cViewConfig]      = GetTaggedViewConfigString(cTranslateTokenFavourite);
                view[cTaggedView]      = "1";
                view[cParentalControl] = "0";
                view.Commit();

                view                   = new DBView();
                view[cIndex]           = "2";
                view[cEnabled]         = "1";
                view[cSort]            = "3";
                view[cTransToken]      = cTranslateTokenOnlineFavourite;
                view[cPrettyName]      = "";
                view[cViewConfig]      = GetTaggedViewConfigString(cTranslateTokenOnlineFavourite);
                view[cTaggedView]      = "1";
                view[cParentalControl] = "0";
                view.Commit();

                view              = new DBView();
                view[cIndex]      = "3";
                view[cEnabled]    = "1";
                view[cSort]       = "4";
                view[cTransToken] = cTranslateTokenUnwatched;
                view[cPrettyName] = "";
                view[cViewConfig] = @"series<;><Episode.Watched>;=;0<;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view              = new DBView();
                view[cIndex]      = "4";
                view[cEnabled]    = "1";
                view[cSort]       = "5";
                view[cTransToken] = cTranslateTokenChannels;
                view[cPrettyName] = "";
                view[cViewConfig] = @"group:<Series.Network><;><;><;>" +
                                    "<nextStep>series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view              = new DBView();
                view[cIndex]      = "5";
                view[cEnabled]    = "1";
                view[cSort]       = "6";
                view[cTransToken] = cTranslateTokenGenres;
                view[cPrettyName] = "";
                view[cViewConfig] = @"group:<Series.Genre><;><;><;>" +
                                    "<nextStep>series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view              = new DBView();
                view[cIndex]      = "6";
                view[cEnabled]    = "1";
                view[cSort]       = "7";
                view[cTransToken] = cTranslateTokenContentRating;
                view[cPrettyName] = "";
                view[cViewConfig] = @"group:<Series.ContentRating><;><;><;>" +
                                    "<nextStep>series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view              = new DBView();
                view[cIndex]      = "7";
                view[cEnabled]    = "1";
                view[cSort]       = "8";
                view[cTransToken] = cTranslateTokenViewTags;
                view[cPrettyName] = "";
                view[cViewConfig] = @"group:<Series.ViewTags><;><;><;>" +
                                    "<nextStep>series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view                   = new DBView();
                view[cIndex]           = "8";
                view[cEnabled]         = "1";
                view[cSort]            = "9";
                view[cTransToken]      = cTranslateTokenLatest;
                view[cPrettyName]      = "";
                view[cViewConfig]      = @"episode<;><Episode.FirstAired>;<=;<today><cond><Episode.FirstAired>;>=;<today-30><;><Episode.FirstAired>;desc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view                   = new DBView();
                view[cIndex]           = "9";
                view[cEnabled]         = "1";
                view[cSort]            = "10";
                view[cTransToken]      = cTranslateTokenRecentlyAdded;
                view[cPrettyName]      = "";
                view[cViewConfig]      = @"episode<;><Episode.FileDateCreated>;>=;<today-7><;><Episode.FileDateCreated>;desc<;>";
                view[cTaggedView]      = "0";
                view[cParentalControl] = "0";
                view.Commit();
            }

            int nCurrentDBVersion = cDBVersion;
            int nUpgradeDBVersion = DBOption.GetOptions(DBOption.cDBViewsVersion);

            while (nUpgradeDBVersion != nCurrentDBVersion)
            {
                // WARNING: as of version 4, we can now remove and add views.
                // Be particularly carefull if adding/Removing/Updating

                // take care of the upgrade in the table
                switch (nUpgradeDBVersion)
                {
                case 1:
                    //Upgrade to version 2; 'Latest' view doesn't show anything from the future, and shows only from the last 30 days
                    DBView view = new DBView(5);
                    view[cViewConfig] = @"episode<;><Episode.FirstAired>;<=;<today><cond><Episode.FirstAired>;>=;<today-30><;><Episode.FirstAired>;desc<;>";
                    view.Commit();
                    nUpgradeDBVersion++;
                    break;

                case 2:
                    // Upgrade to version 3, new view 'Recently Added'
                    view              = new DBView();
                    view[cIndex]      = "6";
                    view[cEnabled]    = "1";
                    view[cSort]       = "7";
                    view[cTransToken] = cTranslateTokenRecentlyAdded;
                    view[cPrettyName] = "";
                    view[cViewConfig] = @"episode<;><Episode.FileDateCreated>;>=;<today-7><;><Episode.FileDateCreated>;desc<;>";
                    view.Commit();
                    nUpgradeDBVersion++;
                    break;

                case 3:
                    // Upgrade to version 4, new view 'Content Rating'
                    view              = new DBView();
                    view[cIndex]      = "7";
                    view[cEnabled]    = "1";
                    view[cSort]       = "8";
                    view[cTransToken] = cTranslateTokenContentRating;
                    view[cPrettyName] = "";
                    view[cViewConfig] = @"group:<Series.ContentRating><;><;><;>" +
                                        "<nextStep>series<;><;><;>" +
                                        "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                        "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                    view[cParentalControl] = "0";
                    view.Commit();

                    // New view 'View Tags'
                    view              = new DBView();
                    view[cIndex]      = "8";
                    view[cEnabled]    = "1";
                    view[cSort]       = "9";
                    view[cTransToken] = cTranslateTokenViewTags;
                    view[cPrettyName] = "";
                    view[cViewConfig] = @"group:<Series.ViewTags><;><;><;>" +
                                        "<nextStep>series<;><;><;>" +
                                        "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                        "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                    view[cParentalControl] = "0";
                    view.Commit();
                    nUpgradeDBVersion++;
                    break;

                case 4:
                    // Get All current Views
                    DBView[] viewList = DBView.getAll(true);

                    // Update old Favourite View to Tagged View
                    foreach (DBView v in viewList)
                    {
                        if (v[DBView.cTransToken] == cTranslateTokenFavourite)
                        {
                            v[cTaggedView] = "1";
                            v[cTransToken] = cTranslateTokenFavourite;
                            v[cPrettyName] = "";
                            v[cViewConfig] = GetTaggedViewConfigString(cTranslateTokenFavourite);
                            v.Commit();
                        }
                    }

                    // Add Online Favourites as Taqged View
                    view                   = new DBView();
                    view[cIndex]           = viewList.Length;
                    view[cEnabled]         = "1";
                    view[cSort]            = viewList.Length + 1;
                    view[cTransToken]      = cTranslateTokenOnlineFavourite;
                    view[cPrettyName]      = "";
                    view[cViewConfig]      = GetTaggedViewConfigString(cTranslateTokenOnlineFavourite);
                    view[cParentalControl] = "0";
                    view[cTaggedView]      = "1";
                    view.Commit();

                    nUpgradeDBVersion++;
                    break;

                default:
                    nUpgradeDBVersion = nCurrentDBVersion;
                    break;
                }
            }
            DBOption.SetOptions(DBOption.cDBViewsVersion, nCurrentDBVersion);
        }
Exemplo n.º 5
0
        public static void fillDefaults()
        {
            DBView dummy = new DBView();

            DBView[] views = DBView.getAll(true);
            if (views == null || views.Length == 0)
            {
                // no views in the db => put the default ones
                DBView view = new DBView();
                view[cIndex] = "0";
                view[cEnabled] = "1";
                view[cSort] = "1";
                view[cTransToken] = cTranslateTokenAll;
                view[cPrettyName] = "";
                view[cViewConfig] = @"series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView] = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view = new DBView();
                view[cIndex] = "1";
                view[cEnabled] = "1";
                view[cSort] = "2";
                view[cTransToken] = cTranslateTokenFavourite;
                view[cPrettyName] = "";
                view[cViewConfig] = GetTaggedViewConfigString(cTranslateTokenFavourite);
                view[cTaggedView] = "1";
                view[cParentalControl] = "0";
                view.Commit();

                view = new DBView();
                view[cIndex] = "2";
                view[cEnabled] = "1";
                view[cSort] = "3";
                view[cTransToken] = cTranslateTokenOnlineFavourite;
                view[cPrettyName] = "";
                view[cViewConfig] = GetTaggedViewConfigString(cTranslateTokenOnlineFavourite);
                view[cTaggedView] = "1";
                view[cParentalControl] = "0";
                view.Commit();

                view = new DBView();
                view[cIndex] = "3";
                view[cEnabled] = "1";
                view[cSort] = "4";
                view[cTransToken] = cTranslateTokenUnwatched;
                view[cPrettyName] = "";
                view[cViewConfig] = @"series<;><Episode.Watched>;=;0<;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView] = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view = new DBView();
                view[cIndex] = "4";
                view[cEnabled] = "1";
                view[cSort] = "5";
                view[cTransToken] = cTranslateTokenChannels;
                view[cPrettyName] = "";
                view[cViewConfig] = @"group:<Series.Network><;><;><;>" +
                                    "<nextStep>series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView] = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view = new DBView();
                view[cIndex] = "5";
                view[cEnabled] = "1";
                view[cSort] = "6";
                view[cTransToken] = cTranslateTokenGenres;
                view[cPrettyName] = "";
                view[cViewConfig] = @"group:<Series.Genre><;><;><;>" +
                                    "<nextStep>series<;><;><;>" +
                                    "<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
                                    "<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                view[cTaggedView] = "0";
                view[cParentalControl] = "0";
                view.Commit();

				view = new DBView();
				view[cIndex] = "6";
				view[cEnabled] = "1";
				view[cSort] = "7";
				view[cTransToken] = cTranslateTokenContentRating;
				view[cPrettyName] = "";
				view[cViewConfig] = @"group:<Series.ContentRating><;><;><;>" +
									"<nextStep>series<;><;><;>" +
									"<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
									"<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
				view[cTaggedView] = "0";
                view[cParentalControl] = "0";
				view.Commit();

				view = new DBView();
				view[cIndex] = "7";
				view[cEnabled] = "1";
				view[cSort] = "8";
				view[cTransToken] = cTranslateTokenViewTags;
				view[cPrettyName] = "";
				view[cViewConfig] = @"group:<Series.ViewTags><;><;><;>" +
									"<nextStep>series<;><;><;>" +
									"<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
									"<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
				view[cTaggedView] = "0";
                view[cParentalControl] = "0";
				view.Commit();

                view = new DBView();
                view[cIndex] = "8";
                view[cEnabled] = "1";
                view[cSort] = "9";
                view[cTransToken] = cTranslateTokenLatest;
                view[cPrettyName] = "";
                view[cViewConfig] = @"episode<;><Episode.FirstAired>;<=;<today><cond><Episode.FirstAired>;>=;<today-30><;><Episode.FirstAired>;desc<;>";
                view[cTaggedView] = "0";
                view[cParentalControl] = "0";
                view.Commit();

                view = new DBView();
                view[cIndex] = "9";
                view[cEnabled] = "1";
                view[cSort] = "10";
                view[cTransToken] = cTranslateTokenRecentlyAdded;
                view[cPrettyName] = "";
                view[cViewConfig] = @"episode<;><Episode.FileDateCreated>;>=;<today-7><;><Episode.FileDateCreated>;desc<;>";
                view[cTaggedView] = "0";
                view[cParentalControl] = "0";
                view.Commit();
            }

            int nCurrentDBVersion = cDBVersion;
            int nUpgradeDBVersion = DBOption.GetOptions(DBOption.cDBViewsVersion);

            while (nUpgradeDBVersion != nCurrentDBVersion)
            {
                // WARNING: as of version 4, we can now remove and add views. 
                // Be particularly carefull if adding/Removing/Updating

                // take care of the upgrade in the table
                switch (nUpgradeDBVersion)
                {
                    case 1:
                        //Upgrade to version 2; 'Latest' view doesn't show anything from the future, and shows only from the last 30 days
                        DBView view = new DBView(5);
                        view[cViewConfig] = @"episode<;><Episode.FirstAired>;<=;<today><cond><Episode.FirstAired>;>=;<today-30><;><Episode.FirstAired>;desc<;>";
                        view.Commit();
                        nUpgradeDBVersion++;
                        break;

                    case 2:
                        // Upgrade to version 3, new view 'Recently Added'
                        view = new DBView();
                        view[cIndex] = "6";
                        view[cEnabled] = "1";
                        view[cSort] = "7";
                        view[cTransToken] = cTranslateTokenRecentlyAdded;
                        view[cPrettyName] = "";
                        view[cViewConfig] = @"episode<;><Episode.FileDateCreated>;>=;<today-7><;><Episode.FileDateCreated>;desc<;>";
                        view.Commit();
                        nUpgradeDBVersion++;
                        break;

					case 3:
						// Upgrade to version 4, new view 'Content Rating'
						view = new DBView();
						view[cIndex] = "7";
						view[cEnabled] = "1";
						view[cSort] = "8";
						view[cTransToken] = cTranslateTokenContentRating;
						view[cPrettyName] = "";
						view[cViewConfig] = @"group:<Series.ContentRating><;><;><;>" +
											"<nextStep>series<;><;><;>" +
											"<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
											"<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                        view[cParentalControl] = "0";
						view.Commit();
						
						// New view 'View Tags'
						view = new DBView();
						view[cIndex] = "8";
						view[cEnabled] = "1";
						view[cSort] = "9";
						view[cTransToken] = cTranslateTokenViewTags;
						view[cPrettyName] = "";
						view[cViewConfig] = @"group:<Series.ViewTags><;><;><;>" +
											"<nextStep>series<;><;><;>" +
											"<nextStep>season<;><;><Season.seasonIndex>;asc<;>" +
											"<nextStep>episode<;><;><Episode.EpisodeIndex>;asc<;>";
                        view[cParentalControl] = "0";
						view.Commit();
						nUpgradeDBVersion++;
						break;
                    
                    case 4:
                        // Get All current Views
                        DBView[] viewList = DBView.getAll(true);

                        // Update old Favourite View to Tagged View
                        foreach (DBView v in viewList) {
                            if (v[DBView.cTransToken] == cTranslateTokenFavourite) {
                                v[cTaggedView] = "1";
                                v[cTransToken] = cTranslateTokenFavourite;
                                v[cPrettyName] = "";
                                v[cViewConfig] = GetTaggedViewConfigString(cTranslateTokenFavourite);
                                v.Commit();
                            }
                        }
                        
                        // Add Online Favourites as Taqged View
                        view = new DBView();
                        view[cIndex] = viewList.Length;
                        view[cEnabled] = "1";
                        view[cSort] = viewList.Length + 1;
                        view[cTransToken] = cTranslateTokenOnlineFavourite;
                        view[cPrettyName] = "";
                        view[cViewConfig] = GetTaggedViewConfigString(cTranslateTokenOnlineFavourite);
                        view[cParentalControl] = "0";
                        view[cTaggedView] = "1";
                        view.Commit();                        

                        nUpgradeDBVersion++;
                        break;

                    default:
                        nUpgradeDBVersion = nCurrentDBVersion;
                        break;
                }
            }
            DBOption.SetOptions(DBOption.cDBViewsVersion, nCurrentDBVersion);
        }
Exemplo n.º 6
0
 public static void AddView(int index, string name, string prettyname, string config, bool tagview) {
     DBView view = new DBView();
     view[cIndex] = index;
     view[cEnabled] = "1";
     view[cSort] = index + 1;
     view[cTransToken] = name;
     view[cPrettyName] = prettyname;
     view[cViewConfig] = config;
     view[cTaggedView] = tagview;
     view[cParentalControl] = "0";
     view.Commit();
     return;
 }