diff --git a/FileManager/UNTESTED/Configuration.cs b/FileManager/UNTESTED/Configuration.cs index c02d2b61..3f291695 100644 --- a/FileManager/UNTESTED/Configuration.cs +++ b/FileManager/UNTESTED/Configuration.cs @@ -31,12 +31,10 @@ namespace FileManager */ #endregion - private const string configFilename = "LibationSettings.json"; - private PersistentDictionary persistentDictionary { get; } [Description("Location of the configuration file where these settings are saved. Please do not edit this file directly while Libation is running.")] - public string Filepath { get; } + public string Filepath => Path.Combine(Path.GetDirectoryName(Exe.FileLocationOnDisk), "Settings.json"); [Description("[Advanced. Leave alone in most cases.] Your user-specific key used to decrypt your audible files (*.aax) into audio files you can use anywhere (*.m4b)")] public string DecryptKey @@ -90,13 +88,10 @@ namespace FileManager public static Configuration Instance { get; } = new Configuration(); private Configuration() { - Filepath = getPath(); - // load json values into memory persistentDictionary = new PersistentDictionary(Filepath); ensureDictionaryEntries(); - // setUserFilesDirectoryDefault // don't create dir. dir creation is the responsibility of places that use the dir if (string.IsNullOrWhiteSpace(LibationFiles)) LibationFiles = Path.Combine(Path.GetDirectoryName(Exe.FileLocationOnDisk), "Libation"); @@ -113,67 +108,6 @@ namespace FileManager return attribute?.Description; } - private static string getPath() - { - // search folders for config file. accept the first match - var defaultdir = Path.GetDirectoryName(Exe.FileLocationOnDisk); - - var baseDirs = new HashSet - { - defaultdir, - getNonDevelopmentDir(defaultdir), - Environment.GetFolderPath(Environment.SpecialFolder.Personal) - }; - - var subDirs = baseDirs.Select(dir => Path.Combine(dir, "Libation")); - var dirs = baseDirs.Concat(subDirs).ToList(); - - foreach (var dir in dirs) - { - var f = Path.Combine(dir, configFilename); - if (File.Exists(f)) - return f; - } - - return Path.Combine(defaultdir, configFilename); - } - - private static string getNonDevelopmentDir(string path) - { - // examples: - // \Libation\Core2_0\bin\Debug\netcoreapp3.1 - // \Libation\StndLib\bin\Debug\netstandard2.1 - // \Libation\MyWnfrm\bin\Debug - // \Libation\Core2_0\bin\Release\netcoreapp3.1 - // \Libation\StndLib\bin\Release\netstandard2.1 - // \Libation\MyWnfrm\bin\Release - - var curr = new DirectoryInfo(path); - - if (!curr.Name.EqualsInsensitive("debug") && !curr.Name.EqualsInsensitive("release") && !curr.Name.StartsWithInsensitive("netcoreapp") && !curr.Name.StartsWithInsensitive("netstandard")) - return path; - - // get out of netcore/standard dir => debug - if (curr.Name.StartsWithInsensitive("netcoreapp") || curr.Name.StartsWithInsensitive("netstandard")) - curr = curr.Parent; - - if (!curr.Name.EqualsInsensitive("debug") && !curr.Name.EqualsInsensitive("release")) - return path; - - // get out of debug => bin - curr = curr.Parent; - if (!curr.Name.EqualsInsensitive("bin")) - return path; - - // get out of bin - curr = curr.Parent; - // get out of csproj-level dir - curr = curr.Parent; - - // curr should now be sln-level dir - return curr.FullName; - } - private void ensureDictionaryEntries() { var stringProperties = getDictionaryProperties().Select(p => p.Name).ToList(); diff --git a/Libation.sln b/Libation.sln index f3cb2547..c9cfefb8 100644 --- a/Libation.sln +++ b/Libation.sln @@ -78,7 +78,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationServices", "Appl EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dinah.Core.WindowsDesktop", "..\Dinah.Core\Dinah.Core.WindowsDesktop\Dinah.Core.WindowsDesktop.csproj", "{059CE32C-9AD6-45E9-A166-790DFFB0B730}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsDesktopUtilities", "WindowsDesktopUtilities\WindowsDesktopUtilities.csproj", "{E7EFD64D-6630-4426-B09C-B6862A92E3FD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindowsDesktopUtilities", "WindowsDesktopUtilities\WindowsDesktopUtilities.csproj", "{E7EFD64D-6630-4426-B09C-B6862A92E3FD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibationLauncher", "LibationLauncher\LibationLauncher.csproj", "{F3B04A3A-20C8-4582-A54A-715AF6A5D859}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -194,6 +196,10 @@ Global {E7EFD64D-6630-4426-B09C-B6862A92E3FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {E7EFD64D-6630-4426-B09C-B6862A92E3FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {E7EFD64D-6630-4426-B09C-B6862A92E3FD}.Release|Any CPU.Build.0 = Release|Any CPU + {F3B04A3A-20C8-4582-A54A-715AF6A5D859}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F3B04A3A-20C8-4582-A54A-715AF6A5D859}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F3B04A3A-20C8-4582-A54A-715AF6A5D859}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F3B04A3A-20C8-4582-A54A-715AF6A5D859}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -226,6 +232,7 @@ Global {B95650EA-25F0-449E-BA5D-99126BC5D730} = {41CDCC73-9B81-49DD-9570-C54406E852AF} {059CE32C-9AD6-45E9-A166-790DFFB0B730} = {43E3ACB3-E0BC-4370-8DBB-E3720C8C8FD1} {E7EFD64D-6630-4426-B09C-B6862A92E3FD} = {F0CBB7A7-D3FB-41FF-8F47-CF3F6A592249} + {F3B04A3A-20C8-4582-A54A-715AF6A5D859} = {8679CAC8-9164-4007-BDD2-F004810EDA14} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {615E00ED-BAEF-4E8E-A92A-9B82D87942A9} diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj new file mode 100644 index 00000000..38cb83d8 --- /dev/null +++ b/LibationLauncher/LibationLauncher.csproj @@ -0,0 +1,26 @@ + + + + WinExe + netcoreapp3.1 + true + libation.ico + Libation + + true + true + + win-x64 + + + + + + + + + PreserveNewest + + + + \ No newline at end of file diff --git a/LibationWinForm/UNTESTED/Program.cs b/LibationLauncher/Program.cs similarity index 76% rename from LibationWinForm/UNTESTED/Program.cs rename to LibationLauncher/Program.cs index 48f8bef7..48cafe95 100644 --- a/LibationWinForm/UNTESTED/Program.cs +++ b/LibationLauncher/Program.cs @@ -1,29 +1,33 @@ -using System; +using System; using System.Windows.Forms; using Dinah.Core.Logging; +using FileManager; +using LibationWinForm; +using Microsoft.Extensions.Configuration; using Serilog; -namespace LibationWinForm +namespace LibationLauncher { - static class Program - { - [STAThread] - static void Main() + static class Program + { + [STAThread] + static void Main() { + Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!createSettings()) return; - init(); + initLogging(); Application.Run(new Form1()); } private static bool createSettings() { - if (!string.IsNullOrWhiteSpace(FileManager.Configuration.Instance.Books)) + if (!string.IsNullOrWhiteSpace(Configuration.Instance.Books)) return true; var welcomeText = @" @@ -44,7 +48,7 @@ Go to Import > Scan Library return true; } - private static void init() + private static void initLogging() { // default. for reference. output example: // 2019-11-26 08:48:40.224 -05:00 [DBG] Begin Libation @@ -54,8 +58,14 @@ Go to Import > Scan Library var code_outputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] (at {Caller}) {Message:lj}{NewLine}{Exception}"; - var logPath = System.IO.Path.Combine(FileManager.Configuration.Instance.LibationFiles, "Log.log"); + var logPath = System.IO.Path.Combine(Configuration.Instance.LibationFiles, "Log.log"); +//var configuration = new ConfigurationBuilder() +// .AddJsonFile("appsettings.json") +// .Build(); +//Log.Logger = new LoggerConfiguration() +// .ReadFrom.Configuration(configuration) +// .CreateLogger(); Log.Logger = new LoggerConfiguration() .Enrich.WithCaller() .MinimumLevel.Debug() diff --git a/LibationLauncher/appsettings.json b/LibationLauncher/appsettings.json new file mode 100644 index 00000000..7da4be1a --- /dev/null +++ b/LibationLauncher/appsettings.json @@ -0,0 +1,11 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug" + } + }, + "Serilog": { + "MinimumLevel": "Debug", + "Enrich": "WithCaller" + } +} diff --git a/LibationLauncher/libation.ico b/LibationLauncher/libation.ico new file mode 100644 index 00000000..5fb77135 Binary files /dev/null and b/LibationLauncher/libation.ico differ diff --git a/LibationWinForm/LibationWinForm.csproj b/LibationWinForm/LibationWinForm.csproj index 7749a377..91ec9cc8 100644 --- a/LibationWinForm/LibationWinForm.csproj +++ b/LibationWinForm/LibationWinForm.csproj @@ -1,11 +1,10 @@  - WinExe + Library netcoreapp3.1 true libation.ico - Libation true true @@ -39,11 +38,4 @@ - - - PreserveNewest - true - - - \ No newline at end of file diff --git a/LibationWinForm/UNTESTED/Form1.cs b/LibationWinForm/UNTESTED/Form1.cs index 9b71c2c3..56915bbd 100644 --- a/LibationWinForm/UNTESTED/Form1.cs +++ b/LibationWinForm/UNTESTED/Form1.cs @@ -13,9 +13,6 @@ namespace LibationWinForm { public partial class Form1 : Form { - // initial call here will initiate config loading - private Configuration config { get; } = Configuration.Instance; - private string backupsCountsLbl_Format { get; } private string pdfsCountsLbl_Format { get; } private string visibleCountLbl_Format { get; } diff --git a/LibationWinForm/appsettings.json b/LibationWinForm/appsettings.json deleted file mode 100644 index 4fc8b29b..00000000 --- a/LibationWinForm/appsettings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "": "" -} \ No newline at end of file diff --git a/_DB_NOTES.txt b/_DB_NOTES.txt index 5cfdb4dd..d40d6e90 100644 --- a/_DB_NOTES.txt +++ b/_DB_NOTES.txt @@ -9,6 +9,7 @@ see comments at top of file: LocalDb ======= +only works if LocalDb is separately installed on host box SSMS db connection: (LocalDb)\MSSQLLocalDB eg: Server=(localdb)\mssqllocaldb;Database=DataLayer.LibationContext;Integrated Security=true; LocalDb database files live at: