From cb02863a93814ad4091af946a03482a8066b2341 Mon Sep 17 00:00:00 2001 From: Thomas Nind Date: Thu, 30 May 2019 15:12:43 +0100 Subject: [PATCH 1/3] RDMPDEV-1425 DeleteWithConfirmation now checks for ObjectExport definitions on the root object (being deleted) and asks if you want to also delete them --- .../WindowManagement/ActivateItems.cs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Application/ResearchDataManagementPlatform/WindowManagement/ActivateItems.cs b/Application/ResearchDataManagementPlatform/WindowManagement/ActivateItems.cs index 4d1b1dabff..fef75d2b0a 100644 --- a/Application/ResearchDataManagementPlatform/WindowManagement/ActivateItems.cs +++ b/Application/ResearchDataManagementPlatform/WindowManagement/ActivateItems.cs @@ -12,10 +12,10 @@ using MapsDirectlyToDatabaseTable; using Rdmp.Core.Curation.Data; using Rdmp.Core.Curation.Data.Aggregation; -using Rdmp.Core.Curation.Data.Cohort; using Rdmp.Core.Curation.Data.Dashboarding; using Rdmp.Core.Curation.Data.DataLoad; using Rdmp.Core.Curation.Data.Defaults; +using Rdmp.Core.Curation.Data.ImportExport; using Rdmp.Core.Providers; using Rdmp.Core.QueryBuilding; using Rdmp.Core.Repositories; @@ -25,8 +25,6 @@ using Rdmp.UI.CommandExecution.AtomicCommands; using Rdmp.UI.Copying; using Rdmp.UI.DataLoadUIs.LoadMetadataUIs.LoadDiagram; -using Rdmp.UI.DataViewing; -using Rdmp.UI.DataViewing.Collections; using Rdmp.UI.ExtractionUIs.FilterUIs; using Rdmp.UI.ExtractionUIs.JoinsAndLookups; using Rdmp.UI.Icons.IconProvision; @@ -37,7 +35,6 @@ using Rdmp.UI.Refreshing; using Rdmp.UI.Rules; using Rdmp.UI.SimpleDialogs; -using Rdmp.UI.SubComponents; using Rdmp.UI.SubComponents.Graphs; using Rdmp.UI.TestsAndSetup.ServicePropogation; using ResearchDataManagementPlatform.WindowManagement.ContentWindowTracking.Persistence; @@ -211,7 +208,7 @@ public Form ShowWindow(Control singleControlForm, bool asDocument = false) public bool DeleteWithConfirmation(object sender, 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; @@ -229,6 +226,19 @@ public bool DeleteWithConfirmation(object sender, IDeleteable deleteable) if (databaseObject != null) idText = " ID=" + databaseObject.ID; + if (databaseObject != null) + { + var exports = RepositoryLocator.CatalogueRepository.GetReferencesTo(databaseObject).ToArray(); + if(exports.Any(e=>e.Exists())) + if(MessageBox.Show("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",MessageBoxButtons.YesNo) == DialogResult.Yes) + { + foreach(ObjectExport e in exports) + e.DeleteInDatabase(); + } + else + return false; + } + DialogResult result = MessageBox.Show( (overrideConfirmationText?? ("Are you sure you want to delete '" + deleteable + "' from the database?")) +Environment.NewLine + "(" + deleteable.GetType().Name + idText +")", "Delete " + deleteable.GetType().Name, From a04d96eb3b1d7432de9a2197ad379eb1a3f7a01e Mon Sep 17 00:00:00 2001 From: Thomas Nind Date: Fri, 31 May 2019 08:46:04 +0100 Subject: [PATCH 2/3] RDMPDEV-1423 Plugins are no longer downloaded if a version matched nuspec is in the MEF directory. Plugins are no longer unzipped if an archive exists with dll files in it that matches the expected archive name. --- Rdmp.Core/Startup/Startup.cs | 54 ++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/Rdmp.Core/Startup/Startup.cs b/Rdmp.Core/Startup/Startup.cs index feaf48760b..36d9dcaef8 100644 --- a/Rdmp.Core/Startup/Startup.cs +++ b/Rdmp.Core/Startup/Startup.cs @@ -244,36 +244,42 @@ private void LoadMEF(ICatalogueRepository catalogueRepository) var existingFiles = subdir.GetFiles("*"+PackPluginRunner.PluginPackageSuffix).ToList(); - foreach(var lma in compatiblePlugins[i].LoadModuleAssemblies.Where(l=>!existingFiles.Any(f=>f.Name.Equals(l.Plugin.Name)))) - lma.DownloadAssembly(subdir); - + //if we have not downloaded this yet + if(!existingFiles.Any(f=>f.Name.Equals(compatiblePlugins[i].Name))) + compatiblePlugins[i].LoadModuleAssemblies.SingleOrDefault()?.DownloadAssembly(subdir); + else + _mefCheckNotifier.OnCheckPerformed(new CheckEventArgs("Found existing file '" + compatiblePlugins[i].Name +"' so didn't bother downloading it.",CheckResult.Success)); + foreach(var archive in subdir.GetFiles("*"+PackPluginRunner.PluginPackageSuffix).ToList()) { //get rid of any old out dirs var outDir = subdir.EnumerateDirectories("out").SingleOrDefault(); + bool mustUnzip = true; + + //if theres already an unpacked version if(outDir != null && outDir.Exists) - try - { - outDir.Delete(true); - } - catch(Exception ex) - { - _mefCheckNotifier.OnCheckPerformed(new CheckEventArgs("Could not delete directory '" + outDir.FullName+"'",CheckResult.Warning,ex)); - } - - outDir = subdir.CreateSubdirectory("out"); - - using(var zf = ZipFile.OpenRead(archive.FullName)) - try - { - zf.ExtractToDirectory(outDir.FullName); - } - catch(Exception ex) - { - _mefCheckNotifier.OnCheckPerformed(new CheckEventArgs("Could not extract Plugin to '" + outDir.FullName+"'",CheckResult.Warning,ex)); - } - + { + //if the directory has no files we have to unzip - otherwise it has an unzipped version already yay + mustUnzip = !outDir.GetFiles("*.dll",SearchOption.AllDirectories).Any(); + } + else + outDir = subdir.CreateSubdirectory("out"); + + if(mustUnzip) + using(var zf = ZipFile.OpenRead(archive.FullName)) + try + { + zf.ExtractToDirectory(outDir.FullName); + } + catch(Exception ex) + { + _mefCheckNotifier.OnCheckPerformed(new CheckEventArgs("Could not extract Plugin to '" + outDir.FullName+"'",CheckResult.Warning,ex)); + } + else + _mefCheckNotifier.OnCheckPerformed(new CheckEventArgs("Found existing directory '" + outDir.FullName+"' so didn't bother unzipping.",CheckResult.Success)); + + toLoad.Add(_environmentInfo.GetPluginSubDirectory(outDir.CreateSubdirectory("lib"))); //tell them we downloaded it From 0a0bb01ef9a498ca354cd1fd869e6726e99f15ea Mon Sep 17 00:00:00 2001 From: ltramma Date: Fri, 31 May 2019 16:58:02 +0100 Subject: [PATCH 3/3] RDMPDEV-186: fixed security code scan warnings --- Rdmp.Core/Curation/Data/Plugin.cs | 2 +- .../Curation/Data/Serialization/JsonConvertExtensions.cs | 4 ++-- .../FilterUIs/ParameterUIs/ParameterCollectionUI.cs | 2 ++ rakefile.rb | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Rdmp.Core/Curation/Data/Plugin.cs b/Rdmp.Core/Curation/Data/Plugin.cs index 4076f3ae83..a3d9ead131 100644 --- a/Rdmp.Core/Curation/Data/Plugin.cs +++ b/Rdmp.Core/Curation/Data/Plugin.cs @@ -63,7 +63,7 @@ public string GetShortName() } /// - /// The master version of the (not the dlls inside - See ). + /// The master version of the /// Not currently used /// public Version PluginVersion diff --git a/Rdmp.Core/Curation/Data/Serialization/JsonConvertExtensions.cs b/Rdmp.Core/Curation/Data/Serialization/JsonConvertExtensions.cs index 32085093c8..fd002dd364 100644 --- a/Rdmp.Core/Curation/Data/Serialization/JsonConvertExtensions.cs +++ b/Rdmp.Core/Curation/Data/Serialization/JsonConvertExtensions.cs @@ -28,7 +28,7 @@ public static string SerializeObject(object value, IRDMPPlatformRepositoryServic var settings = new JsonSerializerSettings { - TypeNameHandling = TypeNameHandling.Objects, + TypeNameHandling = TypeNameHandling.None, TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple, Converters = new JsonConverter[] {databaseEntityJsonConverter} }; @@ -56,7 +56,7 @@ public static object DeserializeObject(string value, Type type,IRDMPPlatformRepo var settings = new JsonSerializerSettings { - TypeNameHandling = TypeNameHandling.Objects, + TypeNameHandling = TypeNameHandling.None, TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple, Converters = new JsonConverter[] {databaseEntityJsonConverter, lazyJsonConverter} }; diff --git a/Rdmp.UI/ExtractionUIs/FilterUIs/ParameterUIs/ParameterCollectionUI.cs b/Rdmp.UI/ExtractionUIs/FilterUIs/ParameterUIs/ParameterCollectionUI.cs index ff052ec93c..1682123a1a 100644 --- a/Rdmp.UI/ExtractionUIs/FilterUIs/ParameterUIs/ParameterCollectionUI.cs +++ b/Rdmp.UI/ExtractionUIs/FilterUIs/ParameterUIs/ParameterCollectionUI.cs @@ -214,7 +214,9 @@ private void miAddParameter_Click(object sender, EventArgs e) { Random r = new Random(); +#pragma warning disable SCS0005 // Weak random generator: This is only used to create an initial value for a parameter. var dialog = new TypeTextOrCancelDialog("Parameter Name", "Name", 100, "@MyParam" + r.Next()); +#pragma warning restore SCS0005 // Weak random generator if (dialog.ShowDialog() == DialogResult.OK) { var newParameter = Options.CreateNewParameter(dialog.ResultText.Trim()); diff --git a/rakefile.rb b/rakefile.rb index c18678949d..7fcd43beae 100644 --- a/rakefile.rb +++ b/rakefile.rb @@ -5,7 +5,7 @@ load 'rakeconfig.rb' $MSBUILD15CMD = MSBUILD15CMD.gsub(/\\/,"/") -task :ci_low_warnings, [:config,:level] => [:assemblyinfo, :build_low_warning] +task :ci_low_warnings, [:config,:level,:aserrors] => [:assemblyinfo, :build_low_warning] task :ci_continuous, [:config] => [:setup_connection, :assemblyinfo, :build, :tests] @@ -43,9 +43,9 @@ sh "\"#{$MSBUILD15CMD}\" #{SOLUTION} \/t:Clean;Build \/p:Configuration=Release" end -task :build_low_warning, [:config,:level] => :restorepackages do |msb, args| +task :build_low_warning, [:config,:level,:aserrors] => :restorepackages do |msb, args| args.with_defaults(:level => 1) - sh "\"#{$MSBUILD15CMD}\" #{SOLUTION} \/t:Clean;Build \/p:Configuration=#{args.config} \/p:WarningLevel=#{args.level} \/p:TreatWarningsAsErrors=false" + sh "\"#{$MSBUILD15CMD}\" #{SOLUTION} \/t:Clean;Build \/p:Configuration=#{args.config} \/v:detailed \/p:WarningLevel=#{args.level} \/p:TreatWarningsAsErrors=#{args.aserrors}" end task :createtestdb, [:config] do |t, args|