public void TEST_DISK_ALREADY_EXISTS() { Console.WriteLine("Starting to check if disk already exists"); string existingPath = null; foreach (Title title in TitleCollectionManager.GetAllTitles()) { existingPath = title.Disks[0].Path; break; } DateTime start = DateTime.Now; bool found = false; Assert.AreEqual(true, found = TitleCollectionManager.ContainsDisks(existingPath), "Disk path should have been found"); Console.WriteLine("Result : " + found); Console.WriteLine(string.Format("Done - Took: {0} milliseconds", (DateTime.Now - start).TotalMilliseconds.ToString())); Console.WriteLine("Starting to check to verify disk is not found"); Assert.AreEqual(false, found = TitleCollectionManager.ContainsDisks(existingPath + "test"), "Disk path should not have been found"); Console.WriteLine("Result : " + found); }
public bool CheckOrphanedTitles(out List <Title> OrphanedTitles) { Dictionary <int, Title> _movieList; OrphanedTitles = new List <Title>(); _movieList = (TitleCollectionManager.GetAllTitles(TitleTypes.Everything)).ToDictionary(k => k.Id); foreach (KeyValuePair <int, Title> t in _movieList) { if (t.Value.ParentTitleId != null) { if (!_movieList.ContainsKey((int)t.Value.ParentTitleId)) { // Cannot find parent OrphanedTitles.Add(t.Value); } } } if (OrphanedTitles.Count() != 0) { return(true); } else { return(false); } }
private void PopulateMediaTree() { Dictionary <int, Title> mediatreefolders = TitleCollectionManager.GetAllTitles(TitleTypes.AllFolders).ToDictionary(k => k.Id); Dictionary <int, int> _parentchildRelationship = new Dictionary <int, int>(); // titleid, parentid if (_mediaTree == null) { _mediaTree = new Dictionary <int, TreeNode>(); } else { _mediaTree.Clear(); } treeMedia.Nodes.Clear(); TreeNode rootnode = new TreeNode("All Media"); rootnode.Name = "All Media"; treeMedia.Nodes.Add(rootnode); //SelectedTreeRoot = null; foreach (KeyValuePair <int, Title> title in mediatreefolders) { if ((title.Value.TitleType & TitleTypes.Shortcut) == 0) { TreeNode tn = new TreeNode(title.Value.Name); tn.Name = title.Value.Id.ToString(); _mediaTree[title.Value.Id] = tn; if (title.Value.ParentTitleId != null) { _parentchildRelationship[title.Value.Id] = (int)title.Value.ParentTitleId; } //if (title.Value.Id == title.Value.ParentTitleId) { rootnode.Nodes.Add(tn); } if ((title.Value.TitleType & TitleTypes.Root) != 0) { rootnode.Nodes.Add(tn); } } } foreach (KeyValuePair <int, TreeNode> kvp in _mediaTree) { if (_parentchildRelationship.ContainsKey(kvp.Key)) { if (kvp.Key != _parentchildRelationship[kvp.Key]) { // This title has a parent. if (_mediaTree.ContainsKey(_parentchildRelationship[kvp.Key])) { _mediaTree[_parentchildRelationship[kvp.Key]].Nodes.Add(_mediaTree[kvp.Key]); } } } } treeMedia.Refresh(); }
public void TEST_DELETE_DISK() { Console.WriteLine("Starting to delete disks"); Title deleteTitle = null; foreach (Title title in TitleCollectionManager.GetAllTitles()) { deleteTitle = title; break; } int titleId = deleteTitle.Id; TitleCollectionManager.DeleteTitle(deleteTitle); Console.WriteLine("Done deleting " + titleId.ToString()); }
public static void Menu() { OMLPlugin plugin = null; string file_to_import = string.Empty; Console.WriteLine("Loading current titles..."); //mainTitleCollection.loadTitleCollection(); IEnumerable <Title> allTitles = TitleCollectionManager.GetAllTitles(); while (true) { plugin = null; Console.Clear(); PrintHeader(); Console.WriteLine("OML Importer: Current {0} titles in the database", allTitles.Count()); Console.WriteLine("Which Importer would you like to use:"); int ii; for (ii = 0; ii < plugins.Count; ii++) { OMLPlugin pi = plugins[ii]; string sFmt = "{0}) {1} (v{2})"; Console.WriteLine(string.Format(sFmt, (ii + 1), pi.Menu, pi.Version)); } //foreach (OMLPlugin pi in plugins) //{ // Console.WriteLine(string.Format("{0}) {1} (v{2})", ii++, pi.Name, pi.Version)); //} ii++; //Console.WriteLine(String.Format("{0}) Save the New Titles", ii++)); Console.WriteLine(String.Format("{0}) Quit", ii++)); Console.WriteLine(String.Format("{0}) Remove all titles from the database (be carefull!!!)", ii++)); Console.WriteLine(); Console.Write("Choice: "); string response = Console.ReadLine(); if (response.Length == 0) { continue; } //response = response.Substring(0, 1); Int32 iResp; if (!Int32.TryParse(response, out iResp)) { continue; } if (!(0 < iResp && iResp < ii)) { continue; } --iResp; if (iResp < plugins.Count) { plugin = plugins[iResp]; DateTime startTime = DateTime.Now; Console.WriteLine("Begin time: " + startTime); plugin.DoWork(plugin.GetWork()); LoadTitlesIntoDatabase(plugin, true, true); Console.WriteLine("End time: " + DateTime.Now.ToString() + " Total seconds: " + (DateTime.Now - startTime).TotalSeconds); Console.WriteLine("Done!"); Console.ReadLine(); } /*else if (iResp == (plugins.Count)) * { * if (isDirty) * { * Console.WriteLine("Adding Titles ..."); * isDirty = !mainTitleCollection.saveTitleCollection(); * } * Console.WriteLine("Complete!"); * } */ else if (iResp == (plugins.Count)) { /*if (isDirty) * { * Console.WriteLine("You have not saved your changes. Do you want to save before quitting? (y/n)"); * string answer = Console.ReadLine(); * if (answer.ToUpper() == "Y") * { * Console.WriteLine("Adding Titles ..."); * mainTitleCollection.saveTitleCollection(); * isDirty = false; * } * }*/ Console.WriteLine("Complete!"); return; } else if (iResp == (plugins.Count + 1)) { Console.WriteLine("This option will delete all titles from the database immediately! This operation CANNOT be undone!"); Console.WriteLine("Are you sure you want to delete all the titles from the database? (please type YES)"); string deleteAllAnswer = Console.ReadLine(); if (deleteAllAnswer == "YES") { Console.WriteLine("Removing all entries...(this can take awhile)"); //mainTitleCollection = new TitleCollection(); //mainTitleCollection.saveTitleCollection(); TitleCollectionManager.DeleteAllDBData(); //isDirty = false; Console.WriteLine("Done!"); } else { Console.WriteLine("Operation aborted. No titles have been deleted!"); } } else { Usage(); } } }
/// <summary> /// // creates a new movie gallery for the homepage listing all available titles /// </summary> public MovieGallery() : this(TitleCollectionManager.GetAllTitles(), Filter.Home) { }