diff --git a/CreateDeliverables.cmd b/CreateDeliverables.cmd
index 432e235..b4fb2cd 100644
--- a/CreateDeliverables.cmd
+++ b/CreateDeliverables.cmd
@@ -1,4 +1,9 @@
REM Run from dev command line
+
+@ECHO OFF
+
+VERIFY ON
+
D:
cd \ProjectsPersonal\JWLMerge
rd JWLMerge\bin /q /s
@@ -6,18 +11,43 @@ rd JWLMergeCLI\bin /q /s
rd Installer\Output /q /s
rd Installer\Staging /q /s
-REM build / publish
+ECHO.
+ECHO Publishing JWLMerge
dotnet publish JWLMerge\JWLMerge.csproj -p:PublishProfile=FolderProfile -c:Release
+IF %ERRORLEVEL% NEQ 0 goto ERROR
+
+ECHO.
+ECHO Publishing JWLMergeCLI
dotnet publish JWLMergeCLI\JWLMergeCLI.csproj -p:PublishProfile=FolderProfile -c:Release
+IF %ERRORLEVEL% NEQ 0 goto ERROR
md Installer\Staging
-REM copy items into staging area
+ECHO.
+ECHO Copying JWLMergeCLI items into staging area
xcopy JWLMergeCLI\bin\Release\net6.0\publish\*.* Installer\Staging /q /s /y /d
+
+ECHO Copying JWLMerge items into staging area
xcopy JWLMerge\bin\Release\net6.0-windows\publish\*.* Installer\Staging /q /s /y /d
-REM Create installer
-"C:\Program Files (x86)\Inno Setup 6\iscc" Installer\jwlmergesetup.iss
+ECHO.
+ECHO Creating installer
+"D:\Program Files (x86)\Inno Setup 6\iscc" Installer\jwlmergesetup.iss
+IF %ERRORLEVEL% NEQ 0 goto ERROR
-REM create portable zip
-powershell Compress-Archive -Path Installer\Staging\* -DestinationPath Installer\Output\JWLMergePortable.zip
\ No newline at end of file
+ECHO.
+ECHO Creating portable zip
+powershell Compress-Archive -Path Installer\Staging\* -DestinationPath Installer\Output\JWLMergePortable.zip
+IF %ERRORLEVEL% NEQ 0 goto ERROR
+
+goto SUCCESS
+
+:ERROR
+ECHO.
+ECHO ******************
+ECHO An ERROR occurred!
+ECHO ******************
+
+:SUCCESS
+
+PAUSE
\ No newline at end of file
diff --git a/JWLMerge.BackupFileServices/BackupFileService.cs b/JWLMerge.BackupFileServices/BackupFileService.cs
index e142df0..bebc29f 100644
--- a/JWLMerge.BackupFileServices/BackupFileService.cs
+++ b/JWLMerge.BackupFileServices/BackupFileService.cs
@@ -86,7 +86,7 @@ namespace JWLMerge.BackupFileServices
{
throw new ArgumentNullException(nameof(backup));
}
-
+
backup.Database.TagMaps.RemoveAll(x => x.TagId == 1);
}
diff --git a/JWLMerge.BackupFileServices/Helpers/Cleaner.cs b/JWLMerge.BackupFileServices/Helpers/Cleaner.cs
index 0168364..9409948 100644
--- a/JWLMerge.BackupFileServices/Helpers/Cleaner.cs
+++ b/JWLMerge.BackupFileServices/Helpers/Cleaner.cs
@@ -23,10 +23,13 @@
/// Number of rows removed.
public int Clean()
{
- return CleanBlockRanges() + CleanLocations();
+ // see also DatabaseForeignKeyChecker
+ return CleanBlockRanges() +
+ CleanTagMaps() +
+ CleanLocations();
}
-
- private HashSet GetUserMarkIdsInUse()
+
+ private HashSet GetValidUserMarkIds()
{
var result = new HashSet();
@@ -38,6 +41,42 @@
return result;
}
+ private HashSet GetValidTagIds()
+ {
+ var result = new HashSet();
+
+ foreach (var tag in _database.Tags)
+ {
+ result.Add(tag.TagId);
+ }
+
+ return result;
+ }
+
+ private HashSet GetValidNoteIds()
+ {
+ var result = new HashSet();
+
+ foreach (var note in _database.Notes)
+ {
+ result.Add(note.NoteId);
+ }
+
+ return result;
+ }
+
+ private HashSet GetValidLocationIds()
+ {
+ var result = new HashSet();
+
+ foreach (var location in _database.Locations)
+ {
+ result.Add(location.LocationId);
+ }
+
+ return result;
+ }
+
private HashSet GetLocationIdsInUse()
{
var result = new HashSet();
@@ -106,6 +145,33 @@
return removed;
}
+ private int CleanTagMaps()
+ {
+ var removed = 0;
+
+ var tagMaps = _database.TagMaps;
+ if (tagMaps.Any())
+ {
+ var tagIds = GetValidTagIds();
+ var noteIds = GetValidNoteIds();
+ var locationIds = GetValidLocationIds();
+
+ foreach (var tag in Enumerable.Reverse(tagMaps))
+ {
+ if (!tagIds.Contains(tag.TagId) ||
+ (tag.NoteId != null && !noteIds.Contains(tag.NoteId.Value)) ||
+ (tag.LocationId != null && !locationIds.Contains(tag.LocationId.Value)))
+ {
+ Log.Logger.Debug($"Removing redundant tag map entry: {tag.TagMapId}");
+ tagMaps.Remove(tag);
+ ++removed;
+ }
+ }
+ }
+
+ return removed;
+ }
+
///
/// Cleans the block ranges.
///
@@ -118,7 +184,7 @@
if (ranges.Any())
{
var userMarkIdsFound = new HashSet();
- var userMarkIds = GetUserMarkIdsInUse();
+ var userMarkIds = GetValidUserMarkIds();
foreach (var range in Enumerable.Reverse(ranges))
{
diff --git a/JWLMerge.BackupFileServices/Helpers/DatabaseForeignKeyChecker.cs b/JWLMerge.BackupFileServices/Helpers/DatabaseForeignKeyChecker.cs
index b54c679..e8d57db 100644
--- a/JWLMerge.BackupFileServices/Helpers/DatabaseForeignKeyChecker.cs
+++ b/JWLMerge.BackupFileServices/Helpers/DatabaseForeignKeyChecker.cs
@@ -5,8 +5,6 @@
internal static class DatabaseForeignKeyChecker
{
- // todo: call this as part of the sanity check when loading backup files.
- // Also perform auto cleanup
public static void Execute(Database database)
{
CheckBlockRangeValidity(database);
diff --git a/JWLMerge.BackupFileServices/JWLMerge.BackupFileServices.csproj b/JWLMerge.BackupFileServices/JWLMerge.BackupFileServices.csproj
index 3bd3303..0d36849 100644
--- a/JWLMerge.BackupFileServices/JWLMerge.BackupFileServices.csproj
+++ b/JWLMerge.BackupFileServices/JWLMerge.BackupFileServices.csproj
@@ -1,47 +1,48 @@
-
- netstandard2.1
- false
- Enable
- AnyCPU
-
+
+ netstandard2.1
+ false
+ Enable
+ latest-recommended
+ AnyCPU
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
-
-
- True
- True
- Resources.resx
-
-
+
+
+ True
+ True
+ Resources.resx
+
+
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
diff --git a/JWLMerge.ExcelServices/JWLMerge.ExcelServices.csproj b/JWLMerge.ExcelServices/JWLMerge.ExcelServices.csproj
index 0b08066..3e1ac53 100644
--- a/JWLMerge.ExcelServices/JWLMerge.ExcelServices.csproj
+++ b/JWLMerge.ExcelServices/JWLMerge.ExcelServices.csproj
@@ -1,26 +1,27 @@
-
- netstandard2.1
- false
- Enable
- AnyCPU
-
+
+ netstandard2.1
+ false
+ Enable
+ latest-recommended
+ AnyCPU
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/JWLMerge.Tests/JWLMerge.Tests.csproj b/JWLMerge.Tests/JWLMerge.Tests.csproj
index 3d75d68..5a53939 100644
--- a/JWLMerge.Tests/JWLMerge.Tests.csproj
+++ b/JWLMerge.Tests/JWLMerge.Tests.csproj
@@ -1,26 +1,27 @@
-
- net6.0
- false
- Enable
- false
- AnyCPU
-
+
+ net6.0
+ false
+ Enable
+ false
+ latest-recommended
+ AnyCPU
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/JWLMerge/JWLMerge.csproj b/JWLMerge/JWLMerge.csproj
index 8070b27..06524fb 100644
--- a/JWLMerge/JWLMerge.csproj
+++ b/JWLMerge/JWLMerge.csproj
@@ -1,58 +1,59 @@
-
- WinExe
- net6.0-windows
- true
- false
- Enable
- JWLMerge.ico
- AnyCPU
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
- True
- Resources.resx
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
-
-
- True
- True
- Settings.settings
-
-
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
+
+ WinExe
+ net6.0-windows
+ true
+ false
+ Enable
+ latest-recommended
+ JWLMerge.ico
+ AnyCPU
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
+ True
+ True
+ Settings.settings
+
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
diff --git a/JWLMerge/ViewModel/MainViewModel.cs b/JWLMerge/ViewModel/MainViewModel.cs
index 4f95ea5..92a421b 100644
--- a/JWLMerge/ViewModel/MainViewModel.cs
+++ b/JWLMerge/ViewModel/MainViewModel.cs
@@ -535,7 +535,7 @@ namespace JWLMerge.ViewModel
await Task.Run(() =>
{
count = _backupFileService.RedactNotes(file.BackupFile);
- _backupFileService.WriteNewDatabase(file.BackupFile, filePath!, filePath!);
+ _backupFileService.WriteNewDatabaseWithClean(file.BackupFile, filePath!, filePath!);
});
_windowService.Close(filePath!);
@@ -582,7 +582,7 @@ namespace JWLMerge.ViewModel
await Task.Run(() =>
{
_backupFileService.RemoveFavourites(file!.BackupFile);
- _backupFileService.WriteNewDatabase(file.BackupFile, filePath!, filePath!);
+ _backupFileService.WriteNewDatabaseWithClean(file.BackupFile, filePath!, filePath!);
});
_snackbarService.Enqueue("Favourites removed successfully");
diff --git a/JWLMergeCLI/JWLMergeCLI.csproj b/JWLMergeCLI/JWLMergeCLI.csproj
index 09be2b2..e9b2323 100644
--- a/JWLMergeCLI/JWLMergeCLI.csproj
+++ b/JWLMergeCLI/JWLMergeCLI.csproj
@@ -1,19 +1,20 @@
-
- Exe
- net6.0
- false
- Enable
- JWLMerge.ico
- AnyCPU
-
-
-
-
-
-
-
-
-
-
+
+ Exe
+ net6.0
+ false
+ Enable
+ JWLMerge.ico
+ latest-recommended
+ AnyCPU
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SolutionInfo.cs b/SolutionInfo.cs
index e77d204..b712957 100644
--- a/SolutionInfo.cs
+++ b/SolutionInfo.cs
@@ -6,4 +6,4 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
-[assembly: AssemblyVersion("2.0.0.10")]
\ No newline at end of file
+[assembly: AssemblyVersion("2.0.0.12")]
\ No newline at end of file