From 7bb98d7970ec21d685e5a6e454d38a2d561670cf Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Fri, 19 Mar 2021 22:09:28 -0300 Subject: [PATCH 01/19] Added program arguments --- .vscode/launch.json | 2 +- AlsToolsManager.cs | 4 ++-- Program.cs | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 76b5cff..a289a03 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,7 @@ "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/als-tools.dll", - "args": [], + "args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console "console": "internalConsole", diff --git a/AlsToolsManager.cs b/AlsToolsManager.cs index bdaad32..ac4036d 100644 --- a/AlsToolsManager.cs +++ b/AlsToolsManager.cs @@ -17,7 +17,7 @@ public void Run(ProgramArgs arguments) foreach (var f in files) { - var project = Decompress(f); + var project = ExtractLiveProjectInfoFromFile(f); PrintProjectAndPlugins(project); } @@ -40,7 +40,7 @@ public void PrintProjectAndPlugins(LiveProject project) Console.WriteLine("\t\tName = {0} | Type = {1}", plugin.Value.Name, plugin.Value.Type); } - public LiveProject Decompress(FileInfo fileToDecompress) + public LiveProject ExtractLiveProjectInfoFromFile(FileInfo fileToDecompress) { var project = new LiveProject() { Name = fileToDecompress.Name, Path = fileToDecompress.FullName }; var plugins = new SortedSet(); diff --git a/Program.cs b/Program.cs index a4b9605..1d71c68 100644 --- a/Program.cs +++ b/Program.cs @@ -10,6 +10,8 @@ namespace AlsTools { class Program { + static AlsToolsManager manager = new AlsToolsManager(); + static int Main(string[] args) { var arguments = GetArguments(args); @@ -18,6 +20,7 @@ static int Main(string[] args) PrintArguments(arguments); + manager.Run(arguments); Console.WriteLine("------------------------------------------------------------------------------"); Console.WriteLine("DONE"); From 49eb4fedeb0f630e0b939896804d710a9a0d7543 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Fri, 19 Mar 2021 23:16:36 -0300 Subject: [PATCH 02/19] Adding async/await and also interactive mode --- .vscode/launch.json | 3 +- AlsToolsManager.cs | 38 ++++++++---- Program.cs | 146 +++++++++++++++++++++++++++++++++----------- ProgramArgs.cs | 2 + 4 files changed, 140 insertions(+), 49 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index a289a03..f838b5a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,8 @@ "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/als-tools.dll", - "args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], + //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], + "args": ["--interactive", "--folder=/Users/zenluiz/Desktop/Testes ALS"], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console "console": "internalConsole", diff --git a/AlsToolsManager.cs b/AlsToolsManager.cs index ac4036d..8c5a70e 100644 --- a/AlsToolsManager.cs +++ b/AlsToolsManager.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; +using System.Threading.Tasks; using System.Xml; using System.Xml.XPath; using AlsTools; @@ -10,7 +11,9 @@ namespace AlsTools { public class AlsToolsManager { - public void Run(ProgramArgs arguments) + IList projects = new List(); + + public void Initialize(ProgramArgs arguments) { var d = new DirectoryInfo(arguments.Folder); var files = d.GetFiles("*.als", new EnumerationOptions() { RecurseSubdirectories = true }); @@ -18,29 +21,38 @@ public void Run(ProgramArgs arguments) foreach (var f in files) { var project = ExtractLiveProjectInfoFromFile(f); - PrintProjectAndPlugins(project); + projects.Add(project); } + } + public async Task Execute(ProgramArgs arguments) + { + foreach (var project in projects) + { + await PrintProjectAndPlugins(project); + } } - - public void PrintProjectAndPlugins(LiveProject project) + + private async Task PrintProjectAndPlugins(LiveProject project) { - Console.WriteLine("------------------------------------------------------------------------------"); - Console.WriteLine("Project name: {0}", project.Name); - Console.WriteLine("Full path: {0}", project.Path); - Console.WriteLine("\tPlugins:"); + await Console.Out.WriteLineAsync("------------------------------------------------------------------------------"); + await Console.Out.WriteLineAsync($"Project name: {project.Name}"); + await Console.Out.WriteLineAsync($"Full path: {project.Path}"); + await Console.Out.WriteLineAsync("\tPlugins:"); if (project.Plugins.Count == 0) { - Console.WriteLine("\t\tNo plugins found!"); - return; + await Console.Out.WriteLineAsync("\t\tNo plugins found!"); + return false; } foreach (var plugin in project.Plugins) - Console.WriteLine("\t\tName = {0} | Type = {1}", plugin.Value.Name, plugin.Value.Type); + await Console.Out.WriteLineAsync($"\t\tName = {plugin.Value.Name} | Type = {plugin.Value.Type}"); + + return true; } - public LiveProject ExtractLiveProjectInfoFromFile(FileInfo fileToDecompress) + private LiveProject ExtractLiveProjectInfoFromFile(FileInfo fileToDecompress) { var project = new LiveProject() { Name = fileToDecompress.Name, Path = fileToDecompress.FullName }; var plugins = new SortedSet(); @@ -70,7 +82,7 @@ public LiveProject ExtractLiveProjectInfoFromFile(FileInfo fileToDecompress) return project; } - public void GetPluginsByExpression(LiveProject project, XPathNavigator nav, string expression, PluginType type) + private void GetPluginsByExpression(LiveProject project, XPathNavigator nav, string expression, PluginType type) { var nodeIter = nav.Select(expression); diff --git a/Program.cs b/Program.cs index 1d71c68..e5d203e 100644 --- a/Program.cs +++ b/Program.cs @@ -3,6 +3,8 @@ using System.IO; using System.IO.Compression; using System.Linq; +using System.Text; +using System.Threading.Tasks; using System.Xml; using System.Xml.XPath; @@ -12,34 +14,82 @@ class Program { static AlsToolsManager manager = new AlsToolsManager(); - static int Main(string[] args) + static async Task Main(string[] args) { - var arguments = GetArguments(args); - if (arguments == null) + var arguments = await GetArguments(args); + if (!(await ValidateArguments(arguments))) return -1; - PrintArguments(arguments); + await PrintArguments(arguments); - manager.Run(arguments); + manager.Initialize(arguments); - Console.WriteLine("------------------------------------------------------------------------------"); - Console.WriteLine("DONE"); + if (arguments.InteractiveMode) + { + string option = string.Empty; + while (option != "3") + { + await PrintMenu(); + option = await GetOption(); + if (string.IsNullOrEmpty(option)) + continue; + + if (option == "1") + arguments.ListPlugins = true; + else if (option == "2") + arguments.LocatePlugins = true; + } + } + else + { + await manager.Execute(arguments); + } + + await Console.Out.WriteLineAsync("------------------------------------------------------------------------------"); + await Console.Out.WriteLineAsync("DONE"); return 0; } - private static void PrintArguments(ProgramArgs args) + private static async Task GetOption() { - Console.WriteLine("ARGUMENTS: "); - Console.WriteLine("Folder: {0}", args.Folder); - Console.WriteLine("File: {0}", args.File); - Console.WriteLine("List? {0}", args.ListPlugins); - Console.WriteLine("Locate? {0}", args.LocatePlugins); - Console.WriteLine("Plugins to locate: {0}", string.Join("; ", args.PluginsToLocate)); + var opt = await Console.In.ReadLineAsync(); //TODO: não está funcionando + var validOpts = new string[] {"1", "2", "3"}; + if (!validOpts.Contains(opt)) + { + await Console.Error.WriteLineAsync("\tInvalid option. Try again."); + return string.Empty; + } + + return opt; } - private static ProgramArgs GetArguments(string[] arguments) + private static async Task PrintMenu() + { + await Console.Out.WriteLineAsync("\nSelect an option"); + await Console.Out.WriteLineAsync("\t1 - List plugins"); + await Console.Out.WriteLineAsync("\t2 - Locate plugins"); + await Console.Out.WriteLineAsync("\t3 - Quit"); + } + + private static async Task PrintArguments(ProgramArgs args) + { + var text = new StringBuilder(); + + text.AppendLine("ARGUMENTS: "); + text.AppendLine($"Interactive mode: {args.InteractiveMode}"); + text.AppendLine($"Folder: {args.Folder}"); + text.AppendLine($"File: {args.File}"); + text.AppendLine($"List? {args.ListPlugins}"); + text.AppendLine($"Locate? {args.LocatePlugins}"); + text.AppendLine($"Plugins to locate: {string.Join("; ", args.PluginsToLocate)}"); + + + await Console.Out.WriteLineAsync(text); + } + + private static async Task GetArguments(string[] arguments) { var result = new ProgramArgs(); var args = arguments.ToList(); @@ -52,17 +102,16 @@ private static ProgramArgs GetArguments(string[] arguments) { result.LocatePlugins = true; result.PluginsToLocate = parts[1].Split(';'); - } + } else - Console.Error.WriteLine("Please specify a semicolon separated list of plugin names to locate!"); + await Console.Error.WriteLineAsync("Please specify a semicolon separated list of plugin names to locate!"); } - else if (args.IndexOf("--list") >= 0) + + if (args.IndexOf("--list") >= 0) result.ListPlugins = true; - else - { - Console.Error.WriteLine("Please specify either --list or --locate option"); - return null; - } + + if (args.IndexOf("--interactive") >= 0) + result.InteractiveMode = true; int indexFolder = args.FindIndex(x => x.StartsWith("--folder=")); if (indexFolder >= 0) @@ -71,24 +120,51 @@ private static ProgramArgs GetArguments(string[] arguments) if (parts.Count() == 2) result.Folder = parts[1]; else - Console.Error.WriteLine("Please specify a folder path!"); + await Console.Error.WriteLineAsync("Please specify a folder path!"); } - else + + int indexFile = args.FindIndex(x => x.StartsWith("--file=")); + if (indexFile >= 0) { - int indexFile = args.FindIndex(x => x.StartsWith("--file=")); - if (indexFile >= 0) - { - var parts = args[indexFile].Split('='); - if (parts.Count() == 2) - result.File = parts[1]; - else - Console.Error.WriteLine("Please specify a file path!"); - } + var parts = args[indexFile].Split('='); + if (parts.Count() == 2) + result.File = parts[1]; + else + await Console.Error.WriteLineAsync("Please specify a file path!"); } return result; } - + private static async Task ValidateArguments(ProgramArgs args) + { + // Folder or file is always mandatory! + if ((string.IsNullOrWhiteSpace(args.File) && string.IsNullOrWhiteSpace(args.Folder)) || + (!string.IsNullOrWhiteSpace(args.File) && !string.IsNullOrWhiteSpace(args.Folder))) + { + await Console.Error.WriteLineAsync("Please specify either a folder or file at least"); + return false; + } + + if (args.InteractiveMode) + { + if (args.ListPlugins || args.LocatePlugins || args.PluginsToLocate.Any()) + { + await Console.Error.WriteLineAsync("In interactive mode, no other options can be used."); + return false; + } + } + else // Non interactive mode + { + if ((args.ListPlugins && args.LocatePlugins) || (!args.ListPlugins && !args.LocatePlugins)) + { + await Console.Error.WriteLineAsync("Please specify either --list or --locate option"); + return false; + } + } + + return true; + } + } } diff --git a/ProgramArgs.cs b/ProgramArgs.cs index 83dc340..0300260 100644 --- a/ProgramArgs.cs +++ b/ProgramArgs.cs @@ -16,6 +16,8 @@ public ProgramArgs() public bool ListPlugins { get; set; } public string[] PluginsToLocate { get; set; } + + public bool InteractiveMode { get; set; } } } From 9222957cbb329c60b0f111f9e078671f16f33966 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Fri, 26 Mar 2021 21:27:46 -0300 Subject: [PATCH 03/19] Search - initial commit. --- .vscode/launch.json | 3 +- AlsToolsManager.cs | 44 +++++++++++-- Program.cs | 61 ++++++++++--------- ProgramArgs.cs | 2 + .../netcoreapp3.1/als-tools.AssemblyInfo.cs | 3 +- 5 files changed, 74 insertions(+), 39 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index f838b5a..fa71e40 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,7 +12,8 @@ // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/als-tools.dll", //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], - "args": ["--interactive", "--folder=/Users/zenluiz/Desktop/Testes ALS"], + //"args": ["--interactive", "--folder=/Users/zenluiz/Desktop/Testes ALS"], + "args": ["--locate=bass mint", "--folder=/Users/zenluiz/Splice/"], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console "console": "internalConsole", diff --git a/AlsToolsManager.cs b/AlsToolsManager.cs index 8c5a70e..77f7c9c 100644 --- a/AlsToolsManager.cs +++ b/AlsToolsManager.cs @@ -1,11 +1,13 @@ using System; +using System.Collections; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.IO.Compression; +using System.Linq; using System.Threading.Tasks; using System.Xml; using System.Xml.XPath; -using AlsTools; namespace AlsTools { @@ -16,7 +18,10 @@ public class AlsToolsManager public void Initialize(ProgramArgs arguments) { var d = new DirectoryInfo(arguments.Folder); - var files = d.GetFiles("*.als", new EnumerationOptions() { RecurseSubdirectories = true }); + var files = d.GetFiles("*.als", new EnumerationOptions() { RecurseSubdirectories = true }).AsEnumerable(); + + if (!arguments.IncludeBackups) + files = files.Where(x => !x.FullName.Contains(@"\backup\")); foreach (var f in files) { @@ -27,10 +32,18 @@ public void Initialize(ProgramArgs arguments) public async Task Execute(ProgramArgs arguments) { - foreach (var project in projects) - { - await PrintProjectAndPlugins(project); - } + var projetsToDisplay = projects; + + if (arguments.LocatePlugins) + projetsToDisplay = LocateProjectsByPlugins(arguments.PluginsToLocate); + + foreach (var project in projetsToDisplay) + await PrintProjectAndPlugins(project); + } + + private IList LocateProjectsByPlugins(string[] pluginsToLocate) + { + return projects.Where(x => x.Plugins.Keys.Intersect(pluginsToLocate, new PluginNameComparer()).Any()).ToList(); } private async Task PrintProjectAndPlugins(LiveProject project) @@ -97,4 +110,23 @@ private void GetPluginsByExpression(LiveProject project, XPathNavigator nav, str } } } + + public class PluginNameComparer : IEqualityComparer + { + public bool Equals([AllowNull] string x, [AllowNull] string y) + { + if ((x == null && x != null) || (x != null && x == null)) + return false; + + if (string.IsNullOrEmpty(x) && string.IsNullOrEmpty(y)) + return true; + + return x.Contains(y, StringComparison.InvariantCultureIgnoreCase); + } + + public int GetHashCode([DisallowNull] string obj) + { + return obj.GetHashCode(); + } + } } diff --git a/Program.cs b/Program.cs index e5d203e..959df6b 100644 --- a/Program.cs +++ b/Program.cs @@ -16,8 +16,8 @@ class Program static async Task Main(string[] args) { - var arguments = await GetArguments(args); - if (!(await ValidateArguments(arguments))) + var arguments = GetArguments(args); + if (!ValidateArguments(arguments)) return -1; await PrintArguments(arguments); @@ -26,17 +26,17 @@ static async Task Main(string[] args) if (arguments.InteractiveMode) { - string option = string.Empty; - while (option != "3") + int? option = null; + while (option != 3) { - await PrintMenu(); - option = await GetOption(); - if (string.IsNullOrEmpty(option)) + PrintMenu(); + option = GetOption(); + if (!option.HasValue) continue; - if (option == "1") + if (option == 1) arguments.ListPlugins = true; - else if (option == "2") + else if (option == 2) arguments.LocatePlugins = true; } } @@ -51,26 +51,26 @@ static async Task Main(string[] args) return 0; } - private static async Task GetOption() + private static int? GetOption() { - var opt = await Console.In.ReadLineAsync(); //TODO: não está funcionando - var validOpts = new string[] {"1", "2", "3"}; + var opt = Console.Read(); //TODO: não está funcionando + var validOpts = new int[] {1, 2, 3}; if (!validOpts.Contains(opt)) { - await Console.Error.WriteLineAsync("\tInvalid option. Try again."); - return string.Empty; + Console.Error.WriteLine("\tInvalid option. Try again."); + return null; } return opt; } - private static async Task PrintMenu() + private static void PrintMenu() { - await Console.Out.WriteLineAsync("\nSelect an option"); - await Console.Out.WriteLineAsync("\t1 - List plugins"); - await Console.Out.WriteLineAsync("\t2 - Locate plugins"); - await Console.Out.WriteLineAsync("\t3 - Quit"); + Console.WriteLine("\nSelect an option"); + Console.WriteLine("\t1 - List plugins"); + Console.WriteLine("\t2 - Locate plugins"); + Console.WriteLine("\t3 - Quit"); } private static async Task PrintArguments(ProgramArgs args) @@ -85,11 +85,10 @@ private static async Task PrintArguments(ProgramArgs args) text.AppendLine($"Locate? {args.LocatePlugins}"); text.AppendLine($"Plugins to locate: {string.Join("; ", args.PluginsToLocate)}"); - await Console.Out.WriteLineAsync(text); } - private static async Task GetArguments(string[] arguments) + private static ProgramArgs GetArguments(string[] arguments) { var result = new ProgramArgs(); var args = arguments.ToList(); @@ -104,13 +103,16 @@ private static async Task GetArguments(string[] arguments) result.PluginsToLocate = parts[1].Split(';'); } else - await Console.Error.WriteLineAsync("Please specify a semicolon separated list of plugin names to locate!"); + Console.Error.WriteLine("Please specify a semicolon separated list of plugin names to locate!"); } if (args.IndexOf("--list") >= 0) result.ListPlugins = true; - if (args.IndexOf("--interactive") >= 0) + if (args.IndexOf("--includebackups") >= 0) + result.IncludeBackups = true; + + if (args.IndexOf("--interact") >= 0) result.InteractiveMode = true; int indexFolder = args.FindIndex(x => x.StartsWith("--folder=")); @@ -120,7 +122,7 @@ private static async Task GetArguments(string[] arguments) if (parts.Count() == 2) result.Folder = parts[1]; else - await Console.Error.WriteLineAsync("Please specify a folder path!"); + Console.Error.WriteLine("Please specify a folder path!"); } int indexFile = args.FindIndex(x => x.StartsWith("--file=")); @@ -130,19 +132,19 @@ private static async Task GetArguments(string[] arguments) if (parts.Count() == 2) result.File = parts[1]; else - await Console.Error.WriteLineAsync("Please specify a file path!"); + Console.Error.WriteLine("Please specify a file path!"); } return result; } - private static async Task ValidateArguments(ProgramArgs args) + private static bool ValidateArguments(ProgramArgs args) { // Folder or file is always mandatory! if ((string.IsNullOrWhiteSpace(args.File) && string.IsNullOrWhiteSpace(args.Folder)) || (!string.IsNullOrWhiteSpace(args.File) && !string.IsNullOrWhiteSpace(args.Folder))) { - await Console.Error.WriteLineAsync("Please specify either a folder or file at least"); + Console.Error.WriteLine("Please specify either a folder or file at least"); return false; } @@ -150,7 +152,7 @@ private static async Task ValidateArguments(ProgramArgs args) { if (args.ListPlugins || args.LocatePlugins || args.PluginsToLocate.Any()) { - await Console.Error.WriteLineAsync("In interactive mode, no other options can be used."); + Console.Error.WriteLine("In interactive mode, no other options can be used."); return false; } } @@ -158,13 +160,12 @@ private static async Task ValidateArguments(ProgramArgs args) { if ((args.ListPlugins && args.LocatePlugins) || (!args.ListPlugins && !args.LocatePlugins)) { - await Console.Error.WriteLineAsync("Please specify either --list or --locate option"); + Console.Error.WriteLine("Please specify either --list or --locate option"); return false; } } return true; } - } } diff --git a/ProgramArgs.cs b/ProgramArgs.cs index 0300260..6a961f9 100644 --- a/ProgramArgs.cs +++ b/ProgramArgs.cs @@ -18,6 +18,8 @@ public ProgramArgs() public string[] PluginsToLocate { get; set; } public bool InteractiveMode { get; set; } + + public bool IncludeBackups { get; set; } } } diff --git a/obj/Debug/netcoreapp3.1/als-tools.AssemblyInfo.cs b/obj/Debug/netcoreapp3.1/als-tools.AssemblyInfo.cs index 884bc47..669a8f8 100644 --- a/obj/Debug/netcoreapp3.1/als-tools.AssemblyInfo.cs +++ b/obj/Debug/netcoreapp3.1/als-tools.AssemblyInfo.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -19,5 +18,5 @@ [assembly: System.Reflection.AssemblyTitleAttribute("als-tools")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] -// Generated by the MSBuild WriteCodeFragment class. +// Gerado pela classe WriteCodeFragment do MSBuild. From b12e4d9c96756e36147b46460ff58c117b4c5136 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Sat, 27 Mar 2021 14:17:11 -0300 Subject: [PATCH 04/19] Refactoring to prepare for DB --- .gitignore | 2 + .vscode/launch.json | 4 +- AlsToolsManager.cs | 132 ----------- App.cs | 72 ++++++ Config/LiteDbOptions.cs | 7 + .../Entities/LiveProject.cs | 3 +- PluginInfo.cs => Core/Entities/PluginInfo.cs | 2 +- PluginType.cs => Core/Entities/PluginType.cs | 0 Core/Interfaces/ILiveProjectExtractor.cs | 10 + Core/Interfaces/ILiveProjectFileSystem.cs | 12 + Core/Interfaces/ILiveProjectRepository.cs | 17 ++ Core/Interfaces/ILiveProjectService.cs | 17 ++ Core/Services/LiveProjectService.cs | 67 ++++++ .../FileSystem/LiveProjectFileSystem.cs | 31 +++ Infrastructure/LiteDbContext.cs | 17 ++ Infrastructure/LiveProjectExtractor.cs | 59 +++++ .../Repositories/LiveProjectRepository.cs | 31 +++ Program.cs | 214 +++++++++++------- ProgramArgs.cs | 4 +- als-tools.csproj | 20 ++ appsettings.json | 5 + 21 files changed, 505 insertions(+), 221 deletions(-) delete mode 100644 AlsToolsManager.cs create mode 100644 App.cs create mode 100644 Config/LiteDbOptions.cs rename LiveProject.cs => Core/Entities/LiveProject.cs (92%) rename PluginInfo.cs => Core/Entities/PluginInfo.cs (79%) rename PluginType.cs => Core/Entities/PluginType.cs (100%) create mode 100644 Core/Interfaces/ILiveProjectExtractor.cs create mode 100644 Core/Interfaces/ILiveProjectFileSystem.cs create mode 100644 Core/Interfaces/ILiveProjectRepository.cs create mode 100644 Core/Interfaces/ILiveProjectService.cs create mode 100644 Core/Services/LiveProjectService.cs create mode 100644 Infrastructure/FileSystem/LiveProjectFileSystem.cs create mode 100644 Infrastructure/LiteDbContext.cs create mode 100644 Infrastructure/LiveProjectExtractor.cs create mode 100644 Infrastructure/Repositories/LiveProjectRepository.cs create mode 100644 appsettings.json diff --git a/.gitignore b/.gitignore index a23ba0b..eaa0671 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ obj/Debug/netcoreapp3.1/als-tools.csproj.FileListAbsolute.txt obj/Debug/netcoreapp3.1/als-tools.csprojAssemblyReference.cache obj/Debug/netcoreapp3.1/als-tools.dll obj/Debug/netcoreapp3.1/als-tools.pdb +*.dll +obj/*.* diff --git a/.vscode/launch.json b/.vscode/launch.json index fa71e40..e8e7a63 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,7 +13,9 @@ "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/als-tools.dll", //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], //"args": ["--interactive", "--folder=/Users/zenluiz/Desktop/Testes ALS"], - "args": ["--locate=bass mint", "--folder=/Users/zenluiz/Splice/"], + // "args": ["--locate=bass mint", "--folder=/Users/zenluiz/Splice/"], + // "args": ["--list", "--folder=/Users/zenluiz/Splice/"], + "args": ["--initdb", "--folder=/Users/zenluiz/Splice/"], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console "console": "internalConsole", diff --git a/AlsToolsManager.cs b/AlsToolsManager.cs deleted file mode 100644 index 77f7c9c..0000000 --- a/AlsToolsManager.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Threading.Tasks; -using System.Xml; -using System.Xml.XPath; - -namespace AlsTools -{ - public class AlsToolsManager - { - IList projects = new List(); - - public void Initialize(ProgramArgs arguments) - { - var d = new DirectoryInfo(arguments.Folder); - var files = d.GetFiles("*.als", new EnumerationOptions() { RecurseSubdirectories = true }).AsEnumerable(); - - if (!arguments.IncludeBackups) - files = files.Where(x => !x.FullName.Contains(@"\backup\")); - - foreach (var f in files) - { - var project = ExtractLiveProjectInfoFromFile(f); - projects.Add(project); - } - } - - public async Task Execute(ProgramArgs arguments) - { - var projetsToDisplay = projects; - - if (arguments.LocatePlugins) - projetsToDisplay = LocateProjectsByPlugins(arguments.PluginsToLocate); - - foreach (var project in projetsToDisplay) - await PrintProjectAndPlugins(project); - } - - private IList LocateProjectsByPlugins(string[] pluginsToLocate) - { - return projects.Where(x => x.Plugins.Keys.Intersect(pluginsToLocate, new PluginNameComparer()).Any()).ToList(); - } - - private async Task PrintProjectAndPlugins(LiveProject project) - { - await Console.Out.WriteLineAsync("------------------------------------------------------------------------------"); - await Console.Out.WriteLineAsync($"Project name: {project.Name}"); - await Console.Out.WriteLineAsync($"Full path: {project.Path}"); - await Console.Out.WriteLineAsync("\tPlugins:"); - - if (project.Plugins.Count == 0) - { - await Console.Out.WriteLineAsync("\t\tNo plugins found!"); - return false; - } - - foreach (var plugin in project.Plugins) - await Console.Out.WriteLineAsync($"\t\tName = {plugin.Value.Name} | Type = {plugin.Value.Type}"); - - return true; - } - - private LiveProject ExtractLiveProjectInfoFromFile(FileInfo fileToDecompress) - { - var project = new LiveProject() { Name = fileToDecompress.Name, Path = fileToDecompress.FullName }; - var plugins = new SortedSet(); - var settings = new XmlReaderSettings() { IgnoreWhitespace = true }; - - using (FileStream originalFileStream = fileToDecompress.OpenRead()) - { - using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress)) - { - using (StreamReader unzip = new StreamReader(decompressionStream)) - { - var xPathDoc = new XPathDocument(unzip); - var nav = xPathDoc.CreateNavigator(); - - var expression = @"//PluginDevice/PluginDesc/Vst3PluginInfo/Name/@Value"; - GetPluginsByExpression(project, nav, expression, PluginType.VST3); - - expression = @"//PluginDevice/PluginDesc/VstPluginInfo/PlugName/@Value"; - GetPluginsByExpression(project, nav, expression, PluginType.VST); - - expression = @"//AuPluginDevice/PluginDesc/AuPluginInfo/Name/@Value"; - GetPluginsByExpression(project, nav, expression, PluginType.AU); - } - } - } - - return project; - } - - private void GetPluginsByExpression(LiveProject project, XPathNavigator nav, string expression, PluginType type) - { - var nodeIter = nav.Select(expression); - - while (nodeIter.MoveNext()) - { - var name = nodeIter.Current.Value; - if (!project.Plugins.ContainsKey(name)) - { - var p = new PluginInfo() { Name = name, Type = type }; - project.Plugins.Add(p.Name, p); - } - } - } - } - - public class PluginNameComparer : IEqualityComparer - { - public bool Equals([AllowNull] string x, [AllowNull] string y) - { - if ((x == null && x != null) || (x != null && x == null)) - return false; - - if (string.IsNullOrEmpty(x) && string.IsNullOrEmpty(y)) - return true; - - return x.Contains(y, StringComparison.InvariantCultureIgnoreCase); - } - - public int GetHashCode([DisallowNull] string obj) - { - return obj.GetHashCode(); - } - } -} diff --git a/App.cs b/App.cs new file mode 100644 index 0000000..68779bd --- /dev/null +++ b/App.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Threading.Tasks; +using System.Xml; +using System.Xml.XPath; +using AlsTools.Core.Entities; +using AlsTools.Core.Interfaces; + +namespace AlsTools +{ + public class App + { + // private readonly ILogger _logger; + // private readonly AppSettings _appSettings; + private readonly ILiveProjectService liveProjectService; + + public App(ILiveProjectService liveProjectService) + { + this.liveProjectService = liveProjectService; + } + + public async Task Run(ProgramArgs args) + { + if (args.InitDb) + { + if (!string.IsNullOrEmpty(args.File)) + liveProjectService.InitializeDbFromFile(args.File); + else + liveProjectService.InitializeDbFromFolder(args.Folder, args.IncludeBackups); + } + else if (args.ListPlugins) + { + var projects = liveProjectService.GetAllProjects(); + await PrintProjectsAndPlugins(projects); + } + else if (args.LocatePlugins) + { + var projects = liveProjectService.GetProjectsContainingPlugins(args.PluginsToLocate); + await PrintProjectsAndPlugins(projects); + } + else + { + throw new InvalidOperationException("Nothing to do?"); + } + } + + private async Task PrintProjectsAndPlugins(IList projects) + { + foreach (var p in projects) + await PrintProjectAndPlugins(p); + } + + private async Task PrintProjectAndPlugins(LiveProject project) + { + await Console.Out.WriteLineAsync("------------------------------------------------------------------------------"); + await Console.Out.WriteLineAsync($"Project name: {project.Name}"); + await Console.Out.WriteLineAsync($"Full path: {project.Path}"); + await Console.Out.WriteLineAsync("\tPlugins:"); + + if (project.Plugins.Count == 0) + await Console.Out.WriteLineAsync("\t\tNo plugins found!"); + + foreach (var plugin in project.Plugins) + await Console.Out.WriteLineAsync($"\t\tName = {plugin.Value.Name} | Type = {plugin.Value.Type}"); + } + } +} diff --git a/Config/LiteDbOptions.cs b/Config/LiteDbOptions.cs new file mode 100644 index 0000000..94982f8 --- /dev/null +++ b/Config/LiteDbOptions.cs @@ -0,0 +1,7 @@ +namespace AlsTools.Config +{ + public class LiteDbOptions + { + public string DatabaseLocation { get; set; } + } +} diff --git a/LiveProject.cs b/Core/Entities/LiveProject.cs similarity index 92% rename from LiveProject.cs rename to Core/Entities/LiveProject.cs index 18f13d7..e44ee0a 100644 --- a/LiveProject.cs +++ b/Core/Entities/LiveProject.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; -namespace AlsTools + +namespace AlsTools.Core.Entities { public class LiveProject { diff --git a/PluginInfo.cs b/Core/Entities/PluginInfo.cs similarity index 79% rename from PluginInfo.cs rename to Core/Entities/PluginInfo.cs index dbd6534..d51477c 100644 --- a/PluginInfo.cs +++ b/Core/Entities/PluginInfo.cs @@ -1,4 +1,4 @@ -namespace AlsTools +namespace AlsTools.Core.Entities { public class PluginInfo { diff --git a/PluginType.cs b/Core/Entities/PluginType.cs similarity index 100% rename from PluginType.cs rename to Core/Entities/PluginType.cs diff --git a/Core/Interfaces/ILiveProjectExtractor.cs b/Core/Interfaces/ILiveProjectExtractor.cs new file mode 100644 index 0000000..d15bbdc --- /dev/null +++ b/Core/Interfaces/ILiveProjectExtractor.cs @@ -0,0 +1,10 @@ +using System.IO; +using AlsTools.Core.Entities; + +namespace AlsTools.Core.Interfaces +{ + public interface ILiveProjectExtractor + { + LiveProject ExtractProjectFromFile(FileInfo file); + } +} diff --git a/Core/Interfaces/ILiveProjectFileSystem.cs b/Core/Interfaces/ILiveProjectFileSystem.cs new file mode 100644 index 0000000..bbe8b62 --- /dev/null +++ b/Core/Interfaces/ILiveProjectFileSystem.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using System.IO; + +namespace AlsTools.Core.Interfaces +{ + public interface ILiveProjectFileSystem + { + IEnumerable LoadProjectFilesFromDirectory(string folderPath, bool includeBackupFolder); + + FileInfo LoadProjectFileFromSetFile(string setFilePath); + } +} diff --git a/Core/Interfaces/ILiveProjectRepository.cs b/Core/Interfaces/ILiveProjectRepository.cs new file mode 100644 index 0000000..c636822 --- /dev/null +++ b/Core/Interfaces/ILiveProjectRepository.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using AlsTools.Core.Entities; + +namespace AlsTools.Core.Interfaces +{ + public interface ILiveProjectRepository + { + void Insert(LiveProject project); + + void Insert(IList projects); + + IList GetProjectsContainingPlugins(string[] pluginsToLocate); + + IList GetAllProjects(); + } +} diff --git a/Core/Interfaces/ILiveProjectService.cs b/Core/Interfaces/ILiveProjectService.cs new file mode 100644 index 0000000..a5873e9 --- /dev/null +++ b/Core/Interfaces/ILiveProjectService.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using AlsTools.Core.Entities; + +namespace AlsTools.Core.Interfaces +{ + public interface ILiveProjectService + { + void InitializeDbFromFile(string filePath); + + void InitializeDbFromFolder(string folderPath, bool includeBackupFolder); + + IList GetAllProjects(); + + IList GetProjectsContainingPlugins(string[] pluginsToLocate); + } +} diff --git a/Core/Services/LiveProjectService.cs b/Core/Services/LiveProjectService.cs new file mode 100644 index 0000000..0a7f25d --- /dev/null +++ b/Core/Services/LiveProjectService.cs @@ -0,0 +1,67 @@ + +using System.Collections.Generic; +using AlsTools.Core.Entities; +using AlsTools.Core.Interfaces; + +namespace AlsTools.Core.Services +{ + public class LiveProjectService : ILiveProjectService + { + private readonly ILiveProjectRepository repository; + private readonly ILiveProjectFileSystem fs; + private readonly ILiveProjectExtractor extractor; + + public LiveProjectService(ILiveProjectRepository repository, ILiveProjectFileSystem fs, ILiveProjectExtractor extractor) + { + this.repository = repository; + this.fs = fs; + this.extractor = extractor; + } + + public IList GetAllProjects() + { + return repository.GetAllProjects(); + } + + public IList GetProjectsContainingPlugins(string[] pluginsToLocate) + { + return repository.GetProjectsContainingPlugins(pluginsToLocate); + } + + public void InitializeDbFromFile(string filePath) + { + var project = LoadProjectFromSetFile(filePath); + repository.Insert(project); + } + + public void InitializeDbFromFolder(string folderPath, bool includeBackupFolder) + { + var projects = LoadProjectsFromDirectory(folderPath, includeBackupFolder); + repository.Insert(projects); + } + + private LiveProject LoadProjectFromSetFile(string setFilePath) + { + var file = fs.LoadProjectFileFromSetFile(setFilePath); + var project = extractor.ExtractProjectFromFile(file); + + return project; + } + + private IList LoadProjectsFromDirectory(string folderPath, bool includeBackupFolder) + { + List projects = new List(); + var files = fs.LoadProjectFilesFromDirectory(folderPath, includeBackupFolder); + + foreach (var f in files) + { + var project = extractor.ExtractProjectFromFile(f); + projects.Add(project); + } + + return projects; + } + + + } +} diff --git a/Infrastructure/FileSystem/LiveProjectFileSystem.cs b/Infrastructure/FileSystem/LiveProjectFileSystem.cs new file mode 100644 index 0000000..e2e59fe --- /dev/null +++ b/Infrastructure/FileSystem/LiveProjectFileSystem.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using AlsTools.Core.Interfaces; + +namespace AlsTools.Infrastructure.FileSystem +{ + public class LiveProjectFileSystem : ILiveProjectFileSystem + { + public IEnumerable LoadProjectFilesFromDirectory(string folderPath, bool includeBackupFolder) + { + var d = new DirectoryInfo(folderPath); + var files = d.GetFiles("*.als", new EnumerationOptions() { RecurseSubdirectories = true }).AsEnumerable(); + + if (!includeBackupFolder) + files = files.Where(x => !x.FullName.Contains(@"\backup\")); + + return files; + } + public FileInfo LoadProjectFileFromSetFile(string setFilePath) + { + FileInfo f = new FileInfo(setFilePath); + + if (!f.Exists) + throw new FileNotFoundException($"The specified file does not exist ({setFilePath})"); + + return f; + } + + } +} diff --git a/Infrastructure/LiteDbContext.cs b/Infrastructure/LiteDbContext.cs new file mode 100644 index 0000000..f1113f4 --- /dev/null +++ b/Infrastructure/LiteDbContext.cs @@ -0,0 +1,17 @@ +using System; +using AlsTools.Config; +using LiteDB; +using Microsoft.Extensions.Options; + +namespace AlsTools.Infrastructure +{ + public class LiteDbContext// : ILiteDbContext + { + public LiteDatabase Database { get; } + + public LiteDbContext(IOptions options) + { + Database = new LiteDatabase(options.Value.DatabaseLocation); + } + } +} diff --git a/Infrastructure/LiveProjectExtractor.cs b/Infrastructure/LiveProjectExtractor.cs new file mode 100644 index 0000000..3d73ee2 --- /dev/null +++ b/Infrastructure/LiveProjectExtractor.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Xml; +using System.Xml.XPath; +using AlsTools; +using AlsTools.Core.Entities; +using AlsTools.Core.Interfaces; + +namespace AlsTools.Infrastructure +{ + public class LiveProjectExtractor : ILiveProjectExtractor + { + public LiveProject ExtractProjectFromFile(FileInfo file) + { + var project = new LiveProject() { Name = file.Name, Path = file.FullName }; + var plugins = new SortedSet(); + var settings = new XmlReaderSettings() { IgnoreWhitespace = true }; + + using (FileStream originalFileStream = file.OpenRead()) + { + using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress)) + { + using (StreamReader unzip = new StreamReader(decompressionStream)) + { + var xPathDoc = new XPathDocument(unzip); + var nav = xPathDoc.CreateNavigator(); + + var expression = @"//PluginDevice/PluginDesc/Vst3PluginInfo/Name/@Value"; + GetPluginsByExpression(project, nav, expression, PluginType.VST3); + + expression = @"//PluginDevice/PluginDesc/VstPluginInfo/PlugName/@Value"; + GetPluginsByExpression(project, nav, expression, PluginType.VST); + + expression = @"//AuPluginDevice/PluginDesc/AuPluginInfo/Name/@Value"; + GetPluginsByExpression(project, nav, expression, PluginType.AU); + } + } + } + + return project; + } + + private void GetPluginsByExpression(LiveProject project, XPathNavigator nav, string expression, PluginType type) + { + var nodeIter = nav.Select(expression); + + while (nodeIter.MoveNext()) + { + var name = nodeIter.Current.Value; + if (!project.Plugins.ContainsKey(name)) + { + var p = new PluginInfo() { Name = name, Type = type }; + project.Plugins.Add(p.Name, p); + } + } + } + } +} diff --git a/Infrastructure/Repositories/LiveProjectRepository.cs b/Infrastructure/Repositories/LiveProjectRepository.cs new file mode 100644 index 0000000..a2cb711 --- /dev/null +++ b/Infrastructure/Repositories/LiveProjectRepository.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using AlsTools.Core.Entities; +using AlsTools.Core.Interfaces; + +namespace AlsTools.Infrastructure.Repositories +{ + public class LiveProjectRepository : ILiveProjectRepository + { + private static List fakeProjects = new List(); + + public IList GetAllProjects() + { + return fakeProjects; + } + + public IList GetProjectsContainingPlugins(string[] pluginsToLocate) + { + return fakeProjects; + } + + public void Insert(LiveProject project) + { + fakeProjects.Add(project); + } + + public void Insert(IList projects) + { + fakeProjects.AddRange(projects); + } + } +} diff --git a/Program.cs b/Program.cs index 959df6b..aaf32a4 100644 --- a/Program.cs +++ b/Program.cs @@ -1,61 +1,136 @@ using System; -using System.Collections.Generic; using System.IO; -using System.IO.Compression; using System.Linq; -using System.Text; using System.Threading.Tasks; -using System.Xml; -using System.Xml.XPath; +using AlsTools.Core.Interfaces; +using AlsTools.Core.Services; +using AlsTools.Infrastructure; +using AlsTools.Infrastructure.FileSystem; +using AlsTools.Infrastructure.Repositories; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Serilog; namespace AlsTools { class Program { - static AlsToolsManager manager = new AlsToolsManager(); + // private static AlsToolsManager manager = new AlsToolsManager(); + // private static IConfiguration config = null; + private static IConfigurationRoot configuration; - static async Task Main(string[] args) + private static async Task Main(string[] args) { - var arguments = GetArguments(args); - if (!ValidateArguments(arguments)) - return -1; + // Initialize serilog logger + Log.Logger = new LoggerConfiguration() + .WriteTo.Console(Serilog.Events.LogEventLevel.Debug) + .MinimumLevel.Debug() + .Enrich.FromLogContext() + .CreateLogger(); + + Log.Debug("Creating service collection"); + var serviceCollection = new ServiceCollection(); + ConfigureServices(serviceCollection); - await PrintArguments(arguments); + Log.Debug("Building service provider"); + var serviceProvider = serviceCollection.BuildServiceProvider(); + + try + { + Log.Debug("Parsing arguments"); + var arguments = ParseArguments(args); - manager.Initialize(arguments); + Log.Debug("Starting application"); + var app = serviceProvider.GetService(); + await app.Run(arguments); - if (arguments.InteractiveMode) + Log.Debug("Returning 0"); + return 0; + } + catch (Exception ex) { - int? option = null; - while (option != 3) - { - PrintMenu(); - option = GetOption(); - if (!option.HasValue) - continue; - - if (option == 1) - arguments.ListPlugins = true; - else if (option == 2) - arguments.LocatePlugins = true; - } + Log.Fatal(ex, "An error occured. Returning code 1"); + return 1; } - else + finally { - await manager.Execute(arguments); + Log.CloseAndFlush(); } + } + + private static void ConfigureServices(IServiceCollection serviceCollection) + { + // Add logging + // serviceCollection.AddSingleton(LoggerFactory.Create(builder => + // { + // builder + // .AddSerilog(dispose: true); + // })); + + serviceCollection.AddLogging(); + + // Build configuration + configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetParent(AppContext.BaseDirectory).FullName) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .Build(); + + // Add access to generic IConfigurationRoot + serviceCollection.AddSingleton(configuration); + + // Add services + serviceCollection + .AddTransient() + .AddTransient() + .AddTransient() + .AddTransient(); + + // Add app + serviceCollection.AddTransient(); + } + + + private static ProgramArgs ParseArguments(string[] args) + { + var arguments = GetArguments(args); + ValidateArguments(arguments); + + PrintArguments(arguments); + + return arguments; + + // manager.Initialize(arguments); - await Console.Out.WriteLineAsync("------------------------------------------------------------------------------"); - await Console.Out.WriteLineAsync("DONE"); + // if (arguments.InteractiveMode) + // { + // int? option = null; + // while (option != 3) + // { + // PrintMenu(); + // option = GetOption(); + // if (!option.HasValue) + // continue; - return 0; + // if (option == 1) + // arguments.ListPlugins = true; + // else if (option == 2) + // arguments.LocatePlugins = true; + // } + // } + // else + // { + // await manager.Execute(arguments); + // } + + + // return 0; } private static int? GetOption() { var opt = Console.Read(); //TODO: não está funcionando - var validOpts = new int[] {1, 2, 3}; - + var validOpts = new int[] { 1, 2, 3 }; + if (!validOpts.Contains(opt)) { Console.Error.WriteLine("\tInvalid option. Try again."); @@ -73,19 +148,9 @@ private static void PrintMenu() Console.WriteLine("\t3 - Quit"); } - private static async Task PrintArguments(ProgramArgs args) + private static void PrintArguments(ProgramArgs args) { - var text = new StringBuilder(); - - text.AppendLine("ARGUMENTS: "); - text.AppendLine($"Interactive mode: {args.InteractiveMode}"); - text.AppendLine($"Folder: {args.Folder}"); - text.AppendLine($"File: {args.File}"); - text.AppendLine($"List? {args.ListPlugins}"); - text.AppendLine($"Locate? {args.LocatePlugins}"); - text.AppendLine($"Plugins to locate: {string.Join("; ", args.PluginsToLocate)}"); - - await Console.Out.WriteLineAsync(text); + Log.Debug("Parameters: {@Args}", args); } private static ProgramArgs GetArguments(string[] arguments) @@ -97,75 +162,56 @@ private static ProgramArgs GetArguments(string[] arguments) if (indexLocate >= 0) { var parts = args[indexLocate].Split('='); - if (parts.Count() == 2) - { - result.LocatePlugins = true; - result.PluginsToLocate = parts[1].Split(';'); - } - else - Console.Error.WriteLine("Please specify a semicolon separated list of plugin names to locate!"); + if (parts.Count() != 2) + throw new ArgumentException("Please specify a semicolon separated list of plugin names to locate!"); + + result.LocatePlugins = true; + result.PluginsToLocate = parts[1].Split(';'); } + if (args.IndexOf("--initdb") >= 0) + result.InitDb = true; + if (args.IndexOf("--list") >= 0) result.ListPlugins = true; if (args.IndexOf("--includebackups") >= 0) result.IncludeBackups = true; - if (args.IndexOf("--interact") >= 0) - result.InteractiveMode = true; - int indexFolder = args.FindIndex(x => x.StartsWith("--folder=")); if (indexFolder >= 0) { var parts = args[indexFolder].Split('='); - if (parts.Count() == 2) - result.Folder = parts[1]; - else - Console.Error.WriteLine("Please specify a folder path!"); + if (parts.Count() != 2) + throw new ArgumentException("Please specify a folder path!"); + + result.Folder = parts[1]; } int indexFile = args.FindIndex(x => x.StartsWith("--file=")); if (indexFile >= 0) { var parts = args[indexFile].Split('='); - if (parts.Count() == 2) - result.File = parts[1]; - else - Console.Error.WriteLine("Please specify a file path!"); + if (parts.Count() != 2) + throw new ArgumentException("Please specify a file path!"); + + result.File = parts[1]; } return result; } - private static bool ValidateArguments(ProgramArgs args) + private static void ValidateArguments(ProgramArgs args) { // Folder or file is always mandatory! if ((string.IsNullOrWhiteSpace(args.File) && string.IsNullOrWhiteSpace(args.Folder)) || (!string.IsNullOrWhiteSpace(args.File) && !string.IsNullOrWhiteSpace(args.Folder))) { - Console.Error.WriteLine("Please specify either a folder or file at least"); - return false; - } - - if (args.InteractiveMode) - { - if (args.ListPlugins || args.LocatePlugins || args.PluginsToLocate.Any()) - { - Console.Error.WriteLine("In interactive mode, no other options can be used."); - return false; - } - } - else // Non interactive mode - { - if ((args.ListPlugins && args.LocatePlugins) || (!args.ListPlugins && !args.LocatePlugins)) - { - Console.Error.WriteLine("Please specify either --list or --locate option"); - return false; - } + throw new ArgumentException("Please specify either a folder or file at least"); } - return true; + if ((args.ListPlugins && args.LocatePlugins && args.InitDb) || (!args.ListPlugins && !args.LocatePlugins && !args.InitDb)) + throw new ArgumentException("Please specify either --initdb or --list or --locate option"); } } } diff --git a/ProgramArgs.cs b/ProgramArgs.cs index 6a961f9..82df753 100644 --- a/ProgramArgs.cs +++ b/ProgramArgs.cs @@ -17,9 +17,9 @@ public ProgramArgs() public string[] PluginsToLocate { get; set; } - public bool InteractiveMode { get; set; } - public bool IncludeBackups { get; set; } + + public bool InitDb { get; set; } } } diff --git a/als-tools.csproj b/als-tools.csproj index 868ceac..4108cf9 100644 --- a/als-tools.csproj +++ b/als-tools.csproj @@ -6,4 +6,24 @@ als_tools + + + Always + + + + + + + + + + + + + + + + + diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..5831320 --- /dev/null +++ b/appsettings.json @@ -0,0 +1,5 @@ +{ + "LiteDbOptions": { + "DatabaseLocation": "LiteDb/LiteDbTest.db" + } +} \ No newline at end of file From d8d2e6c9f276640c0a3c14ef569140ed2970ac3f Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Sat, 27 Mar 2021 14:20:03 -0300 Subject: [PATCH 05/19] Removed bin and obj folders --- .gitignore | 14 +--- ...CoreApp,Version=v3.1.AssemblyAttributes.cs | 4 -- .../netcoreapp3.1/als-tools.AssemblyInfo.cs | 22 ------ .../als-tools.AssemblyInfoInputs.cache | 1 - .../netcoreapp3.1/als-tools.assets.cache | Bin 140 -> 0 bytes .../als-tools.csprojAssemblyReference.cache | Bin 101788 -> 0 bytes obj/als-tools.csproj.nuget.cache | 5 -- obj/als-tools.csproj.nuget.dgspec.json | 58 ---------------- obj/als-tools.csproj.nuget.g.props | 15 ----- obj/als-tools.csproj.nuget.g.targets | 6 -- obj/project.assets.json | 63 ------------------ 11 files changed, 1 insertion(+), 187 deletions(-) delete mode 100644 obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs delete mode 100644 obj/Debug/netcoreapp3.1/als-tools.AssemblyInfo.cs delete mode 100644 obj/Debug/netcoreapp3.1/als-tools.AssemblyInfoInputs.cache delete mode 100644 obj/Debug/netcoreapp3.1/als-tools.assets.cache delete mode 100644 obj/Debug/netcoreapp3.1/als-tools.csprojAssemblyReference.cache delete mode 100644 obj/als-tools.csproj.nuget.cache delete mode 100644 obj/als-tools.csproj.nuget.dgspec.json delete mode 100644 obj/als-tools.csproj.nuget.g.props delete mode 100644 obj/als-tools.csproj.nuget.g.targets delete mode 100644 obj/project.assets.json diff --git a/.gitignore b/.gitignore index eaa0671..e471228 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,2 @@ -bin/Debug/netcoreapp3.1/als-tools.deps.json -bin/Debug/netcoreapp3.1/als-tools.dll -bin/Debug/netcoreapp3.1/als-tools.pdb -bin/Debug/netcoreapp3.1/als-tools.runtimeconfig.dev.json -bin/Debug/netcoreapp3.1/als-tools.runtimeconfig.json -obj/als-tools.csproj.nuget.cache -obj/als-tools.csproj.nuget.dgspec.json -obj/project.assets.json -obj/Debug/netcoreapp3.1/als-tools.csproj.FileListAbsolute.txt -obj/Debug/netcoreapp3.1/als-tools.csprojAssemblyReference.cache -obj/Debug/netcoreapp3.1/als-tools.dll -obj/Debug/netcoreapp3.1/als-tools.pdb *.dll -obj/*.* +*.pdb \ No newline at end of file diff --git a/obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs b/obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs deleted file mode 100644 index 03fd1de..0000000 --- a/obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs +++ /dev/null @@ -1,4 +0,0 @@ -// -using System; -using System.Reflection; -[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")] diff --git a/obj/Debug/netcoreapp3.1/als-tools.AssemblyInfo.cs b/obj/Debug/netcoreapp3.1/als-tools.AssemblyInfo.cs deleted file mode 100644 index 669a8f8..0000000 --- a/obj/Debug/netcoreapp3.1/als-tools.AssemblyInfo.cs +++ /dev/null @@ -1,22 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using System; -using System.Reflection; - -[assembly: System.Reflection.AssemblyCompanyAttribute("als-tools")] -[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] -[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] -[assembly: System.Reflection.AssemblyProductAttribute("als-tools")] -[assembly: System.Reflection.AssemblyTitleAttribute("als-tools")] -[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] - -// Gerado pela classe WriteCodeFragment do MSBuild. - diff --git a/obj/Debug/netcoreapp3.1/als-tools.AssemblyInfoInputs.cache b/obj/Debug/netcoreapp3.1/als-tools.AssemblyInfoInputs.cache deleted file mode 100644 index 40e40e8..0000000 --- a/obj/Debug/netcoreapp3.1/als-tools.AssemblyInfoInputs.cache +++ /dev/null @@ -1 +0,0 @@ -b8c1cbc0c31780edfa78644292b3be19a7b9aa1e diff --git a/obj/Debug/netcoreapp3.1/als-tools.assets.cache b/obj/Debug/netcoreapp3.1/als-tools.assets.cache deleted file mode 100644 index c3ac081cbffb28611639db8650e086a382a49af1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 140 zcmWIWc6a1rU|`Vdw&9&4cA|NOTJPZxmy`FuPj2Op`J1=8J!;Z1xZzD}GD&lV=i7meh{NH)+ojd2wo52aQ*JUQ*I6LReob!F}mUGK{ zx2U+NsAxN0^j~`I)&gSs*l=Y$mWWj+OHZs1N2*FE1ru`;rRA}BsON!GLh(d679G-O zKxv=S-le^J9#~!#Av1gTs~%82sJc&| zssX)&{erE@*+H3oRLoB#L$wvjU@}BjsyZAAIe)c0z*QlNNF-F5LCA zL{Y1j5Uoh;(6j^w?Z(7{RU?9x$ymINho?QlEsxdK1>>Q3Tl(FK@HwGY_%Km2B^ap> zC5nn#7PW5OzU@9<9OL6v;b<_Tzw_BCgNNQsVYG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I}Hq z4Gc=xsf_{@T`XOvHbIfOwfTsDM7K7Z(|*Le>P3Oiv;N2zz8~3=?MJ?bqR|QM&|Ung zMBgwdUAw>aKvAv6+f+r^ioXg2)HWZe?H(usWOOdAQ6(~$nG$H6`D$He+TatOug34B znCSpTPRulWZR*INbZrU}KaoDbCaY@j9=45%qSP*Xine3kI0^9oEW7*NxF zpk{cWD7T>(|2GgS7*N$dP&EP+Uo8R`s4W;!Q6H#SHc<5i18S}hR6{mU=R=XXUs%9D zqWgt~;z#H*^DD3@>yKRG`;o=je&h-$8u636e&=!}gVLSL5&_D{C9W$NP)mKFmU*Cf zvPEC+n+pciEk01oJy5P{c16#^7rCHimRzJdX@(g$jl0A+M84;2ikhkc+{ zX9M*_!GLD$TQ zEf`Q6e4sW8P)6&wsbD~TUSgF?E2#uI-1U6dmAgf}+#B8I(~m>3r(K07Zvro1o}K zZ3(J1N*uicbV76^-t79tkB+f6LD8Ak5)>6ddIji+=0?2P^+C}&(k3W6RGL80 zyk7=|dp%PP1)W@*6R2iyDCl@y^GeZKy9^4LQiC!&H?}Z9(c!ixC_3quK^b+5j&3as SP;|bm35pJzWl*yCwf}$f-+tf# diff --git a/obj/als-tools.csproj.nuget.cache b/obj/als-tools.csproj.nuget.cache deleted file mode 100644 index 643ea8e..0000000 --- a/obj/als-tools.csproj.nuget.cache +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": 1, - "dgSpecHash": "qew0wBwlDkQMg3PCbyOz7VGMKln9Dtpi42t1Tk13Gf1hh/tVvIouWLN/DI4C6GF/EpufpvOSekk7UTEwn8XoDw==", - "success": true -} \ No newline at end of file diff --git a/obj/als-tools.csproj.nuget.dgspec.json b/obj/als-tools.csproj.nuget.dgspec.json deleted file mode 100644 index 5405b4b..0000000 --- a/obj/als-tools.csproj.nuget.dgspec.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "format": 1, - "restore": { - "/Users/zenluiz/Documents/Desenvolvimento/repos/als-tools/als-tools/als-tools.csproj": {} - }, - "projects": { - "/Users/zenluiz/Documents/Desenvolvimento/repos/als-tools/als-tools/als-tools.csproj": { - "version": "1.0.0", - "restore": { - "projectUniqueName": "/Users/zenluiz/Documents/Desenvolvimento/repos/als-tools/als-tools/als-tools.csproj", - "projectName": "als-tools", - "projectPath": "/Users/zenluiz/Documents/Desenvolvimento/repos/als-tools/als-tools/als-tools.csproj", - "packagesPath": "/Users/zenluiz/.nuget/packages/", - "outputPath": "/Users/zenluiz/Documents/Desenvolvimento/repos/als-tools/als-tools/obj/", - "projectStyle": "PackageReference", - "configFilePaths": [ - "/Users/zenluiz/.nuget/NuGet/NuGet.Config" - ], - "originalTargetFrameworks": [ - "netcoreapp3.1" - ], - "sources": { - "https://api.nuget.org/v3/index.json": {} - }, - "frameworks": { - "netcoreapp3.1": { - "projectReferences": {} - } - }, - "warningProperties": { - "warnAsError": [ - "NU1605" - ] - } - }, - "frameworks": { - "netcoreapp3.1": { - "imports": [ - "net461", - "net462", - "net47", - "net471", - "net472", - "net48" - ], - "assetTargetFallback": true, - "warn": true, - "frameworkReferences": { - "Microsoft.NETCore.App": { - "privateAssets": "all" - } - }, - "runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/3.1.113/RuntimeIdentifierGraph.json" - } - } - } - } -} \ No newline at end of file diff --git a/obj/als-tools.csproj.nuget.g.props b/obj/als-tools.csproj.nuget.g.props deleted file mode 100644 index ffdbd22..0000000 --- a/obj/als-tools.csproj.nuget.g.props +++ /dev/null @@ -1,15 +0,0 @@ - - - - True - NuGet - $(MSBuildThisFileDirectory)project.assets.json - /Users/zenluiz/.nuget/packages/ - /Users/zenluiz/.nuget/packages/ - PackageReference - 5.4.0 - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - \ No newline at end of file diff --git a/obj/als-tools.csproj.nuget.g.targets b/obj/als-tools.csproj.nuget.g.targets deleted file mode 100644 index 53cfaa1..0000000 --- a/obj/als-tools.csproj.nuget.g.targets +++ /dev/null @@ -1,6 +0,0 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - \ No newline at end of file diff --git a/obj/project.assets.json b/obj/project.assets.json deleted file mode 100644 index a53a416..0000000 --- a/obj/project.assets.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "version": 3, - "targets": { - ".NETCoreApp,Version=v3.1": {} - }, - "libraries": {}, - "projectFileDependencyGroups": { - ".NETCoreApp,Version=v3.1": [] - }, - "packageFolders": { - "/Users/zenluiz/.nuget/packages/": {} - }, - "project": { - "version": "1.0.0", - "restore": { - "projectUniqueName": "/Users/zenluiz/Documents/Desenvolvimento/repos/als-tools/als-tools/als-tools.csproj", - "projectName": "als-tools", - "projectPath": "/Users/zenluiz/Documents/Desenvolvimento/repos/als-tools/als-tools/als-tools.csproj", - "packagesPath": "/Users/zenluiz/.nuget/packages/", - "outputPath": "/Users/zenluiz/Documents/Desenvolvimento/repos/als-tools/als-tools/obj/", - "projectStyle": "PackageReference", - "configFilePaths": [ - "/Users/zenluiz/.nuget/NuGet/NuGet.Config" - ], - "originalTargetFrameworks": [ - "netcoreapp3.1" - ], - "sources": { - "https://api.nuget.org/v3/index.json": {} - }, - "frameworks": { - "netcoreapp3.1": { - "projectReferences": {} - } - }, - "warningProperties": { - "warnAsError": [ - "NU1605" - ] - } - }, - "frameworks": { - "netcoreapp3.1": { - "imports": [ - "net461", - "net462", - "net47", - "net471", - "net472", - "net48" - ], - "assetTargetFallback": true, - "warn": true, - "frameworkReferences": { - "Microsoft.NETCore.App": { - "privateAssets": "all" - } - }, - "runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/3.1.113/RuntimeIdentifierGraph.json" - } - } - } -} \ No newline at end of file From c0375eb530988c4f3f05000b538eefb60a5e96a8 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Sat, 27 Mar 2021 14:21:44 -0300 Subject: [PATCH 06/19] Updated gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e471228..001e01b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ +/obj/ +/bin/ *.dll -*.pdb \ No newline at end of file +*.pdb +*.cache From 7a97919d495fd7dc20eef111b949fdbbf219ff96 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Sat, 27 Mar 2021 15:03:37 -0300 Subject: [PATCH 07/19] Added LiteDb to the project --- .gitignore | 1 + .vscode/launch.json | 4 +- App.cs | 4 +- Core/Entities/LiveProject.cs | 5 ++ Core/Interfaces/ILiveProjectRepository.cs | 8 +-- Core/Interfaces/ILiveProjectService.cs | 4 +- Core/Services/LiveProjectService.cs | 4 +- Infrastructure/ILiteDbContext.cs | 9 +++ Infrastructure/LiteDbContext.cs | 3 +- .../Repositories/LiveProjectRepository.cs | 52 +++++++++++--- Program.cs | 72 ++++--------------- appsettings.json | 2 +- 12 files changed, 86 insertions(+), 82 deletions(-) create mode 100644 Infrastructure/ILiteDbContext.cs diff --git a/.gitignore b/.gitignore index 001e01b..92f4bdc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.dll *.pdb *.cache +/LiteDb/ diff --git a/.vscode/launch.json b/.vscode/launch.json index e8e7a63..c71d945 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,8 +14,8 @@ //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], //"args": ["--interactive", "--folder=/Users/zenluiz/Desktop/Testes ALS"], // "args": ["--locate=bass mint", "--folder=/Users/zenluiz/Splice/"], - // "args": ["--list", "--folder=/Users/zenluiz/Splice/"], - "args": ["--initdb", "--folder=/Users/zenluiz/Splice/"], + "args": ["--list"], + // "args": ["--initdb", "--folder=/Users/zenluiz/Splice/"], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console "console": "internalConsole", diff --git a/App.cs b/App.cs index 68779bd..eb95328 100644 --- a/App.cs +++ b/App.cs @@ -15,8 +15,6 @@ namespace AlsTools { public class App { - // private readonly ILogger _logger; - // private readonly AppSettings _appSettings; private readonly ILiveProjectService liveProjectService; public App(ILiveProjectService liveProjectService) @@ -49,7 +47,7 @@ public async Task Run(ProgramArgs args) } } - private async Task PrintProjectsAndPlugins(IList projects) + private async Task PrintProjectsAndPlugins(IEnumerable projects) { foreach (var p in projects) await PrintProjectAndPlugins(p); diff --git a/Core/Entities/LiveProject.cs b/Core/Entities/LiveProject.cs index e44ee0a..4ca1d80 100644 --- a/Core/Entities/LiveProject.cs +++ b/Core/Entities/LiveProject.cs @@ -7,8 +7,11 @@ public class LiveProject public LiveProject() { Plugins = new SortedDictionary(); + //Plugins = new PluginInfo[0]; } + public long Id { get; set; } + public string Name { get; set; } public string Path { get; set; } @@ -16,5 +19,7 @@ public LiveProject() public string LiveVersion { get; set; } public SortedDictionary Plugins { get; set; } + // public PluginInfo[] Plugins { get; set; } + } } \ No newline at end of file diff --git a/Core/Interfaces/ILiveProjectRepository.cs b/Core/Interfaces/ILiveProjectRepository.cs index c636822..b1cbb85 100644 --- a/Core/Interfaces/ILiveProjectRepository.cs +++ b/Core/Interfaces/ILiveProjectRepository.cs @@ -6,12 +6,12 @@ namespace AlsTools.Core.Interfaces { public interface ILiveProjectRepository { - void Insert(LiveProject project); + bool Insert(LiveProject project); - void Insert(IList projects); + int Insert(IEnumerable projects); - IList GetProjectsContainingPlugins(string[] pluginsToLocate); + IEnumerable GetProjectsContainingPlugins(string[] pluginsToLocate); - IList GetAllProjects(); + IEnumerable GetAllProjects(); } } diff --git a/Core/Interfaces/ILiveProjectService.cs b/Core/Interfaces/ILiveProjectService.cs index a5873e9..787af64 100644 --- a/Core/Interfaces/ILiveProjectService.cs +++ b/Core/Interfaces/ILiveProjectService.cs @@ -10,8 +10,8 @@ public interface ILiveProjectService void InitializeDbFromFolder(string folderPath, bool includeBackupFolder); - IList GetAllProjects(); + IEnumerable GetAllProjects(); - IList GetProjectsContainingPlugins(string[] pluginsToLocate); + IEnumerable GetProjectsContainingPlugins(string[] pluginsToLocate); } } diff --git a/Core/Services/LiveProjectService.cs b/Core/Services/LiveProjectService.cs index 0a7f25d..83c5852 100644 --- a/Core/Services/LiveProjectService.cs +++ b/Core/Services/LiveProjectService.cs @@ -18,12 +18,12 @@ public LiveProjectService(ILiveProjectRepository repository, ILiveProjectFileSys this.extractor = extractor; } - public IList GetAllProjects() + public IEnumerable GetAllProjects() { return repository.GetAllProjects(); } - public IList GetProjectsContainingPlugins(string[] pluginsToLocate) + public IEnumerable GetProjectsContainingPlugins(string[] pluginsToLocate) { return repository.GetProjectsContainingPlugins(pluginsToLocate); } diff --git a/Infrastructure/ILiteDbContext.cs b/Infrastructure/ILiteDbContext.cs new file mode 100644 index 0000000..ab2e453 --- /dev/null +++ b/Infrastructure/ILiteDbContext.cs @@ -0,0 +1,9 @@ +using LiteDB; + +namespace AlsTools.Infrastructure +{ + public interface ILiteDbContext + { + LiteDatabase Database { get; } + } +} diff --git a/Infrastructure/LiteDbContext.cs b/Infrastructure/LiteDbContext.cs index f1113f4..97e12da 100644 --- a/Infrastructure/LiteDbContext.cs +++ b/Infrastructure/LiteDbContext.cs @@ -1,11 +1,10 @@ -using System; using AlsTools.Config; using LiteDB; using Microsoft.Extensions.Options; namespace AlsTools.Infrastructure { - public class LiteDbContext// : ILiteDbContext + public class LiteDbContext : ILiteDbContext { public LiteDatabase Database { get; } diff --git a/Infrastructure/Repositories/LiveProjectRepository.cs b/Infrastructure/Repositories/LiveProjectRepository.cs index a2cb711..3e89907 100644 --- a/Infrastructure/Repositories/LiveProjectRepository.cs +++ b/Infrastructure/Repositories/LiveProjectRepository.cs @@ -1,31 +1,65 @@ +using System; using System.Collections.Generic; using AlsTools.Core.Entities; using AlsTools.Core.Interfaces; +using LiteDB; namespace AlsTools.Infrastructure.Repositories { public class LiveProjectRepository : ILiveProjectRepository { - private static List fakeProjects = new List(); + private readonly LiteDatabase liteDb; - public IList GetAllProjects() + public LiveProjectRepository(ILiteDbContext dbContext) { - return fakeProjects; + this.liteDb = dbContext.Database; } - public IList GetProjectsContainingPlugins(string[] pluginsToLocate) + public IEnumerable GetAllProjects() { - return fakeProjects; + return liteDb.GetCollection("LiveProject").FindAll(); } - public void Insert(LiveProject project) + public IEnumerable GetProjectsContainingPlugins(string[] pluginsToLocate) { - fakeProjects.Add(project); + // var col = liteDb.GetCollection("LiveProject"); + // var pluginsList = pluginsToLocate + + // // var projects = col.Query() + // // .Where(x => plu x.Plugins.("J")) + // // .OrderBy(x => x.Name) + // // .Select(x => new { x.Name, NameUpper = x.Name.ToUpper() }) + // // .Limit(10) + // // .ToList(); + // var projects = col + // .Include(x => x.Plugins) + // . + + // return projects; + + throw new NotImplementedException(); + } + + public bool Insert(LiveProject project) + { + var col = liteDb.GetCollection("LiveProject"); + var res = col.Insert(project); + + // Create an index over the Name property (if it doesn't exist) + col.EnsureIndex(x => x.Name); + + return res; } - public void Insert(IList projects) + public int Insert(IEnumerable projects) { - fakeProjects.AddRange(projects); + var col = liteDb.GetCollection("LiveProject"); + var res = col.InsertBulk(projects); + + // Create an index over the Name property (if it doesn't exist) + col.EnsureIndex(x => x.Name); + + return res; } } } diff --git a/Program.cs b/Program.cs index aaf32a4..df9878a 100644 --- a/Program.cs +++ b/Program.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using AlsTools.Config; using AlsTools.Core.Interfaces; using AlsTools.Core.Services; using AlsTools.Infrastructure; @@ -15,8 +16,6 @@ namespace AlsTools { class Program { - // private static AlsToolsManager manager = new AlsToolsManager(); - // private static IConfiguration config = null; private static IConfigurationRoot configuration; private static async Task Main(string[] args) @@ -78,18 +77,22 @@ private static void ConfigureServices(IServiceCollection serviceCollection) // Add access to generic IConfigurationRoot serviceCollection.AddSingleton(configuration); + // Add DbContext + serviceCollection.AddSingleton(); + // Add services serviceCollection .AddTransient() .AddTransient() - .AddTransient() + .AddTransient() .AddTransient(); + serviceCollection.Configure(configuration.GetSection("LiteDbOptions")); + // Add app serviceCollection.AddTransient(); } - private static ProgramArgs ParseArguments(string[] args) { var arguments = GetArguments(args); @@ -98,54 +101,6 @@ private static ProgramArgs ParseArguments(string[] args) PrintArguments(arguments); return arguments; - - // manager.Initialize(arguments); - - // if (arguments.InteractiveMode) - // { - // int? option = null; - // while (option != 3) - // { - // PrintMenu(); - // option = GetOption(); - // if (!option.HasValue) - // continue; - - // if (option == 1) - // arguments.ListPlugins = true; - // else if (option == 2) - // arguments.LocatePlugins = true; - // } - // } - // else - // { - // await manager.Execute(arguments); - // } - - - // return 0; - } - - private static int? GetOption() - { - var opt = Console.Read(); //TODO: não está funcionando - var validOpts = new int[] { 1, 2, 3 }; - - if (!validOpts.Contains(opt)) - { - Console.Error.WriteLine("\tInvalid option. Try again."); - return null; - } - - return opt; - } - - private static void PrintMenu() - { - Console.WriteLine("\nSelect an option"); - Console.WriteLine("\t1 - List plugins"); - Console.WriteLine("\t2 - Locate plugins"); - Console.WriteLine("\t3 - Quit"); } private static void PrintArguments(ProgramArgs args) @@ -170,7 +125,7 @@ private static ProgramArgs GetArguments(string[] arguments) } if (args.IndexOf("--initdb") >= 0) - result.InitDb = true; + result.InitDb = true; if (args.IndexOf("--list") >= 0) result.ListPlugins = true; @@ -203,11 +158,14 @@ private static ProgramArgs GetArguments(string[] arguments) private static void ValidateArguments(ProgramArgs args) { - // Folder or file is always mandatory! - if ((string.IsNullOrWhiteSpace(args.File) && string.IsNullOrWhiteSpace(args.Folder)) || - (!string.IsNullOrWhiteSpace(args.File) && !string.IsNullOrWhiteSpace(args.Folder))) + if (args.InitDb) { - throw new ArgumentException("Please specify either a folder or file at least"); + // Folder or file is always mandatory for initializing the DB! + if ((string.IsNullOrWhiteSpace(args.File) && string.IsNullOrWhiteSpace(args.Folder)) || + (!string.IsNullOrWhiteSpace(args.File) && !string.IsNullOrWhiteSpace(args.Folder))) + { + throw new ArgumentException("Please specify either a folder or file at least"); + } } if ((args.ListPlugins && args.LocatePlugins && args.InitDb) || (!args.ListPlugins && !args.LocatePlugins && !args.InitDb)) diff --git a/appsettings.json b/appsettings.json index 5831320..ff31d38 100644 --- a/appsettings.json +++ b/appsettings.json @@ -1,5 +1,5 @@ { "LiteDbOptions": { - "DatabaseLocation": "LiteDb/LiteDbTest.db" + "DatabaseLocation": "LiteDb/AlsToolsDb.db" } } \ No newline at end of file From cf547a0744c9d3f04ac4c8c76c23b16323e3671a Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Sat, 27 Mar 2021 15:38:16 -0300 Subject: [PATCH 08/19] Using IHost and Injecting ILogger into services --- App.cs | 14 ++-- Core/Services/LiveProjectService.cs | 5 +- Infrastructure/LiveProjectExtractor.cs | 11 ++- .../Repositories/LiveProjectRepository.cs | 11 ++- Program.cs | 68 ++++++++++--------- als-tools.csproj | 1 + 6 files changed, 67 insertions(+), 43 deletions(-) diff --git a/App.cs b/App.cs index eb95328..a919711 100644 --- a/App.cs +++ b/App.cs @@ -1,29 +1,27 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.IO.Compression; -using System.Linq; using System.Threading.Tasks; -using System.Xml; -using System.Xml.XPath; using AlsTools.Core.Entities; using AlsTools.Core.Interfaces; +using Microsoft.Extensions.Logging; namespace AlsTools { public class App { + private readonly ILogger logger; private readonly ILiveProjectService liveProjectService; - public App(ILiveProjectService liveProjectService) + public App(ILogger logger, ILiveProjectService liveProjectService) { + this.logger = logger; this.liveProjectService = liveProjectService; } public async Task Run(ProgramArgs args) { + logger.LogDebug("App start"); + if (args.InitDb) { if (!string.IsNullOrEmpty(args.File)) diff --git a/Core/Services/LiveProjectService.cs b/Core/Services/LiveProjectService.cs index 83c5852..8e1c6e5 100644 --- a/Core/Services/LiveProjectService.cs +++ b/Core/Services/LiveProjectService.cs @@ -2,17 +2,20 @@ using System.Collections.Generic; using AlsTools.Core.Entities; using AlsTools.Core.Interfaces; +using Microsoft.Extensions.Logging; namespace AlsTools.Core.Services { public class LiveProjectService : ILiveProjectService { + private readonly ILogger logger; private readonly ILiveProjectRepository repository; private readonly ILiveProjectFileSystem fs; private readonly ILiveProjectExtractor extractor; - public LiveProjectService(ILiveProjectRepository repository, ILiveProjectFileSystem fs, ILiveProjectExtractor extractor) + public LiveProjectService(ILogger logger, ILiveProjectRepository repository, ILiveProjectFileSystem fs, ILiveProjectExtractor extractor) { + this.logger = logger; this.repository = repository; this.fs = fs; this.extractor = extractor; diff --git a/Infrastructure/LiveProjectExtractor.cs b/Infrastructure/LiveProjectExtractor.cs index 3d73ee2..013b6e4 100644 --- a/Infrastructure/LiveProjectExtractor.cs +++ b/Infrastructure/LiveProjectExtractor.cs @@ -3,16 +3,25 @@ using System.IO.Compression; using System.Xml; using System.Xml.XPath; -using AlsTools; using AlsTools.Core.Entities; using AlsTools.Core.Interfaces; +using Microsoft.Extensions.Logging; namespace AlsTools.Infrastructure { public class LiveProjectExtractor : ILiveProjectExtractor { + ILogger logger; + + public LiveProjectExtractor(ILogger logger) + { + this.logger = logger; + } + public LiveProject ExtractProjectFromFile(FileInfo file) { + logger.LogDebug("Extracting file {file}", file.Name); + var project = new LiveProject() { Name = file.Name, Path = file.FullName }; var plugins = new SortedSet(); var settings = new XmlReaderSettings() { IgnoreWhitespace = true }; diff --git a/Infrastructure/Repositories/LiveProjectRepository.cs b/Infrastructure/Repositories/LiveProjectRepository.cs index 3e89907..4cf2135 100644 --- a/Infrastructure/Repositories/LiveProjectRepository.cs +++ b/Infrastructure/Repositories/LiveProjectRepository.cs @@ -3,16 +3,21 @@ using AlsTools.Core.Entities; using AlsTools.Core.Interfaces; using LiteDB; +using Microsoft.Extensions.Logging; namespace AlsTools.Infrastructure.Repositories { public class LiveProjectRepository : ILiveProjectRepository { private readonly LiteDatabase liteDb; + private readonly ILogger logger; + private readonly ILiteDbContext dbContext; - public LiveProjectRepository(ILiteDbContext dbContext) + public LiveProjectRepository(ILogger logger, ILiteDbContext dbContext) { this.liteDb = dbContext.Database; + this.logger = logger; + this.dbContext = dbContext; } public IEnumerable GetAllProjects() @@ -48,6 +53,8 @@ public bool Insert(LiveProject project) // Create an index over the Name property (if it doesn't exist) col.EnsureIndex(x => x.Name); + logger.LogDebug("Insert result {Result}", res); + return res; } @@ -59,6 +66,8 @@ public int Insert(IEnumerable projects) // Create an index over the Name property (if it doesn't exist) col.EnsureIndex(x => x.Name); + logger.LogDebug("Inserted {InsertedProjects} projects", res); + return res; } } diff --git a/Program.cs b/Program.cs index df9878a..434ad99 100644 --- a/Program.cs +++ b/Program.cs @@ -10,7 +10,9 @@ using AlsTools.Infrastructure.Repositories; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Serilog; +using Serilog.Events; namespace AlsTools { @@ -20,52 +22,54 @@ class Program private static async Task Main(string[] args) { - // Initialize serilog logger Log.Logger = new LoggerConfiguration() - .WriteTo.Console(Serilog.Events.LogEventLevel.Debug) .MinimumLevel.Debug() + .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .Enrich.FromLogContext() + .WriteTo.Console() .CreateLogger(); - Log.Debug("Creating service collection"); - var serviceCollection = new ServiceCollection(); - ConfigureServices(serviceCollection); + Log.Debug("Building host"); + var host = BuildHost(args); - Log.Debug("Building service provider"); - var serviceProvider = serviceCollection.BuildServiceProvider(); - - try + using (var serviceScope = host.Services.CreateScope()) { - Log.Debug("Parsing arguments"); - var arguments = ParseArguments(args); + var services = serviceScope.ServiceProvider; - Log.Debug("Starting application"); - var app = serviceProvider.GetService(); - await app.Run(arguments); + try + { + Log.Debug("Parsing arguments"); + var arguments = ParseArguments(args); - Log.Debug("Returning 0"); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "An error occured. Returning code 1"); - return 1; - } - finally - { - Log.CloseAndFlush(); + Log.Debug("Starting application"); + var app = services.GetRequiredService(); + await app.Run(arguments); + + Log.Debug("Returning 0"); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "An error occured. Returning code 1"); + return 1; + } + finally + { + Log.CloseAndFlush(); + } } } - private static void ConfigureServices(IServiceCollection serviceCollection) + public static IHost BuildHost(string[] args) { - // Add logging - // serviceCollection.AddSingleton(LoggerFactory.Create(builder => - // { - // builder - // .AddSerilog(dispose: true); - // })); + return new HostBuilder() + .ConfigureServices(ConfigureServices) + .UseSerilog() + .Build(); + } + private static void ConfigureServices(IServiceCollection serviceCollection) + { serviceCollection.AddLogging(); // Build configuration diff --git a/als-tools.csproj b/als-tools.csproj index 4108cf9..d8256c6 100644 --- a/als-tools.csproj +++ b/als-tools.csproj @@ -22,6 +22,7 @@ + From 5bb6d230ae806e8d8f4c885aabdd1d4421f07fd4 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Sat, 27 Mar 2021 20:59:39 -0300 Subject: [PATCH 09/19] Implemented Search in memory --- .vscode/launch.json | 8 +-- .vscode/tasks.json | 12 +++++ Core/Interfaces/ILiveProjectRepository.cs | 2 + Core/Services/LiveProjectService.cs | 8 +-- DevReferences.md | 8 +++ .../FileSystem/LiveProjectFileSystem.cs | 3 +- Infrastructure/LiveProjectExtractor.cs | 2 +- .../Repositories/LiveProjectRepository.cs | 51 +++++++++++++++---- 8 files changed, 75 insertions(+), 19 deletions(-) create mode 100644 DevReferences.md diff --git a/.vscode/launch.json b/.vscode/launch.json index c71d945..0947d33 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,10 +12,10 @@ // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/als-tools.dll", //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], - //"args": ["--interactive", "--folder=/Users/zenluiz/Desktop/Testes ALS"], - // "args": ["--locate=bass mint", "--folder=/Users/zenluiz/Splice/"], - "args": ["--list"], - // "args": ["--initdb", "--folder=/Users/zenluiz/Splice/"], + "args": ["--locate=HG-2"], + // "args": ["--list"], + // "args": ["--initdb", "--folder=/Users/zenluiz/Desktop/Testes ALS"], + // "args": ["--initdb", "--folder=/Users/zenluiz/Splice"], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console "console": "internalConsole", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3b017ca..34683dd 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -13,6 +13,18 @@ ], "problemMatcher": "$msCompile" }, + { + "label": "clean", + "command": "dotnet", + "type": "process", + "args": [ + "clean", + "${workspaceFolder}/als-tools.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, { "label": "publish", "command": "dotnet", diff --git a/Core/Interfaces/ILiveProjectRepository.cs b/Core/Interfaces/ILiveProjectRepository.cs index b1cbb85..d6a0952 100644 --- a/Core/Interfaces/ILiveProjectRepository.cs +++ b/Core/Interfaces/ILiveProjectRepository.cs @@ -13,5 +13,7 @@ public interface ILiveProjectRepository IEnumerable GetProjectsContainingPlugins(string[] pluginsToLocate); IEnumerable GetAllProjects(); + + void DeleteAll(); } } diff --git a/Core/Services/LiveProjectService.cs b/Core/Services/LiveProjectService.cs index 8e1c6e5..f73e333 100644 --- a/Core/Services/LiveProjectService.cs +++ b/Core/Services/LiveProjectService.cs @@ -32,17 +32,19 @@ public IEnumerable GetProjectsContainingPlugins(string[] pluginsToL } public void InitializeDbFromFile(string filePath) - { - var project = LoadProjectFromSetFile(filePath); + { + repository.DeleteAll(); + var project = LoadProjectFromSetFile(filePath); repository.Insert(project); } public void InitializeDbFromFolder(string folderPath, bool includeBackupFolder) { + repository.DeleteAll(); var projects = LoadProjectsFromDirectory(folderPath, includeBackupFolder); repository.Insert(projects); } - + private LiveProject LoadProjectFromSetFile(string setFilePath) { var file = fs.LoadProjectFileFromSetFile(setFilePath); diff --git a/DevReferences.md b/DevReferences.md new file mode 100644 index 0000000..50ec02e --- /dev/null +++ b/DevReferences.md @@ -0,0 +1,8 @@ +https://www.thecodebuzz.com/dependency-injection-console-app-using-generic-hostbuilder/ +https://dfederm.com/building-a-console-app-with-.net-generic-host/ +https://github.com/serilog/serilog-extensions-hosting +https://keestalkstech.com/2018/04/dependency-injection-with-ioptions-in-console-apps-in-net-core-2/ +https://blog.bitscry.com/2017/05/30/appsettings-json-in-net-core-console-app/ +https://social.technet.microsoft.com/wiki/contents/articles/53416.using-litedb-in-an-asp-net-core-api.aspx +https://blog.georgekosmidis.net/2019/11/02/using-litedb-in-an-asp-net-core-api/ +https://www.litedb.org/ \ No newline at end of file diff --git a/Infrastructure/FileSystem/LiveProjectFileSystem.cs b/Infrastructure/FileSystem/LiveProjectFileSystem.cs index e2e59fe..e9af87d 100644 --- a/Infrastructure/FileSystem/LiveProjectFileSystem.cs +++ b/Infrastructure/FileSystem/LiveProjectFileSystem.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -13,7 +14,7 @@ public IEnumerable LoadProjectFilesFromDirectory(string folderPath, bo var files = d.GetFiles("*.als", new EnumerationOptions() { RecurseSubdirectories = true }).AsEnumerable(); if (!includeBackupFolder) - files = files.Where(x => !x.FullName.Contains(@"\backup\")); + files = files.Where(x => !x.FullName.Contains(@"/Backup/", StringComparison.InvariantCultureIgnoreCase)); return files; } diff --git a/Infrastructure/LiveProjectExtractor.cs b/Infrastructure/LiveProjectExtractor.cs index 013b6e4..cc90ff7 100644 --- a/Infrastructure/LiveProjectExtractor.cs +++ b/Infrastructure/LiveProjectExtractor.cs @@ -20,7 +20,7 @@ public LiveProjectExtractor(ILogger logger) public LiveProject ExtractProjectFromFile(FileInfo file) { - logger.LogDebug("Extracting file {file}", file.Name); + logger.LogDebug("Extracting file {file}", file.FullName); var project = new LiveProject() { Name = file.Name, Path = file.FullName }; var plugins = new SortedSet(); diff --git a/Infrastructure/Repositories/LiveProjectRepository.cs b/Infrastructure/Repositories/LiveProjectRepository.cs index 4cf2135..e73047c 100644 --- a/Infrastructure/Repositories/LiveProjectRepository.cs +++ b/Infrastructure/Repositories/LiveProjectRepository.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using AlsTools.Core.Entities; using AlsTools.Core.Interfaces; using LiteDB; @@ -20,6 +21,12 @@ public LiveProjectRepository(ILogger logger, ILiteDbConte this.dbContext = dbContext; } + public void DeleteAll() + { + var deletedCount = liteDb.GetCollection("LiveProject").DeleteAll(); + logger.LogDebug("Deleted {DeletedCount} projects", deletedCount); + } + public IEnumerable GetAllProjects() { return liteDb.GetCollection("LiveProject").FindAll(); @@ -28,21 +35,45 @@ public IEnumerable GetAllProjects() public IEnumerable GetProjectsContainingPlugins(string[] pluginsToLocate) { // var col = liteDb.GetCollection("LiveProject"); + // var pluginsList = pluginsToLocate - // // var projects = col.Query() - // // .Where(x => plu x.Plugins.("J")) - // // .OrderBy(x => x.Name) - // // .Select(x => new { x.Name, NameUpper = x.Name.ToUpper() }) - // // .Limit(10) - // // .ToList(); // var projects = col - // .Include(x => x.Plugins) - // . + // .Query() + // .Where(proj => proj.Plugins != null && proj.Plugins.Any(k => pluginsToLocate.Any(x => k.Name.Contains(x, StringComparison.InvariantCultureIgnoreCase)))) + // .Select(p => p) + // .ToEnumerable(); - // return projects; + // var projects = col + // .Query() + // .Where(proj => proj.Plugins.Where(plugin => pluginsToLocate.Contains(plugin.Name)).Any()) + // .Select(p => p) + // .ToEnumerable(); + + // var projects = col + // .Query() + // .Where(proj => + // proj.Plugins.Where(plugin => + // pluginsToLocate.Any(p => p.Contains(plugin.Name, StringComparison.InvariantCultureIgnoreCase)) + // ).Any() + // ) + // .Select(p => p) + // .ToEnumerable(); + + // var projects = col + // .Include(x => x.Plugins) + // .FindAll() + // .Where(p => p.Plugins.Intersect(pluginsToLocate)) + + var projects = GetAllProjects(); + IList res = new List(); + foreach (var p in projects) + { + if (p.Plugins.Any(x => pluginsToLocate.Any(y => x.Key.Contains(y, StringComparison.InvariantCultureIgnoreCase)))) + res.Add(p); + } - throw new NotImplementedException(); + return res.AsEnumerable(); } public bool Insert(LiveProject project) From 540ddc6812458c62f50fcb87a397233ee9d7d8bd Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Sat, 27 Mar 2021 21:56:38 -0300 Subject: [PATCH 10/19] Implemented CountProjects. Updated README --- .vscode/launch.json | 4 +-- App.cs | 22 ++++++++++--- Core/Entities/LiveProject.cs | 2 +- Core/Interfaces/ILiveProjectRepository.cs | 2 ++ Core/Interfaces/ILiveProjectService.cs | 6 ++-- Core/Services/LiveProjectService.cs | 15 ++++++--- .../Repositories/LiveProjectRepository.cs | 9 +++++- Program.cs | 9 ++++-- ProgramArgs.cs | 2 ++ README.md | 32 +++++++++++++++++++ 10 files changed, 85 insertions(+), 18 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0947d33..1179992 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,8 +12,8 @@ // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/als-tools.dll", //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], - "args": ["--locate=HG-2"], - // "args": ["--list"], + // "args": ["--locate=mint"], + "args": ["--list"], // "args": ["--initdb", "--folder=/Users/zenluiz/Desktop/Testes ALS"], // "args": ["--initdb", "--folder=/Users/zenluiz/Splice"], "cwd": "${workspaceFolder}", diff --git a/App.cs b/App.cs index a919711..5d9a22e 100644 --- a/App.cs +++ b/App.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using AlsTools.Core.Entities; using AlsTools.Core.Interfaces; @@ -24,20 +25,31 @@ public async Task Run(ProgramArgs args) if (args.InitDb) { + int count = 0; if (!string.IsNullOrEmpty(args.File)) - liveProjectService.InitializeDbFromFile(args.File); + count = liveProjectService.InitializeDbFromFile(args.File); else - liveProjectService.InitializeDbFromFolder(args.Folder, args.IncludeBackups); + count = liveProjectService.InitializeDbFromFolder(args.Folder, args.IncludeBackups); + + await Console.Out.WriteLineAsync($"\nTotal of projects loaded into DB: {count}"); + } + else if (args.CountProjects) + { + int count = liveProjectService.CountProjects(); + + await Console.Out.WriteLineAsync($"\nTotal of projects in the DB: {count}"); } else if (args.ListPlugins) { - var projects = liveProjectService.GetAllProjects(); + var projects = liveProjectService.GetAllProjects().ToList(); await PrintProjectsAndPlugins(projects); + await Console.Out.WriteLineAsync($"\nTotal of projects: {projects.Count}"); } else if (args.LocatePlugins) { - var projects = liveProjectService.GetProjectsContainingPlugins(args.PluginsToLocate); + var projects = liveProjectService.GetProjectsContainingPlugins(args.PluginsToLocate).ToList(); await PrintProjectsAndPlugins(projects); + await Console.Out.WriteLineAsync($"\nTotal of projects: {projects.Count}"); } else { @@ -57,7 +69,7 @@ private async Task PrintProjectAndPlugins(LiveProject project) await Console.Out.WriteLineAsync($"Project name: {project.Name}"); await Console.Out.WriteLineAsync($"Full path: {project.Path}"); await Console.Out.WriteLineAsync("\tPlugins:"); - + if (project.Plugins.Count == 0) await Console.Out.WriteLineAsync("\t\tNo plugins found!"); diff --git a/Core/Entities/LiveProject.cs b/Core/Entities/LiveProject.cs index 4ca1d80..90b974e 100644 --- a/Core/Entities/LiveProject.cs +++ b/Core/Entities/LiveProject.cs @@ -10,7 +10,7 @@ public LiveProject() //Plugins = new PluginInfo[0]; } - public long Id { get; set; } + public int Id { get; set; } public string Name { get; set; } diff --git a/Core/Interfaces/ILiveProjectRepository.cs b/Core/Interfaces/ILiveProjectRepository.cs index d6a0952..45ceb4b 100644 --- a/Core/Interfaces/ILiveProjectRepository.cs +++ b/Core/Interfaces/ILiveProjectRepository.cs @@ -15,5 +15,7 @@ public interface ILiveProjectRepository IEnumerable GetAllProjects(); void DeleteAll(); + + int CountProjects(); } } diff --git a/Core/Interfaces/ILiveProjectService.cs b/Core/Interfaces/ILiveProjectService.cs index 787af64..ec8ae93 100644 --- a/Core/Interfaces/ILiveProjectService.cs +++ b/Core/Interfaces/ILiveProjectService.cs @@ -6,12 +6,14 @@ namespace AlsTools.Core.Interfaces { public interface ILiveProjectService { - void InitializeDbFromFile(string filePath); + int InitializeDbFromFile(string filePath); - void InitializeDbFromFolder(string folderPath, bool includeBackupFolder); + int InitializeDbFromFolder(string folderPath, bool includeBackupFolder); IEnumerable GetAllProjects(); IEnumerable GetProjectsContainingPlugins(string[] pluginsToLocate); + + int CountProjects(); } } diff --git a/Core/Services/LiveProjectService.cs b/Core/Services/LiveProjectService.cs index f73e333..147133a 100644 --- a/Core/Services/LiveProjectService.cs +++ b/Core/Services/LiveProjectService.cs @@ -21,6 +21,11 @@ public LiveProjectService(ILogger logger, ILiveProjectReposi this.extractor = extractor; } + public int CountProjects() + { + return repository.CountProjects(); + } + public IEnumerable GetAllProjects() { return repository.GetAllProjects(); @@ -31,18 +36,18 @@ public IEnumerable GetProjectsContainingPlugins(string[] pluginsToL return repository.GetProjectsContainingPlugins(pluginsToLocate); } - public void InitializeDbFromFile(string filePath) + public int InitializeDbFromFile(string filePath) { repository.DeleteAll(); - var project = LoadProjectFromSetFile(filePath); - repository.Insert(project); + var project = LoadProjectFromSetFile(filePath); + return repository.Insert(project) ? 1 : 0; } - public void InitializeDbFromFolder(string folderPath, bool includeBackupFolder) + public int InitializeDbFromFolder(string folderPath, bool includeBackupFolder) { repository.DeleteAll(); var projects = LoadProjectsFromDirectory(folderPath, includeBackupFolder); - repository.Insert(projects); + return repository.Insert(projects); } private LiveProject LoadProjectFromSetFile(string setFilePath) diff --git a/Infrastructure/Repositories/LiveProjectRepository.cs b/Infrastructure/Repositories/LiveProjectRepository.cs index e73047c..bc00bb0 100644 --- a/Infrastructure/Repositories/LiveProjectRepository.cs +++ b/Infrastructure/Repositories/LiveProjectRepository.cs @@ -21,6 +21,11 @@ public LiveProjectRepository(ILogger logger, ILiteDbConte this.dbContext = dbContext; } + public int CountProjects() + { + return liteDb.GetCollection("LiveProject").Count(); + } + public void DeleteAll() { var deletedCount = liteDb.GetCollection("LiveProject").DeleteAll(); @@ -64,7 +69,9 @@ public IEnumerable GetProjectsContainingPlugins(string[] pluginsToL // .Include(x => x.Plugins) // .FindAll() // .Where(p => p.Plugins.Intersect(pluginsToLocate)) - + + //TODO: implement it correctly + var projects = GetAllProjects(); IList res = new List(); foreach (var p in projects) diff --git a/Program.cs b/Program.cs index 434ad99..4e33f9c 100644 --- a/Program.cs +++ b/Program.cs @@ -131,6 +131,9 @@ private static ProgramArgs GetArguments(string[] arguments) if (args.IndexOf("--initdb") >= 0) result.InitDb = true; + if (args.IndexOf("--count") >= 0) + result.CountProjects = true; + if (args.IndexOf("--list") >= 0) result.ListPlugins = true; @@ -172,8 +175,10 @@ private static void ValidateArguments(ProgramArgs args) } } - if ((args.ListPlugins && args.LocatePlugins && args.InitDb) || (!args.ListPlugins && !args.LocatePlugins && !args.InitDb)) - throw new ArgumentException("Please specify either --initdb or --list or --locate option"); + if ((args.ListPlugins && args.LocatePlugins && args.InitDb && args.CountProjects) || (!args.ListPlugins && !args.LocatePlugins && !args.InitDb && !args.CountProjects)) + throw new ArgumentException("Please specify either --initdb or --count or --list or --locate option"); + + //TODO: implement validation of all other possibilities } } } diff --git a/ProgramArgs.cs b/ProgramArgs.cs index 82df753..2359d3a 100644 --- a/ProgramArgs.cs +++ b/ProgramArgs.cs @@ -20,6 +20,8 @@ public ProgramArgs() public bool IncludeBackups { get; set; } public bool InitDb { get; set; } + + public bool CountProjects { get; set; } } } diff --git a/README.md b/README.md index 3dfeaee..03e02fa 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,34 @@ # als-tools Ableton Live Set tools + +## Building +``` +dotnet build *.sln --configuration Release +``` + +## Running + +Supposing your Live sets are under `/Users/myuser/Music/Projects`, the following command **must be executed first** so that it reads all Live sets plus its plugins and loads them into the application database for further analysis. + +``` +dotnet run --no-build --initdb --folder=/Users/myuser/Music/Projects +``` + +After the database is initialized, you can execute further commands. + +- To count how many projects there are in the database: + ``` + dotnet run --no-build --count + ``` + +- To list all Live projects and its plugins: + ``` + dotnet run --no-build --list + ``` + +- To locate all projects containing at least one of the plugins: + ``` + dotnet run --no-build --locate=plugin1;plugin2 ... + ``` + > Where *plugin1* and *plugin2*, etc, should be the names of the plugins to locate projects using them. + > Example: dotnet run --no-build --locate="Abbey Road Vinyl";HG-2;bx_solo \ No newline at end of file From ea635ba16bbdc72f542df52f54be3fe15bd9d232 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Sat, 27 Mar 2021 22:01:58 -0300 Subject: [PATCH 11/19] Updated README --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 03e02fa..a5d10dc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ -# als-tools -Ableton Live Set tools +# Ableton Live Set tools + +## Introduction +Use this tool to list all Ableton Live sets and their plugins or locate projects which are using some plugin. ## Building ``` @@ -7,7 +9,6 @@ dotnet build *.sln --configuration Release ``` ## Running - Supposing your Live sets are under `/Users/myuser/Music/Projects`, the following command **must be executed first** so that it reads all Live sets plus its plugins and loads them into the application database for further analysis. ``` @@ -31,4 +32,8 @@ After the database is initialized, you can execute further commands. dotnet run --no-build --locate=plugin1;plugin2 ... ``` > Where *plugin1* and *plugin2*, etc, should be the names of the plugins to locate projects using them. - > Example: dotnet run --no-build --locate="Abbey Road Vinyl";HG-2;bx_solo \ No newline at end of file + > Example: dotnet run --no-build --locate="Abbey Road Vinyl";HG-2;bx_solo + +## Next steps +- Export to Text, CSV, HTML, etc. +- Find a way to locate plugins using LiteDb own API. \ No newline at end of file From ebc10984ccf345dbcefa55890fa3272f5b0b90c0 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Mon, 5 Apr 2021 22:10:25 -0300 Subject: [PATCH 12/19] nothing special... --- .vscode/launch.json | 4 ++-- .../Repositories/LiveProjectRepository.cs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 1179992..b957bd7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,8 +12,8 @@ // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/als-tools.dll", //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], - // "args": ["--locate=mint"], - "args": ["--list"], + "args": ["--locate=HG2"], + // "args": ["--list"], // "args": ["--initdb", "--folder=/Users/zenluiz/Desktop/Testes ALS"], // "args": ["--initdb", "--folder=/Users/zenluiz/Splice"], "cwd": "${workspaceFolder}", diff --git a/Infrastructure/Repositories/LiveProjectRepository.cs b/Infrastructure/Repositories/LiveProjectRepository.cs index bc00bb0..18b03e2 100644 --- a/Infrastructure/Repositories/LiveProjectRepository.cs +++ b/Infrastructure/Repositories/LiveProjectRepository.cs @@ -81,6 +81,20 @@ public IEnumerable GetProjectsContainingPlugins(string[] pluginsToL } return res.AsEnumerable(); + + // var pluginToLocate = pluginsToLocate[0]; + // var col = liteDb.GetCollection("LiveProject"); + + // var query = @"SELECT { $.*, $.Plugins[*] FROM LiveProject } WHERE $.Plugins[*].Title LIKE '%" + pluginToLocate + "%'"; + // var s = liteDb.Execute(query).ToList(); + + // var res = col.Query() + // .Where(proj => proj.Plugins.Any(p => p.Key.Contains(pluginToLocate, StringComparison.InvariantCultureIgnoreCase)).Any()) + // .Select(x => x); + + // return res.ToEnumerable(); + + // return null; } public bool Insert(LiveProject project) From 7b271fa18c5f4865cd9c12a619c0b937e95a869a Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Mon, 12 Apr 2021 23:27:29 -0300 Subject: [PATCH 13/19] Implemented track, live device and plugins parsing --- .vscode/launch.json | 4 +- App.cs | 31 +++- Core/Entities/Devices/BaseDevice.cs | 15 ++ Core/Entities/Devices/DeviceType.cs | 9 ++ Core/Entities/Devices/IDevice.cs | 9 ++ Core/Entities/Devices/LiveDevice.cs | 10 ++ Core/Entities/Devices/PluginDevice.cs | 11 ++ Core/Entities/LiveProject.cs | 8 +- Core/Entities/PluginInfo.cs | 8 - Core/Entities/PluginType.cs | 2 + Core/Entities/TrackType.cs | 13 ++ Core/Entities/Tracks/AudioTrack.cs | 9 ++ Core/Entities/Tracks/BaseTrack.cs | 54 +++++++ Core/Entities/Tracks/ITrack.cs | 18 +++ Core/Entities/Tracks/MasterTrack.cs | 9 ++ Core/Entities/Tracks/MidiTrack.cs | 9 ++ Core/Entities/Tracks/ReturnTrack.cs | 9 ++ Core/Factories/DeviceFactory.cs | 20 +++ Core/Factories/TrackFactory.cs | 26 +++ Infrastructure/LiveProjectExtractor.cs | 149 +++++++++++++++--- .../Repositories/LiveProjectRepository.cs | 12 +- Program.cs | 15 +- ProgramArgs.cs | 4 + 23 files changed, 408 insertions(+), 46 deletions(-) create mode 100644 Core/Entities/Devices/BaseDevice.cs create mode 100644 Core/Entities/Devices/DeviceType.cs create mode 100644 Core/Entities/Devices/IDevice.cs create mode 100644 Core/Entities/Devices/LiveDevice.cs create mode 100644 Core/Entities/Devices/PluginDevice.cs delete mode 100644 Core/Entities/PluginInfo.cs create mode 100644 Core/Entities/TrackType.cs create mode 100644 Core/Entities/Tracks/AudioTrack.cs create mode 100644 Core/Entities/Tracks/BaseTrack.cs create mode 100644 Core/Entities/Tracks/ITrack.cs create mode 100644 Core/Entities/Tracks/MasterTrack.cs create mode 100644 Core/Entities/Tracks/MidiTrack.cs create mode 100644 Core/Entities/Tracks/ReturnTrack.cs create mode 100644 Core/Factories/DeviceFactory.cs create mode 100644 Core/Factories/TrackFactory.cs diff --git a/.vscode/launch.json b/.vscode/launch.json index b957bd7..9c92418 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,9 +12,9 @@ // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/als-tools.dll", //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], - "args": ["--locate=HG2"], + //"args": ["--locate=HG2"], // "args": ["--list"], - // "args": ["--initdb", "--folder=/Users/zenluiz/Desktop/Testes ALS"], + "args": ["--initdb", "--folder=/Users/zenluiz/Desktop/Testes ALS"], // "args": ["--initdb", "--folder=/Users/zenluiz/Splice"], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/App.cs b/App.cs index 5d9a22e..202822a 100644 --- a/App.cs +++ b/App.cs @@ -51,12 +51,23 @@ public async Task Run(ProgramArgs args) await PrintProjectsAndPlugins(projects); await Console.Out.WriteLineAsync($"\nTotal of projects: {projects.Count}"); } + else if (args.Export) + { + var projects = liveProjectService.GetAllProjects().ToList(); + await ExportProjectsAndPlugins(projects); + await Console.Out.WriteLineAsync($"\nTotal of projects: {projects.Count}"); + } else { throw new InvalidOperationException("Nothing to do?"); } } + private Task ExportProjectsAndPlugins(List projects) + { + throw new NotImplementedException(); + } + private async Task PrintProjectsAndPlugins(IEnumerable projects) { foreach (var p in projects) @@ -68,13 +79,23 @@ private async Task PrintProjectAndPlugins(LiveProject project) await Console.Out.WriteLineAsync("------------------------------------------------------------------------------"); await Console.Out.WriteLineAsync($"Project name: {project.Name}"); await Console.Out.WriteLineAsync($"Full path: {project.Path}"); - await Console.Out.WriteLineAsync("\tPlugins:"); + await Console.Out.WriteLineAsync("\tTracks and plugins:"); - if (project.Plugins.Count == 0) - await Console.Out.WriteLineAsync("\t\tNo plugins found!"); + if (project.Tracks.Count == 0) + await Console.Out.WriteLineAsync("\t\tNo tracks found!"); + + foreach (var tr in project.Tracks) + { + await Console.Out.WriteLineAsync($"\t\tName = {tr.Name} | Type = {tr.Type}"); - foreach (var plugin in project.Plugins) - await Console.Out.WriteLineAsync($"\t\tName = {plugin.Value.Name} | Type = {plugin.Value.Type}"); + await Console.Out.WriteLineAsync("\t\t\tLive Devices:"); + foreach (var ld in tr.Devices) + await Console.Out.WriteLineAsync($"\t\t\t\tName = {ld.Key}"); + + await Console.Out.WriteLineAsync("\t\t\tPlugins:"); + foreach (var p in tr.Plugins) + await Console.Out.WriteLineAsync($"\t\t\t\tName = {p.Key} | Type = {p.Value.PluginType}"); + } } } } diff --git a/Core/Entities/Devices/BaseDevice.cs b/Core/Entities/Devices/BaseDevice.cs new file mode 100644 index 0000000..15278e7 --- /dev/null +++ b/Core/Entities/Devices/BaseDevice.cs @@ -0,0 +1,15 @@ + +namespace AlsTools.Core.Entities.Devices +{ + public abstract class BaseDevice : IDevice + { + public BaseDevice(DeviceType type) + { + Type = type; + } + + public string Name { get; set; } + + public DeviceType Type { get; protected set; } + } +} diff --git a/Core/Entities/Devices/DeviceType.cs b/Core/Entities/Devices/DeviceType.cs new file mode 100644 index 0000000..9cd7cc7 --- /dev/null +++ b/Core/Entities/Devices/DeviceType.cs @@ -0,0 +1,9 @@ +namespace AlsTools.Core.Entities.Devices +{ + public enum DeviceType + { + LiveDevice, + + Plugin + } +} \ No newline at end of file diff --git a/Core/Entities/Devices/IDevice.cs b/Core/Entities/Devices/IDevice.cs new file mode 100644 index 0000000..8e6ee9a --- /dev/null +++ b/Core/Entities/Devices/IDevice.cs @@ -0,0 +1,9 @@ +namespace AlsTools.Core.Entities.Devices +{ + public interface IDevice + { + string Name { get; set; } + + DeviceType Type { get; } + } +} diff --git a/Core/Entities/Devices/LiveDevice.cs b/Core/Entities/Devices/LiveDevice.cs new file mode 100644 index 0000000..64f2960 --- /dev/null +++ b/Core/Entities/Devices/LiveDevice.cs @@ -0,0 +1,10 @@ + +namespace AlsTools.Core.Entities.Devices +{ + public class LiveDevice : BaseDevice, IDevice + { + public LiveDevice() : base(DeviceType.LiveDevice) + { + } + } +} diff --git a/Core/Entities/Devices/PluginDevice.cs b/Core/Entities/Devices/PluginDevice.cs new file mode 100644 index 0000000..1bf92d2 --- /dev/null +++ b/Core/Entities/Devices/PluginDevice.cs @@ -0,0 +1,11 @@ +namespace AlsTools.Core.Entities.Devices +{ + public class PluginDevice : BaseDevice, IDevice + { + public PluginDevice() : base(DeviceType.Plugin) + { + } + + public PluginType PluginType { get; set; } + } +} diff --git a/Core/Entities/LiveProject.cs b/Core/Entities/LiveProject.cs index 90b974e..6e7a663 100644 --- a/Core/Entities/LiveProject.cs +++ b/Core/Entities/LiveProject.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using AlsTools.Core.Entities.Tracks; namespace AlsTools.Core.Entities { @@ -6,8 +7,7 @@ public class LiveProject { public LiveProject() { - Plugins = new SortedDictionary(); - //Plugins = new PluginInfo[0]; + Tracks = new List(); } public int Id { get; set; } @@ -18,8 +18,6 @@ public LiveProject() public string LiveVersion { get; set; } - public SortedDictionary Plugins { get; set; } - // public PluginInfo[] Plugins { get; set; } - + public IList Tracks { get; set; } } } \ No newline at end of file diff --git a/Core/Entities/PluginInfo.cs b/Core/Entities/PluginInfo.cs deleted file mode 100644 index d51477c..0000000 --- a/Core/Entities/PluginInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace AlsTools.Core.Entities -{ - public class PluginInfo - { - public string Name { get; set; } - public PluginType Type { get; set; } - } -} diff --git a/Core/Entities/PluginType.cs b/Core/Entities/PluginType.cs index 7bb2b05..2866269 100644 --- a/Core/Entities/PluginType.cs +++ b/Core/Entities/PluginType.cs @@ -3,7 +3,9 @@ namespace AlsTools public enum PluginType { VST, + VST3, + AU } } \ No newline at end of file diff --git a/Core/Entities/TrackType.cs b/Core/Entities/TrackType.cs new file mode 100644 index 0000000..644308b --- /dev/null +++ b/Core/Entities/TrackType.cs @@ -0,0 +1,13 @@ +namespace AlsTools.Core.Entities +{ + public enum TrackType + { + Audio, + + Midi, + + Return, + + Master + } +} \ No newline at end of file diff --git a/Core/Entities/Tracks/AudioTrack.cs b/Core/Entities/Tracks/AudioTrack.cs new file mode 100644 index 0000000..bd09a17 --- /dev/null +++ b/Core/Entities/Tracks/AudioTrack.cs @@ -0,0 +1,9 @@ +namespace AlsTools.Core.Entities.Tracks +{ + public class AudioTrack : BaseTrack, ITrack + { + public AudioTrack() : base(TrackType.Audio) + { + } + } +} \ No newline at end of file diff --git a/Core/Entities/Tracks/BaseTrack.cs b/Core/Entities/Tracks/BaseTrack.cs new file mode 100644 index 0000000..46b3c9d --- /dev/null +++ b/Core/Entities/Tracks/BaseTrack.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using AlsTools.Core.Entities.Devices; + +namespace AlsTools.Core.Entities.Tracks +{ + public abstract class BaseTrack : ITrack + { + public BaseTrack(TrackType type) + { + Devices = new SortedDictionary(); + Plugins = new SortedDictionary(); + Type = type; + } + + /// + /// Track name + /// + public string Name { get; set; } + + /// + /// Whether the track is an audio, midi or return track + /// + public TrackType Type { get; set; } + + /// + /// All Live devices used in this track + /// + public SortedDictionary Devices { get; protected set; } + + /// + /// All plugins used in this track + /// + public SortedDictionary Plugins { get; protected set; } + + /// + /// Adds a device to either the or + /// list, only if it does not exist yet. + /// + /// The device object + public void AddDevice(IDevice device) + { + if (device.Type == DeviceType.Plugin) + { + if (!Plugins.ContainsKey(device.Name)) + Plugins.Add(device.Name, device as PluginDevice); + } + else + { + if (!Devices.ContainsKey(device.Name)) + Devices.Add(device.Name, device as LiveDevice); + } + } + } +} \ No newline at end of file diff --git a/Core/Entities/Tracks/ITrack.cs b/Core/Entities/Tracks/ITrack.cs new file mode 100644 index 0000000..9ae6ecf --- /dev/null +++ b/Core/Entities/Tracks/ITrack.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using AlsTools.Core.Entities.Devices; + +namespace AlsTools.Core.Entities.Tracks +{ + public interface ITrack + { + string Name { get; set; } + + TrackType Type { get; set; } + + SortedDictionary Devices { get; } + + SortedDictionary Plugins { get; } + + void AddDevice(IDevice device); + } +} \ No newline at end of file diff --git a/Core/Entities/Tracks/MasterTrack.cs b/Core/Entities/Tracks/MasterTrack.cs new file mode 100644 index 0000000..33a3f62 --- /dev/null +++ b/Core/Entities/Tracks/MasterTrack.cs @@ -0,0 +1,9 @@ +namespace AlsTools.Core.Entities.Tracks +{ + public class MasterTrack : BaseTrack, ITrack + { + public MasterTrack() : base(TrackType.Master) + { + } + } +} \ No newline at end of file diff --git a/Core/Entities/Tracks/MidiTrack.cs b/Core/Entities/Tracks/MidiTrack.cs new file mode 100644 index 0000000..6a0f9c7 --- /dev/null +++ b/Core/Entities/Tracks/MidiTrack.cs @@ -0,0 +1,9 @@ +namespace AlsTools.Core.Entities.Tracks +{ + public class MidiTrack : BaseTrack, ITrack + { + public MidiTrack() : base(TrackType.Midi) + { + } + } +} \ No newline at end of file diff --git a/Core/Entities/Tracks/ReturnTrack.cs b/Core/Entities/Tracks/ReturnTrack.cs new file mode 100644 index 0000000..2490bfb --- /dev/null +++ b/Core/Entities/Tracks/ReturnTrack.cs @@ -0,0 +1,9 @@ +namespace AlsTools.Core.Entities.Tracks +{ + public class ReturnTrack : BaseTrack, ITrack + { + public ReturnTrack() : base(TrackType.Return) + { + } + } +} \ No newline at end of file diff --git a/Core/Factories/DeviceFactory.cs b/Core/Factories/DeviceFactory.cs new file mode 100644 index 0000000..adbc3ff --- /dev/null +++ b/Core/Factories/DeviceFactory.cs @@ -0,0 +1,20 @@ +using AlsTools.Core.Entities.Devices; + +namespace AlsTools.Core.Factories +{ + public static class DeviceFactory + { + public static IDevice CreateDeviceByNodeName(string nodeName) + { + switch (nodeName.ToUpperInvariant()) + { + case "PLUGINDEVICE": + case "AUPLUGINDEVICE": + return new PluginDevice(); + + default: + return new LiveDevice(); + } + } + } +} \ No newline at end of file diff --git a/Core/Factories/TrackFactory.cs b/Core/Factories/TrackFactory.cs new file mode 100644 index 0000000..14a35fd --- /dev/null +++ b/Core/Factories/TrackFactory.cs @@ -0,0 +1,26 @@ +using AlsTools.Core.Entities; +using AlsTools.Core.Entities.Tracks; + +namespace AlsTools.Core.Factories +{ + public static class TrackFactory + { + public static ITrack CreateTrack(TrackType type, string name) + { + switch (type) + { + case TrackType.Audio: + return new AudioTrack() { Name = name }; + + case TrackType.Midi: + return new MidiTrack() { Name = name }; + + case TrackType.Return: + return new ReturnTrack() { Name = name }; + + default: + return new MasterTrack() { Name = name }; + } + } + } +} diff --git a/Infrastructure/LiveProjectExtractor.cs b/Infrastructure/LiveProjectExtractor.cs index cc90ff7..7c72341 100644 --- a/Infrastructure/LiveProjectExtractor.cs +++ b/Infrastructure/LiveProjectExtractor.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; using System.IO; using System.IO.Compression; -using System.Xml; using System.Xml.XPath; using AlsTools.Core.Entities; +using AlsTools.Core.Entities.Devices; +using AlsTools.Core.Factories; using AlsTools.Core.Interfaces; using Microsoft.Extensions.Logging; @@ -23,8 +23,6 @@ public LiveProject ExtractProjectFromFile(FileInfo file) logger.LogDebug("Extracting file {file}", file.FullName); var project = new LiveProject() { Name = file.Name, Path = file.FullName }; - var plugins = new SortedSet(); - var settings = new XmlReaderSettings() { IgnoreWhitespace = true }; using (FileStream originalFileStream = file.OpenRead()) { @@ -33,16 +31,11 @@ public LiveProject ExtractProjectFromFile(FileInfo file) using (StreamReader unzip = new StreamReader(decompressionStream)) { var xPathDoc = new XPathDocument(unzip); - var nav = xPathDoc.CreateNavigator(); - var expression = @"//PluginDevice/PluginDesc/Vst3PluginInfo/Name/@Value"; - GetPluginsByExpression(project, nav, expression, PluginType.VST3); + GetTracks(project, xPathDoc); - expression = @"//PluginDevice/PluginDesc/VstPluginInfo/PlugName/@Value"; - GetPluginsByExpression(project, nav, expression, PluginType.VST); - - expression = @"//AuPluginDevice/PluginDesc/AuPluginInfo/Name/@Value"; - GetPluginsByExpression(project, nav, expression, PluginType.AU); + //TODO: get master track devices and plugins + //GetMasterTrackAndContents(project, xPathDoc); } } } @@ -50,19 +43,137 @@ public LiveProject ExtractProjectFromFile(FileInfo file) return project; } - private void GetPluginsByExpression(LiveProject project, XPathNavigator nav, string expression, PluginType type) + private void GetMasterTrackAndContents(LiveProject project, XPathDocument xPathDoc) { - var nodeIter = nav.Select(expression); + // var nav = xPathDoc.CreateNavigator(); + // nav.MoveToRoot(); + + // var expression = @"//MasterTrack/DeviceChain/DeviceChain/Devices"; + // GetDevices(project, nav, expression); + + // expression = @"//PluginDevice/PluginDesc/Vst3PluginInfo/Name/@Value"; + // GetPluginsByExpression(project, nav, expression, PluginType.VST3); + + // expression = @"//PluginDevice/PluginDesc/VstPluginInfo/PlugName/@Value"; + // GetPluginsByExpression(project, nav, expression, PluginType.VST); + + // expression = @"//AuPluginDevice/PluginDesc/AuPluginInfo/Name/@Value"; + // GetPluginsByExpression(project, nav, expression, PluginType.AU); + } - while (nodeIter.MoveNext()) + private void GetTracks(LiveProject project, XPathDocument xPathDoc) + { + var nav = xPathDoc.CreateNavigator(); + + var expression = @"//LiveSet/Tracks/AudioTrack"; + GetTrackByExpression(project, nav, expression, TrackType.Audio); + + expression = @"//LiveSet/Tracks/MidiTrack"; + GetTrackByExpression(project, nav, expression, TrackType.Midi); + + expression = @"//LiveSet/Tracks/ReturnTrack"; + GetTrackByExpression(project, nav, expression, TrackType.Return); + } + + private void GetTrackByExpression(LiveProject project, XPathNavigator nav, string expression, TrackType trackType) + { + var tracksIterator = nav.Select(expression); + + // Iterate through the tracks of the same type (audio, midi, return, master) + while (tracksIterator.MoveNext()) { - var name = nodeIter.Current.Value; - if (!project.Plugins.ContainsKey(name)) + // Get track name + var nameNode = tracksIterator.Current.Select(@"Name/EffectiveName/@Value"); + nameNode.MoveNext(); + + // Create the track + var track = TrackFactory.CreateTrack(trackType, nameNode.Current.Value); + + // Get all children devices + var devicesIterator = tracksIterator.Current.Select(@"DeviceChain/DeviceChain/Devices"); + devicesIterator.MoveNext(); + if (devicesIterator.Current.HasChildren) { - var p = new PluginInfo() { Name = name, Type = type }; - project.Plugins.Add(p.Name, p); + if (devicesIterator.Current.MoveToFirstChild()) + { + // Get first device + var deviceNode = devicesIterator.Current; + var device = DeviceFactory.CreateDeviceByNodeName(deviceNode.Name); + + GetDeviceInformation(deviceNode, device); + + // Add to devices list + track.AddDevice(device); + + // Iterate through all other devices + while (devicesIterator.Current.MoveToNext()) + { + deviceNode = devicesIterator.Current; + device = DeviceFactory.CreateDeviceByNodeName(deviceNode.Name); + GetDeviceInformation(deviceNode, device); + track.AddDevice(device); + } + } } + + project.Tracks.Add(track); + } + } + + private void GetDeviceInformation(XPathNavigator deviceNode, IDevice device) + { + if (device.Type == DeviceType.LiveDevice) + { + device.Name = deviceNode.Name; + return; + } + + + var pluginDescNode = deviceNode.Select(@"PluginDesc"); + pluginDescNode.MoveNext(); + if (pluginDescNode.Current.HasChildren) + { + if (pluginDescNode.Current.MoveToFirstChild()) + { + var pluginInfo = GetPluginNameAndType(pluginDescNode.Current); + device.Name = pluginInfo.Item1; + (device as PluginDevice).PluginType = pluginInfo.Item2; + } + } + } + + private (string, PluginType) GetPluginNameAndType(XPathNavigator pluginDescNode) + { + var pluginDescNodeName = pluginDescNode.Name.ToUpperInvariant(); + string pluginName = string.Empty; + PluginType pluginType = PluginType.AU; + XPathNodeIterator nodeIterator = null; + + switch (pluginDescNodeName) + { + case "VSTPLUGININFO": + nodeIterator = pluginDescNode.Select(@"PlugName/@Value"); + nodeIterator.MoveNext(); + pluginName = nodeIterator.Current.Value; + pluginType = PluginType.VST; + break; + + case "VST3PLUGININFO": + nodeIterator = pluginDescNode.Select(@"Name/@Value"); + nodeIterator.MoveNext(); + pluginName = nodeIterator.Current.Value; + pluginType = PluginType.VST3; + break; + + default: + nodeIterator = pluginDescNode.Select(@"Name/@Value"); + nodeIterator.MoveNext(); + pluginName = nodeIterator.Current.Value; + pluginType = PluginType.AU; + break; } + + return (pluginName, pluginType); } } } diff --git a/Infrastructure/Repositories/LiveProjectRepository.cs b/Infrastructure/Repositories/LiveProjectRepository.cs index 18b03e2..a234d0a 100644 --- a/Infrastructure/Repositories/LiveProjectRepository.cs +++ b/Infrastructure/Repositories/LiveProjectRepository.cs @@ -70,14 +70,16 @@ public IEnumerable GetProjectsContainingPlugins(string[] pluginsToL // .FindAll() // .Where(p => p.Plugins.Intersect(pluginsToLocate)) - //TODO: implement it correctly - + //TODO: implement it correctly, using DB query var projects = GetAllProjects(); IList res = new List(); foreach (var p in projects) - { - if (p.Plugins.Any(x => pluginsToLocate.Any(y => x.Key.Contains(y, StringComparison.InvariantCultureIgnoreCase)))) - res.Add(p); + { + var plugins = p.Tracks.Select(x => x.Plugins).Single(); + if (plugins.Any(x => pluginsToLocate.Any(y => x.Key.Contains(y, StringComparison.InvariantCultureIgnoreCase)))) + res.Add(p); + // if (p.Plugins.Any(x => pluginsToLocate.Any(y => x.Key.Contains(y, StringComparison.InvariantCultureIgnoreCase)))) + // res.Add(p); } return res.AsEnumerable(); diff --git a/Program.cs b/Program.cs index 4e33f9c..7322cba 100644 --- a/Program.cs +++ b/Program.cs @@ -160,6 +160,16 @@ private static ProgramArgs GetArguments(string[] arguments) result.File = parts[1]; } + int indexExport = args.FindIndex(x => x.StartsWith("--export=")); + if (indexExport >= 0) + { + var parts = args[indexFolder].Split('='); + if (parts.Count() != 2) + throw new ArgumentException("Please specify a file path!"); + + result.ExportFile = parts[1]; + } + return result; } @@ -175,8 +185,9 @@ private static void ValidateArguments(ProgramArgs args) } } - if ((args.ListPlugins && args.LocatePlugins && args.InitDb && args.CountProjects) || (!args.ListPlugins && !args.LocatePlugins && !args.InitDb && !args.CountProjects)) - throw new ArgumentException("Please specify either --initdb or --count or --list or --locate option"); + if ((args.ListPlugins && args.LocatePlugins && args.InitDb && args.CountProjects && args.Export) || + (!args.ListPlugins && !args.LocatePlugins && !args.InitDb && !args.CountProjects && !args.Export)) + throw new ArgumentException("Please specify either --initdb or --count or --list or --locate or --export option"); //TODO: implement validation of all other possibilities } diff --git a/ProgramArgs.cs b/ProgramArgs.cs index 2359d3a..0a280f3 100644 --- a/ProgramArgs.cs +++ b/ProgramArgs.cs @@ -22,6 +22,10 @@ public ProgramArgs() public bool InitDb { get; set; } public bool CountProjects { get; set; } + + public bool Export { get; set; } + + public string ExportFile { get; set; } } } From e1498799c1b7ccaa8ee2e895fcfa75938d665374 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Sat, 5 Jun 2021 22:03:36 -0300 Subject: [PATCH 14/19] Fixing small bug in GetProjectsContainingPlugins --- .vscode/launch.json | 4 ++-- Infrastructure/Repositories/LiveProjectRepository.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 9c92418..fe149bb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,9 +12,9 @@ // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/als-tools.dll", //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], - //"args": ["--locate=HG2"], + "args": ["--locate=radiator"], // "args": ["--list"], - "args": ["--initdb", "--folder=/Users/zenluiz/Desktop/Testes ALS"], + // "args": ["--initdb", "--folder=/Users/zenluiz/Desktop/Testes ALS"], // "args": ["--initdb", "--folder=/Users/zenluiz/Splice"], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/Infrastructure/Repositories/LiveProjectRepository.cs b/Infrastructure/Repositories/LiveProjectRepository.cs index a234d0a..a61e63a 100644 --- a/Infrastructure/Repositories/LiveProjectRepository.cs +++ b/Infrastructure/Repositories/LiveProjectRepository.cs @@ -75,7 +75,7 @@ public IEnumerable GetProjectsContainingPlugins(string[] pluginsToL IList res = new List(); foreach (var p in projects) { - var plugins = p.Tracks.Select(x => x.Plugins).Single(); + var plugins = p.Tracks.Select(x => x.Plugins).SelectMany(x => x); if (plugins.Any(x => pluginsToLocate.Any(y => x.Key.Contains(y, StringComparison.InvariantCultureIgnoreCase)))) res.Add(p); // if (p.Plugins.Any(x => pluginsToLocate.Any(y => x.Key.Contains(y, StringComparison.InvariantCultureIgnoreCase)))) From efd6caf68b900e626517f136eea7e78cff97c84a Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Thu, 21 Apr 2022 16:56:09 -0300 Subject: [PATCH 15/19] Upgraded to .NET 6 --- .DS_Store | Bin 6148 -> 6148 bytes .gitignore | 1 + .vscode/launch.json | 2 +- als-tools.csproj | 56 ++++++++++++++++++++------------------------ global.json | 2 +- 5 files changed, 29 insertions(+), 32 deletions(-) diff --git a/.DS_Store b/.DS_Store index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..5603c4c3813db5ccc1627f3b8a1fc228728fb651 100644 GIT binary patch delta 359 zcmZoMXfc=|#>B)qF;Q%yo}wr-0|Nsi1A_nqLq0C}}^&lB`20ex{ zhGK?fWZArQh#m%Jh9rhehP>L~%+#I|d zvB4Sn<-sM1C8fnqiAB*MUO-|=MiP`AlAoUgXD23wWu}(L*9(X^=jW9qX6B_9fpur5 zqyp8%glFcZ8JX>L^s3n;QVx#%8s( zoE+k+hPIvwxs_GbHMMm!fvyDtMxfupfFDZ3s99n_7Sw}~K!JFBW8w>z$p#`Uo4J7= e0|w*9#P7_L`9&02nSkmQCL4-KZw?UI!VCboAX}aQ delta 70 zcmZoMXfc=|#>AjHu~2NHo+1YW5HK<@2y9kle#WxdfcX^DW_AvK4xj>{$am(+{342+ UKzW7)kiy9(Jj$D6L{=~Z02rPQkN^Mx diff --git a/.gitignore b/.gitignore index 92f4bdc..73a93a3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ *.pdb *.cache /LiteDb/ +.DS_Store diff --git a/.vscode/launch.json b/.vscode/launch.json index fe149bb..a919520 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/als-tools.dll", + "program": "${workspaceFolder}/bin/Debug/net6.0/als-tools.dll", //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], "args": ["--locate=radiator"], // "args": ["--list"], diff --git a/als-tools.csproj b/als-tools.csproj index d8256c6..fafc5d6 100644 --- a/als-tools.csproj +++ b/als-tools.csproj @@ -1,30 +1,26 @@ - - - - Exe - netcoreapp3.1 - als_tools - - - - - Always - - - - - - - - - - - - - - - - - - - + + + Exe + net6.0 + als_tools + + + + Always + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/global.json b/global.json index 4905b60..0a1cebc 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.1.113" + "version": "6.0.200" } } \ No newline at end of file From 74c398940db4ad09f464ece7fcfdaacfd38c6631 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Thu, 21 Apr 2022 21:40:50 -0300 Subject: [PATCH 16/19] Updated packages --- als-tools.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/als-tools.csproj b/als-tools.csproj index fafc5d6..4cccc64 100644 --- a/als-tools.csproj +++ b/als-tools.csproj @@ -11,7 +11,7 @@ - + From c87b43118e18924474845f983e20dd8d77ead108 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Fri, 22 Apr 2022 18:45:03 -0300 Subject: [PATCH 17/19] Implemented reading of Master track details --- .DS_Store | Bin 6148 -> 6148 bytes .gitignore | 2 +- Core/Entities/PluginType.cs | 2 +- Infrastructure/LiveProjectExtractor.cs | 25 ++++--------------------- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/.DS_Store b/.DS_Store index 5603c4c3813db5ccc1627f3b8a1fc228728fb651..f64b171c596e2dbfd3ca9b9d4f2fe33855c9dfdf 100644 GIT binary patch delta 273 zcmZoMXfc=|#>B!ku~2NHo+2ab#(>?7iw&5W7+E*-Fo`k7u`&2CWHOX6q%ycLBqfy> z7bNB6CowQEd`&9I$t*50Fu1|U#LU9V#?HaX#mU3T$H^HRoRME1T#{H)TI`fq6fYnX zoSBlElvos=nNpGwlA7n5lUkOV=U?QLSdu!qfXP!V8l)j0u_Obih*Q}iy8&oC1HI1I5W@!9{sF`FZI;amLMx i%)1#kvvcrs06h%kd}p4_FXG4nG>ZwOe{+P$8fE|uK0-DC delta 68 zcmZoMXfc=|#>B)qu~2NHo+2aj#(>?7jLe&PSi~4N`?Kv}+}NPYyqTSYp9837vmnQJ W=E?jbjvNd?z{tSBvN=Lz4Kn~l)(=wv diff --git a/.gitignore b/.gitignore index 73a93a3..8591897 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ *.pdb *.cache /LiteDb/ -.DS_Store +.DS_Store \ No newline at end of file diff --git a/Core/Entities/PluginType.cs b/Core/Entities/PluginType.cs index 2866269..ea8f268 100644 --- a/Core/Entities/PluginType.cs +++ b/Core/Entities/PluginType.cs @@ -2,7 +2,7 @@ namespace AlsTools { public enum PluginType { - VST, + VST2, VST3, diff --git a/Infrastructure/LiveProjectExtractor.cs b/Infrastructure/LiveProjectExtractor.cs index 7c72341..75e5269 100644 --- a/Infrastructure/LiveProjectExtractor.cs +++ b/Infrastructure/LiveProjectExtractor.cs @@ -33,9 +33,6 @@ public LiveProject ExtractProjectFromFile(FileInfo file) var xPathDoc = new XPathDocument(unzip); GetTracks(project, xPathDoc); - - //TODO: get master track devices and plugins - //GetMasterTrackAndContents(project, xPathDoc); } } } @@ -43,23 +40,6 @@ public LiveProject ExtractProjectFromFile(FileInfo file) return project; } - private void GetMasterTrackAndContents(LiveProject project, XPathDocument xPathDoc) - { - // var nav = xPathDoc.CreateNavigator(); - // nav.MoveToRoot(); - - // var expression = @"//MasterTrack/DeviceChain/DeviceChain/Devices"; - // GetDevices(project, nav, expression); - - // expression = @"//PluginDevice/PluginDesc/Vst3PluginInfo/Name/@Value"; - // GetPluginsByExpression(project, nav, expression, PluginType.VST3); - - // expression = @"//PluginDevice/PluginDesc/VstPluginInfo/PlugName/@Value"; - // GetPluginsByExpression(project, nav, expression, PluginType.VST); - - // expression = @"//AuPluginDevice/PluginDesc/AuPluginInfo/Name/@Value"; - // GetPluginsByExpression(project, nav, expression, PluginType.AU); - } private void GetTracks(LiveProject project, XPathDocument xPathDoc) { @@ -73,6 +53,9 @@ private void GetTracks(LiveProject project, XPathDocument xPathDoc) expression = @"//LiveSet/Tracks/ReturnTrack"; GetTrackByExpression(project, nav, expression, TrackType.Return); + + expression = @"//LiveSet/MasterTrack"; + GetTrackByExpression(project, nav, expression, TrackType.Master); } private void GetTrackByExpression(LiveProject project, XPathNavigator nav, string expression, TrackType trackType) @@ -155,7 +138,7 @@ private void GetDeviceInformation(XPathNavigator deviceNode, IDevice device) nodeIterator = pluginDescNode.Select(@"PlugName/@Value"); nodeIterator.MoveNext(); pluginName = nodeIterator.Current.Value; - pluginType = PluginType.VST; + pluginType = PluginType.VST2; break; case "VST3PLUGININFO": From e186897923c3ca51d398eaf265af227117087101 Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Fri, 22 Apr 2022 19:20:00 -0300 Subject: [PATCH 18/19] Getting project Live creator version --- .DS_Store | Bin 6148 -> 6148 bytes .gitignore | 3 ++- .vscode/launch.json | 4 ++-- App.cs | 1 + Infrastructure/LiveProjectExtractor.cs | 13 +++++++++++++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.DS_Store b/.DS_Store index f64b171c596e2dbfd3ca9b9d4f2fe33855c9dfdf..2814a983ca9e9f277b87604fc8a08dabc4b26b83 100644 GIT binary patch delta 156 zcmZoMXfc@J&&atkU^g=(=Vl%jXQp~KhJ1!nh7yJX5Sf#17@VA+Tfl$-DDt`aE-pzq m`AI-&4sNa+jB7cMI0D&dYElTQDae4?v$5EcaWgx|Uw!}+t-GnXQquMI~X^!bNuB80Df`^#{d8T diff --git a/.gitignore b/.gitignore index 8591897..924a673 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ *.pdb *.cache /LiteDb/ -.DS_Store \ No newline at end of file +.DS_Store +output/* diff --git a/.vscode/launch.json b/.vscode/launch.json index a919520..36534f1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,9 +12,9 @@ // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/bin/Debug/net6.0/als-tools.dll", //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], - "args": ["--locate=radiator"], + //"args": ["--locate=radiator"], // "args": ["--list"], - // "args": ["--initdb", "--folder=/Users/zenluiz/Desktop/Testes ALS"], + "args": ["--initdb", "--folder=/Users/zenluiz/Desktop/Testes ALS"], // "args": ["--initdb", "--folder=/Users/zenluiz/Splice"], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/App.cs b/App.cs index 202822a..f3df14b 100644 --- a/App.cs +++ b/App.cs @@ -78,6 +78,7 @@ private async Task PrintProjectAndPlugins(LiveProject project) { await Console.Out.WriteLineAsync("------------------------------------------------------------------------------"); await Console.Out.WriteLineAsync($"Project name: {project.Name}"); + await Console.Out.WriteLineAsync($"Live version (creator): {project.LiveVersion}"); await Console.Out.WriteLineAsync($"Full path: {project.Path}"); await Console.Out.WriteLineAsync("\tTracks and plugins:"); diff --git a/Infrastructure/LiveProjectExtractor.cs b/Infrastructure/LiveProjectExtractor.cs index 75e5269..133a0e7 100644 --- a/Infrastructure/LiveProjectExtractor.cs +++ b/Infrastructure/LiveProjectExtractor.cs @@ -32,6 +32,8 @@ public LiveProject ExtractProjectFromFile(FileInfo file) { var xPathDoc = new XPathDocument(unzip); + GetProjectDetails(project, xPathDoc); + GetTracks(project, xPathDoc); } } @@ -40,6 +42,17 @@ public LiveProject ExtractProjectFromFile(FileInfo file) return project; } + private void GetProjectDetails(LiveProject project, XPathDocument xPathDoc) + { + var nav = xPathDoc.CreateNavigator(); + var expression = @"/Ableton/@Creator"; + var creatorNode = nav.Select(expression); + + if (!creatorNode.MoveNext()) + return; + + project.LiveVersion = creatorNode.Current.Value; + } private void GetTracks(LiveProject project, XPathDocument xPathDoc) { From e09c2e89e2d5a8d22670989abeb1b89b13e695ff Mon Sep 17 00:00:00 2001 From: Luiz Zen Date: Sun, 24 Apr 2022 19:13:04 -0300 Subject: [PATCH 19/19] Simplified query --- .vscode/launch.json | 4 +- .../Repositories/LiveProjectRepository.cs | 56 +--------- TEMP.txt | 100 ++++++++++++++++++ 3 files changed, 106 insertions(+), 54 deletions(-) create mode 100644 TEMP.txt diff --git a/.vscode/launch.json b/.vscode/launch.json index 36534f1..7e6feaf 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,9 +12,9 @@ // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/bin/Debug/net6.0/als-tools.dll", //"args": ["--locate=HG2;bx_tunner", "--folder=/Users/zenluiz/Desktop/Testes ALS"], - //"args": ["--locate=radiator"], + "args": ["--locate=kickbox;replika"], // "args": ["--list"], - "args": ["--initdb", "--folder=/Users/zenluiz/Desktop/Testes ALS"], + // "args": ["--initdb", "--folder=/Users/zenluiz/Desktop/Testes ALS"], // "args": ["--initdb", "--folder=/Users/zenluiz/Splice"], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/Infrastructure/Repositories/LiveProjectRepository.cs b/Infrastructure/Repositories/LiveProjectRepository.cs index a61e63a..37dba97 100644 --- a/Infrastructure/Repositories/LiveProjectRepository.cs +++ b/Infrastructure/Repositories/LiveProjectRepository.cs @@ -39,64 +39,16 @@ public IEnumerable GetAllProjects() public IEnumerable GetProjectsContainingPlugins(string[] pluginsToLocate) { - // var col = liteDb.GetCollection("LiveProject"); - - // var pluginsList = pluginsToLocate - - // var projects = col - // .Query() - // .Where(proj => proj.Plugins != null && proj.Plugins.Any(k => pluginsToLocate.Any(x => k.Name.Contains(x, StringComparison.InvariantCultureIgnoreCase)))) - // .Select(p => p) - // .ToEnumerable(); - - // var projects = col - // .Query() - // .Where(proj => proj.Plugins.Where(plugin => pluginsToLocate.Contains(plugin.Name)).Any()) - // .Select(p => p) - // .ToEnumerable(); - - // var projects = col - // .Query() - // .Where(proj => - // proj.Plugins.Where(plugin => - // pluginsToLocate.Any(p => p.Contains(plugin.Name, StringComparison.InvariantCultureIgnoreCase)) - // ).Any() - // ) - // .Select(p => p) - // .ToEnumerable(); - - // var projects = col - // .Include(x => x.Plugins) - // .FindAll() - // .Where(p => p.Plugins.Intersect(pluginsToLocate)) - - //TODO: implement it correctly, using DB query + //TODO: implement it correctly, using DB query var projects = GetAllProjects(); IList res = new List(); - foreach (var p in projects) + foreach (var proj in projects) { - var plugins = p.Tracks.Select(x => x.Plugins).SelectMany(x => x); - if (plugins.Any(x => pluginsToLocate.Any(y => x.Key.Contains(y, StringComparison.InvariantCultureIgnoreCase)))) - res.Add(p); - // if (p.Plugins.Any(x => pluginsToLocate.Any(y => x.Key.Contains(y, StringComparison.InvariantCultureIgnoreCase)))) - // res.Add(p); + if (proj.Tracks.Any(track => track.Plugins.Any(plugin => pluginsToLocate.Any(plugToLocate => plugin.Key.Contains(plugToLocate, StringComparison.InvariantCultureIgnoreCase))))) + res.Add(proj); } return res.AsEnumerable(); - - // var pluginToLocate = pluginsToLocate[0]; - // var col = liteDb.GetCollection("LiveProject"); - - // var query = @"SELECT { $.*, $.Plugins[*] FROM LiveProject } WHERE $.Plugins[*].Title LIKE '%" + pluginToLocate + "%'"; - // var s = liteDb.Execute(query).ToList(); - - // var res = col.Query() - // .Where(proj => proj.Plugins.Any(p => p.Key.Contains(pluginToLocate, StringComparison.InvariantCultureIgnoreCase)).Any()) - // .Select(x => x); - - // return res.ToEnumerable(); - - // return null; } public bool Insert(LiveProject project) diff --git a/TEMP.txt b/TEMP.txt new file mode 100644 index 0000000..e16df07 --- /dev/null +++ b/TEMP.txt @@ -0,0 +1,100 @@ + // var col = liteDb.GetCollection("LiveProject"); + + // var colall = liteDb.GetCollection("LiveProject"); + // var all = colall.FindAll().Where(pr => pr.Tracks.Any(tr => tr.Plugins.Any(pl => pl.Value.Name.ToLower() == "decapitator"))).ToList(); + + // // var pluginsList = pluginsToLocate + + // // var q1 = col.Find(proj => proj.Tracks != null && proj.Tracks.Any(track => track.Plugins != null && track + // // .Plugins.Any(plugin => pluginsToLocate.Contains(plugin.Key)) + // // )).ToList(); + + // var q1 = col.Query().Where(proj => proj.Name == "Industrial Acid Techno Youtube.als"); + // // var col1 = q1.Select(x => x); + // var col1 = q1.First(); + + // // var proj = col1.First(); + + // var a = q1.Where(x => x.Tracks.Where(x => x.Plugins != null && x.Plugins.Count > 0).Any()).Select(x => x).ToList(); + + + // // var b = col.Query().Where(x => x.Tracks.Where(x => x.Plugins != null && x.Plugins.Any(p => p.Value.Name == "Decapitator")).Any()).Select(x => x).ToList(); + // // {LiteDB.LiteException: Any/All requires simple parameter on left side. Eg: `x => x.Phones.Select(p => p.Number).Any(n => n > 5)` + + // // var b = col.Query().Where(x => x.Tracks.Where(x => x.Plugins != null && x.Plugins.Keys.Any(k => k.Equals("Decapitator"))).Any()).Select(x => x).ToList(); + // // var b = col.Query().Where(x => x.Tracks.Where(x => x.Plugins.Where(p => p.Value.Name == "Decapitator").Count() > 0).Any()).Select(x => x).ToList(); + // var c = col + // .Query() + // .Where(proj => proj.Name == "Industrial Acid Techno Youtube.als") + // .Where(x => x.Tracks.Where(x => x.Plugins.Values.Where(v => v.Name.Length > 5).Count() > 0).Count() > 0) + // .Select(x => x) + // .ToList(); + + // var q1 = col.Find(proj => proj.Tracks.Count > 40) + // .Select(x => x.Tracks) + // .ToList(); + + // var q2 = col.FindAll().ToList(); + + // var q3 = col.Query().Select(x => x).ToList(); + + + + // var p1 = col + // .Query() + // .Where(proj => proj.Tracks.Any(track => track.Name.Length > 10)) + // .Select(proj => proj) + // .ToList(); + + // var projects = col + // .Query() + // .Where(proj => proj + // .Tracks.Any(track => track + // .Plugins.Any(plugin => pluginsToLocate.Contains(plugin.Key)) + // ) + // ) + // .Select(proj => proj) + // .ToEnumerable(); + + //return null; + + // var projects1 = col + // .Query() + // .Where(proj => proj.Plugins != null && proj.Plugins.Any(k => pluginsToLocate.Any(x => k.Name.Contains(x, StringComparison.InvariantCultureIgnoreCase)))) + // .Select(p => p) + // .ToEnumerable(); + + // var projects2 = col + // .Query() + // .Where(proj => proj.Plugins.Where(plugin => pluginsToLocate.Contains(plugin.Name)).Any()) + // .Select(p => p) + // .ToEnumerable(); + + // var projects3 = col + // .Query() + // .Where(proj => + // proj.Plugins.Where(plugin => + // pluginsToLocate.Any(p => p.Contains(plugin.Name, StringComparison.InvariantCultureIgnoreCase)) + // ).Any() + // ) + // .Select(p => p) + // .ToEnumerable(); + + // var projects4 = col + // .Include(x => x.Plugins) + // .FindAll() + // .Where(p => p.Plugins.Intersect(pluginsToLocate)) + + // var pluginToLocate = pluginsToLocate[0]; + // var col = liteDb.GetCollection("LiveProject"); + + // var query = @"SELECT { $.*, $.Plugins[*] FROM LiveProject } WHERE $.Plugins[*].Title LIKE '%" + pluginToLocate + "%'"; + // var s = liteDb.Execute(query).ToList(); + + // var res = col.Query() + // .Where(proj => proj.Plugins.Any(p => p.Key.Contains(pluginToLocate, StringComparison.InvariantCultureIgnoreCase)).Any()) + // .Select(x => x); + + // return res.ToEnumerable(); + + // return null; \ No newline at end of file