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); }
private static bool ProcessCommandLine(string [] args) { OMLPlugin pluginToUse = null; string pluginName = args[0].Trim(); bool copyImages = true; string path = null; bool clearBeforeImport = false; if (args.Length > 1) { path = args[1]; } else { return(false); } for (int i = 2; i < args.Length; i++) { if (args[i].StartsWith(COPY_IMAGES_KEY, StringComparison.OrdinalIgnoreCase)) { if (!bool.TryParse(args[i].Substring(COPY_IMAGES_KEY.Length), out copyImages)) { return(false); } } else if (args[i].StartsWith(CLEAR_BEFORE_IMPORT_KEY, StringComparison.OrdinalIgnoreCase)) { if (!bool.TryParse(args[i].Substring(CLEAR_BEFORE_IMPORT_KEY.Length), out clearBeforeImport)) { return(false); } } else // command line argument not understood { return(false); } } // Loop through available plugins to find the new we need to create foreach (PluginServices.AvailablePlugin plugin in PluginServices.FindPlugins(FileSystemWalker.PluginsDirectory, "OMLSDK.IOMLPlugin")) { if (plugin.ClassName.Equals(pluginName, StringComparison.OrdinalIgnoreCase)) { pluginToUse = (OMLPlugin)PluginServices.CreateInstance(plugin); pluginToUse.FileFound += new OMLPlugin.FileFoundEventHandler(FileFound); } } if (pluginToUse == null) { Console.WriteLine(pluginName + " was not found as a plugin. The valid plugins are:"); Console.WriteLine(""); foreach (PluginServices.AvailablePlugin plugin in PluginServices.FindPlugins(FileSystemWalker.PluginsDirectory, typeof(IOMLPlugin).Name)) { Console.WriteLine(plugin.ClassName); } } else { // use the found plugin if (pluginToUse.IsSingleFileImporter() && !File.Exists(path)) { Console.WriteLine(pluginToUse.Name + " requires an import file which it can't find (" + path + ")"); } else if (!pluginToUse.IsSingleFileImporter() && !Directory.Exists(path)) { Console.WriteLine(pluginToUse.Name + " requires an import directory which can't be found (" + path + ")"); } else { if (clearBeforeImport) { Console.WriteLine("Clearing out old data before import ( this can take awhile )"); TitleCollectionManager.DeleteAllDBData(); } Console.WriteLine("Beginning to import titles..."); pluginToUse.DoWork(new string[] { path }); LoadTitlesIntoDatabase(pluginToUse, false, true); } } return(true); }