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"); }
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) { bool Cancelled = false; try { Utilities.DebugLine("[OMLImporter] Titles loaded, beginning Import process"); IList <Title> titles = OMLSDK.SDKUtilities.ConvertOMLSDKTitlesToTitles(plugin.GetTitles()); Utilities.DebugLine("[OMLImporter] " + titles.Count + " titles found in input file"); int totalNumberOfTitles = 0; int numberOfTitlesAdded = 0; int numberOfTitlesSkipped = 0; bool YesToAll = true;// false; foreach (Title t in titles) { if (backgroundWorker1.CancellationPending) { // Abort the operation Cancelled = true; break; } backgroundWorker1.ReportProgress(100 * totalNumberOfTitles / titles.Count, "Saving title : " + t.Name); totalNumberOfTitles++; if (TitleCollectionManager.ContainsDisks(t.Disks)) { numberOfTitlesSkipped++; continue; } if (!YesToAll) { //TODO: Need to show a UI that let's the User decide whether to import all titles or be selective about it /*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 { TitleCollectionManager.AddTitle(t); numberOfTitlesAdded++; } } backgroundWorker1.ReportProgress(100, "Finalising..."); TitleCollectionManager.SaveTitleUpdates(); if (Cancelled) { backgroundWorker1.ReportProgress(100, "Cancelled : Added " + numberOfTitlesAdded + " Skipped " + numberOfTitlesSkipped); } else { backgroundWorker1.ReportProgress(100, "Complete : Added " + numberOfTitlesAdded + " Skipped " + numberOfTitlesSkipped); } plugin.GetTitles().Clear(); } catch (Exception e) { XtraMessageBox.Show("Exception in LoadTitlesIntoDatabase: {0}", e.Message); Utilities.DebugLine("[OMLImporter] Exception in LoadTitlesIntoDatabase: " + e.Message); } }
public static void LoadTitlesIntoDatabase(OMLPlugin plugin, bool flushInputBuffer, bool autoYesToAll) { try { Utilities.DebugLine("[OMLImporter] Titles loaded, beginning Import process"); //TitleCollection tc = new TitleCollection(); IList <Title> titles = OMLSDK.SDKUtilities.ConvertOMLSDKTitlesToTitles(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 = autoYesToAll; if (flushInputBuffer && Console.In.Peek() > 0) { Console.In.ReadToEnd(); // flush out anything still in there } foreach (Title t in titles) { if (TitleCollectionManager.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": TitleCollectionManager.AddTitle(t); numberOfTitlesAdded++; break; case "N": numberOfTitlesSkipped++; break; case "A": YesToAll = true; TitleCollectionManager.AddTitle(t); numberOfTitlesAdded++; break; default: break; } } else { TitleCollectionManager.AddTitle(t); numberOfTitlesAdded++; } } // save all the image updates TitleCollectionManager.SaveTitleUpdates(); plugin.GetTitles().Clear(); //if (numberOfTitlesAdded > 0) isDirty = true; Console.WriteLine(); Console.WriteLine("Added " + numberOfTitlesAdded + " titles"); Console.WriteLine("Skipped " + numberOfTitlesSkipped + " titles"); } catch (Exception e) { Console.WriteLine("Exception in LoadTitlesIntoDatabase: {0}", e.Message); } //tc.saveTitleCollection(); //Console.WriteLine("Complete"); }