diff --git a/Application/ResearchDataManagementPlatform/WindowManagement/ActivateItems.cs b/Application/ResearchDataManagementPlatform/WindowManagement/ActivateItems.cs index 9b3609bbe8..11fcb75d81 100644 --- a/Application/ResearchDataManagementPlatform/WindowManagement/ActivateItems.cs +++ b/Application/ResearchDataManagementPlatform/WindowManagement/ActivateItems.cs @@ -386,7 +386,7 @@ private T Activate(T2 databaseObject, Image tabImage) uiInstance.SetDatabaseObject(this, databaseObject); - if (insertIndex is not null) + if (insertIndex is not null && _mainDockPanel.ActivePane is not null) { _mainDockPanel.ActivePane.SetContentIndex(floatable, (int)insertIndex); } diff --git a/Rdmp.Core/Curation/Data/Overview/OverviewModel.cs b/Rdmp.Core/Curation/Data/Overview/OverviewModel.cs index 2af6edcaa6..036b37dc98 100644 --- a/Rdmp.Core/Curation/Data/Overview/OverviewModel.cs +++ b/Rdmp.Core/Curation/Data/Overview/OverviewModel.cs @@ -1,19 +1,16 @@ -// Copyright (c) The University of Dundee 2024-2024 +// Copyright (c) The University of Dundee 2024-2025 // This file is part of the Research Data Management Platform (RDMP). // RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. // RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // You should have received a copy of the GNU General Public License along with RDMP. If not, see . +using MongoDB.Driver; using Rdmp.Core.CommandExecution; using Rdmp.Core.DataExport.Data; -using Rdmp.Core.DataLoad.Triggers; -using Rdmp.Core.DataViewing; -using Rdmp.Core.Logging; -using Rdmp.Core.QueryBuilding; +using Rdmp.Core.DataQualityEngine.Data; using Rdmp.Core.Repositories; using Rdmp.Core.ReusableLibraryCode.DataAccess; using System; -using System.Collections.Generic; using System.Data; using System.Linq; @@ -24,244 +21,134 @@ namespace Rdmp.Core.Curation.Data.Overview; /// public class OverviewModel { + private readonly ICatalogue _catalogue; private readonly IBasicActivateItems _activator; - - private DataTable _dataLoads; - - private int _numberOfPeople; - private int _numberOfRecords; + private Evaluation _evaluation; + private readonly DataTable _dqeTable = new(); + private readonly DateTime? _extractionDate; + private readonly DateTime? _dataLoadDate; public OverviewModel(IBasicActivateItems activator, ICatalogue catalogue) { _activator = activator; _catalogue = catalogue; - if (catalogue != null) - { - Regen(""); - } + _dqeTable = GetCountsByDatePeriod(); + _dataLoadDate = GetDataLoadDate(); + _extractionDate = GetExtractionDate(); } - public void Regen(string whereClause) - { - using var dt = new DataTable(); - var hasExtractionIdentifier = true; - var column = _catalogue.CatalogueItems.FirstOrDefault(static ci => ci.ExtractionInformation.IsExtractionIdentifier); - if (column is null) - { - column = _catalogue.CatalogueItems.FirstOrDefault(); - hasExtractionIdentifier = false; - } - - if (column is null) return; - - var discoveredColumn = column.ColumnInfo.Discover(DataAccessContext.InternalDataProcessing); - var server = discoveredColumn.Table.Database.Server; - using var con = server.GetConnection(); - con.Open(); - var populatedWhere = !string.IsNullOrWhiteSpace(whereClause) ? $"WHERE {whereClause}" : ""; - var sql = $"SELECT {column.ColumnInfo.GetRuntimeName()} FROM {discoveredColumn.Table.GetRuntimeName()} {populatedWhere}"; - using var cmd = server.GetCommand(sql, con); - cmd.CommandTimeout = 30000; - using var da = server.GetDataAdapter(cmd); - dt.BeginLoadData(); - da.Fill(dt); - dt.EndLoadData(); - _numberOfRecords = dt.Rows.Count; - _numberOfPeople = hasExtractionIdentifier - ? dt.AsEnumerable().Select(r => r[column.ColumnInfo.GetRuntimeName()]).Distinct().Count() - : 0; - GetDataLoads(); - } - - public int GetNumberOfRecords() + public bool HasDQEEvaluation() { - return _numberOfRecords; + return _evaluation is not null; } - public int GetNumberOfPeople() + public DataTable GetTableData() { - return _numberOfPeople; + return _dqeTable; } - public Tuple GetStartEndDates(ColumnInfo dateColumn, string whereClause) + private DateTime? GetExtractionDate() { - using var dt = new DataTable(); - - var discoveredColumn = _catalogue.CatalogueItems.First().ColumnInfo.Discover(DataAccessContext.InternalDataProcessing); - var server = discoveredColumn.Table.Database.Server; - var populatedWhereClause = !string.IsNullOrWhiteSpace(whereClause) ? $"WHERE {whereClause}" : ""; - using var con = server.GetConnection(); - con.Open(); - if (server.DatabaseType == FAnsi.DatabaseType.MicrosoftSQLServer) - { - var sql = $@" - select min({dateColumn.GetRuntimeName()}) as min, max({dateColumn.GetRuntimeName()}) as max - from - (select {dateColumn.GetRuntimeName()}, - count(1) over (partition by year({dateColumn.GetRuntimeName()})) as occurs - from {discoveredColumn.Table.GetRuntimeName()} {populatedWhereClause}) as t - where occurs >1 - "; - - using var cmd = server.GetCommand(sql, con); - cmd.CommandTimeout = 30000; - using var da = server.GetDataAdapter(cmd); - dt.BeginLoadData(); - da.Fill(dt); - dt.EndLoadData(); - } - else + var extractableDataSets = _activator.RepositoryLocator.DataExportRepository.GetAllObjectsWhere("Catalogue_ID", _catalogue.ID); + DateTime? maxDateOfExtraction = null; + foreach (var eds in extractableDataSets) { - var repo = new MemoryCatalogueRepository(); - var qb = new QueryBuilder(null, null); - qb.AddColumn(new ColumnInfoToIColumn(repo, dateColumn)); - qb.AddCustomLine($"{dateColumn.Name} IS NOT NULL", FAnsi.Discovery.QuerySyntax.QueryComponent.WHERE); - var cmd = server.GetCommand(qb.SQL, con); - using var da = server.GetDataAdapter(cmd); - dt.BeginLoadData(); - da.Fill(dt); - var latest = dt.AsEnumerable() - .Max(r => r.Field(dateColumn.Name)); - var earliest = dt.AsEnumerable() - .Min(r => r.Field(dateColumn.Name)); - dt.Rows.Clear(); - dt.Rows.Add(earliest, latest); + var results = _activator.RepositoryLocator.DataExportRepository.GetAllObjectsWhere("ExtractableDataSet_ID", eds.ID); + if (results.Length != 0) + { + var max = results.Select(cer => cer.DateOfExtraction).Max(); + if (maxDateOfExtraction == null || max > maxDateOfExtraction) + { + maxDateOfExtraction = max; + } + } } - - return new Tuple(DateTime.Parse(dt.Rows[0].ItemArray[0].ToString()), DateTime.Parse(dt.Rows[0].ItemArray[1].ToString())); + return maxDateOfExtraction; } - - public static DataTable GetCountsByDatePeriod(ColumnInfo dateColumn, string datePeriod, string optionalWhere = "") + private DateTime? GetDataLoadDate() { - var dt = new DataTable(); - if (!(new[] { "Day", "Month", "Year" }).Contains(datePeriod)) - { - throw new Exception("Invalid Date period"); - } - - var discoveredColumn = dateColumn.Discover(DataAccessContext.InternalDataProcessing); - var server = discoveredColumn.Table.Database.Server; - using var con = server.GetConnection(); - con.Open(); - var dateString = datePeriod switch + if (_evaluation is null) return null; + int dataLoadID = _evaluation.RowStates.Max(rs => rs.DataLoadRunID); + if (dataLoadID > 0) { - "Day" => "yyyy-MM-dd", - "Month" => "yyyy-MM", - "Year" => "yyyy", - _ => "yyyy-MM" - }; - - if (server.DatabaseType == FAnsi.DatabaseType.MicrosoftSQLServer) - { - var sql = @$" - SELECT format({dateColumn.GetRuntimeName()}, '{dateString}') as YearMonth, count(*) as '# Records' - FROM {discoveredColumn.Table.GetRuntimeName()} - WHERE {dateColumn.GetRuntimeName()} IS NOT NULL - {(optionalWhere != "" ? "AND" : "")} {optionalWhere.Replace('"', '\'')} - GROUP BY format({dateColumn.GetRuntimeName()}, '{dateString}') - ORDER BY 1 - "; - - using var cmd = server.GetCommand(sql, con); - cmd.CommandTimeout = 30000; - using var da = server.GetDataAdapter(cmd); - dt.BeginLoadData(); - da.Fill(dt); - dt.EndLoadData(); - } - else - { - var repo = new MemoryCatalogueRepository(); - var qb = new QueryBuilder(null, null); - qb.AddColumn(new ColumnInfoToIColumn(repo, dateColumn)); - qb.AddCustomLine($"{dateColumn.Name} IS NOT NULL", FAnsi.Discovery.QuerySyntax.QueryComponent.WHERE); - var cmd = server.GetCommand(qb.SQL, con); - using var da = server.GetDataAdapter(cmd); - dt.BeginLoadData(); - da.Fill(dt); - Dictionary counts = []; - foreach (var key in dt.AsEnumerable().Select(row => DateTime.Parse(row.ItemArray[0].ToString()).ToString(dateString))) + var loggingDB = _catalogue.CatalogueRepository.GetAllObjectsWhere("CreatedByAssembly", "Rdmp.Core/Databases.LoggingDatabase").FirstOrDefault(); + if (loggingDB != null) { - counts[key]++; + var discoveredDB = loggingDB.Discover(DataAccessContext.InternalDataProcessing); + var discoveredTable = discoveredDB.ExpectTable("TableLoadRun"); + if (discoveredTable != null) + { + var conn = discoveredDB.Server.GetConnection(); + conn.Open(); + var cmd = discoveredTable.GetCommand($"SELECT startTime FROM {discoveredTable.GetFullyQualifiedName()} WHERE dataLoadRunID = {dataLoadID}", conn); + var result = cmd.ExecuteScalar(); + conn.Close(); + if (result != null) + { + return DateTime.Parse(result.ToString()); + } + } } - - dt = new DataTable(); - foreach (var item in counts) - { - var dr = dt.NewRow(); - dr["YearMonth"] = item.Key; - dr["# Records"] = item.Value; - dt.Rows.Add(dr); - } - - dt.EndLoadData(); } - return dt; + return null; } - private void GetDataLoads() + public int GetNumberOfRecords() { - _dataLoads = new DataTable(); - var repo = new MemoryCatalogueRepository(); - var qb = new QueryBuilder(null, null); - var columnInfo = _catalogue.CatalogueItems.Where(static c => c.Name == SpecialFieldNames.DataLoadRunID).Select(c => c.ColumnInfo).FirstOrDefault(); - if (columnInfo == null) return; + return _dqeTable.AsEnumerable() + .Sum(x => int.Parse(x["# Records"].ToString())); + } - qb.AddColumn(new ColumnInfoToIColumn(repo, columnInfo)); - qb.AddCustomLine($"{columnInfo.Name} IS NOT NULL", FAnsi.Discovery.QuerySyntax.QueryComponent.WHERE); - var sql = qb.SQL; - var server = columnInfo.Discover(DataAccessContext.InternalDataProcessing).Table.Database.Server; - using var con = server.GetConnection(); - con.Open(); + public string GetLatestExtraction() + { + return _extractionDate != null ? ((DateTime)_extractionDate).ToString("dd/MM/yyyy") : null; + } - using var cmd = server.GetCommand(sql, con); - cmd.CommandTimeout = 30000; - using var da = server.GetDataAdapter(cmd); - _dataLoads.BeginLoadData(); - da.Fill(_dataLoads); - _dataLoads.EndLoadData(); + public string GetLatestDataLoad() + { + return _dataLoadDate != null ? ((DateTime)_dataLoadDate).ToString("dd/MM/yyyy") : null; } - public DataTable GetMostRecentDataLoad() + public Tuple GetStartEndDates() { - if (_dataLoads == null) GetDataLoads(); - if (_dataLoads.Rows.Count == 0) return null; + if (_dqeTable.Rows.Count == 0) return new Tuple(null, null); + var start = DateTime.Parse(_dqeTable.AsEnumerable().First()["YearMonth"].ToString()); + var end = DateTime.Parse(_dqeTable.AsEnumerable().Last()["YearMonth"].ToString()); + return new Tuple(start, end); + } - var maxDataLoadId = _dataLoads.AsEnumerable().Select(static r => int.Parse(r[0].ToString())).Max(); - var loggingServers = _activator.RepositoryLocator.CatalogueRepository.GetAllObjectsWhere("CreatedByAssembly", "Rdmp.Core/Databases.LoggingDatabase"); - var columnInfo = _catalogue.CatalogueItems.Where(c => c.Name == SpecialFieldNames.DataLoadRunID).Select(c => c.ColumnInfo).First(); - var server = columnInfo.Discover(DataAccessContext.InternalDataProcessing).Table.Database.Server; + private DataTable GetCountsByDatePeriod() + { - DataTable dt = new(); - foreach (var loggingServer in loggingServers) + var dt = new DataTable(); + try + { + var repo = new DQERepository(_catalogue.CatalogueRepository); + _evaluation = repo.GetAllObjectsWhere("CatalogueID", _catalogue.ID).LastOrDefault(); + } + catch (Exception) + { + return dt; + } + if (_evaluation != null) { - var logCollection = new ViewLogsCollection(loggingServer, new LogViewerFilter(LoggingTables.DataLoadRun)); - var dataLoadRunSql = $"{logCollection.GetSql()} WHERE ID={maxDataLoadId}"; - var logServer = loggingServer.Discover(DataAccessContext.InternalDataProcessing).Server; - using var loggingCon = logServer.GetConnection(); - loggingCon.Open(); - using var loggingCmd = logServer.GetCommand(dataLoadRunSql, loggingCon); - loggingCmd.CommandTimeout = 30000; - using var loggingDa = server.GetDataAdapter(loggingCmd); - dt.BeginLoadData(); - loggingDa.Fill(dt); - dt.EndLoadData(); - if (dt.Rows.Count > 0) + dt = PeriodicityState.GetPeriodicityForDataTableForEvaluation(_evaluation, "ALL", true); + dt.Columns.Add("# Records"); + foreach (DataRow row in dt.Rows) { - break; + row["# Records"] = int.Parse(row["Correct"].ToString()) + int.Parse(row["Wrong"].ToString()) + int.Parse(row["Missing"].ToString()) + int.Parse(row["InvalidatesRow"].ToString()); } + dt.Columns.Remove("Year"); + dt.Columns.Remove("Month"); + dt.Columns.Remove("Correct"); + dt.Columns.Remove("Wrong"); + dt.Columns.Remove("Missing"); + dt.Columns.Remove("InvalidatesRow"); } - return dt; } - public List GetExtractions() - { - var datasets = _activator.RepositoryLocator.DataExportRepository.GetAllObjectsWhere("Catalogue_ID", _catalogue.ID).Select(d => d.ID); - var results = _activator.RepositoryLocator.DataExportRepository.GetAllObjects().Where(result => datasets.Contains(result.ExtractableDataSet_ID)).ToList(); - return results; - } } diff --git a/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql b/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql index 3d3c8ce877..677babc18a 100644 --- a/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql +++ b/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql @@ -1400,7 +1400,6 @@ CONSTRAINT [PK_RegexRedactionKey] PRIMARY KEY CLUSTERED END GO - EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Table ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Catalogue', @level2type=N'COLUMN',@level2name=N'ID' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'‘SMR01’ for example' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Catalogue', @level2type=N'COLUMN',@level2name=N'Acronym' diff --git a/Rdmp.UI/CommandExecution/Proposals/ProposeExecutionWhenTargetIsCatalogue.cs b/Rdmp.UI/CommandExecution/Proposals/ProposeExecutionWhenTargetIsCatalogue.cs index 9b2a9a3a6d..f8f54b448b 100644 --- a/Rdmp.UI/CommandExecution/Proposals/ProposeExecutionWhenTargetIsCatalogue.cs +++ b/Rdmp.UI/CommandExecution/Proposals/ProposeExecutionWhenTargetIsCatalogue.cs @@ -25,7 +25,7 @@ public ProposeExecutionWhenTargetIsCatalogue(IActivateItems itemActivator) : bas public override void Activate(Catalogue c) { - ItemActivator.Activate(c); + ItemActivator.Activate(c); } public override ICommandExecution ProposeExecution(ICombineToMakeCommand cmd, Catalogue targetCatalogue, diff --git a/Rdmp.UI/Overview/ViewCatalogueOverviewUI.Designer.cs b/Rdmp.UI/Overview/ViewCatalogueOverviewUI.Designer.cs index 2a702eb12b..94f3426c54 100644 --- a/Rdmp.UI/Overview/ViewCatalogueOverviewUI.Designer.cs +++ b/Rdmp.UI/Overview/ViewCatalogueOverviewUI.Designer.cs @@ -31,44 +31,45 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ViewCatalogueOverviewUI)); panel1 = new System.Windows.Forms.Panel(); splitContainer1 = new System.Windows.Forms.SplitContainer(); btnSettings = new System.Windows.Forms.Button(); lblDescription = new System.Windows.Forms.Label(); lblName = new System.Windows.Forms.Label(); - panel3 = new System.Windows.Forms.Panel(); + lblNoDQE = new System.Windows.Forms.Label(); + panel4 = new System.Windows.Forms.Panel(); + pictureBox5 = new System.Windows.Forms.PictureBox(); lblLatestExtraction = new System.Windows.Forms.Label(); - label2 = new System.Windows.Forms.Label(); - label1 = new System.Windows.Forms.Label(); + panel3 = new System.Windows.Forms.Panel(); + pictureBox4 = new System.Windows.Forms.PictureBox(); lblLastDataLoad = new System.Windows.Forms.Label(); - lblTime = new System.Windows.Forms.Label(); - lblWhere = new System.Windows.Forms.Label(); - tbMainWhere = new System.Windows.Forms.TextBox(); - cbTimeColumns = new System.Windows.Forms.ComboBox(); - panel2 = new System.Windows.Forms.Panel(); - button1 = new System.Windows.Forms.Button(); - panel7 = new System.Windows.Forms.Panel(); - label6 = new System.Windows.Forms.Label(); - lblPeople = new System.Windows.Forms.Label(); - label5 = new System.Windows.Forms.Label(); - cbFrequency = new System.Windows.Forms.ComboBox(); - panel6 = new System.Windows.Forms.Panel(); - label4 = new System.Windows.Forms.Label(); - lblDateRange = new System.Windows.Forms.Label(); panel5 = new System.Windows.Forms.Panel(); - label3 = new System.Windows.Forms.Label(); + pictureBox1 = new System.Windows.Forms.PictureBox(); lblRecords = new System.Windows.Forms.Label(); - areaChart1 = new CatalogueSummary.DataQualityReporting.AreaChartUI(OnTabChange); + panel6 = new System.Windows.Forms.Panel(); + pictureBox3 = new System.Windows.Forms.PictureBox(); + lblDateRange = new System.Windows.Forms.Label(); + panel2 = new System.Windows.Forms.Panel(); + toolTip1 = new System.Windows.Forms.ToolTip(components); + toolTip2 = new System.Windows.Forms.ToolTip(components); + viewSourceCodeToolTip1 = new SimpleDialogs.ViewSourceCodeToolTip(); + toolTip3 = new System.Windows.Forms.ToolTip(components); panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit(); splitContainer1.Panel1.SuspendLayout(); + splitContainer1.Panel2.SuspendLayout(); splitContainer1.SuspendLayout(); + panel4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox5).BeginInit(); panel3.SuspendLayout(); - panel2.SuspendLayout(); - panel7.SuspendLayout(); - panel6.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox4).BeginInit(); panel5.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); + panel6.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox3).BeginInit(); + panel2.SuspendLayout(); SuspendLayout(); // // panel1 @@ -90,6 +91,10 @@ private void InitializeComponent() splitContainer1.Panel1.Controls.Add(btnSettings); splitContainer1.Panel1.Controls.Add(lblDescription); splitContainer1.Panel1.Controls.Add(lblName); + // + // splitContainer1.Panel2 + // + splitContainer1.Panel2.Controls.Add(lblNoDQE); splitContainer1.Size = new System.Drawing.Size(1342, 400); splitContainer1.SplitterDistance = 259; splitContainer1.TabIndex = 0; @@ -106,260 +111,179 @@ private void InitializeComponent() // // lblDescription // - lblDescription.Location = new System.Drawing.Point(16, 108); + lblDescription.Location = new System.Drawing.Point(3, 79); lblDescription.Name = "lblDescription"; - lblDescription.Size = new System.Drawing.Size(240, 285); + lblDescription.Size = new System.Drawing.Size(253, 285); lblDescription.TabIndex = 3; - lblDescription.Text = "label1"; - lblDescription.Click += lblDescription_Click; // // lblName // - lblName.Font = new System.Drawing.Font("Segoe UI", 16F); - lblName.Location = new System.Drawing.Point(16, 29); + lblName.Font = new System.Drawing.Font("Segoe UI Semibold", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0); + lblName.Location = new System.Drawing.Point(3, 0); lblName.Name = "lblName"; - lblName.Size = new System.Drawing.Size(240, 79); + lblName.Size = new System.Drawing.Size(221, 79); lblName.TabIndex = 2; - lblName.Text = "lblName"; + lblName.Text = "Catalogue Name"; + lblName.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // lblNoDQE + // + lblNoDQE.AutoSize = true; + lblNoDQE.Font = new System.Drawing.Font("Segoe UI", 16F); + lblNoDQE.Location = new System.Drawing.Point(57, 156); + lblNoDQE.Name = "lblNoDQE"; + lblNoDQE.Size = new System.Drawing.Size(618, 60); + lblNoDQE.TabIndex = 0; + lblNoDQE.Text = "No DQE has been run for this catalogue.\r\nPlease run a DQE for this catalogue to see full overview details."; + lblNoDQE.TextAlign = System.Drawing.ContentAlignment.TopCenter; + lblNoDQE.Visible = false; + lblNoDQE.Click += lblNoDQE_Click; + // + // panel4 + // + panel4.BackColor = System.Drawing.SystemColors.Control; + panel4.Controls.Add(pictureBox5); + panel4.Controls.Add(lblLatestExtraction); + panel4.Location = new System.Drawing.Point(952, 6); + panel4.Name = "panel4"; + panel4.Size = new System.Drawing.Size(354, 39); + panel4.TabIndex = 13; + // + // pictureBox5 + // + pictureBox5.Image = (System.Drawing.Image)resources.GetObject("pictureBox5.Image"); + pictureBox5.InitialImage = (System.Drawing.Image)resources.GetObject("pictureBox5.InitialImage"); + pictureBox5.Location = new System.Drawing.Point(3, 4); + pictureBox5.Name = "pictureBox5"; + pictureBox5.Size = new System.Drawing.Size(28, 28); + pictureBox5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + pictureBox5.TabIndex = 12; + pictureBox5.TabStop = false; + toolTip2.SetToolTip(pictureBox5, "Latest Extraction"); + // + // lblLatestExtraction + // + lblLatestExtraction.BackColor = System.Drawing.SystemColors.Control; + lblLatestExtraction.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); + lblLatestExtraction.Location = new System.Drawing.Point(37, 4); + lblLatestExtraction.Name = "lblLatestExtraction"; + lblLatestExtraction.Size = new System.Drawing.Size(314, 28); + lblLatestExtraction.TabIndex = 3; + lblLatestExtraction.Text = "No Extractions"; + lblLatestExtraction.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // panel3 // - panel3.BackColor = System.Drawing.SystemColors.ControlDark; - panel3.Controls.Add(lblLatestExtraction); - panel3.Controls.Add(label2); - panel3.Controls.Add(label1); + panel3.BackColor = System.Drawing.SystemColors.Control; + panel3.Controls.Add(pictureBox4); panel3.Controls.Add(lblLastDataLoad); - panel3.Location = new System.Drawing.Point(16, 7); + panel3.Location = new System.Drawing.Point(705, 6); panel3.Name = "panel3"; - panel3.Size = new System.Drawing.Size(190, 148); + panel3.Size = new System.Drawing.Size(244, 38); panel3.TabIndex = 4; // - // lblLatestExtraction + // pictureBox4 // - lblLatestExtraction.BackColor = System.Drawing.SystemColors.ControlDark; - lblLatestExtraction.Font = new System.Drawing.Font("Segoe UI", 12F); - lblLatestExtraction.Location = new System.Drawing.Point(13, 116); - lblLatestExtraction.Name = "lblLatestExtraction"; - lblLatestExtraction.Size = new System.Drawing.Size(166, 23); - lblLatestExtraction.TabIndex = 3; - lblLatestExtraction.Text = "label2"; - lblLatestExtraction.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - lblLatestExtraction.Click += lblLatestExtraction_Click; - // - // label2 - // - label2.AutoSize = true; - label2.Font = new System.Drawing.Font("Segoe UI", 16F); - label2.Location = new System.Drawing.Point(13, 77); - label2.Name = "label2"; - label2.Size = new System.Drawing.Size(169, 30); - label2.TabIndex = 2; - label2.Text = "Latest Extraction"; - label2.Click += label2_Click; - // - // label1 - // - label1.AutoSize = true; - label1.Font = new System.Drawing.Font("Segoe UI", 16F); - label1.Location = new System.Drawing.Point(3, 1); - label1.Name = "label1"; - label1.Size = new System.Drawing.Size(181, 30); - label1.TabIndex = 0; - label1.Text = "Lastest Data Load"; + pictureBox4.Image = (System.Drawing.Image)resources.GetObject("pictureBox4.Image"); + pictureBox4.InitialImage = (System.Drawing.Image)resources.GetObject("pictureBox4.InitialImage"); + pictureBox4.Location = new System.Drawing.Point(3, 3); + pictureBox4.Name = "pictureBox4"; + pictureBox4.Size = new System.Drawing.Size(28, 28); + pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + pictureBox4.TabIndex = 11; + pictureBox4.TabStop = false; + toolTip1.SetToolTip(pictureBox4, "Latest Data Load"); // // lblLastDataLoad // - lblLastDataLoad.BackColor = System.Drawing.SystemColors.ControlDark; + lblLastDataLoad.BackColor = System.Drawing.SystemColors.Control; lblLastDataLoad.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); - lblLastDataLoad.Location = new System.Drawing.Point(13, 42); + lblLastDataLoad.Location = new System.Drawing.Point(33, 5); lblLastDataLoad.Name = "lblLastDataLoad"; - lblLastDataLoad.Size = new System.Drawing.Size(166, 25); + lblLastDataLoad.Size = new System.Drawing.Size(208, 31); lblLastDataLoad.TabIndex = 1; - lblLastDataLoad.Text = "label2"; - lblLastDataLoad.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - lblLastDataLoad.Click += lblLastDataLoad_Click; - // - // lblTime - // - lblTime.AutoSize = true; - lblTime.Location = new System.Drawing.Point(781, 9); - lblTime.Name = "lblTime"; - lblTime.Size = new System.Drawing.Size(82, 15); - lblTime.TabIndex = 9; - lblTime.Text = "Time Column:"; + lblLastDataLoad.Text = "No Data Loads"; + lblLastDataLoad.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // lblWhere - // - lblWhere.AutoSize = true; - lblWhere.Location = new System.Drawing.Point(265, 9); - lblWhere.Name = "lblWhere"; - lblWhere.Size = new System.Drawing.Size(44, 15); - lblWhere.TabIndex = 8; - lblWhere.Text = "Where:"; - // - // tbMainWhere - // - tbMainWhere.Location = new System.Drawing.Point(315, 6); - tbMainWhere.Name = "tbMainWhere"; - tbMainWhere.Size = new System.Drawing.Size(402, 23); - tbMainWhere.TabIndex = 7; - tbMainWhere.TextChanged += tbMainWhere_TextChanged; + // panel5 // - // cbTimeColumns + panel5.BackColor = System.Drawing.SystemColors.Control; + panel5.Controls.Add(pictureBox1); + panel5.Controls.Add(lblRecords); + panel5.Location = new System.Drawing.Point(268, 7); + panel5.Name = "panel5"; + panel5.Size = new System.Drawing.Size(199, 32); + panel5.TabIndex = 6; // - cbTimeColumns.FormattingEnabled = true; - cbTimeColumns.Location = new System.Drawing.Point(869, 6); - cbTimeColumns.Name = "cbTimeColumns"; - cbTimeColumns.Size = new System.Drawing.Size(196, 23); - cbTimeColumns.TabIndex = 4; - cbTimeColumns.SelectedIndexChanged += cbTimeColumns_SelectedIndexChanged; + // pictureBox1 // - // panel2 + pictureBox1.Image = (System.Drawing.Image)resources.GetObject("pictureBox1.Image"); + pictureBox1.InitialImage = (System.Drawing.Image)resources.GetObject("pictureBox1.InitialImage"); + pictureBox1.Location = new System.Drawing.Point(3, 3); + pictureBox1.Name = "pictureBox1"; + pictureBox1.Size = new System.Drawing.Size(28, 28); + pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + pictureBox1.TabIndex = 8; + pictureBox1.TabStop = false; // - panel2.Controls.Add(panel3); - panel2.Controls.Add(button1); - panel2.Controls.Add(panel7); - panel2.Controls.Add(label5); - panel2.Controls.Add(cbFrequency); - panel2.Controls.Add(panel6); - panel2.Controls.Add(panel5); - panel2.Controls.Add(tbMainWhere); - panel2.Controls.Add(lblWhere); - panel2.Controls.Add(lblTime); - panel2.Controls.Add(cbTimeColumns); - panel2.Location = new System.Drawing.Point(0, 424); - panel2.Name = "panel2"; - panel2.Size = new System.Drawing.Size(1342, 246); - panel2.TabIndex = 1; + // lblRecords // - // button1 - // - button1.Image = (System.Drawing.Image)resources.GetObject("button1.Image"); - button1.Location = new System.Drawing.Point(723, 6); - button1.Name = "button1"; - button1.Size = new System.Drawing.Size(26, 23); - button1.TabIndex = 5; - button1.UseVisualStyleBackColor = false; - button1.Click += button1_Click; - // - // panel7 - // - panel7.BackColor = System.Drawing.SystemColors.ControlDark; - panel7.Controls.Add(label6); - panel7.Controls.Add(lblPeople); - panel7.Location = new System.Drawing.Point(615, 35); - panel7.Name = "panel7"; - panel7.Size = new System.Drawing.Size(182, 108); - panel7.TabIndex = 7; - // - // label6 - // - label6.AutoSize = true; - label6.Font = new System.Drawing.Font("Segoe UI", 16F); - label6.Location = new System.Drawing.Point(34, 4); - label6.Name = "label6"; - label6.Size = new System.Drawing.Size(98, 30); - label6.TabIndex = 2; - label6.Text = "# People"; - // - // lblPeople - // - lblPeople.Font = new System.Drawing.Font("Segoe UI", 12F); - lblPeople.Location = new System.Drawing.Point(3, 63); - lblPeople.Name = "lblPeople"; - lblPeople.Size = new System.Drawing.Size(176, 23); - lblPeople.TabIndex = 3; - lblPeople.Text = "label2"; - lblPeople.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label5 - // - label5.AutoSize = true; - label5.Location = new System.Drawing.Point(1114, 9); - label5.Name = "label5"; - label5.Size = new System.Drawing.Size(65, 15); - label5.TabIndex = 11; - label5.Text = "Frequency:"; - // - // cbFrequency - // - cbFrequency.FormattingEnabled = true; - cbFrequency.Location = new System.Drawing.Point(1181, 6); - cbFrequency.Name = "cbFrequency"; - cbFrequency.Size = new System.Drawing.Size(135, 23); - cbFrequency.TabIndex = 10; - cbFrequency.SelectedIndexChanged += cbFrequency_SelectedIndexChanged; + lblRecords.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); + lblRecords.Location = new System.Drawing.Point(37, 3); + lblRecords.Name = "lblRecords"; + lblRecords.Size = new System.Drawing.Size(159, 28); + lblRecords.TabIndex = 3; + lblRecords.Text = "- Records"; + lblRecords.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // panel6 // panel6.AutoSize = true; - panel6.BackColor = System.Drawing.SystemColors.ControlDark; - panel6.Controls.Add(label4); + panel6.BackColor = System.Drawing.SystemColors.Control; + panel6.Controls.Add(pictureBox3); panel6.Controls.Add(lblDateRange); - panel6.Location = new System.Drawing.Point(831, 35); + panel6.Location = new System.Drawing.Point(469, 7); panel6.Name = "panel6"; - panel6.Size = new System.Drawing.Size(202, 108); + panel6.Size = new System.Drawing.Size(236, 34); panel6.TabIndex = 7; // - // label4 + // pictureBox3 // - label4.AutoSize = true; - label4.Dock = System.Windows.Forms.DockStyle.Fill; - label4.Font = new System.Drawing.Font("Segoe UI", 16F); - label4.Location = new System.Drawing.Point(0, 0); - label4.Name = "label4"; - label4.Size = new System.Drawing.Size(125, 30); - label4.TabIndex = 2; - label4.Text = "Date Range"; - label4.Click += label4_Click; + pictureBox3.Image = (System.Drawing.Image)resources.GetObject("pictureBox3.Image"); + pictureBox3.InitialImage = (System.Drawing.Image)resources.GetObject("pictureBox3.InitialImage"); + pictureBox3.Location = new System.Drawing.Point(3, 3); + pictureBox3.Name = "pictureBox3"; + pictureBox3.Size = new System.Drawing.Size(28, 28); + pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + pictureBox3.TabIndex = 10; + pictureBox3.TabStop = false; + toolTip3.SetToolTip(pictureBox3, "Date Range"); // // lblDateRange // lblDateRange.AutoSize = true; - lblDateRange.Font = new System.Drawing.Font("Segoe UI", 12F); - lblDateRange.Location = new System.Drawing.Point(16, 63); + lblDateRange.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); + lblDateRange.Location = new System.Drawing.Point(37, 5); lblDateRange.Name = "lblDateRange"; - lblDateRange.Size = new System.Drawing.Size(52, 21); + lblDateRange.Size = new System.Drawing.Size(122, 21); lblDateRange.TabIndex = 3; - lblDateRange.Text = "label2"; - lblDateRange.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // panel5 - // - panel5.BackColor = System.Drawing.SystemColors.ControlDark; - panel5.Controls.Add(label3); - panel5.Controls.Add(lblRecords); - panel5.Location = new System.Drawing.Point(397, 35); - panel5.Name = "panel5"; - panel5.Size = new System.Drawing.Size(182, 108); - panel5.TabIndex = 6; + lblDateRange.Text = "No Dates Found"; + lblDateRange.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // label3 + // panel2 // - label3.AutoSize = true; - label3.Font = new System.Drawing.Font("Segoe UI", 16F); - label3.Location = new System.Drawing.Point(34, 4); - label3.Name = "label3"; - label3.Size = new System.Drawing.Size(109, 30); - label3.TabIndex = 2; - label3.Text = "# Records"; + panel2.Controls.Add(panel4); + panel2.Controls.Add(panel3); + panel2.Controls.Add(panel6); + panel2.Controls.Add(panel5); + panel2.Location = new System.Drawing.Point(0, 424); + panel2.Name = "panel2"; + panel2.Size = new System.Drawing.Size(1342, 405); + panel2.TabIndex = 1; // - // lblRecords + // viewSourceCodeToolTip1 // - lblRecords.Font = new System.Drawing.Font("Segoe UI", 12F); - lblRecords.Location = new System.Drawing.Point(3, 63); - lblRecords.Name = "lblRecords"; - lblRecords.Size = new System.Drawing.Size(176, 23); - lblRecords.TabIndex = 3; - lblRecords.Text = "label2"; - lblRecords.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - splitContainer1.Panel2.Controls.Add(areaChart1); - areaChart1.Location = new System.Drawing.Point(4, 0); - areaChart1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - areaChart1.Name = "areaChart1"; - areaChart1.Size = new System.Drawing.Size(1075, 400); - areaChart1.TabIndex = 0; - areaChart1.Load += areaChart1_Load; + viewSourceCodeToolTip1.OwnerDraw = true; // // ViewCatalogueOverviewUI // @@ -373,18 +297,21 @@ private void InitializeComponent() Size = new System.Drawing.Size(1342, 955); panel1.ResumeLayout(false); splitContainer1.Panel1.ResumeLayout(false); + splitContainer1.Panel2.ResumeLayout(false); + splitContainer1.Panel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit(); splitContainer1.ResumeLayout(false); + panel4.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureBox5).EndInit(); panel3.ResumeLayout(false); - panel3.PerformLayout(); - panel2.ResumeLayout(false); - panel2.PerformLayout(); - panel7.ResumeLayout(false); - panel7.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox4).EndInit(); + panel5.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); panel6.ResumeLayout(false); panel6.PerformLayout(); - panel5.ResumeLayout(false); - panel5.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox3).EndInit(); + panel2.ResumeLayout(false); + panel2.PerformLayout(); ResumeLayout(false); } @@ -396,27 +323,22 @@ private void InitializeComponent() private System.Windows.Forms.Label lblName; private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Label lblLastDataLoad; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; private System.Windows.Forms.Label lblLatestExtraction; - private CatalogueSummary.DataQualityReporting.AreaChartUI areaChart1; - private System.Windows.Forms.ComboBox cbTimeColumns; private System.Windows.Forms.Panel panel3; - private System.Windows.Forms.Label lblTime; - private System.Windows.Forms.Label lblWhere; - private System.Windows.Forms.TextBox tbMainWhere; private System.Windows.Forms.Panel panel6; - private System.Windows.Forms.Label label4; private System.Windows.Forms.Label lblDateRange; private System.Windows.Forms.Panel panel5; - private System.Windows.Forms.Label label3; private System.Windows.Forms.Label lblRecords; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.ComboBox cbFrequency; private System.Windows.Forms.Button btnSettings; - private System.Windows.Forms.Panel panel7; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.Label lblPeople; - private System.Windows.Forms.Button button1; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.PictureBox pictureBox3; + private System.Windows.Forms.PictureBox pictureBox5; + private System.Windows.Forms.PictureBox pictureBox4; + private System.Windows.Forms.Panel panel4; + private System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.ToolTip toolTip2; + private SimpleDialogs.ViewSourceCodeToolTip viewSourceCodeToolTip1; + private System.Windows.Forms.ToolTip toolTip3; + private System.Windows.Forms.Label lblNoDQE; } } \ No newline at end of file diff --git a/Rdmp.UI/Overview/ViewCatalogueOverviewUI.cs b/Rdmp.UI/Overview/ViewCatalogueOverviewUI.cs index 5ec04c1c47..70ec459122 100644 --- a/Rdmp.UI/Overview/ViewCatalogueOverviewUI.cs +++ b/Rdmp.UI/Overview/ViewCatalogueOverviewUI.cs @@ -1,200 +1,101 @@ -// Copyright (c) The University of Dundee 2018-2019 +// Copyright (c) The University of Dundee 2024-2024 // This file is part of the Research Data Management Platform (RDMP). // RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. // RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // You should have received a copy of the GNU General Public License along with RDMP. If not, see . using System; -using System.Collections.Generic; using System.ComponentModel; using System.Data; -using System.Drawing; using System.Linq; +using System.Threading.Tasks; using System.Windows.Forms; -using BrightIdeasSoftware; -using Rdmp.Core; -using Rdmp.Core.CommandExecution; using Rdmp.Core.Curation.Data; using Rdmp.Core.Curation.Data.Overview; -using Rdmp.Core.DataViewing; -using Rdmp.Core.Icons.IconProvision; -using Rdmp.Core.MapsDirectlyToDatabaseTable; using Rdmp.Core.ReusableLibraryCode.DataAccess; -using Rdmp.Core.ReusableLibraryCode.Icons.IconProvision; -using Rdmp.UI.CommandExecution.AtomicCommands; +using Rdmp.UI.CatalogueSummary.DataQualityReporting; using Rdmp.UI.ItemActivation; using Rdmp.UI.MainFormUITabs; -using Rdmp.UI.ScintillaHelper; using Rdmp.UI.TestsAndSetup.ServicePropogation; -using ScintillaNET; -using SixLabors.ImageSharp.PixelFormats; namespace Rdmp.UI.Overview; /// -/// Allows you to view the Extraction SQL that is built by the QueryBuilder when extracting or running data quality engine against a dataset (Catalogue). Includes options for -/// you to display only Core extraction fields or also supplemental / special approval. -/// -/// If you have an ExtractionFilters configured on your Catalogue then you can tick them to view their SQL implementation. Because these are master filters and this dialog -/// is for previewing only, no AND/OR container trees are included in the WHERE logic (See ExtractionFilterUI for more info about filters). -/// -/// If for some reason you see an error instead of your extraction SQL then read the description and take the steps it suggests (e.g. if it is complaining about not knowing -/// how to JOIN two tables then configure an appropriate JoinInfo - See JoinConfiguration). +/// Allows you to view summary data of a catalogue /// public partial class ViewCatalogueOverviewUI : ViewCatalogueOverviewUI_Design { private Catalogue _catalogue; private OverviewModel _overview; - private List _dateColumns; - private static readonly string[] frequencies = new[] { "Day", "Month", "Year" }; - + private AreaChartUI areaChartUI; public ViewCatalogueOverviewUI() { InitializeComponent(); + areaChartUI = new AreaChartUI(OnTabChange); + areaChartUI.Location = new System.Drawing.Point(4, 0); + areaChartUI.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + areaChartUI.Name = "areaChart1"; + areaChartUI.Size = new System.Drawing.Size(1075, 400); + areaChartUI.TabIndex = 0; + splitContainer1.Panel2.Controls.Add(areaChartUI); } private void UpdateCatalogueData() { - lblName.Text = _catalogue.Name; - lblDescription.Text = _catalogue.Description; - var latestDataLoad = _overview.GetMostRecentDataLoad(); - lblLastDataLoad.Text = latestDataLoad != null ? latestDataLoad.Rows[0][3].ToString() : "No Successful DataLoads"; - var extractions = _overview.GetExtractions(); - if (extractions.Any()) + if (!_overview.HasDQEEvaluation()) { - var latestExtractionDate = extractions.AsEnumerable().Select(r => r.DateOfExtraction).Distinct().Max(); - lblLatestExtraction.Text = latestExtractionDate.ToString(); + areaChartUI.Visible = false; + lblNoDQE.Visible = true; } else { - lblLatestExtraction.Text = "Catalogue has not been extracted"; - } - try - { - var syntaxHelper = _catalogue.GetDistinctLiveDatabaseServer(DataAccessContext.InternalDataProcessing, false)?.GetQuerySyntaxHelper(); - var dateTypeString = syntaxHelper.TypeTranslater.GetSQLDBTypeForCSharpType(new TypeGuesser.DatabaseTypeRequest(typeof(DateTime))); - - _dateColumns = _catalogue.CatalogueItems.Where(ci => ci.ColumnInfo.Data_type == dateTypeString).ToList(); - } - catch - { - return; + areaChartUI.Visible = true; + lblNoDQE.Visible = false; } - cbTimeColumns.Items.Clear(); - cbTimeColumns.Items.AddRange(_dateColumns.ToArray()); - var pks = _dateColumns.Where(ci => ci.ColumnInfo.IsPrimaryKey).ToList(); + lblName.Text = _catalogue.Name; + lblDescription.Text = _catalogue.Description; - if (pks.Any()) + var latestDataLoad = _overview.GetLatestDataLoad(); + lblLastDataLoad.Text = latestDataLoad ?? "No Successful Data Loads"; + var extraction = _overview.GetLatestExtraction(); + lblLatestExtraction.Text = extraction ?? "Catalogue has not been extracted"; + lblRecords.Text = $"{_overview.GetNumberOfRecords().ToString()} Records"; + var dates = _overview.GetStartEndDates(); + var startDate = dates.Item1 != null ? ((DateTime)dates.Item1).ToString("dd/MM/yyyy") : null; + var endDate = dates.Item2 != null ? ((DateTime)dates.Item2).ToString("dd/MM/yyyy") : null; + if (startDate == null && endDate == null) { - cbTimeColumns.SelectedIndex = _dateColumns.IndexOf(pks[0]); + lblDateRange.Text = "No Dates Found"; } - else if (_dateColumns.Any()) + else { - cbTimeColumns.SelectedIndex = 0; + lblDateRange.Text = $"{startDate} - {endDate}"; } - lblRecords.Text = _overview.GetNumberOfRecords().ToString(); - var dates = _overview.GetStartEndDates(_dateColumns[cbTimeColumns.SelectedIndex].ColumnInfo, tbMainWhere.Text); - lblDateRange.Text = $"{dates.Item1} - {dates.Item2}"; - lblPeople.Text = $"{_overview.GetNumberOfPeople()}"; - } - - private void cbFrequency_SelectedIndexChanged(object sender, EventArgs e) - { - UpdateCatalogueData(); + areaChartUI.GenerateChart(_overview.GetTableData(), $"Records per month"); } private int OnTabChange(int tabIndex) { - if (tabIndex == 0) - { - tbMainWhere.Visible = true; - lblWhere.Visible = true; - cbTimeColumns.Visible = true; - lblTime.Visible = true; - } - else - { - tbMainWhere.Visible = false; - lblWhere.Visible = false; - cbTimeColumns.Visible = false; - lblTime.Visible = false; - } return 1; } - private void cbTimeColumns_SelectedIndexChanged(object sender, EventArgs e) - { - var dt = OverviewModel.GetCountsByDatePeriod(_dateColumns[cbTimeColumns.SelectedIndex].ColumnInfo, cbFrequency.SelectedItem.ToString(), tbMainWhere.Text); - areaChart1.GenerateChart(dt, $"Records per {cbFrequency.SelectedItem}"); - } - public override void SetDatabaseObject(IActivateItems activator, Catalogue databaseObject) { base.SetDatabaseObject(activator, databaseObject); _catalogue = databaseObject; _overview = new OverviewModel(activator, _catalogue); - cbFrequency.Items.Clear(); - cbFrequency.Items.AddRange(frequencies); - cbFrequency.SelectedIndex = 1; UpdateCatalogueData(); } public override string GetTabName() => $"{_catalogue.Name} Overview"; - private void lblLastDataLoad_Click(object sender, EventArgs e) - { - - } - - private void label2_Click(object sender, EventArgs e) - { - - } - - private void lblDescription_Click(object sender, EventArgs e) - { - - } - - private void lblLatestExtraction_Click(object sender, EventArgs e) - { - - } - - private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) - { - - } - - private void areaChart1_Load(object sender, EventArgs e) - { - - } - - private void tbMainWhere_TextChanged(object sender, EventArgs e) - { - } - private void btnSettings_Click(object sender, EventArgs e) { Activator.Activate(_catalogue); } - - private void button1_Click(object sender, EventArgs e) - { - _overview.Regen(tbMainWhere.Text); - lblRecords.Text = _overview.GetNumberOfRecords().ToString(); - lblPeople.Text = _overview.GetNumberOfPeople().ToString(); - var dates = _overview.GetStartEndDates(_dateColumns[cbTimeColumns.SelectedIndex].ColumnInfo, tbMainWhere.Text); - lblDateRange.Text = $"{dates.Item1} - {dates.Item2}"; - lblPeople.Text = $"{_overview.GetNumberOfPeople()}"; - var dt = OverviewModel.GetCountsByDatePeriod(_dateColumns[cbTimeColumns.SelectedIndex].ColumnInfo, cbFrequency.SelectedItem.ToString(), tbMainWhere.Text); - areaChart1.GenerateChart(dt, $"Records per {cbFrequency.SelectedItem}"); - } - - private void label4_Click(object sender, EventArgs e) + private void lblNoDQE_Click(object sender, EventArgs e) { } diff --git a/Rdmp.UI/Overview/ViewCatalogueOverviewUI.resx b/Rdmp.UI/Overview/ViewCatalogueOverviewUI.resx index 6d81376dc8..928afcd58a 100644 --- a/Rdmp.UI/Overview/ViewCatalogueOverviewUI.resx +++ b/Rdmp.UI/Overview/ViewCatalogueOverviewUI.resx @@ -1,7 +1,7 @@