From 1cd500abe28e9fa96891d200443e0de21a47c41b Mon Sep 17 00:00:00 2001 From: jas88 Date: Thu, 20 Jul 2023 17:53:32 -0500 Subject: [PATCH] Format fixups --- .../ExecuteFullExtractionToDatabaseMSSql.cs | 38 +++++++++---------- .../ColumnInfoToANOTableConverter.cs | 10 ++--- .../Aliases/AliasHandler.cs | 8 ++-- .../IconProvision/CatalogueIconProvider.cs | 7 +--- .../TableRepository.cs | 2 +- 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/Rdmp.Core/DataExport/DataExtraction/Pipeline/Destinations/ExecuteFullExtractionToDatabaseMSSql.cs b/Rdmp.Core/DataExport/DataExtraction/Pipeline/Destinations/ExecuteFullExtractionToDatabaseMSSql.cs index 64c2e833ab..d8a38df4b0 100644 --- a/Rdmp.Core/DataExport/DataExtraction/Pipeline/Destinations/ExecuteFullExtractionToDatabaseMSSql.cs +++ b/Rdmp.Core/DataExport/DataExtraction/Pipeline/Destinations/ExecuteFullExtractionToDatabaseMSSql.cs @@ -112,7 +112,7 @@ protected override void WriteRows(DataTable toProcess, IDataLoadEventListener jo { return; } - + if(_request.IsBatchResume) { _destination.AllowLoadingPopulatedTables = true; @@ -192,7 +192,7 @@ private DataTableUploadDestination PrepareDestination(IDataLoadEventListener lis } private void PrimeDestinationTypesBasedOnCatalogueTypes(IDataLoadEventListener listener, DataTable toProcess) - { + { //if the extraction is of a Catalogue if(_request is not IExtractDatasetCommand datasetCommand) @@ -264,7 +264,7 @@ private string GetDestinationDatabaseType(ConcreteColumn col) var intermediate = fromSyntax.TypeTranslater.GetDataTypeRequestForSQLDBType(col.ColumnInfo.Data_type); return toSyntax.TypeTranslater.GetSQLDBTypeForCSharpType(intermediate); } - + return col.ColumnInfo.Data_type; } @@ -283,7 +283,7 @@ private string GetTableName(string suffix = null) tblName = TableNamingPattern; var project = _request.Configuration.Project; - + tblName = tblName.Replace("$p", project.Name); tblName = tblName.Replace("$n", project.ProjectNumber.ToString()); tblName = tblName.Replace("$c", _request.Configuration.Name); @@ -387,7 +387,7 @@ public override void Abort(IDataLoadEventListener listener) } protected override void PreInitializeImpl(IExtractCommand value, IDataLoadEventListener listener) { - + } @@ -441,20 +441,20 @@ protected override void TryExtractSupportingSQLTableImpl(SupportingSQLTable sqlT using(var cmd = DatabaseCommandHelper.GetCommand(sqlTable.SQL, con)) using (var da = DatabaseCommandHelper.GetDataAdapter(cmd)) { - var sw = new Stopwatch(); - - sw.Start(); - da.Fill(dt); - } + var sw = Stopwatch.StartNew(); + dt.BeginLoadData(); + da.Fill(dt); + dt.EndLoadData(); + } - dt.TableName = GetTableName(_destinationDatabase.Server.GetQuerySyntaxHelper().GetSensibleEntityNameFromString(sqlTable.Name)); - linesWritten = dt.Rows.Count; + dt.TableName = GetTableName(_destinationDatabase.Server.GetQuerySyntaxHelper().GetSensibleEntityNameFromString(sqlTable.Name)); + linesWritten = dt.Rows.Count; - var destinationDb = GetDestinationDatabase(listener); - var tbl = destinationDb.ExpectTable(dt.TableName); + var destinationDb = GetDestinationDatabase(listener); + var tbl = destinationDb.ExpectTable(dt.TableName); - if(tbl.Exists()) - tbl.Drop(); + if(tbl.Exists()) + tbl.Drop(); destinationDb.CreateTable(dt.TableName,dt); destinationDescription = $"{TargetDatabaseServer.ID}|{GetDatabaseName()}|{dt.TableName}"; @@ -465,7 +465,7 @@ protected override void TryExtractLookupTableImpl(BundledLookupTable lookup, Dir IExtractionConfiguration requestConfiguration,IDataLoadEventListener listener, out int linesWritten, out string destinationDescription) { using var dt = lookup.GetDataTable(); - + dt.TableName = GetTableName(_destinationDatabase.Server.GetQuerySyntaxHelper().GetSensibleEntityNameFromString(lookup.TableInfo.Name)); //describe the destination for the abstract base @@ -474,7 +474,7 @@ protected override void TryExtractLookupTableImpl(BundledLookupTable lookup, Dir var destinationDb = GetDestinationDatabase(listener); var existing = destinationDb.ExpectTable(dt.TableName); - + if(existing.Exists()) { listener.OnNotify(this,new NotifyEventArgs(ProgressEventType.Warning, @@ -575,7 +575,7 @@ public override void Check(ICheckNotifier notifier) notifier.OnCheckPerformed(new CheckEventArgs( $"Catalogue '{dsRequest.Catalogue}' does not have an Acronym but TableNamingPattern contains $a", CheckResult.Fail)); } - + base.Check(notifier); try diff --git a/Rdmp.Core/DataLoad/Engine/Pipeline/Components/Anonymisation/ColumnInfoToANOTableConverter.cs b/Rdmp.Core/DataLoad/Engine/Pipeline/Components/Anonymisation/ColumnInfoToANOTableConverter.cs index a09cf1584c..666f75a5a6 100644 --- a/Rdmp.Core/DataLoad/Engine/Pipeline/Components/Anonymisation/ColumnInfoToANOTableConverter.cs +++ b/Rdmp.Core/DataLoad/Engine/Pipeline/Components/Anonymisation/ColumnInfoToANOTableConverter.cs @@ -44,14 +44,14 @@ public bool ConvertEmptyColumnInfo(Func shouldApplySql, ICheckNoti var tbl = _tableInfo.Discover(DataAccessContext.DataLoad); var rowcount = tbl.GetRowCount(); - + if(rowcount>0) throw new NotSupportedException( $"Table {_tableInfo} contains {rowcount} rows of data, you cannot use ColumnInfoToANOTableConverter.ConvertEmptyColumnInfo on this table"); using var con = tbl.Database.Server.GetConnection(); con.Open(); - + if (!IsOldColumnDroppable(con, notifier)) return false; @@ -77,9 +77,9 @@ public bool ConvertFullColumnInfo(Func shouldApplySql, ICheckNotif if (!IsOldColumnDroppable(con, notifier)) return false; - EnsureNoTriggerOnTable(tbl); + EnsureNoTriggerOnTable(tbl); - AddNewANOColumnInfo(shouldApplySql, con, notifier); + AddNewANOColumnInfo(shouldApplySql, con, notifier); MigrateExistingData(shouldApplySql,con, notifier,tbl); @@ -106,7 +106,7 @@ private void MigrateExistingData(Func shouldApplySql, DbConnection { var from = _colToNuke.GetRuntimeName(LoadStage.PostLoad); var to = _newANOColumnInfo.GetRuntimeName(LoadStage.PostLoad); - + //create an empty table for the anonymised data using (var cmdCreateTempMap = DatabaseCommandHelper.GetCommand( diff --git a/Rdmp.Core/DataLoad/Modules/DataFlowOperations/Aliases/AliasHandler.cs b/Rdmp.Core/DataLoad/Modules/DataFlowOperations/Aliases/AliasHandler.cs index 21aee5fa52..080e78e390 100644 --- a/Rdmp.Core/DataLoad/Modules/DataFlowOperations/Aliases/AliasHandler.cs +++ b/Rdmp.Core/DataLoad/Modules/DataFlowOperations/Aliases/AliasHandler.cs @@ -182,11 +182,11 @@ private Dictionary> GenerateAliasTable(int timeoutInSeconds haveCheckedColumns = true; } - var input = r[0]; - var alias = r[1]; + var input = r[0]; + var alias = r[1]; - if(input == null || input == DBNull.Value || alias == null || alias == DBNull.Value) - throw new AliasTableFetchException("Alias table contained nulls"); + if(input == null || input == DBNull.Value || alias == null || alias == DBNull.Value) + throw new AliasTableFetchException("Alias table contained nulls"); if(input.Equals(alias)) throw new AliasTableFetchException("Alias table SQL should only return aliases not exact matches e.g. in the case of a simple alias X is Y, do not return 4 rows {X=X AND Y=Y AND Y=X AND X=Y}, only return 2 rows {X=Y and Y=X}"); diff --git a/Rdmp.Core/Icons/IconProvision/CatalogueIconProvider.cs b/Rdmp.Core/Icons/IconProvision/CatalogueIconProvider.cs index c8e3ee66fb..d70fde6340 100644 --- a/Rdmp.Core/Icons/IconProvision/CatalogueIconProvider.cs +++ b/Rdmp.Core/Icons/IconProvision/CatalogueIconProvider.cs @@ -250,10 +250,7 @@ public static RDMPConcept GetConceptForCollection(RDMPCollection rdmpCollection) /// public static bool ConceptIs(Type t, object concept) { - if (t.IsInstanceOfType(concept)) - return true; - - return concept is Type type && t.IsAssignableFrom(type); + return t.IsInstanceOfType(concept) || (concept is Type type && t.IsAssignableFrom(type)); } @@ -278,7 +275,7 @@ public Dictionary> GetImageList(bool addFavouritesOverlayK return imageList; } - private Image GetActualImage(Image img, OverlayKind kind) + private static Image GetActualImage(Image img, OverlayKind kind) { return kind == OverlayKind.None ? img : IconOverlayProvider.GetOverlay(img, kind); } diff --git a/Rdmp.Core/MapsDirectlyToDatabaseTable/TableRepository.cs b/Rdmp.Core/MapsDirectlyToDatabaseTable/TableRepository.cs index ae337b8ebb..1148007f91 100644 --- a/Rdmp.Core/MapsDirectlyToDatabaseTable/TableRepository.cs +++ b/Rdmp.Core/MapsDirectlyToDatabaseTable/TableRepository.cs @@ -559,7 +559,7 @@ public IEnumerable SelectAllWhere(string selectQuery, string columnWithObj return Enumerable.Empty(); - var toReturn = GetAllObjects($"WHERE ID in ({string.Join(",", idsToReturn)})").ToList(); + var toReturn = GetAllObjects($"WHERE ID in ({string.Join(",", idsToReturn)})").ToList(); //this bit of hackery is if you're a crazy person who hates transparency and wants something like ColumnInfo.Missing to appear in the return list instead of an empty return list if(dbNullSubstition != null)