private void treeView1_ItemActivate(object sender, EventArgs e) { var o = treeView1.SelectedObject; if (o == null) { return; } if (o is ArchivalDataLoadInfo dli) { new ExecuteCommandViewLoggedData(Activator, new LogViewerFilter(LoggingTables.DataLoadRun) { Run = dli.ID }).Execute(); } else if (o is LoadEventsTreeView_Category cat) { new ExecuteCommandViewLoggedData(Activator, new LogViewerFilter(cat.AssociatedTable) { Run = cat.RunId }).Execute(); } else if (o is IHasSummary s) { WideMessageBox.Show(s); } }
private void btnFetchData_Click(object sender, EventArgs e) { fetchDataResultedInNoErrors = true; var fetcher = new DiffDatabaseDataFetcher(_batchSizeToGet, _toInterrogate, _dataLoadRunID, _timeout); fetcher.FetchData(this); dgInserts.DataSource = fetcher.Inserts; if (fetcher.Updates_New == null || fetcher.Updates_Replaced == null) { diffDataTables1.Clear(); } else { diffDataTables1.PopulateWith(fetcher.Updates_New, fetcher.Updates_Replaced); } //if user is already viewing the updates we will need to re-highlight if (tabControl1.SelectedTab == tpViewUpdates) { diffDataTables1.HighlightDiffCells(); } //we didn't see any errors so probably everything was fine if (fetchDataResultedInNoErrors) { WideMessageBox.Show("Data Ready", "Data ready for you to view in the Inserts / Updates tabs", WideMessageBoxTheme.Help); } }
public void SetLookupTableInfo(TableInfo t, bool setComboBox = true) { if (t != null && t.IsTableValuedFunction) { WideMessageBox.Show("Lookup table not valid", "Table '" + t + "' is a TableValuedFunction, you cannot use it as a lookup table"); return; } if (setComboBox) { cbxLookup.SelectedItem = t; } olvLookupColumns.ClearObjects(); if (t != null) { olvLookupColumns.AddObjects(t.ColumnInfos); SetStage(LookupCreationStage.DragAPrimaryKey); pk1.IsValidGetter = c => c.TableInfo_ID == t.ID; pk2.IsValidGetter = c => c.TableInfo_ID == t.ID; pk3.IsValidGetter = c => c.TableInfo_ID == t.ID; fk1.IsValidGetter = c => c.TableInfo_ID != t.ID; fk2.IsValidGetter = c => c.TableInfo_ID != t.ID; fk3.IsValidGetter = c => c.TableInfo_ID != t.ID; } else { SetStage(LookupCreationStage.ChooseLookupTable); } }
private void DataGridView1OnCellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex == -1) { return; } if (e.Button == MouseButtons.Right) { var menu = new ContextMenuStrip(); foreach (ExecuteCommandViewLoggedData cmd in GetCommands(e.RowIndex)) { ExecuteCommandViewLoggedData 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); } }
public void ShowHelp(IActivateItems activator) { var typeDocs = activator.RepositoryLocator.CatalogueRepository.CommentStore; StringBuilder sb = new StringBuilder(); string firstMatch = null; foreach (var c in Controls) { if (typeDocs.ContainsKey(c.GetType().Name)) { if (firstMatch == null) { firstMatch = c.GetType().Name; } sb.AppendLine(typeDocs.GetDocumentationIfExists(c.GetType().Name, false, true)); sb.AppendLine(); } } if (sb.Length > 0) { WideMessageBox.Show(firstMatch, sb.ToString(), Environment.StackTrace, true, firstMatch, WideMessageBoxTheme.Help); } }
void lbCohortDatabaseTable_ButtonClick(object sender, CellClickEventArgs e) { var ecd = e.Model as ExtractableCohortDescription; if (e.Column == olvViewLog && ecd != null) { WideMessageBox.Show("Cohort audit log", ecd.Cohort.AuditLog, WideMessageBoxTheme.Help); } }
void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } WideMessageBox.Show("Full Text", dataGridView1.Rows[e.RowIndex]); }
private void btnPrimaryKeyCompositeHelp_Click(object sender, EventArgs e) { WideMessageBox.Show("Lookup help", @"Usually you only need one primary key/foreign key relationship e.g. M=Male, F=Female in which z_GenderLookup..Sex is the primary key and Demography..PatientGender is the foreign key. However sometimes you need additional lookup joins. For example: if the Drug Code 'TIB' is reused in Tayside and Fife healthboard with different meanings then the primary key/foreign key would of the Lookup table would have to be both the 'Code' (TIB) and the 'Prescribing Healthboard' (T or F). Only define secondary columns if you really need them! if any of the key fields do not match between the Lookup table and the Dataset table then no lookup description will be recorded", null, true, null, WideMessageBoxTheme.Help); }
void olvChecks_ItemActivate(object sender, EventArgs e) { var args = olvChecks.SelectedObject as CheckEventArgs; if (args != null) { if (args.Ex != null) { ExceptionViewer.Show(args.Message, args.Ex); } else { WideMessageBox.Show(args, false); } } }
void olvProgressEvents_ItemActivate(object sender, EventArgs e) { var model = olvProgressEvents.SelectedObject as ProgressUIEntry; if (model != null) { if (model.Exception != null) { ExceptionViewer.Show(model.Message, model.Exception, false); } else { WideMessageBox.Show("Progress Message", model.Message, model.Args.StackTrace, false, theme: model.GetTheme()); } } }
private void MenuBuilt(object sender, MenuBuiltEventArgs e) { var c = GetKey(e.Obj); if (c != null) { e.Menu.Items.Add(new ToolStripSeparator()); e.Menu.Items.Add( BuildItem("View Sql", c, a => !string.IsNullOrWhiteSpace(a.CountSQL), a => WideMessageBox.Show($"Sql {c}", a.CountSQL, WideMessageBoxTheme.Help)) ); e.Menu.Items.Add( new ToolStripMenuItem("View Crash Message", null, (s, ev) => ViewCrashMessage(c)) { Enabled = c.CrashMessage != null }); e.Menu.Items.Add( new ToolStripMenuItem("View Build Log", null, (s, ev) => WideMessageBox.Show($"Build Log {c}", c.Log, WideMessageBoxTheme.Help))); e.Menu.Items.Add( BuildItem("View Results", c, a => a.Identifiers != null, a => { Activator.ShowWindow(new DataTableViewerUI(a.Identifiers, $"Results {c}")); }) ); e.Menu.Items.Add( BuildItem("Clear Cache", c, a => a.SubqueriesCached > 0, a => { if (c is ICacheableTask cacheable) { ClearCacheFor(new[] { cacheable }); } }) ); } }
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 bool OnCheckPerformed(CheckEventArgs args) { //if there is a fix suggest it to the user if (args.ProposedFix != null) { return(ShowYesNoMessageBoxToApplyFix(_dialog, args.Message, args.ProposedFix)); } //else show an Exception if (args.Ex != null) { ExceptionViewer.Show(args.Ex); } else if (args.Result == CheckResult.Fail) { WideMessageBox.Show(args.Message, "", environmentDotStackTrace: Environment.StackTrace); } return(false); }
/// <summary> /// Creates a new instance of the given RDMPCollectionUI specified by the Enum collectionToCreate at the specified dock position /// </summary> /// <param name="collectionToCreate"></param> /// <param name="position"></param> /// <returns></returns> public PersistableToolboxDockContent Create(RDMPCollection collectionToCreate, DockState position = DockState.DockLeft) { PersistableToolboxDockContent toReturn; RDMPCollectionUI collection; switch (collectionToCreate) { case RDMPCollection.Catalogue: collection = new CatalogueCollectionUI(); toReturn = Show(RDMPCollection.Catalogue, collection, "Catalogues", CatalogueIcons.Catalogue); break; case RDMPCollection.DataLoad: collection = new LoadMetadataCollectionUI(); toReturn = Show(RDMPCollection.DataLoad, collection, "Load Configurations", CatalogueIcons.LoadMetadata); break; case RDMPCollection.Tables: collection = new TableInfoCollectionUI(); toReturn = Show(RDMPCollection.Tables, collection, "Tables", CatalogueIcons.TableInfo); break; case RDMPCollection.DataExport: if (RepositoryLocator.DataExportRepository == null) { WideMessageBox.Show("Data export database unavailable", "Cannot create DataExport Toolbox because DataExportRepository has not been set/created yet"); return(null); } collection = new DataExportCollectionUI(); toReturn = Show(RDMPCollection.DataExport, collection, "Data Export", CatalogueIcons.Project); break; case RDMPCollection.Cohort: collection = new CohortIdentificationCollectionUI(); toReturn = Show(RDMPCollection.Cohort, collection, "Cohort Builder", CatalogueIcons.CohortIdentificationConfiguration); break; case RDMPCollection.SavedCohorts: collection = new SavedCohortsCollectionUI(); toReturn = Show(RDMPCollection.SavedCohorts, collection, "Saved Cohorts", CatalogueIcons.AllCohortsNode); break; case RDMPCollection.Favourites: collection = new FavouritesCollectionUI(); toReturn = Show(RDMPCollection.Favourites, collection, "Favourites", CatalogueIcons.Favourite); break; default: throw new ArgumentOutOfRangeException("collectionToCreate"); } toReturn.DockState = position; collection.SetItemActivator(ActivateItems); if (CollectionCreated != null) { CollectionCreated(this, new RDMPCollectionCreatedEventHandlerArgs(collectionToCreate)); } return(toReturn); }
public override void Show(string message) { WideMessageBox.Show("Message", message, Environment.StackTrace, true, null, WideMessageBoxTheme.Help); }
public override bool DeleteWithConfirmation(IDeleteable deleteable) { var databaseObject = deleteable as DatabaseEntity; //If there is some special way of describing the effects of deleting this object e.g. Selected Datasets var customMessageDeletable = deleteable as IDeletableWithCustomMessage; if (databaseObject is Catalogue c) { if (c.GetExtractabilityStatus(RepositoryLocator.DataExportRepository).IsExtractable) { if (YesNo("Catalogue must first be made non extractable before it can be deleted, mark non extractable?", "Make Non Extractable")) { var cmd = new ExecuteCommandChangeExtractability(this, c); cmd.Execute(); } else { return(false); } } } if (databaseObject is AggregateConfiguration ac && ac.IsJoinablePatientIndexTable()) { var users = ac.JoinableCohortAggregateConfiguration?.Users?.Select(u => u.AggregateConfiguration); if (users != null) { users = users.ToArray(); if (users.Any()) { WideMessageBox.Show("Cannot Delete", $"Cannot Delete '{ac.Name}' because it is linked to by the following AggregateConfigurations:{Environment.NewLine}{string.Join(Environment.NewLine,users)}"); return(false); } } } string overrideConfirmationText = null; if (customMessageDeletable != null) { overrideConfirmationText = "Are you sure you want to " + customMessageDeletable.GetDeleteMessage() + "?"; } //it has already been deleted before if (databaseObject != null && !databaseObject.Exists()) { return(false); } string idText = ""; if (databaseObject != null) { idText = " ID=" + databaseObject.ID; } if (databaseObject != null) { var exports = RepositoryLocator.CatalogueRepository.GetReferencesTo <ObjectExport>(databaseObject).ToArray(); if (exports.Any(e => e.Exists())) { if (YesNo("This object has been shared as an ObjectExport. Deleting it may prevent you loading any saved copies. Do you want to delete the ObjectExport definition?", "Delete ObjectExport")) { foreach (ObjectExport e in exports) { e.DeleteInDatabase(); } } else { return(false); } } } if ( YesNo( overrideConfirmationText ?? ("Are you sure you want to delete '" + deleteable + "'?") + Environment.NewLine + "(" + deleteable.GetType().Name + idText + ")", "Delete " + deleteable.GetType().Name)) { deleteable.DeleteInDatabase(); if (databaseObject == null) { var descendancy = CoreChildProvider.GetDescendancyListIfAnyFor(deleteable); if (descendancy != null) { databaseObject = descendancy.Parents.OfType <DatabaseEntity>().LastOrDefault(); } } if (deleteable is IMasqueradeAs) { databaseObject = databaseObject ?? ((IMasqueradeAs)deleteable).MasqueradingAs() as DatabaseEntity; } if (databaseObject == null) { throw new NotSupportedException("IDeletable " + deleteable + " was not a DatabaseObject and it did not have a Parent in it's tree which was a DatabaseObject (DescendancyList)"); } RefreshBus.Publish(this, new RefreshObjectEventArgs(databaseObject) { DeletedObjectDescendancy = CoreChildProvider.GetDescendancyListIfAnyFor(databaseObject) }); return(true); } return(false); }
void olvSelectColumns_CellClick(object sender, CellClickEventArgs e) { if (e.Column == olvAddRemove) { var countColumn = e.Model as AggregateCountColumn; var importableColumn = e.Model as ExtractionInformation; var dimensionColumn = e.Model as AggregateDimension; if (countColumn == null && importableColumn == null && dimensionColumn == null) { throw new Exception("Object in list view of type that wasn't IColumn, it was " + e.Model.GetType().Name); } //if it is an add if (_availableColumns.Contains(e.Model)) { //count column added if (countColumn != null) { if (_options.GetCountColumnRequirement(_aggregate) == CountColumnRequirement.CannotHaveOne) { WideMessageBox.Show("Cohort Sets cannot have count columns", "A count column is a SELECT column with an aggregate function (count(*), sum(x) etc). The SELECT component for cohort identification must be the patient id column only."); } else { Save(countColumn); } } //regular column added if (importableColumn != null) { var dimension = new AggregateDimension(Activator.RepositoryLocator.CatalogueRepository, importableColumn, _aggregate); _availableColumns.Remove(importableColumn); _includedColumns.Add(dimension); olvSelectColumns.RemoveObject(importableColumn); olvSelectColumns.AddObject(dimension); olvSelectColumns.EnsureModelVisible(dimension); Save(dimension); //object doesn't exist, that might cause problems return; } } else { //it is a removal //user is trying to remove count column if (countColumn != null) { if (_options.GetCountColumnRequirement(_aggregate) == CountColumnRequirement.MustHaveOne) { return; //leave it checked - removal is forbidden } _aggregate.CountSQL = ""; _aggregate.SaveToDatabase(); _includedColumns.Remove(countColumn); _availableColumns.Add(countColumn); olvSelectColumns.RemoveObject(countColumn); olvSelectColumns.AddObject(countColumn); olvSelectColumns.EnsureModelVisible(countColumn); Activator.RefreshBus.Publish(this, new RefreshObjectEventArgs(_aggregate)); } //user is trying to remove a dimension if (dimensionColumn != null) { dimensionColumn.DeleteInDatabase(); //get the master it was based on var extractionInformation = dimensionColumn.ExtractionInformation; try { dimensionColumn.DeleteInDatabase(); } catch (Exception ex) { //couldn't delete it so don't update the UI just tell the user why ExceptionViewer.Show(ex); return; } //remove it from the inclusion list _includedColumns.Remove(dimensionColumn); olvSelectColumns.RemoveObject(dimensionColumn); //add the master importable version it was based on into available columns again _availableColumns.Add(extractionInformation); olvSelectColumns.AddObject(extractionInformation); Save(extractionInformation); } } } }
public override void Execute() { base.Execute(); var db = SelectDatabase("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 theres 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); } }
public override void Execute() { base.Execute(); WideMessageBox.Show(_title, _help, WideMessageBoxTheme.Help); }
private void btnExecute_Click(object sender, EventArgs e) { var pipeline = CreateAndInitializePipeline(); //if it is already executing if (btnExecute.Text == "Stop") { _cancel.Cancel();//set the cancellation token return; } btnExecute.Text = "Stop"; _cancel = new CancellationTokenSource(); //clear any old results progressUI1.Clear(); if (PipelineExecutionStarted != null) { PipelineExecutionStarted(this, new PipelineEngineEventArgs(pipeline)); } progressUI1.ShowRunning(true); bool success = false; Exception exception = null; //start a new thread Task t = new Task(() => { try { pipeline.ExecutePipeline(new GracefulCancellationToken(_cancel.Token, _cancel.Token)); success = true; } catch (Exception ex) { fork.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Pipeline execution failed", ex)); exception = ex; } } ); t.ContinueWith(x => { if (success) { //if it successfully got here then Thread has run the engine to completion successfully if (PipelineExecutionFinishedsuccessfully != null) { PipelineExecutionFinishedsuccessfully(this, new PipelineEngineEventArgs(pipeline)); } } progressUI1.ShowRunning(false); btnExecute.Text = "Execute"; //make it so user can execute again if (UserSettings.ShowPipelineCompletedPopup) { if (success) { WideMessageBox.Show("Pipeline Completed", "Pipeline execution completed", WideMessageBoxTheme.Help); } else { var worst = progressUI1.GetWorst(); if (UserSettings.ShowPipelineCompletedPopup) { ExceptionViewer.Show("Pipeline crashed", exception ?? worst?.Exception); } } } }, TaskScheduler.FromCurrentSynchronizationContext()); t.Start(); }
private void olvComponents_CellRightClick(object sender, CellRightClickEventArgs e) { var model = (AdvertisedPipelineComponentTypeUnderContext)e.Model; ContextMenuStrip RightClickMenu = new ContextMenuStrip(); if (model != null) { if (!model.IsCompatible()) { RightClickMenu.Items.Add("Component incompatible", null, (s, v) => WideMessageBox.Show(model.ToString(), model.GetReasonIncompatible(), WideMessageBoxTheme.Help)); } } //show it if (RightClickMenu.Items.Count != 0) { RightClickMenu.Show(this, e.Location); } }
public override void Show(string message) { WideMessageBox.Show("Message", message); }