private void DataGridView1OnCellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1) { return; } if (e.Button == MouseButtons.Right) { var menu = new ContextMenuStrip(); foreach (BasicCommandExecution cmd in GetCommands(e.RowIndex)) { BasicCommandExecution cmd1 = cmd; var mi = new ToolStripMenuItem(cmd.GetCommandName(), null, (s, x) => cmd1.Execute()); menu.Items.Add(mi); } if (menu.Items.Count != 0) { menu.Items.Add(new ToolStripSeparator()); } menu.Items.Add("View as text", null, (s, ex) => WideMessageBox.Show("Full Text", dataGridView1.Rows[e.RowIndex])); menu.Show(Cursor.Position.X, Cursor.Position.Y); } }
void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } WideMessageBox.Show("Full Text", dataGridView1.Rows[e.RowIndex]); }
void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) return; var cmd = GetCommands(e.RowIndex).FirstOrDefault(); if (cmd != null) cmd.Execute(); else WideMessageBox.Show("Full Text", dataGridView1.Rows[e.RowIndex]); }
public override void Execute() { base.Execute(); var db = SelectDatabase(false, "Import all Tables form Database..."); if (db == null) { return; } ShareManager shareManager = new ShareManager(Activator.RepositoryLocator, LocalReferenceGetter); List <ICatalogue> catalogues = new List <ICatalogue>(); //don't do any double importing! var existing = Activator.RepositoryLocator.CatalogueRepository.GetAllObjects <TableInfo>(); var ignoredTables = new List <TableInfo>(); if (YesNo("Would you also like to import ShareDefinitions (metadata)?", "Import Metadata From File(s)")) { OpenFileDialog ofd = new OpenFileDialog() { Multiselect = true }; ofd.Filter = "Share Definitions|*.sd"; if (ofd.ShowDialog() == DialogResult.OK) { foreach (var f in ofd.FileNames) { using (var stream = File.Open(f, FileMode.Open)) { var newObjects = shareManager.ImportSharedObject(stream); if (newObjects != null) { catalogues.AddRange(newObjects.OfType <ICatalogue>()); } } } } } bool generateCatalogues = false; if (YesNo("Would you like to try to guess non-matching Catalogues by Name?", "Guess by name")) { catalogues.AddRange(Activator.RepositoryLocator.CatalogueRepository.GetAllObjects <Catalogue>()); } else if (YesNo("Would you like to generate empty Catalogues for non-matching tables instead?", "Generate New Catalogues")) { generateCatalogues = true; } var married = new Dictionary <CatalogueItem, ColumnInfo>(); TableInfo anyNewTable = null; foreach (DiscoveredTable discoveredTable in db.DiscoverTables(includeViews: false)) { var collide = existing.FirstOrDefault(t => t.Is(discoveredTable)); if (collide != null) { ignoredTables.Add(collide); continue; } var importer = new TableInfoImporter(Activator.RepositoryLocator.CatalogueRepository, discoveredTable); TableInfo ti; ColumnInfo[] cis; //import the table importer.DoImport(out ti, out cis); anyNewTable = anyNewTable ?? ti; //find a Catalogue of the same name (possibly imported from Share Definition) var matchingCatalogues = catalogues.Where(c => c.Name.Equals(ti.GetRuntimeName(), StringComparison.CurrentCultureIgnoreCase)).ToArray(); //if there's 1 Catalogue with the same name if (matchingCatalogues.Length == 1) { //we know we want to import all these ColumnInfos var unmatched = new List <ColumnInfo>(cis); //But hopefully most already have orphan CatalogueItems we can hook them together to foreach (var cataItem in matchingCatalogues[0].CatalogueItems) { if (cataItem.ColumnInfo_ID == null) { var matches = cataItem.GuessAssociatedColumn(cis, allowPartial: false).ToArray(); if (matches.Length == 1) { cataItem.SetColumnInfo(matches[0]); unmatched.Remove(matches[0]); //we married them together married.Add(cataItem, matches[0]); } } } //is anyone unmarried? i.e. new ColumnInfos that don't have CatalogueItems with the same name foreach (ColumnInfo columnInfo in unmatched) { var cataItem = new CatalogueItem(Activator.RepositoryLocator.CatalogueRepository, (Catalogue)matchingCatalogues[0], columnInfo.GetRuntimeName()); cataItem.ColumnInfo_ID = columnInfo.ID; cataItem.SaveToDatabase(); married.Add(cataItem, columnInfo); } } else if (generateCatalogues) { new ForwardEngineerCatalogue(ti, cis).ExecuteForwardEngineering(); } } if (married.Any() && YesNo("Found " + married.Count + " columns, make them all extractable?", "Make Extractable")) { foreach (var kvp in married) { //yup thats how we roll, the database is main memory! var ei = new ExtractionInformation(Activator.RepositoryLocator.CatalogueRepository, kvp.Key, kvp.Value, kvp.Value.Name); } } if (ignoredTables.Any()) { WideMessageBox.Show("Ignored some tables", "Ignored " + ignoredTables.Count + " tables because they already existed as TableInfos:" + string.Join(Environment.NewLine, ignoredTables.Select(ti => ti.GetRuntimeName()))); } if (anyNewTable != null) { Publish(anyNewTable); Emphasise(anyNewTable); } }