private void ConvertTitles() { int numTitles = ClbEpisodes.Items.Count; for (int i = 0; i < numTitles; i++) { StatusUpdate("episodes/disks", i + 1, numTitles); Title t = (Title)ClbEpisodes.Items[i]; if (t != null) { if (ClbEpisodes.GetItemChecked(i)) { try { GeneralPersistense.Upsert(t); } catch (Exception e) { MessageBox.Show(e.Message, "Error updating title " + t.TitleName); } } } } EndUpdate(); ClbEpisodes.Items.Clear(); }
private void BtnAutoMove_Click(object sender, EventArgs e) { if (m_title == null) { MessageBox.Show("Need to create series first"); return; } var seasons = new Dictionary <int, long>(); long seriesTitleId = m_title.Id; int numSeasonItems = ClbSeasons.Items.Count; for (int i = 0; i < numSeasonItems; i++) { StatusUpdate("seasons", i + 1, numSeasonItems); Title s = (Title)ClbSeasons.Items[i]; if (s != null) { if (ClbSeasons.GetItemChecked(i) && !s.ParentTitleId.HasValue) { s.ParentTitleId = seriesTitleId; TitlePersistence.ReparentTitle(s.Id, seriesTitleId); } if (!seasons.ContainsKey(s.Season)) { seasons.Add(s.Season, s.Id); } } } int numDiskItems = ClbEpisodes.Items.Count; for (int i = 0; i < numDiskItems; i++) { StatusUpdate("episodes and disks", i + 1, numDiskItems); Title ep = (Title)ClbEpisodes.Items[i]; if (ClbEpisodes.GetItemChecked(i) && ep != null) { if (!ep.ParentTitleId.HasValue) { long seasonTitleId; if (seasons.TryGetValue(ep.Season, out seasonTitleId)) { ep.ParentTitleId = seasonTitleId; TitlePersistence.ReparentTitle(ep.Id, seasonTitleId); } } } } BtnSearchForSeasons_Click(sender, e); EndUpdate(); }