private void buttonImport_Click(object sender, RoutedEventArgs e) { const string warnMessage = "Importing the standard CC libraries will overwrite all existing:\n\n" + " - ENUM libraries named \"ENUMLibrary\",\n" + " - PRIM libraries named \"PRIMLibrary\",\n" + " - CDT libraries named \"CDTLibrary \", and \n" + " - CC libraries named \"CCLibrary\"\n\n" + "Are you sure you want to proceed?"; const string caption = "VIENNA Add-In Warning"; DialogResult dialogResult = MessageBox.Show(warnMessage, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { Mouse.OverrideCursor = Cursors.Wait; buttonClose.IsEnabled = false; buttonImport.IsEnabled = false; string bLibraryGuid = eaRepository.GetTreeSelectedPackage().Element.ElementGUID; Package bLibrary = eaRepository.GetPackageByGuid(bLibraryGuid); var resourceDescriptor = new ResourceDescriptor(cclPath, cbxMajor.SelectedItem.ToString(), cbxMinor.SelectedItem.ToString()); var importer = new LibraryImporter(eaRepository, resourceDescriptor) { bLibrary = bLibrary }; bw.RunWorkerAsync(importer); } }
private void btnImport_Click(object sender, EventArgs e) { const string warnMessage = "Importing the standard CC libraries will overwrite all existing:\n\n" + " - ENUM libraries named \"ENUMLibrary\",\n" + " - PRIM libraries named \"PRIMLibrary\",\n" + " - CDT libraries named \"CDTLibrary \", and \n" + " - CC libraries named \"CCLibrary\"\n\n" + "Are you sure you want to proceed?"; const string caption = "VIENNA Add-In Warning"; DialogResult dialogResult = MessageBox.Show(warnMessage, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dialogResult == DialogResult.Yes) { Cursor.Current = Cursors.WaitCursor; btnClose.Enabled = false; btnImport.Enabled = false; string bLibraryGuid = eaRepository.GetTreeSelectedPackage().Element.ElementGUID; Package bLibrary = eaRepository.GetPackageByGuid(bLibraryGuid); ResourceDescriptor resourceDescriptor = new ResourceDescriptor(cclPath, cbxMajor.SelectedItem.ToString(), cbxMinor.SelectedItem.ToString()); LibraryImporter importer = new LibraryImporter(eaRepository, resourceDescriptor); importer.StatusChanged += OnStatusChanged; importer.ImportStandardCcLibraries(bLibrary); btnImport.Enabled = true; btnClose.Enabled = true; Cursor.Current = Cursors.Default; } }
public LibraryImporterTests() { var builder = new DbContextOptionsBuilder <CocktailsContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); _db = new CocktailsContext(builder.Options); _sut = new LibraryImporter(_db); }
private static async Task <int> importIntoDbAsync(List <ImportItem> importItems) { using var context = DbContexts.GetContext(); var libraryImporter = new LibraryImporter(context); var newCount = await Task.Run(() => libraryImporter.Import(importItems)); context.SaveChanges(); return(newCount); }
public void TestImportStandardCcLibrariesIntoEmptyBusinessLibrary() { Repository eaRepository = new TemporaryFileBasedRepository(new EARepositoryLibraryImporter()); var bLibrary = eaRepository.Resolve <Package>((Path)"Test Model 1" / "bLibrary"); DeleteDownloadDirectory(); var importer = new LibraryImporter(eaRepository, resourceDescriptor); importer.ImportStandardCcLibraries(bLibrary); AssertEmptyStandardCcLibrariesInBusinessLibrary(eaRepository, "Test Model 1", "bLibrary"); AssertStandardCcLibrariesContentInBusinessLibrary(eaRepository, "Test Model 1", "bLibrary"); AssertNonExistenceOfBieLibrariesinBusinessLibrary(eaRepository, "Test Model 1", "bLibrary"); }