public void BeginLoading() { OMLApplication.DebugLine("Start loading new titles"); plugin = GetPlugin(); Application.DeferredInvokeOnWorkerThread(delegate { OMLApplication.DebugLine("[Setup UI] _BeginLoading called"); LoadStarted = true; try { for (int i = 0; i <= _treeView.CheckedNodes.Count - 1; i++) { OMLApplication.DebugLine("[Setup UI] Found a node"); TreeNode node = (TreeNode)_treeView.CheckedNodes[i]; if (node != null) { OMLApplication.DebugLine("[Setup UI] Scanning node: " + node.FullPath); if (plugin.IsSingleFileImporter()) { string fileNameToFind = plugin.DefaultFileToImport(); if (fileNameToFind != null) { OMLApplication.DebugLine("[Setup UI] Looking for file: " + fileNameToFind); if (Directory.Exists(node.FullPath)) { DirectoryInfo dirInfo = new DirectoryInfo(node.FullPath); if (dirInfo != null) { FileInfo[] fileInfos = dirInfo.GetFiles(fileNameToFind, SearchOption.TopDirectoryOnly); foreach (FileInfo fInfo in fileInfos) { OMLApplication.DebugLine("[Setup UI] File Found: " + fInfo.Name); plugin.DoWork(new string[] { fInfo.FullName }); } } } } } else { OMLApplication.DebugLine("[Setup UI] Processing path: " + node.FullPath); plugin.DoWork(new string[] { node.FullPath }); } } } } catch (Exception e) { OMLApplication.DebugLine("[Setup UI] Error finding file: " + e.Message); } }, delegate { OMLApplication.DebugLine("[Setup UI] _LoadingComplete called"); LoadComplete = true; _titles = plugin.GetTitles(); if (_titles.Count > 0) { TotalTitlesFound = _titles.Count; CurrentTitleIndex = 0; CurrentTitle = _titles[CurrentTitleIndex]; } }, null); }
public void LoadTitlesIntoDatabase(OMLPlugin plugin) { try { Utilities.DebugLine("[OMLImporter] Titles loaded, beginning Import process"); //TitleCollection tc = new TitleCollection(); IList<Title> titles = plugin.GetTitles(); Utilities.DebugLine("[OMLImporter] " + titles.Count + " titles found in input file"); //Console.WriteLine("Found " + titles.Count + " titles"); int numberOfTitlesAdded = 0; int numberOfTitlesSkipped = 0; bool YesToAll = true;// false; //if (Console.In.Peek() > 0) // Console.In.ReadToEnd(); // flush out anything still in there foreach (Title t in titles) { if (_titleCollection.ContainsDisks(t.Disks)) { //Console.WriteLine("Title {0} skipped because already in the collection", t.Name); numberOfTitlesSkipped++; continue; } //Console.WriteLine("Adding: " + t.Name); if (YesToAll == false) { /*Console.WriteLine("Would you like to add this title? (y/n/a)"); string response = Console.ReadLine(); switch (response.ToUpper()) { case "Y": mainTitleCollection.Add(t); numberOfTitlesAdded++; break; case "N": numberOfTitlesSkipped++; break; case "A": YesToAll = true; mainTitleCollection.Add(t); numberOfTitlesAdded++; break; default: break; }*/ } else { OMLPlugin.BuildResizedMenuImage(t); _titleCollection.Add(t); numberOfTitlesAdded++; tvSourceList_AddItem(t.Name, t.InternalItemID.ToString(), "Movies"); } } MessageBox.Show("Added " + numberOfTitlesAdded + " titles\nSkipped " + numberOfTitlesSkipped + " titles\n", "Import Results"); plugin.GetTitles().Clear(); /*if (numberOfTitlesAdded > 0) isDirty = true; Console.WriteLine(); Console.WriteLine("Added " + numberOfTitlesAdded + " titles"); Console.WriteLine("Skipped " + numberOfTitlesSkipped + " titles");*/ } catch (Exception e) { MessageBox.Show("Exception in LoadTitlesIntoDatabase: %1", e.Message); //Console.WriteLine("Exception in LoadTitlesIntoDatabase: %1", e.Message); } //tc.saveTitleCollection(); //Console.WriteLine("Complete"); }