From 7c252202c880badceb01abd0efe18eb495e695a4 Mon Sep 17 00:00:00 2001 From: Dmitry Kolinchuk Date: Fri, 3 Sep 2021 14:41:36 +0300 Subject: [PATCH 1/8] #610 Add fallback resolving of the logs folder for Sitecore members --- src/SIM.Instances/Instance.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/SIM.Instances/Instance.cs b/src/SIM.Instances/Instance.cs index 37005cb0..d1426ffe 100644 --- a/src/SIM.Instances/Instance.cs +++ b/src/SIM.Instances/Instance.cs @@ -647,6 +647,25 @@ protected virtual string GetDataFolderPath() return MapPath(dataFolder); } + // This exception occurs when the RuntimeSettingsAccessor.GetWebConfigResult method fails due to missing node (e.g. in xConnect, Identity Server, etc.) + // In this case, the logs folder can be resolved manually + catch (InvalidOperationException ex) + { + string rootData = FileSystem.FileSystem.Local.Directory.MapPath("App_data", WebRootPath); + if (FileSystem.FileSystem.Local.Directory.Exists(rootData)) + { + return rootData; + } + + // xConnect contains the logs folder in the root folder + rootData = FileSystem.FileSystem.Local.Directory.MapPath("logs", WebRootPath); + if (FileSystem.FileSystem.Local.Directory.Exists(rootData)) + { + return WebRootPath; + } + + throw new InvalidOperationException($"Cannot get data folder of {WebRootPath}"); + } catch (Exception ex) { var rootData = Path.Combine(Path.GetDirectoryName(WebRootPath), "Data"); From 9a6604a708da2e2ae73bbccd595f7936b4084aa3 Mon Sep 17 00:00:00 2001 From: Dmitry Kolinchuk Date: Fri, 3 Sep 2021 14:44:56 +0300 Subject: [PATCH 2/8] #610 Remove duplicated OpenLogsButton definitions --- src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json b/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json index 547ca65b..9f7be77c 100644 --- a/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json +++ b/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json @@ -108,7 +108,6 @@ "DatabaseManagerButton", "UpdateLicenseButton", "MultipleDeletionButton", - "OpenLogsButton", "OpenSSPGButton", "ConfigBuilderButton", "InstallSolrButton", @@ -144,7 +143,6 @@ "DatabaseManagerButton", "UpdateLicenseButton", "MultipleDeletionButton", - "OpenLogsButton", "OpenSSPGButton", "ConfigBuilderButton", "InstallSolrButton", From 96516e88a8f7f8d8a5bc3dfe9b7346946b6aefe4 Mon Sep 17 00:00:00 2001 From: Dmitry Kolinchuk Date: Fri, 3 Sep 2021 15:10:41 +0300 Subject: [PATCH 3/8] #610 Remove duplicated OpenLogsButton definition --- src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json b/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json index 9f7be77c..9ff11b4e 100644 --- a/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json +++ b/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json @@ -22,8 +22,6 @@ "UpdateLicenseButton", /*Multiple Deletion*/ "MultipleDeletionButton", - /*Log Analyzer*/ - "OpenLogsButton", /*SSPG*/ "OpenSSPGButton", /*Config Builder*/ @@ -58,7 +56,7 @@ "AppStateButton", /*Current Log file*/ "OpenCurrentLogButton", - /*Entire Log files*/ + /*Log Analyzer, Entire Log files*/ "OpenLogsButton", /*Visual Studio*/ "OpenVisualStudioButton", From 9ae146bc62b79202c0ab5d4456774cd9c6eea79b Mon Sep 17 00:00:00 2001 From: Dmitry Kolinchuk Date: Fri, 3 Sep 2021 16:51:15 +0300 Subject: [PATCH 4/8] #610 Implement log file folder resolver depending on instance type --- src/SIM.Instances/Instance.cs | 9 +------ .../LogFileFolder/LogFileFolderFactory.cs | 9 +++++++ .../LogFileFolder/LogFileFolderResolver.cs | 24 +++++++++++++++++++ .../SitecoreDefaultLogFileFolderFactory.cs | 18 ++++++++++++++ .../SitecoreMembersLogFileFolderFactory.cs | 19 +++++++++++++++ .../Buttons/OpenLogsButton.cs | 15 ++++++++---- src/SIM.Tool.Windows/SIM.Tool.Windows.csproj | 4 ++++ 7 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs create mode 100644 src/SIM.Tool.Windows/LogFileFolder/LogFileFolderResolver.cs create mode 100644 src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderFactory.cs create mode 100644 src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderFactory.cs diff --git a/src/SIM.Instances/Instance.cs b/src/SIM.Instances/Instance.cs index d1426ffe..209a6ece 100644 --- a/src/SIM.Instances/Instance.cs +++ b/src/SIM.Instances/Instance.cs @@ -649,7 +649,7 @@ protected virtual string GetDataFolderPath() } // This exception occurs when the RuntimeSettingsAccessor.GetWebConfigResult method fails due to missing node (e.g. in xConnect, Identity Server, etc.) // In this case, the logs folder can be resolved manually - catch (InvalidOperationException ex) + catch (InvalidOperationException) { string rootData = FileSystem.FileSystem.Local.Directory.MapPath("App_data", WebRootPath); if (FileSystem.FileSystem.Local.Directory.Exists(rootData)) @@ -657,13 +657,6 @@ protected virtual string GetDataFolderPath() return rootData; } - // xConnect contains the logs folder in the root folder - rootData = FileSystem.FileSystem.Local.Directory.MapPath("logs", WebRootPath); - if (FileSystem.FileSystem.Local.Directory.Exists(rootData)) - { - return WebRootPath; - } - throw new InvalidOperationException($"Cannot get data folder of {WebRootPath}"); } catch (Exception ex) diff --git a/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs b/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs new file mode 100644 index 00000000..c62ca3f6 --- /dev/null +++ b/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs @@ -0,0 +1,9 @@ +using SIM.Instances; + +namespace SIM.Tool.Windows.LogFileFolder +{ + public abstract class LogFileFolderFactory + { + public abstract string GetLogFolder(Instance instance); + } +} \ No newline at end of file diff --git a/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderResolver.cs b/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderResolver.cs new file mode 100644 index 00000000..8d888f25 --- /dev/null +++ b/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderResolver.cs @@ -0,0 +1,24 @@ +using SIM.Instances; + +namespace SIM.Tool.Windows.LogFileFolder +{ + public class LogFileFolderResolver + { + private readonly Instance _instance; + + public LogFileFolderResolver(Instance instance) + { + this._instance = instance; + } + + public string GetLogFolder() + { + if (_instance.Type == Instance.InstanceType.SitecoreMember) + { + return new SitecoreMembersLogFileFolderFactory().GetLogFolder(_instance); + } + + return new SitecoreDefaultLogFileFolderFactory().GetLogFolder(_instance); + } + } +} \ No newline at end of file diff --git a/src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderFactory.cs b/src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderFactory.cs new file mode 100644 index 00000000..3aaf1723 --- /dev/null +++ b/src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderFactory.cs @@ -0,0 +1,18 @@ +using System.IO; +using SIM.Extensions; +using SIM.Instances; + +namespace SIM.Tool.Windows.LogFileFolder +{ + public class SitecoreDefaultLogFileFolderFactory : LogFileFolderFactory + { + public override string GetLogFolder(Instance instance) + { + var dataFolderPath = instance.DataFolderPath; + + FileSystem.FileSystem.Local.Directory.AssertExists(dataFolderPath, "The data folder ({0}) of the {1} instance doesn't exist".FormatWith(dataFolderPath, instance.Name)); + + return Path.Combine(dataFolderPath, "logs"); + } + } +} \ No newline at end of file diff --git a/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderFactory.cs b/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderFactory.cs new file mode 100644 index 00000000..2bca98f5 --- /dev/null +++ b/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderFactory.cs @@ -0,0 +1,19 @@ +using SIM.Instances; + +namespace SIM.Tool.Windows.LogFileFolder +{ + public class SitecoreMembersLogFileFolderFactory : LogFileFolderFactory + { + public override string GetLogFolder(Instance instance) + { + // Sitecore members like Identity Server contain the logs folder inside the root folder + string logsPath = FileSystem.FileSystem.Local.Directory.MapPath("logs", instance.WebRootPath); + if (FileSystem.FileSystem.Local.Directory.Exists(logsPath)) + { + return logsPath; + } + + return new SitecoreDefaultLogFileFolderFactory().GetLogFolder(instance); + } + } +} \ No newline at end of file diff --git a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs index 867335b5..3771090a 100644 --- a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs +++ b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs @@ -3,6 +3,8 @@ using JetBrains.Annotations; using SIM.Extensions; using SIM.Instances; +using SIM.Tool.Base; +using SIM.Tool.Windows.LogFileFolder; namespace SIM.Tool.Windows.MainWindowComponents.Buttons { @@ -39,11 +41,16 @@ public override void OnClick(Window mainWindow, Instance instance) { if (instance != null) { - var dataFolderPath = instance.DataFolderPath; - FileSystem.FileSystem.Local.Directory.AssertExists(dataFolderPath, "The data folder ({0}) of the {1} instance doesn't exist".FormatWith(dataFolderPath, instance.Name)); + string logs = new LogFileFolderResolver(instance).GetLogFolder(); - var logs = Path.Combine(dataFolderPath, "logs"); - RunApp(mainWindow, logs); + if (string.IsNullOrEmpty(logs)) + { + WindowHelper.ShowMessage($"Unable to find the logs folder under '{instance.WebRootPath}'.", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + RunApp(mainWindow, logs); + } return; } diff --git a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj index f1c804bd..284189a8 100644 --- a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj +++ b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj @@ -151,6 +151,7 @@ RestoreDatabaseDialog.xaml + @@ -221,7 +222,10 @@ + + + From 12d58bc2f8b0e55bd9ae5006972ca62496619716 Mon Sep 17 00:00:00 2001 From: Dmitry Kolinchuk Date: Fri, 3 Sep 2021 16:55:36 +0300 Subject: [PATCH 5/8] #610 Remove OpenCurrentLogButton from Sitecore members since it does not support their log name format --- src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json b/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json index 9ff11b4e..76f9def7 100644 --- a/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json +++ b/src/SIM.Tool/ButtonsConfiguration/ButtonsConfiguration.json @@ -149,7 +149,6 @@ "CreateSupportHotfixButton", "OpenFileButton", "ConfigBuilderButton", - "OpenCurrentLogButton", "OpenLogsButton", "OpenVisualStudioButton", "ControlAppPoolButton", From 900a2cafa2f359105408c4363157d194ee9422b5 Mon Sep 17 00:00:00 2001 From: Dmitry Kolinchuk Date: Fri, 10 Sep 2021 09:54:30 +0300 Subject: [PATCH 6/8] #610 Change implementation of log file folder factory and resolver --- .../LogFileFolder/LogFileFolderFactory.cs | 12 +++++++-- .../LogFileFolder/LogFileFolderResolver.cs | 23 +++------------- .../SitecoreDefaultLogFileFolderFactory.cs | 18 ------------- .../SitecoreDefaultLogFileFolderResolver.cs | 25 ++++++++++++++++++ .../SitecoreMembersLogFileFolderFactory.cs | 19 -------------- .../SitecoreMembersLogFileFolderResolver.cs | 26 +++++++++++++++++++ .../Buttons/OpenLogsButton.cs | 2 +- src/SIM.Tool.Windows/SIM.Tool.Windows.csproj | 6 ++--- 8 files changed, 68 insertions(+), 63 deletions(-) delete mode 100644 src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderFactory.cs create mode 100644 src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderResolver.cs delete mode 100644 src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderFactory.cs create mode 100644 src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderResolver.cs diff --git a/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs b/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs index c62ca3f6..57d27a13 100644 --- a/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs +++ b/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs @@ -2,8 +2,16 @@ namespace SIM.Tool.Windows.LogFileFolder { - public abstract class LogFileFolderFactory + public static class LogFileFolderFactory { - public abstract string GetLogFolder(Instance instance); + public static LogFileFolderResolver GetResolver(Instance instance) + { + if (instance.Type == Instance.InstanceType.SitecoreMember) + { + return new SitecoreMembersLogFileFolderResolver(instance); + } + + return new SitecoreDefaultLogFileFolderResolver(instance); + } } } \ No newline at end of file diff --git a/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderResolver.cs b/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderResolver.cs index 8d888f25..716ddb02 100644 --- a/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderResolver.cs +++ b/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderResolver.cs @@ -1,24 +1,7 @@ -using SIM.Instances; - -namespace SIM.Tool.Windows.LogFileFolder +namespace SIM.Tool.Windows.LogFileFolder { - public class LogFileFolderResolver + public abstract class LogFileFolderResolver { - private readonly Instance _instance; - - public LogFileFolderResolver(Instance instance) - { - this._instance = instance; - } - - public string GetLogFolder() - { - if (_instance.Type == Instance.InstanceType.SitecoreMember) - { - return new SitecoreMembersLogFileFolderFactory().GetLogFolder(_instance); - } - - return new SitecoreDefaultLogFileFolderFactory().GetLogFolder(_instance); - } + public abstract string GetLogFolder(); } } \ No newline at end of file diff --git a/src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderFactory.cs b/src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderFactory.cs deleted file mode 100644 index 3aaf1723..00000000 --- a/src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderFactory.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.IO; -using SIM.Extensions; -using SIM.Instances; - -namespace SIM.Tool.Windows.LogFileFolder -{ - public class SitecoreDefaultLogFileFolderFactory : LogFileFolderFactory - { - public override string GetLogFolder(Instance instance) - { - var dataFolderPath = instance.DataFolderPath; - - FileSystem.FileSystem.Local.Directory.AssertExists(dataFolderPath, "The data folder ({0}) of the {1} instance doesn't exist".FormatWith(dataFolderPath, instance.Name)); - - return Path.Combine(dataFolderPath, "logs"); - } - } -} \ No newline at end of file diff --git a/src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderResolver.cs b/src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderResolver.cs new file mode 100644 index 00000000..e7cbea4a --- /dev/null +++ b/src/SIM.Tool.Windows/LogFileFolder/SitecoreDefaultLogFileFolderResolver.cs @@ -0,0 +1,25 @@ +using System.IO; +using SIM.Extensions; +using SIM.Instances; + +namespace SIM.Tool.Windows.LogFileFolder +{ + public class SitecoreDefaultLogFileFolderResolver : LogFileFolderResolver + { + private readonly Instance _instance; + + public SitecoreDefaultLogFileFolderResolver(Instance instance) + { + this._instance = instance; + } + + public override string GetLogFolder() + { + var dataFolderPath = _instance.DataFolderPath; + + FileSystem.FileSystem.Local.Directory.AssertExists(dataFolderPath, "The data folder ({0}) of the {1} instance doesn't exist".FormatWith(dataFolderPath, _instance.Name)); + + return Path.Combine(dataFolderPath, "logs"); + } + } +} \ No newline at end of file diff --git a/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderFactory.cs b/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderFactory.cs deleted file mode 100644 index 2bca98f5..00000000 --- a/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderFactory.cs +++ /dev/null @@ -1,19 +0,0 @@ -using SIM.Instances; - -namespace SIM.Tool.Windows.LogFileFolder -{ - public class SitecoreMembersLogFileFolderFactory : LogFileFolderFactory - { - public override string GetLogFolder(Instance instance) - { - // Sitecore members like Identity Server contain the logs folder inside the root folder - string logsPath = FileSystem.FileSystem.Local.Directory.MapPath("logs", instance.WebRootPath); - if (FileSystem.FileSystem.Local.Directory.Exists(logsPath)) - { - return logsPath; - } - - return new SitecoreDefaultLogFileFolderFactory().GetLogFolder(instance); - } - } -} \ No newline at end of file diff --git a/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderResolver.cs b/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderResolver.cs new file mode 100644 index 00000000..6ba88204 --- /dev/null +++ b/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderResolver.cs @@ -0,0 +1,26 @@ +using SIM.Instances; + +namespace SIM.Tool.Windows.LogFileFolder +{ + public class SitecoreMembersLogFileFolderResolver : LogFileFolderResolver + { + private readonly Instance _instance; + + public SitecoreMembersLogFileFolderResolver(Instance instance) + { + this._instance = instance; + } + + public override string GetLogFolder() + { + // Sitecore members like Identity Server contain the logs folder inside the root folder + string logsPath = FileSystem.FileSystem.Local.Directory.MapPath("logs", _instance.WebRootPath); + if (FileSystem.FileSystem.Local.Directory.Exists(logsPath)) + { + return logsPath; + } + + return new SitecoreDefaultLogFileFolderResolver(_instance).GetLogFolder(); + } + } +} \ No newline at end of file diff --git a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs index 3771090a..b52e5ea1 100644 --- a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs +++ b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs @@ -41,7 +41,7 @@ public override void OnClick(Window mainWindow, Instance instance) { if (instance != null) { - string logs = new LogFileFolderResolver(instance).GetLogFolder(); + string logs = LogFileFolderFactory.GetResolver(instance).GetLogFolder(); if (string.IsNullOrEmpty(logs)) { diff --git a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj index 284189a8..8629c367 100644 --- a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj +++ b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj @@ -151,7 +151,7 @@ RestoreDatabaseDialog.xaml - + @@ -222,10 +222,10 @@ - + - + From fa4509f24e87834039d3d1c81e0ffb314873cc68 Mon Sep 17 00:00:00 2001 From: Dmitry Kolinchuk Date: Fri, 10 Sep 2021 10:32:18 +0300 Subject: [PATCH 7/8] #610 Rework resolving of data folder path when an exception occurs --- src/SIM.Instances/Instance.cs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/SIM.Instances/Instance.cs b/src/SIM.Instances/Instance.cs index 209a6ece..9aec41b8 100644 --- a/src/SIM.Instances/Instance.cs +++ b/src/SIM.Instances/Instance.cs @@ -647,25 +647,19 @@ protected virtual string GetDataFolderPath() return MapPath(dataFolder); } - // This exception occurs when the RuntimeSettingsAccessor.GetWebConfigResult method fails due to missing node (e.g. in xConnect, Identity Server, etc.) - // In this case, the logs folder can be resolved manually - catch (InvalidOperationException) + catch (Exception ex) { - string rootData = FileSystem.FileSystem.Local.Directory.MapPath("App_data", WebRootPath); - if (FileSystem.FileSystem.Local.Directory.Exists(rootData)) + string rootData = Path.Combine(Path.GetDirectoryName(WebRootPath), "Data"); + if (this.IsValidDataFolderPath(rootData, ex)) { return rootData; } - throw new InvalidOperationException($"Cannot get data folder of {WebRootPath}"); - } - catch (Exception ex) - { - var rootData = Path.Combine(Path.GetDirectoryName(WebRootPath), "Data"); - if (FileSystem.FileSystem.Local.Directory.Exists(rootData)) + // InvalidOperationException occurs when the RuntimeSettingsAccessor.GetWebConfigResult method fails due to missing node (e.g. in xConnect, Identity Server, etc.) + // In this case, the log file folder can be resolved manually + rootData = FileSystem.FileSystem.Local.Directory.MapPath("App_data", WebRootPath); + if (this.IsValidDataFolderPath(rootData, ex)) { - Log.Error(ex, $"Cannot get data folder of {WebRootPath}"); - return rootData; } @@ -674,6 +668,18 @@ protected virtual string GetDataFolderPath() } } + private bool IsValidDataFolderPath(string rootData, Exception ex) + { + if (FileSystem.FileSystem.Local.Directory.Exists(rootData)) + { + Log.Error(ex, $"Cannot get data folder of {WebRootPath}"); + + return true; + } + + return false; + } + protected virtual bool GetIsHidden() { try From 59e0ecdbde69f8a18538dfaf8ae7858ff93a3300 Mon Sep 17 00:00:00 2001 From: Dmitry Kolinchuk Date: Fri, 17 Sep 2021 08:57:31 +0300 Subject: [PATCH 8/8] #610 Move the fallback logic of log file folder resolver to OpenLogsButton --- src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs | 5 +++++ .../LogFileFolder/SitecoreMembersLogFileFolderResolver.cs | 2 +- .../MainWindowComponents/Buttons/OpenLogsButton.cs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs b/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs index 57d27a13..9647c42a 100644 --- a/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs +++ b/src/SIM.Tool.Windows/LogFileFolder/LogFileFolderFactory.cs @@ -13,5 +13,10 @@ public static LogFileFolderResolver GetResolver(Instance instance) return new SitecoreDefaultLogFileFolderResolver(instance); } + + public static LogFileFolderResolver GetDefaultResolver(Instance instance) + { + return new SitecoreDefaultLogFileFolderResolver(instance); + } } } \ No newline at end of file diff --git a/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderResolver.cs b/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderResolver.cs index 6ba88204..1da81fba 100644 --- a/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderResolver.cs +++ b/src/SIM.Tool.Windows/LogFileFolder/SitecoreMembersLogFileFolderResolver.cs @@ -20,7 +20,7 @@ public override string GetLogFolder() return logsPath; } - return new SitecoreDefaultLogFileFolderResolver(_instance).GetLogFolder(); + return null; } } } \ No newline at end of file diff --git a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs index b52e5ea1..2dec0afa 100644 --- a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs +++ b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/OpenLogsButton.cs @@ -41,7 +41,7 @@ public override void OnClick(Window mainWindow, Instance instance) { if (instance != null) { - string logs = LogFileFolderFactory.GetResolver(instance).GetLogFolder(); + string logs = LogFileFolderFactory.GetResolver(instance).GetLogFolder() ?? LogFileFolderFactory.GetDefaultResolver(instance).GetLogFolder(); if (string.IsNullOrEmpty(logs)) {