From 3012eed3f35e6bb5d53023c7248a85985752fa00 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Fri, 13 Nov 2020 11:22:46 -0500 Subject: [PATCH 01/51] created Install PS button, enabled it as long as an instance is selected, and created an args class for it --- .../InstallPublishingServiceWizardArgs.cs | 19 ++++++++++ src/SIM.Tool.Base/SIM.Tool.Base.csproj | 1 + .../InstallPublishingServiceButton.cs | 37 +++++++++++++++++++ src/SIM.Tool.Windows/MainWindowData.cs | 6 +++ src/SIM.Tool.Windows/SIM.Tool.Windows.csproj | 1 + 5 files changed, 64 insertions(+) create mode 100644 src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs create mode 100644 src/SIM.Tool.Windows/MainWindowComponents/InstallPublishingServiceButton.cs diff --git a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs new file mode 100644 index 00000000..4dcde049 --- /dev/null +++ b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs @@ -0,0 +1,19 @@ +namespace SIM.Tool.Base.Pipelines +{ + using System.Data.SqlClient; + + using SIM.Instances; + using SIM.Pipelines.Install; + using SIM.Pipelines.Processors; + using SIM.Tool.Base.Wizards; + + public class InstallPublishingServiceWizardArgs : WizardArgs + { + public InstallPublishingServiceWizardArgs(Instance instance) + { + Instance = instance; + } + + public Instance Instance { get; } + } +} \ No newline at end of file diff --git a/src/SIM.Tool.Base/SIM.Tool.Base.csproj b/src/SIM.Tool.Base/SIM.Tool.Base.csproj index 561327f7..6446f6b3 100644 --- a/src/SIM.Tool.Base/SIM.Tool.Base.csproj +++ b/src/SIM.Tool.Base/SIM.Tool.Base.csproj @@ -79,6 +79,7 @@ + diff --git a/src/SIM.Tool.Windows/MainWindowComponents/InstallPublishingServiceButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/InstallPublishingServiceButton.cs new file mode 100644 index 00000000..4e88de7a --- /dev/null +++ b/src/SIM.Tool.Windows/MainWindowComponents/InstallPublishingServiceButton.cs @@ -0,0 +1,37 @@ +namespace SIM.Tool.Windows.MainWindowComponents +{ + using System.Windows; + using SIM.Core.Common; + using SIM.Instances; + using SIM.Tool.Base.Plugins; + using JetBrains.Annotations; + using SIM.Tool.Base.Pipelines; + using SIM.Tool.Base.Wizards; + + [UsedImplicitly] + public class InstallPublishingServiceButton : IMainWindowButton + { + #region Public methods + + public bool IsEnabled(Window mainWindow, Instance instance) + { + return instance != null; + } + + public bool IsVisible(Window mainWindow, Instance instance) + { + return true; + } + + public void OnClick(Window mainWindow, Instance instance) + { + if (instance != null) + { + var id = MainWindowHelper.GetListItemID(instance.ID); + WizardPipelineManager.Start("installpublishingservice", mainWindow, null, null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new InstallPublishingServiceWizardArgs(instance)); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/src/SIM.Tool.Windows/MainWindowData.cs b/src/SIM.Tool.Windows/MainWindowData.cs index 254af682..5eb946f3 100644 --- a/src/SIM.Tool.Windows/MainWindowData.cs +++ b/src/SIM.Tool.Windows/MainWindowData.cs @@ -670,6 +670,12 @@ private static ButtonDefinition GetPatchButton() Image = "/Images/$lg/install.png, SIM.Tool.Windows", Handler = new SIM.Tool.Windows.MainWindowComponents.InstallModulesButton() }, + new ButtonDefinition + { + Label = "Publishing Service", + Image = "/Images/$lg/install.png, SIM.Tool.Windows", + Handler = new SIM.Tool.Windows.MainWindowComponents.InstallPublishingServiceButton() + }, } }, GetManageGroupDefinition(), diff --git a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj index 11df7f7a..d08fe692 100644 --- a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj +++ b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj @@ -169,6 +169,7 @@ + From b8aef0a1498c2c4f6d394af274b03c49edfdd963 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Fri, 13 Nov 2020 13:51:16 -0500 Subject: [PATCH 02/51] Added first Wizard step page (not completed, not visible) --- .../InstallPublishingServiceWizardArgs.cs | 11 ++++ src/SIM.Tool.Windows/SIM.Tool.Windows.csproj | 7 +++ .../ConfigureParameters.xaml | 25 +++++++++ .../ConfigureParameters.xaml.cs | 52 +++++++++++++++++++ src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 9 ++++ 5 files changed, 104 insertions(+) create mode 100644 src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml create mode 100644 src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs diff --git a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs index 4dcde049..4fe34312 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs @@ -1,10 +1,13 @@ namespace SIM.Tool.Base.Pipelines { + using System.Collections.Generic; using System.Data.SqlClient; using SIM.Instances; using SIM.Pipelines.Install; using SIM.Pipelines.Processors; + using SIM.Services; + using SIM.Tool.Base.Converters; using SIM.Tool.Base.Wizards; public class InstallPublishingServiceWizardArgs : WizardArgs @@ -12,8 +15,16 @@ public class InstallPublishingServiceWizardArgs : WizardArgs public InstallPublishingServiceWizardArgs(Instance instance) { Instance = instance; + InstanceName = instance.Name; + InstanceWebrootDirectory = instance.WebRootPath; + } public Instance Instance { get; } + public string InstanceName { get; } + public string InstanceWebrootDirectory { get; } + public string PublishingServiceName { get; set; } + public string PublishingServiceWebrootDirectory { get; set; } + public Dictionary ConnectionStrings { get; set; } } } \ No newline at end of file diff --git a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj index d08fe692..2a53edc3 100644 --- a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj +++ b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj @@ -301,6 +301,9 @@ Install9ParametersEditor.xaml + + ConfigureParameters.xaml + ValidationDetails.xaml @@ -644,6 +647,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml new file mode 100644 index 00000000..deec4f0a --- /dev/null +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs new file mode 100644 index 00000000..ec3bc040 --- /dev/null +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs @@ -0,0 +1,52 @@ +using SIM.Tool.Base.Pipelines; +using SIM.Tool.Base.Wizards; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SIM.Tool.Windows.UserControls.Install.PublishingService +{ + /// + /// Interaction logic for ConfigureParameters.xaml + /// + public partial class ConfigureParameters : IWizardStep, IFlowControl + { + public ConfigureParameters() + { + InitializeComponent(); + } + + public void InitializeStep(WizardArgs wizardArgs) + { + InstallPublishingServiceWizardArgs args = (InstallPublishingServiceWizardArgs)wizardArgs; + InstanceNameTextBlock.Text = args.InstanceName; + InstancePathTextBlock.Text = args.Instance.RootPath; + } + + public bool OnMovingBack(WizardArgs wizardArgs) + { + return true; + } + + public bool OnMovingNext(WizardArgs wizardArgs) + { + return true; + } + + public bool SaveChanges(WizardArgs wizardArgs) + { + return true; + } + } +} diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index c3755a19..fbce7872 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -425,6 +425,15 @@ By clicking 'Next' you accept the License Agreement."" /> + + + + + + "; From 6372657142c46d4b68ff733ea2c2118132dadc72 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Tue, 17 Nov 2020 13:06:28 -0500 Subject: [PATCH 03/51] Completed wizard pipeline (bare minumum required, second page to come later). Started processor pipeline. --- .../InstallPublishingServiceProcessorArgs.cs | 24 +++++++ src/SIM.Pipelines/PipelinesConfig.cs | 8 +++ src/SIM.Pipelines/SIM.Pipelines.csproj | 1 + .../InstallPublishingServiceWizardArgs.cs | 64 ++++++++++++++++--- src/SIM.Tool.Base/Windows/Wizard.xaml.cs | 2 +- .../ConfigureParameters.xaml | 23 ++++--- .../ConfigureParameters.xaml.cs | 33 +++++++++- src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 2 +- 8 files changed, 130 insertions(+), 27 deletions(-) create mode 100644 src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs new file mode 100644 index 00000000..bf0a491b --- /dev/null +++ b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs @@ -0,0 +1,24 @@ +using SIM.Pipelines.Processors; +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.InstallPublishingService +{ + public class InstallPublishingServiceProcessorArgs : ProcessorArgs + { + #region Properties + public string InstanceName { get; set; } + public string InstanceInstallRoot { get; set; } + public string PublishingServiceInstallRoot { get; set; } + public string SqlAdminUsername { get; set; } + public string SqlAdminPassword { get; set; } + public string PublishingServiceSiteName { get; set; } + public Dictionary PublishingServiceConnectionStrings { get; set; } + + #endregion + } +} diff --git a/src/SIM.Pipelines/PipelinesConfig.cs b/src/SIM.Pipelines/PipelinesConfig.cs index 59024c3e..fd707d55 100644 --- a/src/SIM.Pipelines/PipelinesConfig.cs +++ b/src/SIM.Pipelines/PipelinesConfig.cs @@ -217,6 +217,14 @@ public static class PipelinesConfig + + + + + + + + "; } } diff --git a/src/SIM.Pipelines/SIM.Pipelines.csproj b/src/SIM.Pipelines/SIM.Pipelines.csproj index 99f9c652..09907284 100644 --- a/src/SIM.Pipelines/SIM.Pipelines.csproj +++ b/src/SIM.Pipelines/SIM.Pipelines.csproj @@ -100,6 +100,7 @@ + diff --git a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs index 4fe34312..085d1027 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs @@ -2,29 +2,73 @@ { using System.Collections.Generic; using System.Data.SqlClient; - + using SIM.Adapters.WebServer; using SIM.Instances; using SIM.Pipelines.Install; + using SIM.Pipelines.InstallPublishingService; using SIM.Pipelines.Processors; using SIM.Services; using SIM.Tool.Base.Converters; + using SIM.Tool.Base.Profiles; using SIM.Tool.Base.Wizards; public class InstallPublishingServiceWizardArgs : WizardArgs { public InstallPublishingServiceWizardArgs(Instance instance) { - Instance = instance; - InstanceName = instance.Name; - InstanceWebrootDirectory = instance.WebRootPath; + Initialize(instance); + } + + #region Properties + + //From Instance + public Instance Instance { get; private set; } + public string InstanceName { get; private set; } + public ConnectionStringCollection InstanceConnectionStrings { get; private set; } + + //From Profile + public string InstanceInstallRoot { get; set; } + public string PublishingServiceInstallRoot { get; set; } + + public string SqlAdminUsername { get; private set; } + public string SqlAdminPassword { get; private set; } + + + //From User Input + public string PublishingServiceSiteName { get; set; } + public Dictionary PublishingServiceConnectionStrings { get; set; } + + #endregion + + #region Methods + private void Initialize(Instance instance) + { + this.Instance = instance; + this.InstanceName = instance.Name; + this.InstanceInstallRoot = ProfileManager.Profile.InstancesFolder; + this.InstanceConnectionStrings = instance.Configuration.ConnectionStrings; + this.PublishingServiceInstallRoot = ProfileManager.Profile.InstancesFolder; + + SqlConnectionStringBuilder SqlServerConnectionString = ProfileManager.GetConnectionString(); + this.SqlAdminUsername = SqlServerConnectionString.UserID; + this.SqlAdminPassword = SqlServerConnectionString.Password; + } + + public override ProcessorArgs ToProcessorArgs() + { + return new InstallPublishingServiceProcessorArgs() + { + InstanceName = this.InstanceName, + PublishingServiceSiteName = this.PublishingServiceSiteName, + InstanceInstallRoot = this.InstanceInstallRoot, + PublishingServiceInstallRoot = this.PublishingServiceInstallRoot, + SqlAdminUsername = this.SqlAdminUsername, + SqlAdminPassword = this.SqlAdminPassword, + PublishingServiceConnectionStrings = this.PublishingServiceConnectionStrings + }; } - public Instance Instance { get; } - public string InstanceName { get; } - public string InstanceWebrootDirectory { get; } - public string PublishingServiceName { get; set; } - public string PublishingServiceWebrootDirectory { get; set; } - public Dictionary ConnectionStrings { get; set; } + #endregion } } \ No newline at end of file diff --git a/src/SIM.Tool.Base/Windows/Wizard.xaml.cs b/src/SIM.Tool.Base/Windows/Wizard.xaml.cs index 190d0585..1c361865 100644 --- a/src/SIM.Tool.Base/Windows/Wizard.xaml.cs +++ b/src/SIM.Tool.Base/Windows/Wizard.xaml.cs @@ -761,7 +761,7 @@ private void MoveNextClick(object sender, RoutedEventArgs e) catch (Exception ex) { WindowHelper.HandleError( - $"Something went wrong with Wizard logic. It is to be closed. {Environment.NewLine}{Environment.NewLine}{ex.Message}", false, ex); + $"Something went wrong with Wizard logic. It is to be closed. {Environment.NewLine}{Environment.NewLine}{ex.Message}{ex.StackTrace}", false, ex); Close(); } } diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml index deec4f0a..0c17489a 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml @@ -3,23 +3,22 @@ mc:Ignorable="d" d:DesignHeight="399" d:DesignWidth="633"> - - - + + - - - - - - + - - - + + + + + + + diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs index ec3bc040..b91e36e3 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs @@ -1,7 +1,10 @@ -using SIM.Tool.Base.Pipelines; +using SIM.Adapters.WebServer; +using SIM.Extensions; +using SIM.Tool.Base.Pipelines; using SIM.Tool.Base.Wizards; using System; using System.Collections.Generic; +using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -22,6 +25,9 @@ namespace SIM.Tool.Windows.UserControls.Install.PublishingService /// public partial class ConfigureParameters : IWizardStep, IFlowControl { + + public ConnectionStringCollection ConnectionStrings { get; set; } + public ConfigureParameters() { InitializeComponent(); @@ -30,8 +36,19 @@ public ConfigureParameters() public void InitializeStep(WizardArgs wizardArgs) { InstallPublishingServiceWizardArgs args = (InstallPublishingServiceWizardArgs)wizardArgs; - InstanceNameTextBlock.Text = args.InstanceName; - InstancePathTextBlock.Text = args.Instance.RootPath; + foreach (var connString in args.InstanceConnectionStrings) + { + switch (connString.Name.ToLower().Trim()) + { + case "core": + case "master": + case "web": + ConnectionStringsListBox.Items.Add(new CheckBox() { Content = connString.Name, IsChecked = true }); break; + default: + ConnectionStringsListBox.Items.Add(new CheckBox() { Content = connString.Name }); break; + } + } + return; } public bool OnMovingBack(WizardArgs wizardArgs) @@ -41,6 +58,16 @@ public bool OnMovingBack(WizardArgs wizardArgs) public bool OnMovingNext(WizardArgs wizardArgs) { + InstallPublishingServiceWizardArgs args = (InstallPublishingServiceWizardArgs)wizardArgs; + args.PublishingServiceSiteName = PublishingServiceSiteNameTextBox.Text.Trim(); + foreach (CheckBox checkbox in ConnectionStringsListBox.Items) + { + if (checkbox.IsChecked ?? false) + { + args.PublishingServiceConnectionStrings.Add(checkbox.Content.ToString(), + new SqlConnectionStringBuilder(args.InstanceConnectionStrings.Find(cs => cs.Name.Equals(checkbox.Content)).Value)); + } + } return true; } diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index fbce7872..99bfc5e6 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -429,7 +429,7 @@ By clicking 'Next' you accept the License Agreement."" /> startButton=""Install"" finishText=""Publishing Service installation completed""> - From ff9c599881aecc8c3eeada18bbfec469c529a631 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Wed, 18 Nov 2020 16:40:54 -0500 Subject: [PATCH 04/51] Added a new first wizard page to select PS version and provide links for downloading PS, open the local repo, and compatibility KBs --- .../InstallPublishingServiceProcessorArgs.cs | 1 + src/SIM.Pipelines/PipelinesConfig.cs | 10 ++- .../InstallPublishingServiceWizardArgs.cs | 9 ++- src/SIM.Tool.Windows/SIM.Tool.Windows.csproj | 7 ++ .../ConfigureParameters.xaml | 7 +- .../SelectPublishingServicePackage.xaml | 47 +++++++++++ .../SelectPublishingServicePackage.xaml.cs | 79 +++++++++++++++++++ src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 4 +- 8 files changed, 157 insertions(+), 7 deletions(-) create mode 100644 src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml create mode 100644 src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs index bf0a491b..a48f815c 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs +++ b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs @@ -16,6 +16,7 @@ public class InstallPublishingServiceProcessorArgs : ProcessorArgs public string PublishingServiceInstallRoot { get; set; } public string SqlAdminUsername { get; set; } public string SqlAdminPassword { get; set; } + public string PublishingServicePackagePath { get; set; } public string PublishingServiceSiteName { get; set; } public Dictionary PublishingServiceConnectionStrings { get; set; } diff --git a/src/SIM.Pipelines/PipelinesConfig.cs b/src/SIM.Pipelines/PipelinesConfig.cs index fd707d55..82480740 100644 --- a/src/SIM.Pipelines/PipelinesConfig.cs +++ b/src/SIM.Pipelines/PipelinesConfig.cs @@ -217,6 +217,12 @@ public static class PipelinesConfig +"; + } +} + +/* + TO BE ADDED: @@ -225,6 +231,4 @@ public static class PipelinesConfig -"; - } -} +*/ \ No newline at end of file diff --git a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs index 085d1027..694b8502 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs @@ -2,6 +2,7 @@ { using System.Collections.Generic; using System.Data.SqlClient; + using System.IO; using SIM.Adapters.WebServer; using SIM.Instances; using SIM.Pipelines.Install; @@ -14,6 +15,7 @@ public class InstallPublishingServiceWizardArgs : WizardArgs { + private string _publishingServicePackagePath; public InstallPublishingServiceWizardArgs(Instance instance) { Initialize(instance); @@ -35,6 +37,11 @@ public InstallPublishingServiceWizardArgs(Instance instance) //From User Input + public string PublishingServicePackage + { + get { return Path.GetFileNameWithoutExtension(_publishingServicePackagePath); } + set { _publishingServicePackagePath = value; } + } public string PublishingServiceSiteName { get; set; } public Dictionary PublishingServiceConnectionStrings { get; set; } @@ -62,11 +69,11 @@ public override ProcessorArgs ToProcessorArgs() PublishingServiceSiteName = this.PublishingServiceSiteName, InstanceInstallRoot = this.InstanceInstallRoot, PublishingServiceInstallRoot = this.PublishingServiceInstallRoot, + PublishingServicePackagePath = this._publishingServicePackagePath, SqlAdminUsername = this.SqlAdminUsername, SqlAdminPassword = this.SqlAdminPassword, PublishingServiceConnectionStrings = this.PublishingServiceConnectionStrings }; - } #endregion diff --git a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj index 2a53edc3..a6127017 100644 --- a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj +++ b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj @@ -304,6 +304,9 @@ ConfigureParameters.xaml + + SelectPublishingServicePackage.xaml + ValidationDetails.xaml @@ -651,6 +654,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml index 0c17489a..0d0c2bf6 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml @@ -1,5 +1,8 @@ - diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml new file mode 100644 index 00000000..da9fcbb8 --- /dev/null +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + You can + + get publishing service packages here. + + Then place them into + + SIM's local repository + + to populate the dropdown. + + + Please check the compatibility tables to ensure your selected version is compatible with your instance: + + Sitecore Publishing Service – compatibility tables (for SPS prior to 4.1.0) + + + Sitecore Publishing Service – compatibility tables (for SPS 4.1.0 and later) + + + SXA Compatibility With Sitecore Publishing Service + + + + + diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs new file mode 100644 index 00000000..1d8f7d6b --- /dev/null +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs @@ -0,0 +1,79 @@ +using Fluent; +using SIM.Tool.Base.Pipelines; +using SIM.Tool.Base.Profiles; +using SIM.Tool.Base.Wizards; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Windows.Controls; +using System.Windows.Navigation; + +namespace SIM.Tool.Windows.UserControls.Install.PublishingService +{ + /// + /// Interaction logic for SelectPublishingServicePackage.xaml + /// + public partial class SelectPublishingServicePackage : IWizardStep, IFlowControl + { + private const string KB_SPS_COMPATIBILTY_PRIOR_TO_410 = @"https://kb.sitecore.net/articles/545289"; + private const string KB_SPS_COMPATIBILTY_410_AND_LATER = @"https://kb.sitecore.net/articles/761308"; + private const string KB_SXA_COMPATIBILITY_WITH_SPS = @"https://kb.sitecore.net/articles/180187#CompatibilityWithSitecorePublishingService"; + + public SelectPublishingServicePackage() + { + InitializeComponent(); + Initialize(); + } + + public void InitializeStep(WizardArgs wizardArgs) + { + return; + } + + public bool OnMovingBack(WizardArgs wizardArgs) + { + return true; + } + + public bool OnMovingNext(WizardArgs wizardArgs) + { + InstallPublishingServiceWizardArgs args = (InstallPublishingServiceWizardArgs)wizardArgs; + args.PublishingServicePackage = PublishingServicePackageComboBox.SelectedItem.ToString(); + return true; + } + + public bool SaveChanges(WizardArgs wizardArgs) + { + return true; + } + + private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) + { + Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); + e.Handled = true; + } + + private void Initialize() + { + //Prepare links + DownloadPublishingServiceLink.NavigateUri = new Uri(@"https://dev.sitecore.net/Downloads/Sitecore_Publishing_Service.aspx"); + OpenLocalRepoLink.NavigateUri = new Uri($@"{ProfileManager.Profile.LocalRepository}"); + KBForSPSCompatibilityPriorTo410.NavigateUri = new Uri(KB_SPS_COMPATIBILTY_PRIOR_TO_410); + KBForSPSCompatibility410AndLater.NavigateUri = new Uri(KB_SPS_COMPATIBILTY_410_AND_LATER); + KBForSXACompatibilityPriorWithSPS.NavigateUri = new Uri(KB_SXA_COMPATIBILITY_WITH_SPS); + + //Populate ComboBox + foreach (string packagePath in Directory.GetFiles(ProfileManager.Profile.LocalRepository, "Sitecore Publishing Service*.zip")) + { + PublishingServicePackageComboBox.Items.Add(new ComboBoxItem() + { + Content = Path.GetFileNameWithoutExtension(packagePath), + Tag = packagePath + }); + } + return; + } + } +} diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index 99bfc5e6..8d871ee6 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -429,7 +429,9 @@ By clicking 'Next' you accept the License Agreement."" /> startButton=""Install"" finishText=""Publishing Service installation completed""> - + From fd6a992e488797c0693de992e3253d5cee5b804c Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Fri, 20 Nov 2020 15:22:54 -0500 Subject: [PATCH 05/51] Pipeline processors are working, installation seems good. Project effectively complete. --- .../InstallPublishingService/Commands.cs | 46 +++++++++++++++++++ .../CreateIISiteProcessor.cs | 16 +++++++ .../InstallPublishingServiceProcessor.cs | 46 +++++++++++++++++++ .../InstallPublishingServiceProcessorArgs.cs | 9 +++- .../ResetDatabaseSchemaProcessor.cs | 19 ++++++++ .../SetActualConnectionStringsProcessor.cs | 22 +++++++++ .../SetAdminConnectionStringsProcessor.cs | 29 ++++++++++++ .../UnzipPackageProcessor.cs | 30 ++++++++++++ .../UpgradeDatabaseSchemaProcessor.cs | 18 ++++++++ src/SIM.Pipelines/PipelinesConfig.cs | 28 +++++------ src/SIM.Pipelines/SIM.Pipelines.csproj | 9 ++++ .../InstallPublishingServiceWizardArgs.cs | 14 +++--- .../ConfigureParameters.xaml.cs | 17 +++++-- .../SelectPublishingServicePackage.xaml.cs | 2 +- 14 files changed, 279 insertions(+), 26 deletions(-) create mode 100644 src/SIM.Pipelines/InstallPublishingService/Commands.cs create mode 100644 src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs create mode 100644 src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs create mode 100644 src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs create mode 100644 src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs create mode 100644 src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs create mode 100644 src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs create mode 100644 src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs diff --git a/src/SIM.Pipelines/InstallPublishingService/Commands.cs b/src/SIM.Pipelines/InstallPublishingService/Commands.cs new file mode 100644 index 00000000..2f5d1f43 --- /dev/null +++ b/src/SIM.Pipelines/InstallPublishingService/Commands.cs @@ -0,0 +1,46 @@ +using MongoDB.Driver.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.InstallPublishingService +{ + public static class Commands + { + private const string SET_CONNECTION_STRING = ".\\Sitecore.Framework.Publishing.Host.exe configuration setconnectionstring {0} \"{1}\""; + private const string SCHEMA_UPGRADE = ".\\Sitecore.Framework.Publishing.Host.exe schema upgrade --force"; + private const string SCHEMA_RESET = ".\\Sitecore.Framework.Publishing.Host.exe schema reset --force"; + private const string IIS_INSTALL = ".\\Sitecore.Framework.Publishing.Host.exe iis install --sitename \"{0}\" --apppool \"{1}\" --hosts --force"; + + public static void SetConnectionString(string connectionStringName, string connectrionStringValue) + { + ExecuteCommand(SET_CONNECTION_STRING, connectionStringName, connectrionStringValue); + } + + public static void SchemaUpgrade() + { + ExecuteCommand(SCHEMA_UPGRADE); + } + + public static void SchemaReset() + { + ExecuteCommand(SCHEMA_RESET); + } + + public static void IISInstall(string siteName, string appPoolName) + { + ExecuteCommand(IIS_INSTALL, siteName, appPoolName); + } + + private static void ExecuteCommand(string commandFormat, params object[] args) + { + using (PowerShell PS = PowerShell.Create()) + { + PS.AddScript(string.Format(commandFormat, args)).Invoke(); + } + } + } +} diff --git a/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs new file mode 100644 index 00000000..f11a9e98 --- /dev/null +++ b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.InstallPublishingService +{ + public class CreateIISiteProcessor : InstallPublishingServiceProcessor + { + protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + { + Commands.IISInstall(args.PublishingServiceSiteName, args.PublishingServiceSiteName); + } + } +} diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs new file mode 100644 index 00000000..c45cdd50 --- /dev/null +++ b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs @@ -0,0 +1,46 @@ +using JetBrains.Annotations; +using SIM.Pipelines.Processors; +using Sitecore.Diagnostics.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.InstallPublishingService +{ + public abstract class InstallPublishingServiceProcessor : Processor + { + protected static bool AbortPipeline = false; + + protected override void Process([NotNull] ProcessorArgs args) + { + InstallPublishingServiceProcessorArgs processorArgs = args as InstallPublishingServiceProcessorArgs; + + if (processorArgs == null) + { + throw new Exception("Invalid ProcessorArgs passed to InstallPublishingServiceProcessor"); + } + + if (AbortPipeline) + { + Log.Warn($"{this} processor was skipped."); + this.Skip(); + return; + } + + try + { + this.ProcessCore(processorArgs); + } + catch (Exception ex) + { + AbortPipeline = true; + Log.Error($"installpublishingservice Pipeline was aborted. The remaining steps were skipped."); + throw ex; + } + } + + protected abstract void ProcessCore(InstallPublishingServiceProcessorArgs processorArgs); + } +} diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs index a48f815c..8de5b5b6 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs +++ b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Data.SqlClient; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -11,15 +12,19 @@ namespace SIM.Pipelines.InstallPublishingService public class InstallPublishingServiceProcessorArgs : ProcessorArgs { #region Properties + //Populated from InstallPublishingServiceWizardArgs public string InstanceName { get; set; } - public string InstanceInstallRoot { get; set; } - public string PublishingServiceInstallRoot { get; set; } + public string InstanceFolder { get; set; } + public string PublishingServiceInstanceFolder { get; set; } public string SqlAdminUsername { get; set; } public string SqlAdminPassword { get; set; } public string PublishingServicePackagePath { get; set; } public string PublishingServiceSiteName { get; set; } public Dictionary PublishingServiceConnectionStrings { get; set; } + //Other Properties + public string PubilshingServiceWebroot { get { return Path.Combine(PublishingServiceInstanceFolder, PublishingServiceSiteName); } } + #endregion } } diff --git a/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs new file mode 100644 index 00000000..1fae90a5 --- /dev/null +++ b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.InstallPublishingService +{ + public class ResetDatabaseSchemaProcessor : InstallPublishingServiceProcessor + { + //Resetting the schema is done to clear any potentially existing Publishing tables + protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + { + Directory.SetCurrentDirectory(args.PubilshingServiceWebroot); + Commands.SchemaReset(); + } + } +} diff --git a/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs new file mode 100644 index 00000000..a54d8b4b --- /dev/null +++ b/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.InstallPublishingService +{ + public class SetActualConnectionStringsProcessor : InstallPublishingServiceProcessor + { + protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + { + Directory.SetCurrentDirectory(args.PubilshingServiceWebroot); + foreach (KeyValuePair connString in args.PublishingServiceConnectionStrings) + { + Commands.SetConnectionString(connString.Key, connString.Value.ToString()); + } + } + } +} diff --git a/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs new file mode 100644 index 00000000..c9fac242 --- /dev/null +++ b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.InstallPublishingService +{ + public class SetAdminConnectionStringsProcessor : InstallPublishingServiceProcessor + { + //Using the admin credentials for connection strings is necessary to upgrade and reset the database schema + protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + { + Directory.SetCurrentDirectory(args.PubilshingServiceWebroot); + foreach (KeyValuePair connString in args.PublishingServiceConnectionStrings) + { + string AdminConnString = new SqlConnectionStringBuilder(connString.Value.ToString()) + { + UserID = args.SqlAdminUsername, + Password = args.SqlAdminPassword + }.ToString(); + + Commands.SetConnectionString(connString.Key, AdminConnString); + } + } + } +} diff --git a/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs new file mode 100644 index 00000000..689bd97a --- /dev/null +++ b/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs @@ -0,0 +1,30 @@ +using JetBrains.Annotations; +using SIM.Pipelines.Processors; +using Sitecore.Diagnostics.Logging; +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.InstallPublishingService +{ + public class UnzipPackageProcessor : InstallPublishingServiceProcessor + { + protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + { + try + { + ZipFile.ExtractToDirectory(args.PublishingServicePackagePath, args.PubilshingServiceWebroot); + } + catch (Exception ex) + { + Log.Error($"\nSOURCE PATH: {args.PublishingServicePackagePath}\nDESTINATION PATH: {args.PubilshingServiceWebroot}"); + throw ex; + } + } + } +} diff --git a/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs new file mode 100644 index 00000000..54debaf0 --- /dev/null +++ b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.InstallPublishingService +{ + public class UpgradeDatabaseSchemaProcessor : InstallPublishingServiceProcessor + { + protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + { + Directory.SetCurrentDirectory(args.PubilshingServiceWebroot); + Commands.SchemaUpgrade(); + } + } +} diff --git a/src/SIM.Pipelines/PipelinesConfig.cs b/src/SIM.Pipelines/PipelinesConfig.cs index 82480740..585085cd 100644 --- a/src/SIM.Pipelines/PipelinesConfig.cs +++ b/src/SIM.Pipelines/PipelinesConfig.cs @@ -217,18 +217,20 @@ public static class PipelinesConfig -"; - } -} - -/* - TO BE ADDED: - - - - - - + + + + + + -*/ \ No newline at end of file +"; + } +} \ No newline at end of file diff --git a/src/SIM.Pipelines/SIM.Pipelines.csproj b/src/SIM.Pipelines/SIM.Pipelines.csproj index 09907284..248a518d 100644 --- a/src/SIM.Pipelines/SIM.Pipelines.csproj +++ b/src/SIM.Pipelines/SIM.Pipelines.csproj @@ -70,6 +70,7 @@ + @@ -100,7 +101,15 @@ + + + + + + + + diff --git a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs index 694b8502..7badf452 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs @@ -29,8 +29,8 @@ public InstallPublishingServiceWizardArgs(Instance instance) public ConnectionStringCollection InstanceConnectionStrings { get; private set; } //From Profile - public string InstanceInstallRoot { get; set; } - public string PublishingServiceInstallRoot { get; set; } + public string InstanceFolder { get; set; } + public string PublishingServiceInstanceFolder { get; set; } public string SqlAdminUsername { get; private set; } public string SqlAdminPassword { get; private set; } @@ -43,7 +43,7 @@ public string PublishingServicePackage set { _publishingServicePackagePath = value; } } public string PublishingServiceSiteName { get; set; } - public Dictionary PublishingServiceConnectionStrings { get; set; } + public Dictionary PublishingServiceConnectionStrings { get; set; } = new Dictionary(); #endregion @@ -52,9 +52,9 @@ private void Initialize(Instance instance) { this.Instance = instance; this.InstanceName = instance.Name; - this.InstanceInstallRoot = ProfileManager.Profile.InstancesFolder; + this.InstanceFolder = ProfileManager.Profile.InstancesFolder; this.InstanceConnectionStrings = instance.Configuration.ConnectionStrings; - this.PublishingServiceInstallRoot = ProfileManager.Profile.InstancesFolder; + this.PublishingServiceInstanceFolder = ProfileManager.Profile.InstancesFolder; SqlConnectionStringBuilder SqlServerConnectionString = ProfileManager.GetConnectionString(); this.SqlAdminUsername = SqlServerConnectionString.UserID; @@ -67,8 +67,8 @@ public override ProcessorArgs ToProcessorArgs() { InstanceName = this.InstanceName, PublishingServiceSiteName = this.PublishingServiceSiteName, - InstanceInstallRoot = this.InstanceInstallRoot, - PublishingServiceInstallRoot = this.PublishingServiceInstallRoot, + InstanceFolder = this.InstanceFolder, + PublishingServiceInstanceFolder = this.PublishingServiceInstanceFolder, PublishingServicePackagePath = this._publishingServicePackagePath, SqlAdminUsername = this.SqlAdminUsername, SqlAdminPassword = this.SqlAdminPassword, diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs index b91e36e3..e7ef8983 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs @@ -1,10 +1,14 @@ using SIM.Adapters.WebServer; using SIM.Extensions; +using SIM.Instances; +using SIM.Tool.Base; using SIM.Tool.Base.Pipelines; using SIM.Tool.Base.Wizards; +using Sitecore.Diagnostics.Logging; using System; using System.Collections.Generic; using System.Data.SqlClient; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -16,7 +20,6 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; -using System.Windows.Shapes; namespace SIM.Tool.Windows.UserControls.Install.PublishingService { @@ -60,14 +63,22 @@ public bool OnMovingNext(WizardArgs wizardArgs) { InstallPublishingServiceWizardArgs args = (InstallPublishingServiceWizardArgs)wizardArgs; args.PublishingServiceSiteName = PublishingServiceSiteNameTextBox.Text.Trim(); + + string newWebroot = Path.Combine(args.PublishingServiceInstanceFolder, args.PublishingServiceSiteName); + if (Directory.Exists(newWebroot)){ + WindowHelper.ShowMessage($"{newWebroot} already exists, please remove it or choose a different name for your instance"); + return false; + } + foreach (CheckBox checkbox in ConnectionStringsListBox.Items) { if (checkbox.IsChecked ?? false) { - args.PublishingServiceConnectionStrings.Add(checkbox.Content.ToString(), - new SqlConnectionStringBuilder(args.InstanceConnectionStrings.Find(cs => cs.Name.Equals(checkbox.Content)).Value)); + ConnectionString connString = args.InstanceConnectionStrings.Single(cs => cs.Name.Equals(checkbox.Content)); + args.PublishingServiceConnectionStrings.Add(checkbox.Content.ToString(), new SqlConnectionStringBuilder(connString.Value)); } } + return true; } diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs index 1d8f7d6b..98028358 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs @@ -40,7 +40,7 @@ public bool OnMovingBack(WizardArgs wizardArgs) public bool OnMovingNext(WizardArgs wizardArgs) { InstallPublishingServiceWizardArgs args = (InstallPublishingServiceWizardArgs)wizardArgs; - args.PublishingServicePackage = PublishingServicePackageComboBox.SelectedItem.ToString(); + args.PublishingServicePackage = ((ComboBoxItem)PublishingServicePackageComboBox.SelectedItem).Tag.ToString(); return true; } From 58dbeea5c5f790f269f2dee498d26963c22c25c2 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Fri, 20 Nov 2020 15:27:43 -0500 Subject: [PATCH 06/51] Added Install Publishing Service button to right click context menu --- src/SIM.Tool.Windows/MainWindowData.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SIM.Tool.Windows/MainWindowData.cs b/src/SIM.Tool.Windows/MainWindowData.cs index 5eb946f3..af87d79a 100644 --- a/src/SIM.Tool.Windows/MainWindowData.cs +++ b/src/SIM.Tool.Windows/MainWindowData.cs @@ -1144,6 +1144,8 @@ private static GroupDefinition GetManageGroupDefinition() new ButtonDefinition { Label = "Reinstall instance", Image = "/Images/$sm/redo.png, SIM.Tool.Windows", Handler = new SIM.Tool.Windows.MainWindowComponents.ReinstallInstanceButton() }, new ButtonDefinition(), new ButtonDefinition { Label = "Delete", Image = "/Images/$sm/uninstall.png, SIM.Tool.Windows", Handler = new SIM.Tool.Windows.MainWindowComponents.DeleteInstanceButton() }, + new ButtonDefinition(), + new ButtonDefinition { Label = "Install Publishing Service", Image = "/Images/$sm/install.png, SIM.Tool.Windows", Handler = new SIM.Tool.Windows.MainWindowComponents.InstallPublishingServiceButton() }, }; public static TabDefinition[] Tabs { get; } = { From d2c681e4461102091a3e0bc7df9a03048ec9d430 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Fri, 20 Nov 2020 15:46:14 -0500 Subject: [PATCH 07/51] Fixed bug where moving back and forward in wizard incorrectly adds more copies of connection string names to list and incorrectly resets which ones are checked --- .../ConfigureParameters.xaml.cs | 36 ++++++------------- .../SelectPublishingServicePackage.xaml.cs | 5 +-- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs index e7ef8983..8e2adfb2 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs @@ -1,25 +1,11 @@ using SIM.Adapters.WebServer; -using SIM.Extensions; -using SIM.Instances; using SIM.Tool.Base; using SIM.Tool.Base.Pipelines; using SIM.Tool.Base.Wizards; -using Sitecore.Diagnostics.Logging; -using System; -using System.Collections.Generic; using System.Data.SqlClient; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; namespace SIM.Tool.Windows.UserControls.Install.PublishingService { @@ -28,9 +14,6 @@ namespace SIM.Tool.Windows.UserControls.Install.PublishingService /// public partial class ConfigureParameters : IWizardStep, IFlowControl { - - public ConnectionStringCollection ConnectionStrings { get; set; } - public ConfigureParameters() { InitializeComponent(); @@ -39,16 +22,19 @@ public ConfigureParameters() public void InitializeStep(WizardArgs wizardArgs) { InstallPublishingServiceWizardArgs args = (InstallPublishingServiceWizardArgs)wizardArgs; - foreach (var connString in args.InstanceConnectionStrings) + if (ConnectionStringsListBox.Items.Count < 1) { - switch (connString.Name.ToLower().Trim()) + foreach (var connString in args.InstanceConnectionStrings) { - case "core": - case "master": - case "web": - ConnectionStringsListBox.Items.Add(new CheckBox() { Content = connString.Name, IsChecked = true }); break; - default: - ConnectionStringsListBox.Items.Add(new CheckBox() { Content = connString.Name }); break; + switch (connString.Name.ToLower().Trim()) + { + case "core": + case "master": + case "web": + ConnectionStringsListBox.Items.Add(new CheckBox() { Content = connString.Name, IsChecked = true }); break; + default: + ConnectionStringsListBox.Items.Add(new CheckBox() { Content = connString.Name }); break; + } } } return; diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs index 98028358..c87bb90a 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs @@ -1,12 +1,9 @@ -using Fluent; -using SIM.Tool.Base.Pipelines; +using SIM.Tool.Base.Pipelines; using SIM.Tool.Base.Profiles; using SIM.Tool.Base.Wizards; using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; using System.Windows.Controls; using System.Windows.Navigation; From df2f4f43f5798b485193a738cfcec7db293fa7f6 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Fri, 20 Nov 2020 17:29:55 -0500 Subject: [PATCH 08/51] Added another processor to check the status endpoint after installation is completed --- .../CreateIISiteProcessor.cs | 1 + .../VerifyInstallationProcessor.cs | 45 +++++++++++++++++++ src/SIM.Pipelines/PipelinesConfig.cs | 2 + src/SIM.Pipelines/SIM.Pipelines.csproj | 8 ++++ src/SIM.Pipelines/packages.config | 1 + src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 4 +- 6 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs diff --git a/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs index f11a9e98..23f87241 100644 --- a/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs new file mode 100644 index 00000000..6a979121 --- /dev/null +++ b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs @@ -0,0 +1,45 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using SIM.Pipelines.Processors; +using Sitecore.Diagnostics.Logging; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.InstallPublishingService +{ + public class VerifyInstallationProcessor : InstallPublishingServiceProcessor + { + protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + { + string statusEndpoint = $"http://{args.PublishingServiceSiteName}/api/publishing/operations/status"; + if (!ValidateStatusEndpoint(statusEndpoint)) + { + Log.Error("Publishing Service returned errors"); + } + OpenStatusEndpoint(statusEndpoint); + } + + private bool ValidateStatusEndpoint(string statusEndpoint) + { + JObject response; + using (WebClient wc = new WebClient()) + { + response = JObject.Parse(wc.DownloadString(statusEndpoint)); + } + + return response["status"].Value().Equals(0); + } + + private void OpenStatusEndpoint(string statusEndpoint) + { + System.Diagnostics.Process.Start(new ProcessStartInfo(statusEndpoint)); + } + + } +} diff --git a/src/SIM.Pipelines/PipelinesConfig.cs b/src/SIM.Pipelines/PipelinesConfig.cs index 585085cd..e60e0935 100644 --- a/src/SIM.Pipelines/PipelinesConfig.cs +++ b/src/SIM.Pipelines/PipelinesConfig.cs @@ -230,6 +230,8 @@ public static class PipelinesConfig title=""Setting actual connection strings"" /> + "; } diff --git a/src/SIM.Pipelines/SIM.Pipelines.csproj b/src/SIM.Pipelines/SIM.Pipelines.csproj index 248a518d..8445668e 100644 --- a/src/SIM.Pipelines/SIM.Pipelines.csproj +++ b/src/SIM.Pipelines/SIM.Pipelines.csproj @@ -60,6 +60,9 @@ ..\packages\mongocsharpdriver.1.10.1\lib\net35\MongoDB.Driver.dll True + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + ..\packages\Sitecore.Diagnostics.Base.2.0.1.171\lib\Sitecore.Diagnostics.Base.dll @@ -71,6 +74,10 @@ + + False + ..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net471\lib\System.Net.Http.dll + @@ -110,6 +117,7 @@ + diff --git a/src/SIM.Pipelines/packages.config b/src/SIM.Pipelines/packages.config index 80369967..e313ec4f 100644 --- a/src/SIM.Pipelines/packages.config +++ b/src/SIM.Pipelines/packages.config @@ -3,6 +3,7 @@ + \ No newline at end of file diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index 8d871ee6..f5e5c43e 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -427,14 +427,14 @@ By clicking 'Next' you accept the License Agreement."" /> + finishText=""Publishing service installation completed.""> - + From 1168c056d6fba2a4f6ca7cb7958d22731b838130 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Fri, 20 Nov 2020 17:39:42 -0500 Subject: [PATCH 09/51] Added completion instructions for installing the PS module afterward --- src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index f5e5c43e..85f23882 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -425,16 +425,15 @@ By clicking 'Next' you accept the License Agreement."" /> - + Control Panel > ADMINISTRATION > Install a package""> - From 06d6b239da4598163034ddf44fe2752053b47b91 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Fri, 20 Nov 2020 18:12:31 -0500 Subject: [PATCH 10/51] Fixed a typo and added an overwrite option (work in progress) --- .../InstallPublishingServiceProcessorArgs.cs | 3 ++- .../ResetDatabaseSchemaProcessor.cs | 2 +- .../SetActualConnectionStringsProcessor.cs | 2 +- .../SetAdminConnectionStringsProcessor.cs | 2 +- .../InstallPublishingService/UnzipPackageProcessor.cs | 8 ++++++-- .../UpgradeDatabaseSchemaProcessor.cs | 2 +- .../Pipelines/InstallPublishingServiceWizardArgs.cs | 4 +++- .../PublishingService/ConfigureParameters.xaml | 11 ++++++++++- .../PublishingService/ConfigureParameters.xaml.cs | 6 ++++-- 9 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs index 8de5b5b6..a5d54cf2 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs +++ b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs @@ -21,9 +21,10 @@ public class InstallPublishingServiceProcessorArgs : ProcessorArgs public string PublishingServicePackagePath { get; set; } public string PublishingServiceSiteName { get; set; } public Dictionary PublishingServiceConnectionStrings { get; set; } + public bool OverwriteExisting { get; set; } //Other Properties - public string PubilshingServiceWebroot { get { return Path.Combine(PublishingServiceInstanceFolder, PublishingServiceSiteName); } } + public string PublishingServiceWebroot { get { return Path.Combine(PublishingServiceInstanceFolder, PublishingServiceSiteName); } } #endregion } diff --git a/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs index 1fae90a5..688d4847 100644 --- a/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs @@ -12,7 +12,7 @@ public class ResetDatabaseSchemaProcessor : InstallPublishingServiceProcessor //Resetting the schema is done to clear any potentially existing Publishing tables protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) { - Directory.SetCurrentDirectory(args.PubilshingServiceWebroot); + Directory.SetCurrentDirectory(args.PublishingServiceWebroot); Commands.SchemaReset(); } } diff --git a/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs index a54d8b4b..3a6bd494 100644 --- a/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs @@ -12,7 +12,7 @@ public class SetActualConnectionStringsProcessor : InstallPublishingServiceProce { protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) { - Directory.SetCurrentDirectory(args.PubilshingServiceWebroot); + Directory.SetCurrentDirectory(args.PublishingServiceWebroot); foreach (KeyValuePair connString in args.PublishingServiceConnectionStrings) { Commands.SetConnectionString(connString.Key, connString.Value.ToString()); diff --git a/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs index c9fac242..5b81b194 100644 --- a/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs @@ -13,7 +13,7 @@ public class SetAdminConnectionStringsProcessor : InstallPublishingServiceProces //Using the admin credentials for connection strings is necessary to upgrade and reset the database schema protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) { - Directory.SetCurrentDirectory(args.PubilshingServiceWebroot); + Directory.SetCurrentDirectory(args.PublishingServiceWebroot); foreach (KeyValuePair connString in args.PublishingServiceConnectionStrings) { string AdminConnString = new SqlConnectionStringBuilder(connString.Value.ToString()) diff --git a/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs index 689bd97a..9083d9e7 100644 --- a/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs @@ -18,11 +18,15 @@ protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) { try { - ZipFile.ExtractToDirectory(args.PublishingServicePackagePath, args.PubilshingServiceWebroot); + if (args.OverwriteExisting) + { + Directory.Delete(args.PublishingServiceWebroot, true); + } + ZipFile.ExtractToDirectory(args.PublishingServicePackagePath, args.PublishingServiceWebroot); } catch (Exception ex) { - Log.Error($"\nSOURCE PATH: {args.PublishingServicePackagePath}\nDESTINATION PATH: {args.PubilshingServiceWebroot}"); + Log.Error($"\nSOURCE PATH: {args.PublishingServicePackagePath}\nDESTINATION PATH: {args.PublishingServiceWebroot}"); throw ex; } } diff --git a/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs index 54debaf0..84cead7f 100644 --- a/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs @@ -11,7 +11,7 @@ public class UpgradeDatabaseSchemaProcessor : InstallPublishingServiceProcessor { protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) { - Directory.SetCurrentDirectory(args.PubilshingServiceWebroot); + Directory.SetCurrentDirectory(args.PublishingServiceWebroot); Commands.SchemaUpgrade(); } } diff --git a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs index 7badf452..a4ec6160 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs @@ -37,6 +37,7 @@ public InstallPublishingServiceWizardArgs(Instance instance) //From User Input + public bool OverwriteExisting { get; set; } public string PublishingServicePackage { get { return Path.GetFileNameWithoutExtension(_publishingServicePackagePath); } @@ -72,7 +73,8 @@ public override ProcessorArgs ToProcessorArgs() PublishingServicePackagePath = this._publishingServicePackagePath, SqlAdminUsername = this.SqlAdminUsername, SqlAdminPassword = this.SqlAdminPassword, - PublishingServiceConnectionStrings = this.PublishingServiceConnectionStrings + PublishingServiceConnectionStrings = this.PublishingServiceConnectionStrings, + OverwriteExisting = this.OverwriteExisting }; } diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml index 0d0c2bf6..733e25d6 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml @@ -16,7 +16,16 @@ - + + + + + + + + Date: Sat, 21 Nov 2020 14:16:42 -0500 Subject: [PATCH 11/51] Finished overwrite functionality --- .../InstallPublishingServiceProcessor.cs | 2 +- ...emoveExistingPublishingServiceProcessor.cs | 46 +++++++++++++++++++ .../UnzipPackageProcessor.cs | 14 +----- 3 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 src/SIM.Pipelines/InstallPublishingService/RemoveExistingPublishingServiceProcessor.cs diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs index c45cdd50..9690d5de 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs @@ -41,6 +41,6 @@ protected override void Process([NotNull] ProcessorArgs args) } } - protected abstract void ProcessCore(InstallPublishingServiceProcessorArgs processorArgs); + protected abstract void ProcessCore(InstallPublishingServiceProcessorArgs args); } } diff --git a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingPublishingServiceProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingPublishingServiceProcessor.cs new file mode 100644 index 00000000..b04fcc0c --- /dev/null +++ b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingPublishingServiceProcessor.cs @@ -0,0 +1,46 @@ +using Microsoft.Web.Administration; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.InstallPublishingService +{ + public class RemoveExistingPublishingServiceProcessor : InstallPublishingServiceProcessor + { + protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + { + if (!args.OverwriteExisting) + { + return; + } + + using (ServerManager IISManager = new ServerManager()) + { + Site spsSite = IISManager.Sites[args.PublishingServiceSiteName]; + ApplicationPool spsAppPool = IISManager.ApplicationPools[args.PublishingServiceSiteName]; + + if (spsSite != null) + { + spsSite.Stop(); + IISManager.Sites.Remove(spsSite); + } + + if (spsAppPool != null) + { + spsAppPool.Stop(); + IISManager.ApplicationPools.Remove(spsAppPool); + } + + IISManager.CommitChanges(); + } + + if (Directory.Exists(args.PublishingServiceWebroot)) + { + Directory.Delete(args.PublishingServiceWebroot); + } + } + } +} diff --git a/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs index 9083d9e7..0da8cc0d 100644 --- a/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs @@ -16,19 +16,7 @@ public class UnzipPackageProcessor : InstallPublishingServiceProcessor { protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) { - try - { - if (args.OverwriteExisting) - { - Directory.Delete(args.PublishingServiceWebroot, true); - } - ZipFile.ExtractToDirectory(args.PublishingServicePackagePath, args.PublishingServiceWebroot); - } - catch (Exception ex) - { - Log.Error($"\nSOURCE PATH: {args.PublishingServicePackagePath}\nDESTINATION PATH: {args.PublishingServiceWebroot}"); - throw ex; - } + ZipFile.ExtractToDirectory(args.PublishingServicePackagePath, args.PublishingServiceWebroot); } } } From b19b3b8ea2c46aa7327abc3cf00da2f1fbc5ce99 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 21 Nov 2020 14:19:41 -0500 Subject: [PATCH 12/51] Finished overwrite functionality --- .../InstallPublishingServiceProcessor.cs | 7 +- ...emoveExistingPublishingServiceProcessor.cs | 88 ++++++++++++++++--- .../VerifyInstallationProcessor.cs | 1 - src/SIM.Pipelines/PipelinesConfig.cs | 2 + src/SIM.Pipelines/SIM.Pipelines.csproj | 1 + src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 7 +- 6 files changed, 86 insertions(+), 20 deletions(-) diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs index 9690d5de..f361bb88 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs @@ -17,14 +17,9 @@ protected override void Process([NotNull] ProcessorArgs args) { InstallPublishingServiceProcessorArgs processorArgs = args as InstallPublishingServiceProcessorArgs; - if (processorArgs == null) - { - throw new Exception("Invalid ProcessorArgs passed to InstallPublishingServiceProcessor"); - } - if (AbortPipeline) { - Log.Warn($"{this} processor was skipped."); + Log.Warn($"The {this.GetType().Name} processor was skipped."); this.Skip(); return; } diff --git a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingPublishingServiceProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingPublishingServiceProcessor.cs index b04fcc0c..8c0a5aca 100644 --- a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingPublishingServiceProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingPublishingServiceProcessor.cs @@ -1,46 +1,110 @@ -using Microsoft.Web.Administration; +using JetBrains.Annotations; +using Microsoft.Web.Administration; +using SIM.Adapters.WebServer; +using Sitecore.Diagnostics.Logging; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace SIM.Pipelines.InstallPublishingService { public class RemoveExistingPublishingServiceProcessor : InstallPublishingServiceProcessor { + private const int STOP_RETRIES = 6; + private const int RETRY_INTERVAL_MS = 5000; + protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) { if (!args.OverwriteExisting) { + this.Skip(); return; } - using (ServerManager IISManager = new ServerManager()) + using (ServerManager sm = new ServerManager()) { - Site spsSite = IISManager.Sites[args.PublishingServiceSiteName]; - ApplicationPool spsAppPool = IISManager.ApplicationPools[args.PublishingServiceSiteName]; + Site spsSite = sm.Sites.FirstOrDefault(s => s.Name.Equals(args.PublishingServiceSiteName)); + ApplicationPool spsAppPool = sm.ApplicationPools.FirstOrDefault(s => s.Name.Equals(args.PublishingServiceSiteName)); - if (spsSite != null) + if (!DeleteSite(sm, spsSite)) { - spsSite.Stop(); - IISManager.Sites.Remove(spsSite); + throw new Exception($"Could not stop site with the name {args.PublishingServiceSiteName}. Please remove it manually in IIS."); } - if (spsAppPool != null) + if (!DeleteAppPool(sm, spsAppPool)) { - spsAppPool.Stop(); - IISManager.ApplicationPools.Remove(spsAppPool); + throw new Exception($"Could not stop app pool with the name {args.PublishingServiceSiteName}. Please remove it manually in IIS."); } - IISManager.CommitChanges(); + sm.CommitChanges(); } if (Directory.Exists(args.PublishingServiceWebroot)) { - Directory.Delete(args.PublishingServiceWebroot); + try + { + Directory.Delete(args.PublishingServiceWebroot, true); + } + catch (IOException ex) + { + //Unlikely user scenario, but it can occur when you create an instance, then immediately try to overwrite it without restarting SIM + throw new Exception($"SIM may be locking the {args.PublishingServiceWebroot} folder if it was just created. Try restarting SIM and installing publishing service again", ex); + } + } + } + + private bool DeleteSite(ServerManager sm, [CanBeNull] Site site) + { + if (site != null) + { + int retries = 0; + while (!site.State.Equals(ObjectState.Stopped) && retries < STOP_RETRIES) + { + //If the site is starting/stopping IIS won't accept commands and will throw an error, we'll check if its in a started state first + if (site.State.Equals(ObjectState.Started)) + { + site.Stop(); + } + retries++; + Thread.Sleep(RETRY_INTERVAL_MS); + } + Log.Info($"The site {site.Name}'s state is currently {site.State}"); + if (!site.State.Equals(ObjectState.Stopped)) + { + return false; + } + sm.Sites.Remove(site); + } + return true; + } + + private bool DeleteAppPool (ServerManager sm, [CanBeNull] ApplicationPool appPool) + { + if (appPool != null) + { + int retries = 0; + while (!appPool.State.Equals(ObjectState.Stopped) && retries < STOP_RETRIES) + { + //If the site is starting/stopping IIS won't accept commands and will throw an error, we'll check if its in a started state first + if (appPool.State.Equals(ObjectState.Started)) + { + appPool.Stop(); + } + retries++; + Thread.Sleep(RETRY_INTERVAL_MS); + } + Log.Info($"The appl pool {appPool.Name}'s state is currently {appPool.State}"); + if (!appPool.State.Equals(ObjectState.Stopped)) + { + return false; + } + sm.ApplicationPools.Remove(appPool); } + return true; } } } diff --git a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs index 6a979121..0bdfaadb 100644 --- a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs @@ -40,6 +40,5 @@ private void OpenStatusEndpoint(string statusEndpoint) { System.Diagnostics.Process.Start(new ProcessStartInfo(statusEndpoint)); } - } } diff --git a/src/SIM.Pipelines/PipelinesConfig.cs b/src/SIM.Pipelines/PipelinesConfig.cs index e60e0935..d434b782 100644 --- a/src/SIM.Pipelines/PipelinesConfig.cs +++ b/src/SIM.Pipelines/PipelinesConfig.cs @@ -218,6 +218,8 @@ public static class PipelinesConfig + + diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index 85f23882..0c84176e 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -427,7 +427,12 @@ By clicking 'Next' you accept the License Agreement."" /> Control Panel > ADMINISTRATION > Install a package""> +Sitecore Launchpad > Control Panel > ADMINISTRATION > Install a package + +Your browser should have opened a page to: +http://{Your Publishing Service Hostname}/api/publishing/operations/status + +If you get a response with a status of 0, it means your publishing service is running without any issues. ""> From 05fa0e0becb3d2109a601f8b0c270e5ef7c11bbe Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 21 Nov 2020 14:38:01 -0500 Subject: [PATCH 13/51] Created uninstall publishing service button --- .../InstallPublishingServiceWizardArgs.cs | 4 +- .../UninstallPublishingServiceWizardArgs.cs | 83 +++++++++++++++++++ src/SIM.Tool.Base/SIM.Tool.Base.csproj | 1 + .../UninstallPublishingServiceButton.cs | 37 +++++++++ src/SIM.Tool.Windows/MainWindowData.cs | 17 +++- src/SIM.Tool.Windows/SIM.Tool.Windows.csproj | 1 + 6 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 src/SIM.Tool.Base/Pipelines/UninstallPublishingServiceWizardArgs.cs create mode 100644 src/SIM.Tool.Windows/MainWindowComponents/UninstallPublishingServiceButton.cs diff --git a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs index a4ec6160..c758371b 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs @@ -13,10 +13,10 @@ using SIM.Tool.Base.Profiles; using SIM.Tool.Base.Wizards; - public class InstallPublishingServiceWizardArgs : WizardArgs + public class UninstallPublishingServiceWizardArgs : WizardArgs { private string _publishingServicePackagePath; - public InstallPublishingServiceWizardArgs(Instance instance) + public UninstallPublishingServiceWizardArgs(Instance instance) { Initialize(instance); } diff --git a/src/SIM.Tool.Base/Pipelines/UninstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/UninstallPublishingServiceWizardArgs.cs new file mode 100644 index 00000000..a4ec6160 --- /dev/null +++ b/src/SIM.Tool.Base/Pipelines/UninstallPublishingServiceWizardArgs.cs @@ -0,0 +1,83 @@ +namespace SIM.Tool.Base.Pipelines +{ + using System.Collections.Generic; + using System.Data.SqlClient; + using System.IO; + using SIM.Adapters.WebServer; + using SIM.Instances; + using SIM.Pipelines.Install; + using SIM.Pipelines.InstallPublishingService; + using SIM.Pipelines.Processors; + using SIM.Services; + using SIM.Tool.Base.Converters; + using SIM.Tool.Base.Profiles; + using SIM.Tool.Base.Wizards; + + public class InstallPublishingServiceWizardArgs : WizardArgs + { + private string _publishingServicePackagePath; + public InstallPublishingServiceWizardArgs(Instance instance) + { + Initialize(instance); + } + + #region Properties + + //From Instance + public Instance Instance { get; private set; } + public string InstanceName { get; private set; } + public ConnectionStringCollection InstanceConnectionStrings { get; private set; } + + //From Profile + public string InstanceFolder { get; set; } + public string PublishingServiceInstanceFolder { get; set; } + + public string SqlAdminUsername { get; private set; } + public string SqlAdminPassword { get; private set; } + + + //From User Input + public bool OverwriteExisting { get; set; } + public string PublishingServicePackage + { + get { return Path.GetFileNameWithoutExtension(_publishingServicePackagePath); } + set { _publishingServicePackagePath = value; } + } + public string PublishingServiceSiteName { get; set; } + public Dictionary PublishingServiceConnectionStrings { get; set; } = new Dictionary(); + + #endregion + + #region Methods + private void Initialize(Instance instance) + { + this.Instance = instance; + this.InstanceName = instance.Name; + this.InstanceFolder = ProfileManager.Profile.InstancesFolder; + this.InstanceConnectionStrings = instance.Configuration.ConnectionStrings; + this.PublishingServiceInstanceFolder = ProfileManager.Profile.InstancesFolder; + + SqlConnectionStringBuilder SqlServerConnectionString = ProfileManager.GetConnectionString(); + this.SqlAdminUsername = SqlServerConnectionString.UserID; + this.SqlAdminPassword = SqlServerConnectionString.Password; + } + + public override ProcessorArgs ToProcessorArgs() + { + return new InstallPublishingServiceProcessorArgs() + { + InstanceName = this.InstanceName, + PublishingServiceSiteName = this.PublishingServiceSiteName, + InstanceFolder = this.InstanceFolder, + PublishingServiceInstanceFolder = this.PublishingServiceInstanceFolder, + PublishingServicePackagePath = this._publishingServicePackagePath, + SqlAdminUsername = this.SqlAdminUsername, + SqlAdminPassword = this.SqlAdminPassword, + PublishingServiceConnectionStrings = this.PublishingServiceConnectionStrings, + OverwriteExisting = this.OverwriteExisting + }; + } + + #endregion + } +} \ No newline at end of file diff --git a/src/SIM.Tool.Base/SIM.Tool.Base.csproj b/src/SIM.Tool.Base/SIM.Tool.Base.csproj index 6446f6b3..923d30b1 100644 --- a/src/SIM.Tool.Base/SIM.Tool.Base.csproj +++ b/src/SIM.Tool.Base/SIM.Tool.Base.csproj @@ -79,6 +79,7 @@ + diff --git a/src/SIM.Tool.Windows/MainWindowComponents/UninstallPublishingServiceButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/UninstallPublishingServiceButton.cs new file mode 100644 index 00000000..28fb9461 --- /dev/null +++ b/src/SIM.Tool.Windows/MainWindowComponents/UninstallPublishingServiceButton.cs @@ -0,0 +1,37 @@ +namespace SIM.Tool.Windows.MainWindowComponents +{ + using System.Windows; + using SIM.Core.Common; + using SIM.Instances; + using SIM.Tool.Base.Plugins; + using JetBrains.Annotations; + using SIM.Tool.Base.Pipelines; + using SIM.Tool.Base.Wizards; + + [UsedImplicitly] + public class UninstallPublishingServiceButton : IMainWindowButton + { + #region Public methods + + public bool IsEnabled(Window mainWindow, Instance instance) + { + return instance != null; + } + + public bool IsVisible(Window mainWindow, Instance instance) + { + return true; + } + + public void OnClick(Window mainWindow, Instance instance) + { + if (instance != null) + { + var id = MainWindowHelper.GetListItemID(instance.ID); + WizardPipelineManager.Start("uninstallpublishingservice", mainWindow, null, null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new UninstallPublishingServiceWizardArgs(instance)); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/src/SIM.Tool.Windows/MainWindowData.cs b/src/SIM.Tool.Windows/MainWindowData.cs index af87d79a..28239b34 100644 --- a/src/SIM.Tool.Windows/MainWindowData.cs +++ b/src/SIM.Tool.Windows/MainWindowData.cs @@ -674,7 +674,22 @@ private static ButtonDefinition GetPatchButton() { Label = "Publishing Service", Image = "/Images/$lg/install.png, SIM.Tool.Windows", - Handler = new SIM.Tool.Windows.MainWindowComponents.InstallPublishingServiceButton() + Handler = new SIM.Tool.Windows.MainWindowComponents.InstallPublishingServiceButton(), + Buttons = new[] + { + new ButtonDefinition + { + Label = "Install", + Image = "/Images/$lg/install.png, SIM.Tool.Windows", + Handler = new SIM.Tool.Windows.MainWindowComponents.InstallPublishingServiceButton(), + }, + new ButtonDefinition + { + Label = "Uninstall", + Image = "/Images/$lg/uninstall.png, SIM.Tool.Windows", + Handler = new SIM.Tool.Windows.MainWindowComponents.UninstallPublishingServiceButton(), + } + } }, } }, diff --git a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj index a6127017..11c654cc 100644 --- a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj +++ b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj @@ -169,6 +169,7 @@ + From bf278dffd478bed0441fa1895247b6b01f9c1d6d Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 21 Nov 2020 14:53:45 -0500 Subject: [PATCH 14/51] Renamed class names and members to use 'SPS' instead of 'PublishingService' to shorten the names --- .../CreateIISiteProcessor.cs | 6 ++-- ...iceProcessor.cs => InstallSPSProcessor.cs} | 6 ++-- ...ssorArgs.cs => InstallSPSProcessorArgs.cs} | 12 ++++---- ...essor.cs => RemoveExistingSPSProcessor.cs} | 18 +++++------ .../ResetDatabaseSchemaProcessor.cs | 6 ++-- .../SetActualConnectionStringsProcessor.cs | 8 ++--- .../SetAdminConnectionStringsProcessor.cs | 8 ++--- ...ocessor.cs => UnzipSPSPackageProcessor.cs} | 6 ++-- .../UpgradeDatabaseSchemaProcessor.cs | 6 ++-- .../VerifyInstallationProcessor.cs | 6 ++-- src/SIM.Pipelines/PipelinesConfig.cs | 4 +-- src/SIM.Pipelines/SIM.Pipelines.csproj | 8 ++--- .../InstallPublishingServiceWizardArgs.cs | 30 +++++++++---------- .../InstallPublishingServiceButton.cs | 4 +-- src/SIM.Tool.Windows/MainWindowData.cs | 4 +-- .../ConfigureParameters.xaml | 2 +- .../ConfigureParameters.xaml.cs | 10 +++---- .../SelectPublishingServicePackage.xaml | 4 +-- .../SelectPublishingServicePackage.xaml.cs | 8 ++--- 19 files changed, 78 insertions(+), 78 deletions(-) rename src/SIM.Pipelines/InstallPublishingService/{InstallPublishingServiceProcessor.cs => InstallSPSProcessor.cs} (75%) rename src/SIM.Pipelines/InstallPublishingService/{InstallPublishingServiceProcessorArgs.cs => InstallSPSProcessorArgs.cs} (55%) rename src/SIM.Pipelines/InstallPublishingService/{RemoveExistingPublishingServiceProcessor.cs => RemoveExistingSPSProcessor.cs} (79%) rename src/SIM.Pipelines/InstallPublishingService/{UnzipPackageProcessor.cs => UnzipSPSPackageProcessor.cs} (59%) diff --git a/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs index 23f87241..662c525e 100644 --- a/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs @@ -7,11 +7,11 @@ namespace SIM.Pipelines.InstallPublishingService { - public class CreateIISiteProcessor : InstallPublishingServiceProcessor + public class CreateIISiteProcessor : InstallSPSProcessor { - protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + protected override void ProcessCore(InstallSPSProcessorArgs args) { - Commands.IISInstall(args.PublishingServiceSiteName, args.PublishingServiceSiteName); + Commands.IISInstall(args.SPSSiteName, args.SPSSiteName); } } } diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessor.cs similarity index 75% rename from src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs rename to src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessor.cs index f361bb88..91dd7c18 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessor.cs @@ -9,13 +9,13 @@ namespace SIM.Pipelines.InstallPublishingService { - public abstract class InstallPublishingServiceProcessor : Processor + public abstract class InstallSPSProcessor : Processor { protected static bool AbortPipeline = false; protected override void Process([NotNull] ProcessorArgs args) { - InstallPublishingServiceProcessorArgs processorArgs = args as InstallPublishingServiceProcessorArgs; + InstallSPSProcessorArgs processorArgs = args as InstallSPSProcessorArgs; if (AbortPipeline) { @@ -36,6 +36,6 @@ protected override void Process([NotNull] ProcessorArgs args) } } - protected abstract void ProcessCore(InstallPublishingServiceProcessorArgs args); + protected abstract void ProcessCore(InstallSPSProcessorArgs args); } } diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs similarity index 55% rename from src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs rename to src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs index a5d54cf2..3f75a3de 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallPublishingServiceProcessorArgs.cs +++ b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs @@ -9,22 +9,22 @@ namespace SIM.Pipelines.InstallPublishingService { - public class InstallPublishingServiceProcessorArgs : ProcessorArgs + public class InstallSPSProcessorArgs : ProcessorArgs { #region Properties //Populated from InstallPublishingServiceWizardArgs public string InstanceName { get; set; } public string InstanceFolder { get; set; } - public string PublishingServiceInstanceFolder { get; set; } + public string SPSInstanceFolder { get; set; } public string SqlAdminUsername { get; set; } public string SqlAdminPassword { get; set; } - public string PublishingServicePackagePath { get; set; } - public string PublishingServiceSiteName { get; set; } - public Dictionary PublishingServiceConnectionStrings { get; set; } + public string SPSPackagePath { get; set; } + public string SPSSiteName { get; set; } + public Dictionary SPSConnectionStrings { get; set; } public bool OverwriteExisting { get; set; } //Other Properties - public string PublishingServiceWebroot { get { return Path.Combine(PublishingServiceInstanceFolder, PublishingServiceSiteName); } } + public string SPSWebroot { get { return Path.Combine(SPSInstanceFolder, SPSSiteName); } } #endregion } diff --git a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingPublishingServiceProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs similarity index 79% rename from src/SIM.Pipelines/InstallPublishingService/RemoveExistingPublishingServiceProcessor.cs rename to src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs index 8c0a5aca..9dedbb3a 100644 --- a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingPublishingServiceProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs @@ -12,12 +12,12 @@ namespace SIM.Pipelines.InstallPublishingService { - public class RemoveExistingPublishingServiceProcessor : InstallPublishingServiceProcessor + public class RemoveExistingSPSProcessor : InstallSPSProcessor { private const int STOP_RETRIES = 6; private const int RETRY_INTERVAL_MS = 5000; - protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + protected override void ProcessCore(InstallSPSProcessorArgs args) { if (!args.OverwriteExisting) { @@ -27,32 +27,32 @@ protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) using (ServerManager sm = new ServerManager()) { - Site spsSite = sm.Sites.FirstOrDefault(s => s.Name.Equals(args.PublishingServiceSiteName)); - ApplicationPool spsAppPool = sm.ApplicationPools.FirstOrDefault(s => s.Name.Equals(args.PublishingServiceSiteName)); + Site spsSite = sm.Sites.FirstOrDefault(s => s.Name.Equals(args.SPSSiteName)); + ApplicationPool spsAppPool = sm.ApplicationPools.FirstOrDefault(s => s.Name.Equals(args.SPSSiteName)); if (!DeleteSite(sm, spsSite)) { - throw new Exception($"Could not stop site with the name {args.PublishingServiceSiteName}. Please remove it manually in IIS."); + throw new Exception($"Could not stop site with the name {args.SPSSiteName}. Please remove it manually in IIS."); } if (!DeleteAppPool(sm, spsAppPool)) { - throw new Exception($"Could not stop app pool with the name {args.PublishingServiceSiteName}. Please remove it manually in IIS."); + throw new Exception($"Could not stop app pool with the name {args.SPSSiteName}. Please remove it manually in IIS."); } sm.CommitChanges(); } - if (Directory.Exists(args.PublishingServiceWebroot)) + if (Directory.Exists(args.SPSWebroot)) { try { - Directory.Delete(args.PublishingServiceWebroot, true); + Directory.Delete(args.SPSWebroot, true); } catch (IOException ex) { //Unlikely user scenario, but it can occur when you create an instance, then immediately try to overwrite it without restarting SIM - throw new Exception($"SIM may be locking the {args.PublishingServiceWebroot} folder if it was just created. Try restarting SIM and installing publishing service again", ex); + throw new Exception($"SIM may be locking the {args.SPSWebroot} folder if it was just created. Try restarting SIM and installing publishing service again", ex); } } } diff --git a/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs index 688d4847..95c90ab7 100644 --- a/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs @@ -7,12 +7,12 @@ namespace SIM.Pipelines.InstallPublishingService { - public class ResetDatabaseSchemaProcessor : InstallPublishingServiceProcessor + public class ResetDatabaseSchemaProcessor : InstallSPSProcessor { //Resetting the schema is done to clear any potentially existing Publishing tables - protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + protected override void ProcessCore(InstallSPSProcessorArgs args) { - Directory.SetCurrentDirectory(args.PublishingServiceWebroot); + Directory.SetCurrentDirectory(args.SPSWebroot); Commands.SchemaReset(); } } diff --git a/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs index 3a6bd494..ce6d34a6 100644 --- a/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs @@ -8,12 +8,12 @@ namespace SIM.Pipelines.InstallPublishingService { - public class SetActualConnectionStringsProcessor : InstallPublishingServiceProcessor + public class SetActualConnectionStringsProcessor : InstallSPSProcessor { - protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + protected override void ProcessCore(InstallSPSProcessorArgs args) { - Directory.SetCurrentDirectory(args.PublishingServiceWebroot); - foreach (KeyValuePair connString in args.PublishingServiceConnectionStrings) + Directory.SetCurrentDirectory(args.SPSWebroot); + foreach (KeyValuePair connString in args.SPSConnectionStrings) { Commands.SetConnectionString(connString.Key, connString.Value.ToString()); } diff --git a/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs index 5b81b194..41a7609a 100644 --- a/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs @@ -8,13 +8,13 @@ namespace SIM.Pipelines.InstallPublishingService { - public class SetAdminConnectionStringsProcessor : InstallPublishingServiceProcessor + public class SetAdminConnectionStringsProcessor : InstallSPSProcessor { //Using the admin credentials for connection strings is necessary to upgrade and reset the database schema - protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + protected override void ProcessCore(InstallSPSProcessorArgs args) { - Directory.SetCurrentDirectory(args.PublishingServiceWebroot); - foreach (KeyValuePair connString in args.PublishingServiceConnectionStrings) + Directory.SetCurrentDirectory(args.SPSWebroot); + foreach (KeyValuePair connString in args.SPSConnectionStrings) { string AdminConnString = new SqlConnectionStringBuilder(connString.Value.ToString()) { diff --git a/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs similarity index 59% rename from src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs rename to src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs index 0da8cc0d..53c9aac7 100644 --- a/src/SIM.Pipelines/InstallPublishingService/UnzipPackageProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs @@ -12,11 +12,11 @@ namespace SIM.Pipelines.InstallPublishingService { - public class UnzipPackageProcessor : InstallPublishingServiceProcessor + public class UnzipSPSPackageProcessor : InstallSPSProcessor { - protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + protected override void ProcessCore(InstallSPSProcessorArgs args) { - ZipFile.ExtractToDirectory(args.PublishingServicePackagePath, args.PublishingServiceWebroot); + ZipFile.ExtractToDirectory(args.SPSPackagePath, args.SPSWebroot); } } } diff --git a/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs index 84cead7f..1023e2f9 100644 --- a/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs @@ -7,11 +7,11 @@ namespace SIM.Pipelines.InstallPublishingService { - public class UpgradeDatabaseSchemaProcessor : InstallPublishingServiceProcessor + public class UpgradeDatabaseSchemaProcessor : InstallSPSProcessor { - protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + protected override void ProcessCore(InstallSPSProcessorArgs args) { - Directory.SetCurrentDirectory(args.PublishingServiceWebroot); + Directory.SetCurrentDirectory(args.SPSWebroot); Commands.SchemaUpgrade(); } } diff --git a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs index 0bdfaadb..63c0f294 100644 --- a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs @@ -13,11 +13,11 @@ namespace SIM.Pipelines.InstallPublishingService { - public class VerifyInstallationProcessor : InstallPublishingServiceProcessor + public class VerifyInstallationProcessor : InstallSPSProcessor { - protected override void ProcessCore(InstallPublishingServiceProcessorArgs args) + protected override void ProcessCore(InstallSPSProcessorArgs args) { - string statusEndpoint = $"http://{args.PublishingServiceSiteName}/api/publishing/operations/status"; + string statusEndpoint = $"http://{args.SPSSiteName}/api/publishing/operations/status"; if (!ValidateStatusEndpoint(statusEndpoint)) { Log.Error("Publishing Service returned errors"); diff --git a/src/SIM.Pipelines/PipelinesConfig.cs b/src/SIM.Pipelines/PipelinesConfig.cs index d434b782..d51898e2 100644 --- a/src/SIM.Pipelines/PipelinesConfig.cs +++ b/src/SIM.Pipelines/PipelinesConfig.cs @@ -218,9 +218,9 @@ public static class PipelinesConfig - - diff --git a/src/SIM.Pipelines/SIM.Pipelines.csproj b/src/SIM.Pipelines/SIM.Pipelines.csproj index 429fd6da..d1e6957c 100644 --- a/src/SIM.Pipelines/SIM.Pipelines.csproj +++ b/src/SIM.Pipelines/SIM.Pipelines.csproj @@ -109,13 +109,13 @@ - - + + - + - + diff --git a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs index a4ec6160..63f3b6fa 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs @@ -13,10 +13,10 @@ using SIM.Tool.Base.Profiles; using SIM.Tool.Base.Wizards; - public class InstallPublishingServiceWizardArgs : WizardArgs + public class InstallSPSWizardArgs : WizardArgs { - private string _publishingServicePackagePath; - public InstallPublishingServiceWizardArgs(Instance instance) + private string _spsPackagePath; + public InstallSPSWizardArgs(Instance instance) { Initialize(instance); } @@ -30,7 +30,7 @@ public InstallPublishingServiceWizardArgs(Instance instance) //From Profile public string InstanceFolder { get; set; } - public string PublishingServiceInstanceFolder { get; set; } + public string SPSInstanceFolder { get; set; } public string SqlAdminUsername { get; private set; } public string SqlAdminPassword { get; private set; } @@ -38,13 +38,13 @@ public InstallPublishingServiceWizardArgs(Instance instance) //From User Input public bool OverwriteExisting { get; set; } - public string PublishingServicePackage + public string SPSPackage { - get { return Path.GetFileNameWithoutExtension(_publishingServicePackagePath); } - set { _publishingServicePackagePath = value; } + get { return Path.GetFileNameWithoutExtension(_spsPackagePath); } + set { _spsPackagePath = value; } } - public string PublishingServiceSiteName { get; set; } - public Dictionary PublishingServiceConnectionStrings { get; set; } = new Dictionary(); + public string SPSSiteName { get; set; } + public Dictionary SPSConnectionStrings { get; set; } = new Dictionary(); #endregion @@ -55,7 +55,7 @@ private void Initialize(Instance instance) this.InstanceName = instance.Name; this.InstanceFolder = ProfileManager.Profile.InstancesFolder; this.InstanceConnectionStrings = instance.Configuration.ConnectionStrings; - this.PublishingServiceInstanceFolder = ProfileManager.Profile.InstancesFolder; + this.SPSInstanceFolder = ProfileManager.Profile.InstancesFolder; SqlConnectionStringBuilder SqlServerConnectionString = ProfileManager.GetConnectionString(); this.SqlAdminUsername = SqlServerConnectionString.UserID; @@ -64,16 +64,16 @@ private void Initialize(Instance instance) public override ProcessorArgs ToProcessorArgs() { - return new InstallPublishingServiceProcessorArgs() + return new InstallSPSProcessorArgs() { InstanceName = this.InstanceName, - PublishingServiceSiteName = this.PublishingServiceSiteName, + SPSSiteName = this.SPSSiteName, InstanceFolder = this.InstanceFolder, - PublishingServiceInstanceFolder = this.PublishingServiceInstanceFolder, - PublishingServicePackagePath = this._publishingServicePackagePath, + SPSInstanceFolder = this.SPSInstanceFolder, + SPSPackagePath = this._spsPackagePath, SqlAdminUsername = this.SqlAdminUsername, SqlAdminPassword = this.SqlAdminPassword, - PublishingServiceConnectionStrings = this.PublishingServiceConnectionStrings, + SPSConnectionStrings = this.SPSConnectionStrings, OverwriteExisting = this.OverwriteExisting }; } diff --git a/src/SIM.Tool.Windows/MainWindowComponents/InstallPublishingServiceButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/InstallPublishingServiceButton.cs index 4e88de7a..edae7f53 100644 --- a/src/SIM.Tool.Windows/MainWindowComponents/InstallPublishingServiceButton.cs +++ b/src/SIM.Tool.Windows/MainWindowComponents/InstallPublishingServiceButton.cs @@ -9,7 +9,7 @@ using SIM.Tool.Base.Wizards; [UsedImplicitly] - public class InstallPublishingServiceButton : IMainWindowButton + public class InstallSPSButton : IMainWindowButton { #region Public methods @@ -28,7 +28,7 @@ public void OnClick(Window mainWindow, Instance instance) if (instance != null) { var id = MainWindowHelper.GetListItemID(instance.ID); - WizardPipelineManager.Start("installpublishingservice", mainWindow, null, null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new InstallPublishingServiceWizardArgs(instance)); + WizardPipelineManager.Start("installpublishingservice", mainWindow, null, null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new InstallSPSWizardArgs(instance)); } } diff --git a/src/SIM.Tool.Windows/MainWindowData.cs b/src/SIM.Tool.Windows/MainWindowData.cs index af87d79a..0ca2fd7c 100644 --- a/src/SIM.Tool.Windows/MainWindowData.cs +++ b/src/SIM.Tool.Windows/MainWindowData.cs @@ -674,7 +674,7 @@ private static ButtonDefinition GetPatchButton() { Label = "Publishing Service", Image = "/Images/$lg/install.png, SIM.Tool.Windows", - Handler = new SIM.Tool.Windows.MainWindowComponents.InstallPublishingServiceButton() + Handler = new SIM.Tool.Windows.MainWindowComponents.InstallSPSButton() }, } }, @@ -1145,7 +1145,7 @@ private static GroupDefinition GetManageGroupDefinition() new ButtonDefinition(), new ButtonDefinition { Label = "Delete", Image = "/Images/$sm/uninstall.png, SIM.Tool.Windows", Handler = new SIM.Tool.Windows.MainWindowComponents.DeleteInstanceButton() }, new ButtonDefinition(), - new ButtonDefinition { Label = "Install Publishing Service", Image = "/Images/$sm/install.png, SIM.Tool.Windows", Handler = new SIM.Tool.Windows.MainWindowComponents.InstallPublishingServiceButton() }, + new ButtonDefinition { Label = "Install Publishing Service", Image = "/Images/$sm/install.png, SIM.Tool.Windows", Handler = new SIM.Tool.Windows.MainWindowComponents.InstallSPSButton() }, }; public static TabDefinition[] Tabs { get; } = { diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml index 733e25d6..e868e07f 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml @@ -22,7 +22,7 @@ - + diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs index 15873ccf..83b1145d 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs @@ -21,7 +21,7 @@ public ConfigureParameters() public void InitializeStep(WizardArgs wizardArgs) { - InstallPublishingServiceWizardArgs args = (InstallPublishingServiceWizardArgs)wizardArgs; + InstallSPSWizardArgs args = (InstallSPSWizardArgs)wizardArgs; if (ConnectionStringsListBox.Items.Count < 1) { foreach (var connString in args.InstanceConnectionStrings) @@ -47,11 +47,11 @@ public bool OnMovingBack(WizardArgs wizardArgs) public bool OnMovingNext(WizardArgs wizardArgs) { - InstallPublishingServiceWizardArgs args = (InstallPublishingServiceWizardArgs)wizardArgs; - args.PublishingServiceSiteName = PublishingServiceSiteNameTextBox.Text.Trim(); + InstallSPSWizardArgs args = (InstallSPSWizardArgs)wizardArgs; + args.SPSSiteName = SPSSiteNameTextBox.Text.Trim(); args.OverwriteExisting = OverwriteIfExistsCheckBox.IsChecked ?? false; - string newWebroot = Path.Combine(args.PublishingServiceInstanceFolder, args.PublishingServiceSiteName); + string newWebroot = Path.Combine(args.SPSInstanceFolder, args.SPSSiteName); if (Directory.Exists(newWebroot) && !args.OverwriteExisting){ WindowHelper.ShowMessage($"{newWebroot} already exists, please delete the existing instance, choose a different name, or select the" + $"\"Overwrite if exists?\" checkbox to replace the existing solution"); @@ -63,7 +63,7 @@ public bool OnMovingNext(WizardArgs wizardArgs) if (checkbox.IsChecked ?? false) { ConnectionString connString = args.InstanceConnectionStrings.Single(cs => cs.Name.Equals(checkbox.Content)); - args.PublishingServiceConnectionStrings.Add(checkbox.Content.ToString(), new SqlConnectionStringBuilder(connString.Value)); + args.SPSConnectionStrings.Add(checkbox.Content.ToString(), new SqlConnectionStringBuilder(connString.Value)); } } diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml index da9fcbb8..b3c768b5 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml @@ -17,11 +17,11 @@ - + You can - + get publishing service packages here. Then place them into diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs index c87bb90a..07effe87 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs @@ -36,8 +36,8 @@ public bool OnMovingBack(WizardArgs wizardArgs) public bool OnMovingNext(WizardArgs wizardArgs) { - InstallPublishingServiceWizardArgs args = (InstallPublishingServiceWizardArgs)wizardArgs; - args.PublishingServicePackage = ((ComboBoxItem)PublishingServicePackageComboBox.SelectedItem).Tag.ToString(); + InstallSPSWizardArgs args = (InstallSPSWizardArgs)wizardArgs; + args.SPSPackage = ((ComboBoxItem)SPSPackageComboBox.SelectedItem).Tag.ToString(); return true; } @@ -55,7 +55,7 @@ private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e private void Initialize() { //Prepare links - DownloadPublishingServiceLink.NavigateUri = new Uri(@"https://dev.sitecore.net/Downloads/Sitecore_Publishing_Service.aspx"); + DownloadSPSLink.NavigateUri = new Uri(@"https://dev.sitecore.net/Downloads/Sitecore_Publishing_Service.aspx"); OpenLocalRepoLink.NavigateUri = new Uri($@"{ProfileManager.Profile.LocalRepository}"); KBForSPSCompatibilityPriorTo410.NavigateUri = new Uri(KB_SPS_COMPATIBILTY_PRIOR_TO_410); KBForSPSCompatibility410AndLater.NavigateUri = new Uri(KB_SPS_COMPATIBILTY_410_AND_LATER); @@ -64,7 +64,7 @@ private void Initialize() //Populate ComboBox foreach (string packagePath in Directory.GetFiles(ProfileManager.Profile.LocalRepository, "Sitecore Publishing Service*.zip")) { - PublishingServicePackageComboBox.Items.Add(new ComboBoxItem() + SPSPackageComboBox.Items.Add(new ComboBoxItem() { Content = Path.GetFileNameWithoutExtension(packagePath), Tag = packagePath From a81936f3e49518d48e30e42ddaaca06876a01181 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 21 Nov 2020 15:20:38 -0500 Subject: [PATCH 15/51] First wizard page created for sps uninstall (work in progress) --- .../UninstallPublishingServiceWizardArgs.cs | 31 ++++++------ .../UninstallPublishingServiceButton.cs | 4 +- src/SIM.Tool.Windows/MainWindowData.cs | 2 +- src/SIM.Tool.Windows/SIM.Tool.Windows.csproj | 7 +++ .../SelectServiceToUninstall.xaml | 23 +++++++++ .../SelectServiceToUninstall.xaml.cs | 49 +++++++++++++++++++ src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 7 +++ 7 files changed, 104 insertions(+), 19 deletions(-) create mode 100644 src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml create mode 100644 src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs diff --git a/src/SIM.Tool.Base/Pipelines/UninstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/UninstallPublishingServiceWizardArgs.cs index a4ec6160..c72a68a1 100644 --- a/src/SIM.Tool.Base/Pipelines/UninstallPublishingServiceWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/UninstallPublishingServiceWizardArgs.cs @@ -12,11 +12,10 @@ using SIM.Tool.Base.Converters; using SIM.Tool.Base.Profiles; using SIM.Tool.Base.Wizards; - - public class InstallPublishingServiceWizardArgs : WizardArgs + public class UninstallSPSWizardArgs : WizardArgs { - private string _publishingServicePackagePath; - public InstallPublishingServiceWizardArgs(Instance instance) + private string _spsPackagePath; + public UninstallSPSWizardArgs(Instance instance) { Initialize(instance); } @@ -30,7 +29,7 @@ public InstallPublishingServiceWizardArgs(Instance instance) //From Profile public string InstanceFolder { get; set; } - public string PublishingServiceInstanceFolder { get; set; } + public string SPSInstanceFolder { get; set; } public string SqlAdminUsername { get; private set; } public string SqlAdminPassword { get; private set; } @@ -38,13 +37,13 @@ public InstallPublishingServiceWizardArgs(Instance instance) //From User Input public bool OverwriteExisting { get; set; } - public string PublishingServicePackage + public string SPSPackage { - get { return Path.GetFileNameWithoutExtension(_publishingServicePackagePath); } - set { _publishingServicePackagePath = value; } + get { return Path.GetFileNameWithoutExtension(_spsPackagePath); } + set { _spsPackagePath = value; } } - public string PublishingServiceSiteName { get; set; } - public Dictionary PublishingServiceConnectionStrings { get; set; } = new Dictionary(); + public string SPSSiteName { get; set; } + public Dictionary SPSConnectionStrings { get; set; } = new Dictionary(); #endregion @@ -55,7 +54,7 @@ private void Initialize(Instance instance) this.InstanceName = instance.Name; this.InstanceFolder = ProfileManager.Profile.InstancesFolder; this.InstanceConnectionStrings = instance.Configuration.ConnectionStrings; - this.PublishingServiceInstanceFolder = ProfileManager.Profile.InstancesFolder; + this.SPSInstanceFolder = ProfileManager.Profile.InstancesFolder; SqlConnectionStringBuilder SqlServerConnectionString = ProfileManager.GetConnectionString(); this.SqlAdminUsername = SqlServerConnectionString.UserID; @@ -64,16 +63,16 @@ private void Initialize(Instance instance) public override ProcessorArgs ToProcessorArgs() { - return new InstallPublishingServiceProcessorArgs() + return new InstallSPSProcessorArgs() { InstanceName = this.InstanceName, - PublishingServiceSiteName = this.PublishingServiceSiteName, + SPSSiteName = this.SPSSiteName, InstanceFolder = this.InstanceFolder, - PublishingServiceInstanceFolder = this.PublishingServiceInstanceFolder, - PublishingServicePackagePath = this._publishingServicePackagePath, + SPSInstanceFolder = this.SPSInstanceFolder, + SPSPackagePath = this._spsPackagePath, SqlAdminUsername = this.SqlAdminUsername, SqlAdminPassword = this.SqlAdminPassword, - PublishingServiceConnectionStrings = this.PublishingServiceConnectionStrings, + SPSConnectionStrings = this.SPSConnectionStrings, OverwriteExisting = this.OverwriteExisting }; } diff --git a/src/SIM.Tool.Windows/MainWindowComponents/UninstallPublishingServiceButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/UninstallPublishingServiceButton.cs index 28fb9461..8b8babce 100644 --- a/src/SIM.Tool.Windows/MainWindowComponents/UninstallPublishingServiceButton.cs +++ b/src/SIM.Tool.Windows/MainWindowComponents/UninstallPublishingServiceButton.cs @@ -9,7 +9,7 @@ using SIM.Tool.Base.Wizards; [UsedImplicitly] - public class UninstallPublishingServiceButton : IMainWindowButton + public class UninstallSPSButton : IMainWindowButton { #region Public methods @@ -28,7 +28,7 @@ public void OnClick(Window mainWindow, Instance instance) if (instance != null) { var id = MainWindowHelper.GetListItemID(instance.ID); - WizardPipelineManager.Start("uninstallpublishingservice", mainWindow, null, null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new UninstallPublishingServiceWizardArgs(instance)); + WizardPipelineManager.Start("uninstallpublishingservice", mainWindow, null, null, ignore => MainWindowHelper.MakeInstanceSelected(id), () => new UninstallSPSWizardArgs(instance)); } } diff --git a/src/SIM.Tool.Windows/MainWindowData.cs b/src/SIM.Tool.Windows/MainWindowData.cs index d0f36b24..890f7f97 100644 --- a/src/SIM.Tool.Windows/MainWindowData.cs +++ b/src/SIM.Tool.Windows/MainWindowData.cs @@ -687,7 +687,7 @@ private static ButtonDefinition GetPatchButton() { Label = "Uninstall", Image = "/Images/$lg/uninstall.png, SIM.Tool.Windows", - Handler = new SIM.Tool.Windows.MainWindowComponents.UninstallPublishingServiceButton(), + Handler = new SIM.Tool.Windows.MainWindowComponents.UninstallSPSButton(), } } }, diff --git a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj index 11c654cc..435cf0e1 100644 --- a/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj +++ b/src/SIM.Tool.Windows/SIM.Tool.Windows.csproj @@ -308,6 +308,9 @@ SelectPublishingServicePackage.xaml + + SelectServiceToUninstall.xaml + ValidationDetails.xaml @@ -659,6 +662,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml new file mode 100644 index 00000000..13e6559c --- /dev/null +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs new file mode 100644 index 00000000..6714c786 --- /dev/null +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs @@ -0,0 +1,49 @@ +using SIM.Tool.Base.Wizards; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SIM.Tool.Windows.UserControls.Install.PublishingService +{ + /// + /// Interaction logic for SelectServiceToUninstall.xaml + /// + public partial class SelectServiceToUninstall : IWizardStep, IFlowControl + { + public SelectServiceToUninstall() + { + InitializeComponent(); + } + + public void InitializeStep(WizardArgs wizardArgs) + { + return; + } + + public bool OnMovingBack(WizardArgs wizardArgs) + { + return true; + } + + public bool OnMovingNext(WizardArgs wizardArgs) + { + return true; + } + + public bool SaveChanges(WizardArgs wizardArgs) + { + return true; + } + } +} diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index 0c84176e..ff62b8aa 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -440,6 +440,13 @@ Sitecore Launchpad > Control Panel > ADMINISTRATION > Install a package type=""SIM.Tool.Windows.UserControls.Install.PublishingService.ConfigureParameters, SIM.Tool.Windows"" /> + + + + + "; From 644a047cc4ba0264bf9dc0d48330d30fd13cac87 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 21 Nov 2020 15:23:15 -0500 Subject: [PATCH 16/51] Added sps uninstall to right-click context menu --- src/SIM.Tool.Windows/MainWindowData.cs | 1 + .../Install/PublishingService/SelectServiceToUninstall.xaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SIM.Tool.Windows/MainWindowData.cs b/src/SIM.Tool.Windows/MainWindowData.cs index 890f7f97..96c2795f 100644 --- a/src/SIM.Tool.Windows/MainWindowData.cs +++ b/src/SIM.Tool.Windows/MainWindowData.cs @@ -1161,6 +1161,7 @@ private static GroupDefinition GetManageGroupDefinition() new ButtonDefinition { Label = "Delete", Image = "/Images/$sm/uninstall.png, SIM.Tool.Windows", Handler = new SIM.Tool.Windows.MainWindowComponents.DeleteInstanceButton() }, new ButtonDefinition(), new ButtonDefinition { Label = "Install Publishing Service", Image = "/Images/$sm/install.png, SIM.Tool.Windows", Handler = new SIM.Tool.Windows.MainWindowComponents.InstallSPSButton() }, + new ButtonDefinition { Label = "Uninstall Publishing Service", Image = "/Images/$sm/uninstall.png, SIM.Tool.Windows", Handler = new SIM.Tool.Windows.MainWindowComponents.UninstallSPSButton() }, }; public static TabDefinition[] Tabs { get; } = { diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml index 13e6559c..2d19ee0c 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml @@ -16,7 +16,7 @@ - + From 83f2ced17ede5071b807dc2ec73695dd0f7643b1 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 21 Nov 2020 16:51:30 -0500 Subject: [PATCH 17/51] Cleaned up some code, attempted to add port, but now bad gateway issue exists on the last processor (regardless of using port or not) --- .../InstallPublishingService/Commands.cs | 21 ++-- .../CreateIISiteProcessor.cs | 2 +- .../InstallSPSProcessorArgs.cs | 1 + .../RemoveExistingSPSProcessor.cs | 3 - .../VerifyInstallationProcessor.cs | 1 + ...eWizardArgs.cs => InstallSPSWizardArgs.cs} | 2 + src/SIM.Tool.Base/SIM.Tool.Base.csproj | 2 +- .../ConfigureParameters.xaml | 12 +- .../ConfigureParameters.xaml.cs | 110 +++++++++++++----- 9 files changed, 111 insertions(+), 43 deletions(-) rename src/SIM.Tool.Base/Pipelines/{InstallPublishingServiceWizardArgs.cs => InstallSPSWizardArgs.cs} (97%) diff --git a/src/SIM.Pipelines/InstallPublishingService/Commands.cs b/src/SIM.Pipelines/InstallPublishingService/Commands.cs index 2f5d1f43..0e5b705a 100644 --- a/src/SIM.Pipelines/InstallPublishingService/Commands.cs +++ b/src/SIM.Pipelines/InstallPublishingService/Commands.cs @@ -10,10 +10,14 @@ namespace SIM.Pipelines.InstallPublishingService { public static class Commands { - private const string SET_CONNECTION_STRING = ".\\Sitecore.Framework.Publishing.Host.exe configuration setconnectionstring {0} \"{1}\""; - private const string SCHEMA_UPGRADE = ".\\Sitecore.Framework.Publishing.Host.exe schema upgrade --force"; - private const string SCHEMA_RESET = ".\\Sitecore.Framework.Publishing.Host.exe schema reset --force"; - private const string IIS_INSTALL = ".\\Sitecore.Framework.Publishing.Host.exe iis install --sitename \"{0}\" --apppool \"{1}\" --hosts --force"; + private const string SET_CONNECTION_STRING = "configuration setconnectionstring {0} \"{1}\""; + private const string SCHEMA_UPGRADE = "schema upgrade --force"; + private const string SCHEMA_RESET = "schema reset --force"; + + /*[PORT - BAD GATEWAY ISSUE]*/ + //private const string IIS_INSTALL = "iis install --sitename \"{0}\" --apppool \"{1}\" --port \"{2}\" --hosts --force"; + + private const string IIS_INSTALL = "iis install --sitename \"{0}\" --apppool \"{1}\" --hosts --force"; public static void SetConnectionString(string connectionStringName, string connectrionStringValue) { @@ -30,16 +34,19 @@ public static void SchemaReset() ExecuteCommand(SCHEMA_RESET); } - public static void IISInstall(string siteName, string appPoolName) + public static void IISInstall(string siteName, string appPoolName, int port) { + /*[PORT - BAD GATEWAY ISSUE]*/ + //ExecuteCommand(IIS_INSTALL, siteName, appPoolName, port); + ExecuteCommand(IIS_INSTALL, siteName, appPoolName); } - private static void ExecuteCommand(string commandFormat, params object[] args) + private static void ExecuteCommand(string commandArgs, params object[] args) { using (PowerShell PS = PowerShell.Create()) { - PS.AddScript(string.Format(commandFormat, args)).Invoke(); + PS.AddScript(string.Format(".\\Sitecore.Framework.Publishing.Host.exe " + commandArgs, args)).Invoke(); } } } diff --git a/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs index 662c525e..4a202a9b 100644 --- a/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs @@ -11,7 +11,7 @@ public class CreateIISiteProcessor : InstallSPSProcessor { protected override void ProcessCore(InstallSPSProcessorArgs args) { - Commands.IISInstall(args.SPSSiteName, args.SPSSiteName); + Commands.IISInstall(args.SPSSiteName, args.SPSSiteName, args.SPSPort); } } } diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs index 3f75a3de..b309404a 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs +++ b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs @@ -20,6 +20,7 @@ public class InstallSPSProcessorArgs : ProcessorArgs public string SqlAdminPassword { get; set; } public string SPSPackagePath { get; set; } public string SPSSiteName { get; set; } + public int SPSPort { get; set; } public Dictionary SPSConnectionStrings { get; set; } public bool OverwriteExisting { get; set; } diff --git a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs index 9dedbb3a..1fb00838 100644 --- a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs @@ -21,7 +21,6 @@ protected override void ProcessCore(InstallSPSProcessorArgs args) { if (!args.OverwriteExisting) { - this.Skip(); return; } @@ -72,7 +71,6 @@ private bool DeleteSite(ServerManager sm, [CanBeNull] Site site) retries++; Thread.Sleep(RETRY_INTERVAL_MS); } - Log.Info($"The site {site.Name}'s state is currently {site.State}"); if (!site.State.Equals(ObjectState.Stopped)) { return false; @@ -97,7 +95,6 @@ private bool DeleteAppPool (ServerManager sm, [CanBeNull] ApplicationPool appPoo retries++; Thread.Sleep(RETRY_INTERVAL_MS); } - Log.Info($"The appl pool {appPool.Name}'s state is currently {appPool.State}"); if (!appPool.State.Equals(ObjectState.Stopped)) { return false; diff --git a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs index 63c0f294..202be9a4 100644 --- a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs @@ -27,6 +27,7 @@ protected override void ProcessCore(InstallSPSProcessorArgs args) private bool ValidateStatusEndpoint(string statusEndpoint) { + Log.Info($"HTTP GET {statusEndpoint}"); JObject response; using (WebClient wc = new WebClient()) { diff --git a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs similarity index 97% rename from src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs rename to src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs index 63f3b6fa..557af1fb 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallPublishingServiceWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs @@ -44,6 +44,7 @@ public string SPSPackage set { _spsPackagePath = value; } } public string SPSSiteName { get; set; } + public int SPSPort { get; set; } public Dictionary SPSConnectionStrings { get; set; } = new Dictionary(); #endregion @@ -68,6 +69,7 @@ public override ProcessorArgs ToProcessorArgs() { InstanceName = this.InstanceName, SPSSiteName = this.SPSSiteName, + SPSPort = this.SPSPort, InstanceFolder = this.InstanceFolder, SPSInstanceFolder = this.SPSInstanceFolder, SPSPackagePath = this._spsPackagePath, diff --git a/src/SIM.Tool.Base/SIM.Tool.Base.csproj b/src/SIM.Tool.Base/SIM.Tool.Base.csproj index 6446f6b3..c343b6f5 100644 --- a/src/SIM.Tool.Base/SIM.Tool.Base.csproj +++ b/src/SIM.Tool.Base/SIM.Tool.Base.csproj @@ -79,7 +79,7 @@ - + diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml index e868e07f..6aa84b67 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml @@ -19,12 +19,16 @@ - + + + - - diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs index 83b1145d..978cb5b2 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs @@ -22,22 +22,14 @@ public ConfigureParameters() public void InitializeStep(WizardArgs wizardArgs) { InstallSPSWizardArgs args = (InstallSPSWizardArgs)wizardArgs; - if (ConnectionStringsListBox.Items.Count < 1) - { - foreach (var connString in args.InstanceConnectionStrings) - { - switch (connString.Name.ToLower().Trim()) - { - case "core": - case "master": - case "web": - ConnectionStringsListBox.Items.Add(new CheckBox() { Content = connString.Name, IsChecked = true }); break; - default: - ConnectionStringsListBox.Items.Add(new CheckBox() { Content = connString.Name }); break; - } - } - } - return; + + /*[PORT - BAD GATEWAY ISSUE]*/ + PortLabel.Visibility = System.Windows.Visibility.Hidden; + PortTextBox.Visibility = System.Windows.Visibility.Hidden; + + InitConnectrionStringsListBox(args); + InitSiteName(); + InitPort(); } public bool OnMovingBack(WizardArgs wizardArgs) @@ -48,31 +40,95 @@ public bool OnMovingBack(WizardArgs wizardArgs) public bool OnMovingNext(WizardArgs wizardArgs) { InstallSPSWizardArgs args = (InstallSPSWizardArgs)wizardArgs; - args.SPSSiteName = SPSSiteNameTextBox.Text.Trim(); + bool passedValidation = true; + + ValidateAndSetSiteName(args, ref passedValidation); + ValidateAndSetPort(args, ref passedValidation); + SetConnectionStrings(args); + + return passedValidation; + } + + public bool SaveChanges(WizardArgs wizardArgs) + { + return true; + } + + #region Private methods + private void ValidateAndSetSiteName(InstallSPSWizardArgs args, ref bool isValid) + { + args.SPSSiteName = SiteNameTextBox.Text.Trim(); args.OverwriteExisting = OverwriteIfExistsCheckBox.IsChecked ?? false; string newWebroot = Path.Combine(args.SPSInstanceFolder, args.SPSSiteName); - if (Directory.Exists(newWebroot) && !args.OverwriteExisting){ + if (Directory.Exists(newWebroot) && !args.OverwriteExisting) + { WindowHelper.ShowMessage($"{newWebroot} already exists, please delete the existing instance, choose a different name, or select the" + - $"\"Overwrite if exists?\" checkbox to replace the existing solution"); - return false; + $"\"Overwrite\" checkbox to replace the existing solution"); + isValid = false; + } + } + + private void ValidateAndSetPort(InstallSPSWizardArgs args, ref bool isValid) + { + int port = -1; + if(!int.TryParse(PortTextBox.Text, out port)) + { + isValid = false; } + args.SPSPort = port; + } - foreach (CheckBox checkbox in ConnectionStringsListBox.Items) + private void SetConnectionStrings(InstallSPSWizardArgs args) + { + if (ConnectionStringsListBox.Items.Count < 1) { - if (checkbox.IsChecked ?? false) + foreach (CheckBox checkbox in ConnectionStringsListBox.Items) { - ConnectionString connString = args.InstanceConnectionStrings.Single(cs => cs.Name.Equals(checkbox.Content)); - args.SPSConnectionStrings.Add(checkbox.Content.ToString(), new SqlConnectionStringBuilder(connString.Value)); + if (checkbox.IsChecked ?? false) + { + ConnectionString connString = args.InstanceConnectionStrings.Single(cs => cs.Name.Equals(checkbox.Content)); + args.SPSConnectionStrings.Add(checkbox.Content.ToString(), new SqlConnectionStringBuilder(connString.Value)); + } } } + } - return true; + private void InitConnectrionStringsListBox(InstallSPSWizardArgs args) + { + if (ConnectionStringsListBox.Items.Count < 1) + { + foreach (var connString in args.InstanceConnectionStrings) + { + switch (connString.Name.ToLower().Trim()) + { + case "core": + case "master": + case "web": + ConnectionStringsListBox.Items.Add(new CheckBox() { Content = connString.Name, IsChecked = true }); break; + default: + ConnectionStringsListBox.Items.Add(new CheckBox() { Content = connString.Name }); break; + } + } + } } - public bool SaveChanges(WizardArgs wizardArgs) + private void InitSiteName() { - return true; + if (string.IsNullOrEmpty(SiteNameTextBox.Text.Trim())) + { + SiteNameTextBox.Text = "sitecore.publishing"; + } + } + + private void InitPort() + { + if (string.IsNullOrEmpty(PortTextBox.Text.Trim())) + { + PortTextBox.Text = "80"; + } } + + #endregion } } From c928506b41eab78ad06b0ec81737cd735cb185a0 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 21 Nov 2020 17:25:25 -0500 Subject: [PATCH 18/51] Resolved bad gateway issue (not caused by port, it was missing connectionstrings due to incorrect code logic) and re-added port as a parameter --- .../InstallPublishingService/Commands.cs | 11 ++--------- .../VerifyInstallationProcessor.cs | 2 +- .../ConfigureParameters.xaml.cs | 18 ++++++------------ 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/SIM.Pipelines/InstallPublishingService/Commands.cs b/src/SIM.Pipelines/InstallPublishingService/Commands.cs index 0e5b705a..78df4e8f 100644 --- a/src/SIM.Pipelines/InstallPublishingService/Commands.cs +++ b/src/SIM.Pipelines/InstallPublishingService/Commands.cs @@ -13,11 +13,7 @@ public static class Commands private const string SET_CONNECTION_STRING = "configuration setconnectionstring {0} \"{1}\""; private const string SCHEMA_UPGRADE = "schema upgrade --force"; private const string SCHEMA_RESET = "schema reset --force"; - - /*[PORT - BAD GATEWAY ISSUE]*/ - //private const string IIS_INSTALL = "iis install --sitename \"{0}\" --apppool \"{1}\" --port \"{2}\" --hosts --force"; - - private const string IIS_INSTALL = "iis install --sitename \"{0}\" --apppool \"{1}\" --hosts --force"; + private const string IIS_INSTALL = "iis install --sitename \"{0}\" --apppool \"{1}\" --port \"{2}\" --hosts --force"; public static void SetConnectionString(string connectionStringName, string connectrionStringValue) { @@ -36,10 +32,7 @@ public static void SchemaReset() public static void IISInstall(string siteName, string appPoolName, int port) { - /*[PORT - BAD GATEWAY ISSUE]*/ - //ExecuteCommand(IIS_INSTALL, siteName, appPoolName, port); - - ExecuteCommand(IIS_INSTALL, siteName, appPoolName); + ExecuteCommand(IIS_INSTALL, siteName, appPoolName, port); } private static void ExecuteCommand(string commandArgs, params object[] args) diff --git a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs index 202be9a4..026464c4 100644 --- a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs @@ -17,7 +17,7 @@ public class VerifyInstallationProcessor : InstallSPSProcessor { protected override void ProcessCore(InstallSPSProcessorArgs args) { - string statusEndpoint = $"http://{args.SPSSiteName}/api/publishing/operations/status"; + string statusEndpoint = $"http://{args.SPSSiteName}:{args.SPSPort}/api/publishing/operations/status"; if (!ValidateStatusEndpoint(statusEndpoint)) { Log.Error("Publishing Service returned errors"); diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs index 978cb5b2..5c22c1cf 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs @@ -23,10 +23,6 @@ public void InitializeStep(WizardArgs wizardArgs) { InstallSPSWizardArgs args = (InstallSPSWizardArgs)wizardArgs; - /*[PORT - BAD GATEWAY ISSUE]*/ - PortLabel.Visibility = System.Windows.Visibility.Hidden; - PortTextBox.Visibility = System.Windows.Visibility.Hidden; - InitConnectrionStringsListBox(args); InitSiteName(); InitPort(); @@ -81,18 +77,16 @@ private void ValidateAndSetPort(InstallSPSWizardArgs args, ref bool isValid) private void SetConnectionStrings(InstallSPSWizardArgs args) { - if (ConnectionStringsListBox.Items.Count < 1) + args.SPSConnectionStrings.Clear(); + foreach (CheckBox checkbox in ConnectionStringsListBox.Items) { - foreach (CheckBox checkbox in ConnectionStringsListBox.Items) + if (checkbox.IsChecked ?? false) { - if (checkbox.IsChecked ?? false) - { - ConnectionString connString = args.InstanceConnectionStrings.Single(cs => cs.Name.Equals(checkbox.Content)); - args.SPSConnectionStrings.Add(checkbox.Content.ToString(), new SqlConnectionStringBuilder(connString.Value)); - } + ConnectionString connString = args.InstanceConnectionStrings.Single(cs => cs.Name.Equals(checkbox.Content)); + args.SPSConnectionStrings.Add(checkbox.Content.ToString(), new SqlConnectionStringBuilder(connString.Value)); } } - } + } private void InitConnectrionStringsListBox(InstallSPSWizardArgs args) { From 3de75b32c2c9b35a5e2d95d9b45357b0f3952c56 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 21 Nov 2020 17:30:51 -0500 Subject: [PATCH 19/51] Fixed class name --- ...llPublishingServiceWizardArgs.cs => UninstallSPSWizardArgs.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/SIM.Tool.Base/Pipelines/{UninstallPublishingServiceWizardArgs.cs => UninstallSPSWizardArgs.cs} (100%) diff --git a/src/SIM.Tool.Base/Pipelines/UninstallPublishingServiceWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/UninstallSPSWizardArgs.cs similarity index 100% rename from src/SIM.Tool.Base/Pipelines/UninstallPublishingServiceWizardArgs.cs rename to src/SIM.Tool.Base/Pipelines/UninstallSPSWizardArgs.cs From de03f6eae85c3c40aee2c3c59594c634e57f2b67 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 21 Nov 2020 17:34:06 -0500 Subject: [PATCH 20/51] joining branches --- src/SIM.Tool.Base/SIM.Tool.Base.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SIM.Tool.Base/SIM.Tool.Base.csproj b/src/SIM.Tool.Base/SIM.Tool.Base.csproj index 923d30b1..2c4fc17a 100644 --- a/src/SIM.Tool.Base/SIM.Tool.Base.csproj +++ b/src/SIM.Tool.Base/SIM.Tool.Base.csproj @@ -79,8 +79,8 @@ - - + + From be234679b314df90243ee29b579bd2126a3a32bb Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 21 Nov 2020 18:13:54 -0500 Subject: [PATCH 21/51] Uninstall sps wizard essentially complete (want to pull site name from instance config--todo for later), need to implement actual pipeline now --- .../Pipelines/UninstallSPSWizardArgs.cs | 51 ++-------------- .../SelectServiceToUninstall.xaml | 13 +++- .../SelectServiceToUninstall.xaml.cs | 59 ++++++++++++++----- src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 2 +- 4 files changed, 62 insertions(+), 63 deletions(-) diff --git a/src/SIM.Tool.Base/Pipelines/UninstallSPSWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/UninstallSPSWizardArgs.cs index c72a68a1..991eb03c 100644 --- a/src/SIM.Tool.Base/Pipelines/UninstallSPSWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/UninstallSPSWizardArgs.cs @@ -1,5 +1,6 @@ namespace SIM.Tool.Base.Pipelines { + using System; using System.Collections.Generic; using System.Data.SqlClient; using System.IO; @@ -14,67 +15,25 @@ using SIM.Tool.Base.Wizards; public class UninstallSPSWizardArgs : WizardArgs { - private string _spsPackagePath; public UninstallSPSWizardArgs(Instance instance) { - Initialize(instance); } #region Properties - //From Instance public Instance Instance { get; private set; } public string InstanceName { get; private set; } - public ConnectionStringCollection InstanceConnectionStrings { get; private set; } + public string SPSInstanceFolder { get; } = ProfileManager.Profile.InstancesFolder; - //From Profile - public string InstanceFolder { get; set; } - public string SPSInstanceFolder { get; set; } - - public string SqlAdminUsername { get; private set; } - public string SqlAdminPassword { get; private set; } - - - //From User Input - public bool OverwriteExisting { get; set; } - public string SPSPackage - { - get { return Path.GetFileNameWithoutExtension(_spsPackagePath); } - set { _spsPackagePath = value; } - } public string SPSSiteName { get; set; } - public Dictionary SPSConnectionStrings { get; set; } = new Dictionary(); + public string SPSAppPoolName { get; set; } + public string SPSWebroot { get; set; } - #endregion - - #region Methods - private void Initialize(Instance instance) - { - this.Instance = instance; - this.InstanceName = instance.Name; - this.InstanceFolder = ProfileManager.Profile.InstancesFolder; - this.InstanceConnectionStrings = instance.Configuration.ConnectionStrings; - this.SPSInstanceFolder = ProfileManager.Profile.InstancesFolder; - SqlConnectionStringBuilder SqlServerConnectionString = ProfileManager.GetConnectionString(); - this.SqlAdminUsername = SqlServerConnectionString.UserID; - this.SqlAdminPassword = SqlServerConnectionString.Password; - } public override ProcessorArgs ToProcessorArgs() { - return new InstallSPSProcessorArgs() - { - InstanceName = this.InstanceName, - SPSSiteName = this.SPSSiteName, - InstanceFolder = this.InstanceFolder, - SPSInstanceFolder = this.SPSInstanceFolder, - SPSPackagePath = this._spsPackagePath, - SqlAdminUsername = this.SqlAdminUsername, - SqlAdminPassword = this.SqlAdminPassword, - SPSConnectionStrings = this.SPSConnectionStrings, - OverwriteExisting = this.OverwriteExisting - }; + throw new NotImplementedException(); } #endregion diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml index 2d19ee0c..01341230 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml @@ -11,13 +11,22 @@ + + - - + + + + + + + + + diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs index 6714c786..da663a24 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs @@ -1,18 +1,9 @@ -using SIM.Tool.Base.Wizards; -using System; -using System.Collections.Generic; +using Microsoft.Web.Administration; +using SIM.Tool.Base; +using SIM.Tool.Base.Pipelines; +using SIM.Tool.Base.Wizards; +using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; namespace SIM.Tool.Windows.UserControls.Install.PublishingService { @@ -28,6 +19,19 @@ public SelectServiceToUninstall() public void InitializeStep(WizardArgs wizardArgs) { + UninstallSPSWizardArgs args = (UninstallSPSWizardArgs)wizardArgs; + if (string.IsNullOrEmpty(SiteNameTextBox.Text)) + { + SiteNameTextBox.Text = "sitecore.publishing"; + } + if (string.IsNullOrEmpty(AppPoolTextBox.Text)) + { + AppPoolTextBox.Text = "sitecore.publishing"; + } + if (string.IsNullOrEmpty(WebrootTextBox.Text)) + { + WebrootTextBox.Text = Path.Combine(args.SPSInstanceFolder, "sitecore.publishing"); + } return; } @@ -38,6 +42,33 @@ public bool OnMovingBack(WizardArgs wizardArgs) public bool OnMovingNext(WizardArgs wizardArgs) { + Site site; + ApplicationPool appPool; + string webroot; + + using (ServerManager sm = new ServerManager()) + { + site = sm.Sites.FirstOrDefault(s => s.Name.Equals(SiteNameTextBox.Text)); + appPool = sm.ApplicationPools.FirstOrDefault(a => a.Name.Equals(AppPoolTextBox.Text)); + } + webroot = WebrootTextBox.Text; + + if (site == null) + { + WindowHelper.ShowMessage($"The site {site.Name} was not found in IIS"); + return false; + } + + if (appPool == null) + { + WindowHelper.ShowMessage($"The site {appPool.Name} was not found in IIS"); + return false; + } + + if (!Directory.Exists(webroot)) + { + WindowHelper.ShowMessage($"The {webroot} directory does not exist"); + } return true; } diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index ff62b8aa..6eb77bbf 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -443,7 +443,7 @@ Sitecore Launchpad > Control Panel > ADMINISTRATION > Install a package - From 62849d911080bca869a5d4d5467078df172d7c3e Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Wed, 25 Nov 2020 10:47:14 -0500 Subject: [PATCH 22/51] Finished uninstall pipeline --- .../CreateIISiteProcessor.cs | 2 +- .../InstallSPSProcessorArgs.cs | 5 +- .../RemoveExistingSPSProcessor.cs | 95 +++---------------- .../ResetDatabaseSchemaProcessor.cs | 2 +- ...InstallSPSProcessor.cs => SPSProcessor.cs} | 15 ++- .../SetActualConnectionStringsProcessor.cs | 2 +- .../SetAdminConnectionStringsProcessor.cs | 2 +- .../UnzipSPSPackageProcessor.cs | 2 +- .../UpgradeDatabaseSchemaProcessor.cs | 2 +- .../VerifyInstallationProcessor.cs | 2 +- src/SIM.Pipelines/PipelinesConfig.cs | 8 ++ src/SIM.Pipelines/SIM.Pipelines.csproj | 6 +- .../RemoveAppPoolProcessor.cs | 57 +++++++++++ .../RemoveIISSiteProcessor.cs | 57 +++++++++++ .../RemoveWebrootFolderProcessor.cs | 31 ++++++ .../UninstallSPSProcessorArgs.cs | 26 +++++ .../Pipelines/InstallSPSWizardArgs.cs | 2 + .../Pipelines/UninstallSPSWizardArgs.cs | 19 +++- .../SelectServiceToUninstall.xaml | 13 ++- .../SelectServiceToUninstall.xaml.cs | 52 ++++++++-- src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 4 +- 21 files changed, 291 insertions(+), 113 deletions(-) rename src/SIM.Pipelines/InstallPublishingService/{InstallSPSProcessor.cs => SPSProcessor.cs} (58%) create mode 100644 src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs create mode 100644 src/SIM.Pipelines/UninstallPublishingService/RemoveIISSiteProcessor.cs create mode 100644 src/SIM.Pipelines/UninstallPublishingService/RemoveWebrootFolderProcessor.cs create mode 100644 src/SIM.Pipelines/UninstallPublishingService/UninstallSPSProcessorArgs.cs diff --git a/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs index 4a202a9b..5ae7dcbd 100644 --- a/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs @@ -7,7 +7,7 @@ namespace SIM.Pipelines.InstallPublishingService { - public class CreateIISiteProcessor : InstallSPSProcessor + public class CreateIISiteProcessor : SPSProcessor { protected override void ProcessCore(InstallSPSProcessorArgs args) { diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs index b309404a..3540bf20 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs +++ b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs @@ -20,13 +20,12 @@ public class InstallSPSProcessorArgs : ProcessorArgs public string SqlAdminPassword { get; set; } public string SPSPackagePath { get; set; } public string SPSSiteName { get; set; } + public string SPSAppPoolName { get; set; } + public string SPSWebroot { get; set; } public int SPSPort { get; set; } public Dictionary SPSConnectionStrings { get; set; } public bool OverwriteExisting { get; set; } - //Other Properties - public string SPSWebroot { get { return Path.Combine(SPSInstanceFolder, SPSSiteName); } } - #endregion } } diff --git a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs index 1fb00838..3c896749 100644 --- a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs @@ -1,6 +1,7 @@ using JetBrains.Annotations; using Microsoft.Web.Administration; using SIM.Adapters.WebServer; +using SIM.Pipelines.UninstallPublishingService; using Sitecore.Diagnostics.Logging; using System; using System.Collections.Generic; @@ -12,11 +13,8 @@ namespace SIM.Pipelines.InstallPublishingService { - public class RemoveExistingSPSProcessor : InstallSPSProcessor + public class RemoveExistingSPSProcessor : SPSProcessor { - private const int STOP_RETRIES = 6; - private const int RETRY_INTERVAL_MS = 5000; - protected override void ProcessCore(InstallSPSProcessorArgs args) { if (!args.OverwriteExisting) @@ -24,84 +22,19 @@ protected override void ProcessCore(InstallSPSProcessorArgs args) return; } - using (ServerManager sm = new ServerManager()) - { - Site spsSite = sm.Sites.FirstOrDefault(s => s.Name.Equals(args.SPSSiteName)); - ApplicationPool spsAppPool = sm.ApplicationPools.FirstOrDefault(s => s.Name.Equals(args.SPSSiteName)); - - if (!DeleteSite(sm, spsSite)) - { - throw new Exception($"Could not stop site with the name {args.SPSSiteName}. Please remove it manually in IIS."); - } - - if (!DeleteAppPool(sm, spsAppPool)) - { - throw new Exception($"Could not stop app pool with the name {args.SPSSiteName}. Please remove it manually in IIS."); - } - - sm.CommitChanges(); - } - - if (Directory.Exists(args.SPSWebroot)) - { - try - { - Directory.Delete(args.SPSWebroot, true); - } - catch (IOException ex) - { - //Unlikely user scenario, but it can occur when you create an instance, then immediately try to overwrite it without restarting SIM - throw new Exception($"SIM may be locking the {args.SPSWebroot} folder if it was just created. Try restarting SIM and installing publishing service again", ex); - } - } - } - - private bool DeleteSite(ServerManager sm, [CanBeNull] Site site) - { - if (site != null) + UninstallSPSProcessorArgs uninstallArgs = new UninstallSPSProcessorArgs() { - int retries = 0; - while (!site.State.Equals(ObjectState.Stopped) && retries < STOP_RETRIES) - { - //If the site is starting/stopping IIS won't accept commands and will throw an error, we'll check if its in a started state first - if (site.State.Equals(ObjectState.Started)) - { - site.Stop(); - } - retries++; - Thread.Sleep(RETRY_INTERVAL_MS); - } - if (!site.State.Equals(ObjectState.Stopped)) - { - return false; - } - sm.Sites.Remove(site); - } - return true; - } - - private bool DeleteAppPool (ServerManager sm, [CanBeNull] ApplicationPool appPool) - { - if (appPool != null) - { - int retries = 0; - while (!appPool.State.Equals(ObjectState.Stopped) && retries < STOP_RETRIES) - { - //If the site is starting/stopping IIS won't accept commands and will throw an error, we'll check if its in a started state first - if (appPool.State.Equals(ObjectState.Started)) - { - appPool.Stop(); - } - retries++; - Thread.Sleep(RETRY_INTERVAL_MS); - } - if (!appPool.State.Equals(ObjectState.Stopped)) - { - return false; - } - sm.ApplicationPools.Remove(appPool); - } - return true; + SPSSiteName = args.SPSSiteName, + SPSAppPoolName = args.SPSAppPoolName, + SPSWebroot = args.SPSWebroot, + SkipSPSSite = false, + SkipSPSAppPool = false, + SkipSPSWebroot = false + }; + + new RemoveIISSiteProcessor().DoProcess(uninstallArgs); + new RemoveAppPoolProcessor().DoProcess(uninstallArgs); + new RemoveWebrootFolderProcessor().DoProcess(uninstallArgs); } } } diff --git a/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs index 95c90ab7..3473ae75 100644 --- a/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs @@ -7,7 +7,7 @@ namespace SIM.Pipelines.InstallPublishingService { - public class ResetDatabaseSchemaProcessor : InstallSPSProcessor + public class ResetDatabaseSchemaProcessor : SPSProcessor { //Resetting the schema is done to clear any potentially existing Publishing tables protected override void ProcessCore(InstallSPSProcessorArgs args) diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SPSProcessor.cs similarity index 58% rename from src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessor.cs rename to src/SIM.Pipelines/InstallPublishingService/SPSProcessor.cs index 91dd7c18..cdc45077 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SPSProcessor.cs @@ -3,19 +3,20 @@ using Sitecore.Diagnostics.Logging; using System; using System.Collections.Generic; +using System.Deployment.Internal; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SIM.Pipelines.InstallPublishingService { - public abstract class InstallSPSProcessor : Processor + public abstract class SPSProcessor : Processor where T : ProcessorArgs { protected static bool AbortPipeline = false; protected override void Process([NotNull] ProcessorArgs args) { - InstallSPSProcessorArgs processorArgs = args as InstallSPSProcessorArgs; + T processorArgs = args as T; if (AbortPipeline) { @@ -31,11 +32,17 @@ protected override void Process([NotNull] ProcessorArgs args) catch (Exception ex) { AbortPipeline = true; - Log.Error($"installpublishingservice Pipeline was aborted. The remaining steps were skipped."); + Log.Error($"Publishing Service Pipeline was aborted. The remaining steps were skipped."); throw ex; } } - protected abstract void ProcessCore(InstallSPSProcessorArgs args); + protected abstract void ProcessCore([NotNull] T args); + + //Kind of a hack so I can resure some of the uninstall sps processors in the RemoveExistingSPSProcessor class + internal void DoProcess([NotNull] T args) + { + this.Process(args); + } } } diff --git a/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs index ce6d34a6..69c09d7d 100644 --- a/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs @@ -8,7 +8,7 @@ namespace SIM.Pipelines.InstallPublishingService { - public class SetActualConnectionStringsProcessor : InstallSPSProcessor + public class SetActualConnectionStringsProcessor : SPSProcessor { protected override void ProcessCore(InstallSPSProcessorArgs args) { diff --git a/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs index 41a7609a..0b6c4dea 100644 --- a/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs @@ -8,7 +8,7 @@ namespace SIM.Pipelines.InstallPublishingService { - public class SetAdminConnectionStringsProcessor : InstallSPSProcessor + public class SetAdminConnectionStringsProcessor : SPSProcessor { //Using the admin credentials for connection strings is necessary to upgrade and reset the database schema protected override void ProcessCore(InstallSPSProcessorArgs args) diff --git a/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs index 53c9aac7..6d623ab2 100644 --- a/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs @@ -12,7 +12,7 @@ namespace SIM.Pipelines.InstallPublishingService { - public class UnzipSPSPackageProcessor : InstallSPSProcessor + public class UnzipSPSPackageProcessor : SPSProcessor { protected override void ProcessCore(InstallSPSProcessorArgs args) { diff --git a/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs index 1023e2f9..b286bbc7 100644 --- a/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs @@ -7,7 +7,7 @@ namespace SIM.Pipelines.InstallPublishingService { - public class UpgradeDatabaseSchemaProcessor : InstallSPSProcessor + public class UpgradeDatabaseSchemaProcessor : SPSProcessor { protected override void ProcessCore(InstallSPSProcessorArgs args) { diff --git a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs index 026464c4..93dd2b00 100644 --- a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs @@ -13,7 +13,7 @@ namespace SIM.Pipelines.InstallPublishingService { - public class VerifyInstallationProcessor : InstallSPSProcessor + public class VerifyInstallationProcessor : SPSProcessor { protected override void ProcessCore(InstallSPSProcessorArgs args) { diff --git a/src/SIM.Pipelines/PipelinesConfig.cs b/src/SIM.Pipelines/PipelinesConfig.cs index d51898e2..52b2ae44 100644 --- a/src/SIM.Pipelines/PipelinesConfig.cs +++ b/src/SIM.Pipelines/PipelinesConfig.cs @@ -235,6 +235,14 @@ public static class PipelinesConfig + + + + + "; } } \ No newline at end of file diff --git a/src/SIM.Pipelines/SIM.Pipelines.csproj b/src/SIM.Pipelines/SIM.Pipelines.csproj index d1e6957c..6f5e1570 100644 --- a/src/SIM.Pipelines/SIM.Pipelines.csproj +++ b/src/SIM.Pipelines/SIM.Pipelines.csproj @@ -109,7 +109,7 @@ - + @@ -209,6 +209,10 @@ + + + + diff --git a/src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs b/src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs new file mode 100644 index 00000000..b504f83b --- /dev/null +++ b/src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs @@ -0,0 +1,57 @@ +using JetBrains.Annotations; +using Microsoft.Web.Administration; +using SIM.Pipelines.InstallPublishingService; +using System; +using System.Linq; +using System.Threading; + +namespace SIM.Pipelines.UninstallPublishingService +{ + public class RemoveAppPoolProcessor : SPSProcessor + { + protected override void ProcessCore([NotNull] UninstallSPSProcessorArgs args) + { + if (args.SkipSPSAppPool) + { + return; + } + + using (ServerManager sm = new ServerManager()) + { + ApplicationPool spsAppPool = sm.ApplicationPools.FirstOrDefault(s => s.Name.Equals(args.SPSAppPoolName)); + + if (!DeleteAppPool(sm, spsAppPool, args.MaxRetries, args.RetryInterval)) + { + throw new Exception($"Could not stop site with the name {args.SPSAppPoolName}. Please remove it manually in IIS."); + } + + sm.CommitChanges(); + } + } + + private bool DeleteAppPool(ServerManager sm, [CanBeNull] ApplicationPool appPool, int maxRetries, int retryInterval) + { + if (appPool != null) + { + int retries = 0; + while (!appPool.State.Equals(ObjectState.Stopped) && retries < maxRetries) + { + //If the site is starting/stopping IIS won't accept commands and will throw an error, we'll check if its in a started state first + if (appPool.State.Equals(ObjectState.Started)) + { + appPool.Stop(); + } + retries++; + Thread.Sleep(retryInterval); + } + if (!appPool.State.Equals(ObjectState.Stopped)) + { + return false; + } + sm.ApplicationPools.Remove(appPool); + } + return true; + } + + } +} diff --git a/src/SIM.Pipelines/UninstallPublishingService/RemoveIISSiteProcessor.cs b/src/SIM.Pipelines/UninstallPublishingService/RemoveIISSiteProcessor.cs new file mode 100644 index 00000000..8d1343f9 --- /dev/null +++ b/src/SIM.Pipelines/UninstallPublishingService/RemoveIISSiteProcessor.cs @@ -0,0 +1,57 @@ +using JetBrains.Annotations; +using Microsoft.Web.Administration; +using SIM.Pipelines.InstallPublishingService; +using System; +using System.Linq; +using System.Threading; + +namespace SIM.Pipelines.UninstallPublishingService +{ + public class RemoveIISSiteProcessor : SPSProcessor + { + protected override void ProcessCore([NotNull] UninstallSPSProcessorArgs args) + { + if (args.SkipSPSSite) + { + return; + } + + using (ServerManager sm = new ServerManager()) + { + Site spsSite = sm.Sites.FirstOrDefault(s => s.Name.Equals(args.SPSSiteName)); + + if (!DeleteSite(sm, spsSite, args.MaxRetries, args.RetryInterval)) + { + throw new Exception($"Could not stop site with the name {args.SPSSiteName}. Please remove it manually in IIS."); + } + + sm.CommitChanges(); + } + } + + private bool DeleteSite(ServerManager sm, [CanBeNull] Site site, int maxRetries, int retryInterval) + { + if (site != null) + { + int retries = 0; + while (!site.State.Equals(ObjectState.Stopped) && retries < maxRetries) + { + //If the site is starting/stopping IIS won't accept commands and will throw an error, we'll check if its in a started state first + if (site.State.Equals(ObjectState.Started)) + { + site.Stop(); + } + retries++; + Thread.Sleep(retryInterval); + } + if (!site.State.Equals(ObjectState.Stopped)) + { + return false; + } + sm.Sites.Remove(site); + } + return true; + } + + } +} diff --git a/src/SIM.Pipelines/UninstallPublishingService/RemoveWebrootFolderProcessor.cs b/src/SIM.Pipelines/UninstallPublishingService/RemoveWebrootFolderProcessor.cs new file mode 100644 index 00000000..8753991e --- /dev/null +++ b/src/SIM.Pipelines/UninstallPublishingService/RemoveWebrootFolderProcessor.cs @@ -0,0 +1,31 @@ +using JetBrains.Annotations; +using SIM.Pipelines.InstallPublishingService; +using System; +using System.IO; + +namespace SIM.Pipelines.UninstallPublishingService +{ + public class RemoveWebrootFolderProcessor : SPSProcessor + { + protected override void ProcessCore([NotNull] UninstallSPSProcessorArgs args) + { + if (args.SkipSPSWebroot) + { + return; + } + + if (Directory.Exists(args.SPSWebroot)) + { + try + { + Directory.Delete(args.SPSWebroot, true); + } + catch (IOException ex) + { + //Unlikely user scenario, but it can occur when you create an instance, then immediately try to overwrite it without restarting SIM + throw new Exception($"SIM may be locking the {args.SPSWebroot} folder if it was just created. Try restarting SIM and installing publishing service again", ex); + } + } + } + } +} diff --git a/src/SIM.Pipelines/UninstallPublishingService/UninstallSPSProcessorArgs.cs b/src/SIM.Pipelines/UninstallPublishingService/UninstallSPSProcessorArgs.cs new file mode 100644 index 00000000..ca3e4587 --- /dev/null +++ b/src/SIM.Pipelines/UninstallPublishingService/UninstallSPSProcessorArgs.cs @@ -0,0 +1,26 @@ +using SIM.Pipelines.Processors; +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SIM.Pipelines.UninstallPublishingService +{ + public class UninstallSPSProcessorArgs : ProcessorArgs + { + #region Properties + public string SPSSiteName { get; set; } + public string SPSAppPoolName { get; set; } + public string SPSWebroot { get; set; } + public bool SkipSPSSite { get; set; } + public bool SkipSPSAppPool { get; set; } + public bool SkipSPSWebroot { get; set; } + public int MaxRetries { get; set; } = 6; + public int RetryInterval { get; set; } = 5000; + + #endregion + } +} diff --git a/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs index 49fcbe0a..a0b665b0 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs @@ -68,6 +68,8 @@ public override ProcessorArgs ToProcessorArgs() { InstanceName = this.InstanceName, SPSSiteName = this.SPSSiteName, + SPSAppPoolName = this.SPSSiteName, + SPSWebroot = Path.Combine(this.SPSInstanceFolder, this.SPSSiteName), SPSPort = this.SPSPort, InstanceFolder = this.InstanceFolder, SPSInstanceFolder = this.SPSInstanceFolder, diff --git a/src/SIM.Tool.Base/Pipelines/UninstallSPSWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/UninstallSPSWizardArgs.cs index 991eb03c..52cb0996 100644 --- a/src/SIM.Tool.Base/Pipelines/UninstallSPSWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/UninstallSPSWizardArgs.cs @@ -7,7 +7,7 @@ using SIM.Adapters.WebServer; using SIM.Instances; using SIM.Pipelines.Install; - using SIM.Pipelines.InstallPublishingService; + using SIM.Pipelines.UninstallPublishingService; using SIM.Pipelines.Processors; using SIM.Services; using SIM.Tool.Base.Converters; @@ -17,6 +17,8 @@ public class UninstallSPSWizardArgs : WizardArgs { public UninstallSPSWizardArgs(Instance instance) { + this.Instance = instance; + this.InstanceName = instance.Name; } #region Properties @@ -28,12 +30,21 @@ public UninstallSPSWizardArgs(Instance instance) public string SPSSiteName { get; set; } public string SPSAppPoolName { get; set; } public string SPSWebroot { get; set; } - - + public bool SkipSPSSite { get; set; } + public bool SkipSPSAppPool { get; set; } + public bool SkipSPSWebroot { get; set; } public override ProcessorArgs ToProcessorArgs() { - throw new NotImplementedException(); + return new UninstallSPSProcessorArgs() + { + SPSSiteName = this.SPSSiteName, + SPSAppPoolName = this.SPSAppPoolName, + SPSWebroot = this.SPSWebroot, + SkipSPSSite = this.SkipSPSSite, + SkipSPSAppPool = this.SkipSPSAppPool, + SkipSPSWebroot = this.SkipSPSWebroot + }; } #endregion diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml index 01341230..c3fd65b7 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml @@ -8,6 +8,8 @@ + + @@ -18,15 +20,22 @@ - + + + + + + + - + + diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs index da663a24..5ba0a6b3 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs @@ -12,6 +12,7 @@ namespace SIM.Tool.Windows.UserControls.Install.PublishingService /// public partial class SelectServiceToUninstall : IWizardStep, IFlowControl { + private string InstanceFolder { get; set; } public SelectServiceToUninstall() { InitializeComponent(); @@ -20,6 +21,8 @@ public SelectServiceToUninstall() public void InitializeStep(WizardArgs wizardArgs) { UninstallSPSWizardArgs args = (UninstallSPSWizardArgs)wizardArgs; + this.InstanceFolder = args.SPSInstanceFolder; + if (string.IsNullOrEmpty(SiteNameTextBox.Text)) { SiteNameTextBox.Text = "sitecore.publishing"; @@ -30,7 +33,7 @@ public void InitializeStep(WizardArgs wizardArgs) } if (string.IsNullOrEmpty(WebrootTextBox.Text)) { - WebrootTextBox.Text = Path.Combine(args.SPSInstanceFolder, "sitecore.publishing"); + WebrootTextBox.Text = Path.Combine(InstanceFolder, "sitecore.publishing"); } return; } @@ -42,9 +45,14 @@ public bool OnMovingBack(WizardArgs wizardArgs) public bool OnMovingNext(WizardArgs wizardArgs) { - Site site; - ApplicationPool appPool; - string webroot; + UninstallSPSWizardArgs args = (UninstallSPSWizardArgs)wizardArgs; + args.SkipSPSSite = SkipSiteName.IsChecked ?? false; + args.SkipSPSAppPool = SkipAppPool.IsChecked ?? false; + args.SkipSPSWebroot = SkipWebrootFolder.IsChecked ?? false; + + Site site = null; + ApplicationPool appPool = null; + string webroot = ""; using (ServerManager sm = new ServerManager()) { @@ -53,22 +61,27 @@ public bool OnMovingNext(WizardArgs wizardArgs) } webroot = WebrootTextBox.Text; - if (site == null) + if (site == null && !args.SkipSPSSite) { - WindowHelper.ShowMessage($"The site {site.Name} was not found in IIS"); + WindowHelper.ShowMessage($"The site {SiteNameTextBox.Text} was not found in IIS"); return false; } - if (appPool == null) + if (appPool == null && !args.SkipSPSAppPool) { - WindowHelper.ShowMessage($"The site {appPool.Name} was not found in IIS"); + WindowHelper.ShowMessage($"The application pool {AppPoolTextBox.Text} was not found in IIS"); return false; } - if (!Directory.Exists(webroot)) + if (!Directory.Exists(webroot) && !args.SkipSPSWebroot) { WindowHelper.ShowMessage($"The {webroot} directory does not exist"); + return false; } + + args.SPSSiteName = site.Name; + args.SPSAppPoolName = appPool.Name; + args.SPSWebroot = webroot; return true; } @@ -76,5 +89,26 @@ public bool SaveChanges(WizardArgs wizardArgs) { return true; } + + private void SiteNameTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) + { + AppPoolTextBox.Text = SiteNameTextBox.Text; + WebrootTextBox.Text = Path.Combine(InstanceFolder, SiteNameTextBox.Text); + } + + private void SkipSiteName_Checked(object sender, System.Windows.RoutedEventArgs e) + { + SiteNameTextBox.IsEnabled = !(SkipSiteName.IsChecked ?? false); + } + + private void SkipAppPool_Checked(object sender, System.Windows.RoutedEventArgs e) + { + AppPoolTextBox.IsEnabled = !(SkipAppPool.IsChecked ?? false); + } + + private void SkipWebrootFolder_Checked(object sender, System.Windows.RoutedEventArgs e) + { + WebrootTextBox.IsEnabled = !(SkipWebrootFolder.IsChecked ?? false); + } } } diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index 6eb77bbf..dd9b0ab5 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -429,10 +429,10 @@ By clicking 'Next' you accept the License Agreement."" /> finishText=""Publishing service installation completed. Please login into Sitecore and install the Publishing Module via the wizard: Sitecore Launchpad > Control Panel > ADMINISTRATION > Install a package -Your browser should have opened a page to: +If successful your browser should have opened a page to: http://{Your Publishing Service Hostname}/api/publishing/operations/status -If you get a response with a status of 0, it means your publishing service is running without any issues. ""> +A response with a status of 0 means your publishing service is running without any issues. ""> From c3294acedbe23d2698f16cde2ec737c0df9d4284 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Mon, 25 Jan 2021 15:40:53 -0500 Subject: [PATCH 23/51] Removing exception stacktrace from WindowHelper popup message (previously added during development for debugging) --- src/SIM.Tool.Base/Windows/Wizard.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SIM.Tool.Base/Windows/Wizard.xaml.cs b/src/SIM.Tool.Base/Windows/Wizard.xaml.cs index 5ba30b68..2e7b6fbe 100644 --- a/src/SIM.Tool.Base/Windows/Wizard.xaml.cs +++ b/src/SIM.Tool.Base/Windows/Wizard.xaml.cs @@ -775,7 +775,7 @@ private void MoveNextClick(object sender, RoutedEventArgs e) catch (Exception ex) { WindowHelper.HandleError( - $"Something went wrong with Wizard logic. It is to be closed. {Environment.NewLine}{Environment.NewLine}{ex.Message}{ex.StackTrace}", false, ex); + $"Something went wrong with Wizard logic. It is to be closed. {Environment.NewLine}{Environment.NewLine}{ex.Message}", false, ex); Close(); } } From b0e6c91dc2dc1fd208b96e62e79be458a48f3348 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 6 Feb 2021 12:11:59 -0500 Subject: [PATCH 24/51] Extended Instance class to return a collection of Roles, and bool property for checking if it is a CM. Publishing service buttons is only visible now if instance is a CM --- src/SIM.Instances/Instance.cs | 74 +++++++++++++++++++ .../Buttons/InstallPublishingServiceButton.cs | 17 ++++- 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/src/SIM.Instances/Instance.cs b/src/SIM.Instances/Instance.cs index 259e5c7f..3c10256f 100644 --- a/src/SIM.Instances/Instance.cs +++ b/src/SIM.Instances/Instance.cs @@ -494,6 +494,67 @@ public InstanceType Type } } + /// + /// A collection of server roles this instance is defined as + /// + public ICollection Roles + { + get + { + ICollection InstanceRoles = new List(); + + //Find role by name + string instanceName = this.Name; + if (instanceName.Contains(".identityserver")) + { + InstanceRoles.Add(InstanceRole.IdentityServer); + return InstanceRoles; + } + if (instanceName.Contains(".xconnect")) + { + InstanceRoles.Add(InstanceRole.XConnect); + return InstanceRoles; + } + + //Find role by 'role:define' key in web.config + string roleDefine = this.GetWebConfig().GetElementAttributeValue("/configuration/appSettings/add[@key='role:define']", "value").ToLower(); + if (string.IsNullOrEmpty(roleDefine)) + { + InstanceRoles.Add((InstanceRole.Unknown)); //If 'role:define' is not present, this is likely a pre-version 9 solution, and we don't know the role + return InstanceRoles; + } + if (roleDefine.Contains("standalone")) + { + InstanceRoles.Add(InstanceRole.Standalone); + } + if (roleDefine.Contains("contentmanagement")) + { + InstanceRoles.Add(InstanceRole.ContentManagement); + } + if (roleDefine.Contains("contentdelivery")) + { + InstanceRoles.Add(InstanceRole.ContentDelivery); + } + if (roleDefine.Contains("reporting")) + { + InstanceRoles.Add(InstanceRole.Reporting); + } + if (roleDefine.Contains("processing")) + { + InstanceRoles.Add(InstanceRole.Processing); + } + if (roleDefine.Contains("indexing")) + { + InstanceRoles.Add(InstanceRole.Indexing); + } + + return InstanceRoles; + } + } + public bool IsContentManagementInstance => this.Roles.Contains(InstanceRole.Standalone) || + this.Roles.Contains(InstanceRole.ContentManagement) || + this.Roles.Contains(InstanceRole.Unknown); + public enum InstanceType { Sitecore8AndEarlier, @@ -503,6 +564,19 @@ public enum InstanceType Unknown } + public enum InstanceRole + { + Standalone, + ContentManagement, + ContentDelivery, + Reporting, + Processing, + Indexing, + XConnect, + IdentityServer, + Unknown + } + #endregion #region Public methods diff --git a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs index 5f19956a..8e4aede4 100644 --- a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs +++ b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs @@ -1,4 +1,9 @@ -namespace SIM.Tool.Windows.MainWindowComponents.Buttons +using System; +using System.Collections.Generic; +using Microsoft.VisualBasic.Logging; +using SIM.Tool.Base; + +namespace SIM.Tool.Windows.MainWindowComponents.Buttons { using System.Windows; using SIM.Core.Common; @@ -20,7 +25,7 @@ public bool IsEnabled(Window mainWindow, Instance instance) public bool IsVisible(Window mainWindow, Instance instance) { - return true; + return instance != null && instance.IsContentManagementInstance; } public void OnClick(Window mainWindow, Instance instance) @@ -33,5 +38,13 @@ public void OnClick(Window mainWindow, Instance instance) } #endregion + + #region Private Methods + + + + #endregion + + } } \ No newline at end of file From 4cd73e25b9969ac0c9054a11c1e888af8e530c94 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 6 Feb 2021 12:19:33 -0500 Subject: [PATCH 25/51] Install group of Edit tab is no longer visible for all instances, moved SPS buttons to Manage section instead --- src/SIM.Tool.Windows/MainWindowData.cs | 42 +++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/SIM.Tool.Windows/MainWindowData.cs b/src/SIM.Tool.Windows/MainWindowData.cs index 79a8e88e..b38af52e 100644 --- a/src/SIM.Tool.Windows/MainWindowData.cs +++ b/src/SIM.Tool.Windows/MainWindowData.cs @@ -685,27 +685,6 @@ private static ButtonDefinition GetPatchButton() Image = "/Images/$lg/install.png, SIM.Tool.Windows", Handler = new InstallModulesButton() }, - new ButtonDefinition - { - Label = "Publishing Service", - Image = "/Images/$lg/install.png, SIM.Tool.Windows", - Handler = new SIM.Tool.Windows.MainWindowComponents.Buttons.InstallSPSButton(), - Buttons = new[] - { - new ButtonDefinition - { - Label = "Install", - Image = "/Images/$lg/install.png, SIM.Tool.Windows", - Handler = new SIM.Tool.Windows.MainWindowComponents.Buttons.InstallSPSButton(), - }, - new ButtonDefinition - { - Label = "Uninstall", - Image = "/Images/$lg/uninstall.png, SIM.Tool.Windows", - Handler = new SIM.Tool.Windows.MainWindowComponents.Buttons.UninstallSPSButton(), - } - } - }, } }, GetManageGroupDefinition(), @@ -944,6 +923,27 @@ private static GroupDefinition GetManageGroupDefinition() }, } }, + new ButtonDefinition + { + Label = "Publishing Service", + Image = "/Images/$lg/install.png, SIM.Tool.Windows", + Handler = new InstallSPSButton(), + Buttons = new[] + { + new ButtonDefinition + { + Label = "Install", + Image = "/Images/$lg/install.png, SIM.Tool.Windows", + Handler = new InstallSPSButton(), + }, + new ButtonDefinition + { + Label = "Uninstall", + Image = "/Images/$lg/uninstall.png, SIM.Tool.Windows", + Handler = new UninstallSPSButton(), + } + } + }, } }; } From b2f3f4cded9d3795e8b80fd9b9b949c650865e1a Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 6 Feb 2021 12:31:56 -0500 Subject: [PATCH 26/51] Preventing potential NullRefenceExceptions if a package is not selected --- .../SelectPublishingServicePackage.xaml.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs index 07effe87..1614d979 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs @@ -6,6 +6,7 @@ using System.IO; using System.Windows.Controls; using System.Windows.Navigation; +using SIM.Tool.Base; namespace SIM.Tool.Windows.UserControls.Install.PublishingService { @@ -37,7 +38,14 @@ public bool OnMovingBack(WizardArgs wizardArgs) public bool OnMovingNext(WizardArgs wizardArgs) { InstallSPSWizardArgs args = (InstallSPSWizardArgs)wizardArgs; - args.SPSPackage = ((ComboBoxItem)SPSPackageComboBox.SelectedItem).Tag.ToString(); + args.SPSPackage = ((ComboBoxItem)SPSPackageComboBox.SelectedItem)?.Tag.ToString(); + + if (args.SPSPackage == null) + { + WindowHelper.ShowMessage("Please select a package before continuing!"); + return false; + } + return true; } From 0ec9fbda5fa5852d01d2d3a3181ad7aebbb7af57 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 6 Feb 2021 12:36:15 -0500 Subject: [PATCH 27/51] Removed '#' from wizard pipeline step names --- src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index 8c295525..b4cc99e8 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -459,16 +459,16 @@ Sitecore Launchpad > Control Panel > ADMINISTRATION > Install a package A response with a status of 0 means your publishing service is running without any issues. ""> - - - From 0e1c0ea542d1c2bece843074fb119807190c949b Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 6 Feb 2021 12:47:00 -0500 Subject: [PATCH 28/51] SPS Installer now looks for packages in the SIM local repo and any subdirectories --- .../PublishingService/SelectPublishingServicePackage.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs index 1614d979..911b8dfa 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs @@ -70,7 +70,7 @@ private void Initialize() KBForSXACompatibilityPriorWithSPS.NavigateUri = new Uri(KB_SXA_COMPATIBILITY_WITH_SPS); //Populate ComboBox - foreach (string packagePath in Directory.GetFiles(ProfileManager.Profile.LocalRepository, "Sitecore Publishing Service*.zip")) + foreach (string packagePath in Directory.GetFiles(ProfileManager.Profile.LocalRepository, "Sitecore Publishing Service*.zip", SearchOption.AllDirectories)) { SPSPackageComboBox.Items.Add(new ComboBoxItem() { From 6a69d06e81fb5afd1f5d5ef7473869f68d9de1be Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 6 Feb 2021 15:05:58 -0500 Subject: [PATCH 29/51] Only display Sitecore Publishing Service packages that are compatible with the CMS version, in the package selector dropdown --- .../SelectPublishingServicePackage.xaml.cs | 69 +++++++++++++++++-- 1 file changed, 62 insertions(+), 7 deletions(-) diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs index 911b8dfa..5e0a00b1 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs @@ -2,8 +2,11 @@ using SIM.Tool.Base.Profiles; using SIM.Tool.Base.Wizards; using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; +using System.Text.RegularExpressions; using System.Windows.Controls; using System.Windows.Navigation; using SIM.Tool.Base; @@ -27,6 +30,23 @@ public SelectPublishingServicePackage() public void InitializeStep(WizardArgs wizardArgs) { + InstallSPSWizardArgs args = (InstallSPSWizardArgs)wizardArgs; + int cmsVersionInt = args.Instance.Product?.Release?.Version.MajorMinorUpdateInt ?? -1; + + //Populate ComboBox + foreach (string packagePath in Directory.GetFiles(ProfileManager.Profile.LocalRepository, "Sitecore Publishing Service*.zip", SearchOption.AllDirectories)) + { + string spsPackageName = Path.GetFileNameWithoutExtension(packagePath); + if (IsCompatible(spsPackageName, cmsVersionInt)) + { + SPSPackageComboBox.Items.Add(new ComboBoxItem() + { + Content = spsPackageName, + Tag = packagePath + }); + } + } + return; } @@ -69,16 +89,51 @@ private void Initialize() KBForSPSCompatibility410AndLater.NavigateUri = new Uri(KB_SPS_COMPATIBILTY_410_AND_LATER); KBForSXACompatibilityPriorWithSPS.NavigateUri = new Uri(KB_SXA_COMPATIBILITY_WITH_SPS); - //Populate ComboBox - foreach (string packagePath in Directory.GetFiles(ProfileManager.Profile.LocalRepository, "Sitecore Publishing Service*.zip", SearchOption.AllDirectories)) + return; + } + + private bool IsCompatible(string spsPackageName, int cmsVersionInt) + { + Regex versionPattern = new Regex("\\d+\\.\\d+\\.\\d+"); + int spsPackageVersionInt = int.Parse(versionPattern.Match(spsPackageName).Value.Replace(".", "")); + + //sps version 410 and above + if (spsPackageVersionInt >= 410) { - SPSPackageComboBox.Items.Add(new ComboBoxItem() + /* + * If cmsVersionInt is negative, it means there was an error getting the version, and we should not restrict options. + * This can happen if a new version of Sitecore is released and SIM cannot parse its version number yet. + * Since we are assuming this is a new version of Sitecore, it is still safe to allow compatibility for SPS version 4.1.0 and above + */ + return cmsVersionInt >= 910 || cmsVersionInt < 0; + } + + //sps version 400 and below + return (from pair in LegacySPSCompatibilityTable where spsPackageVersionInt == pair.Key //Get the array of compatible cms versions for the given sps version + select pair.Value.Any(i => i == cmsVersionInt)).FirstOrDefault(); //Check if the selected instance's version is in this array + } + + private static Dictionary LegacySPSCompatibilityTable + { + get + { + return new Dictionary() { - Content = Path.GetFileNameWithoutExtension(packagePath), - Tag = packagePath - }); + { 111, new [] { 820, 821 }}, + { 200, new [] { 822, 823 }}, + { 201, new [] { 822, 823, 824, 825 }}, + { 210, new [] { 822, 823, 824, 825, 826 }}, + { 220, new [] { 822, 823, 824, 825, 826, 827 }}, + { 221, new [] { 822, 823, 824, 825, 826, 827 }}, + { 300, new [] { 900 }}, + { 310, new [] { 900, 901, 902 }}, + { 311, new [] { 900, 901, 902 }}, + { 312, new [] { 900, 901, 902 }}, + { 313, new [] { 900, 901, 902 }}, + { 314, new [] { 900, 901, 902 }}, + { 400, new [] { 910, 911 }} + }; } - return; } } } From 17ca458372e3a3f1c705213d2c93784d094d7ed7 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sun, 7 Mar 2021 13:33:10 -0500 Subject: [PATCH 30/51] Fixed visibility for install/uninstall button given the selected instance --- src/SIM.Instances/Instance.cs | 21 +++++++++++++---- .../RemoveAppPoolProcessor.cs | 2 +- .../RemoveWebrootFolderProcessor.cs | 2 +- src/SIM.Products/ProductHelper.cs | 7 ++++++ .../UninstallPublishingServiceButton.cs | 2 +- src/SIM.Tool.Windows/MainWindowData.cs | 23 ++++++------------- .../SelectServiceToUninstall.xaml.cs | 18 +++++++-------- src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 2 +- 8 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/SIM.Instances/Instance.cs b/src/SIM.Instances/Instance.cs index 3c10256f..298b6b6c 100644 --- a/src/SIM.Instances/Instance.cs +++ b/src/SIM.Instances/Instance.cs @@ -168,7 +168,7 @@ public virtual bool IsSitecoreEnvironmentMember } } - return false; + return FileSystem.FileSystem.Local.File.Exists(ProductHelper.GetPublishingHostPath(WebRootPath)); } catch (Exception ex) { @@ -504,18 +504,26 @@ public ICollection Roles ICollection InstanceRoles = new List(); //Find role by name - string instanceName = this.Name; - if (instanceName.Contains(".identityserver")) + string instanceName = this.Name.ToLower(); + if (instanceName.Contains("identityserver")) { InstanceRoles.Add(InstanceRole.IdentityServer); return InstanceRoles; } - if (instanceName.Contains(".xconnect")) + if (instanceName.Contains("xconnect")) { InstanceRoles.Add(InstanceRole.XConnect); return InstanceRoles; } + //Check if sitecore publishing service + string spsRole = this.GetWebConfig().GetElementAttributeValue("/configuration/system.webServer/aspNetCore", "processPath").ToLower(); + if (!spsRole.IsNullOrEmpty() && spsRole.Contains("sitecore.framework.publishing.host")) + { + InstanceRoles.Add(InstanceRole.PublishingService); + return InstanceRoles; + } + //Find role by 'role:define' key in web.config string roleDefine = this.GetWebConfig().GetElementAttributeValue("/configuration/appSettings/add[@key='role:define']", "value").ToLower(); if (string.IsNullOrEmpty(roleDefine)) @@ -523,6 +531,8 @@ public ICollection Roles InstanceRoles.Add((InstanceRole.Unknown)); //If 'role:define' is not present, this is likely a pre-version 9 solution, and we don't know the role return InstanceRoles; } + + //Add any many roles that apply if (roleDefine.Contains("standalone")) { InstanceRoles.Add(InstanceRole.Standalone); @@ -574,7 +584,8 @@ public enum InstanceRole Indexing, XConnect, IdentityServer, - Unknown + Unknown, + PublishingService } #endregion diff --git a/src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs b/src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs index b504f83b..e4e0e777 100644 --- a/src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs +++ b/src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs @@ -22,7 +22,7 @@ protected override void ProcessCore([NotNull] UninstallSPSProcessorArgs args) if (!DeleteAppPool(sm, spsAppPool, args.MaxRetries, args.RetryInterval)) { - throw new Exception($"Could not stop site with the name {args.SPSAppPoolName}. Please remove it manually in IIS."); + throw new Exception($"Could not stop application pool with the name {args.SPSAppPoolName}. Please remove it manually in IIS."); } sm.CommitChanges(); diff --git a/src/SIM.Pipelines/UninstallPublishingService/RemoveWebrootFolderProcessor.cs b/src/SIM.Pipelines/UninstallPublishingService/RemoveWebrootFolderProcessor.cs index 8753991e..6cad9b07 100644 --- a/src/SIM.Pipelines/UninstallPublishingService/RemoveWebrootFolderProcessor.cs +++ b/src/SIM.Pipelines/UninstallPublishingService/RemoveWebrootFolderProcessor.cs @@ -23,7 +23,7 @@ protected override void ProcessCore([NotNull] UninstallSPSProcessorArgs args) catch (IOException ex) { //Unlikely user scenario, but it can occur when you create an instance, then immediately try to overwrite it without restarting SIM - throw new Exception($"SIM may be locking the {args.SPSWebroot} folder if it was just created. Try restarting SIM and installing publishing service again", ex); + throw new Exception($"SIM may be locking the {args.SPSWebroot} folder if it was just created. Try restarting SIM and running the operation again", ex); } } } diff --git a/src/SIM.Products/ProductHelper.cs b/src/SIM.Products/ProductHelper.cs index 1b4dccb7..ad20032c 100644 --- a/src/SIM.Products/ProductHelper.cs +++ b/src/SIM.Products/ProductHelper.cs @@ -97,6 +97,13 @@ public static string GetKernelPath([NotNull] string webRootPath) return Path.Combine(webRootPath, "bin\\Sitecore.Kernel.dll"); } + [NotNull] + public static string GetPublishingHostPath([NotNull] string webRootPath) + { + Assert.ArgumentNotNullOrEmpty(webRootPath, nameof(webRootPath)); + + return Path.Combine(webRootPath, "Sitecore.Framework.Publishing.Host.exe"); + } #endregion #region Methods diff --git a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/UninstallPublishingServiceButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/UninstallPublishingServiceButton.cs index 42421100..01134ac3 100644 --- a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/UninstallPublishingServiceButton.cs +++ b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/UninstallPublishingServiceButton.cs @@ -20,7 +20,7 @@ public bool IsEnabled(Window mainWindow, Instance instance) public bool IsVisible(Window mainWindow, Instance instance) { - return true; + return instance != null && instance.Roles.Contains((Instance.InstanceRole.PublishingService)); } public void OnClick(Window mainWindow, Instance instance) diff --git a/src/SIM.Tool.Windows/MainWindowData.cs b/src/SIM.Tool.Windows/MainWindowData.cs index b38af52e..d22b500d 100644 --- a/src/SIM.Tool.Windows/MainWindowData.cs +++ b/src/SIM.Tool.Windows/MainWindowData.cs @@ -925,24 +925,15 @@ private static GroupDefinition GetManageGroupDefinition() }, new ButtonDefinition { - Label = "Publishing Service", + Label = "Install Publishing Service", Image = "/Images/$lg/install.png, SIM.Tool.Windows", Handler = new InstallSPSButton(), - Buttons = new[] - { - new ButtonDefinition - { - Label = "Install", - Image = "/Images/$lg/install.png, SIM.Tool.Windows", - Handler = new InstallSPSButton(), - }, - new ButtonDefinition - { - Label = "Uninstall", - Image = "/Images/$lg/uninstall.png, SIM.Tool.Windows", - Handler = new UninstallSPSButton(), - } - } + }, + new ButtonDefinition + { + Label = "Uninstall Publishing Service", + Image = "/Images/$lg/uninstall.png, SIM.Tool.Windows", + Handler = new UninstallSPSButton(), }, } }; diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs index 5ba0a6b3..d116b5eb 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs @@ -23,18 +23,16 @@ public void InitializeStep(WizardArgs wizardArgs) UninstallSPSWizardArgs args = (UninstallSPSWizardArgs)wizardArgs; this.InstanceFolder = args.SPSInstanceFolder; - if (string.IsNullOrEmpty(SiteNameTextBox.Text)) - { - SiteNameTextBox.Text = "sitecore.publishing"; - } - if (string.IsNullOrEmpty(AppPoolTextBox.Text)) - { - AppPoolTextBox.Text = "sitecore.publishing"; - } - if (string.IsNullOrEmpty(WebrootTextBox.Text)) + + + using (ServerManager sm = new ServerManager()) { - WebrootTextBox.Text = Path.Combine(InstanceFolder, "sitecore.publishing"); + Site spsSite = sm.Sites.FirstOrDefault(s => s.Name.Equals(args.InstanceName)); + SiteNameTextBox.Text = spsSite?.Name ?? args.InstanceName; + AppPoolTextBox.Text = spsSite?.Applications.FirstOrDefault()?.ApplicationPoolName ?? args.InstanceName; + WebrootTextBox.Text = args.Instance.WebRootPath; } + return; } diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index b4cc99e8..bc711ddd 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -468,7 +468,7 @@ A response with a status of 0 means your publishing service is running without a - From 1b80d856e32bc72de9c262d8eaed4211f389888f Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sun, 7 Mar 2021 13:59:17 -0500 Subject: [PATCH 31/51] Fixed some potential nullreferenceexceptions, and cleaned up unused usings --- .../InstallPublishingService/Commands.cs | 8 +------- .../CreateIISiteProcessor.cs | 9 +-------- .../InstallSPSProcessorArgs.cs | 5 ----- .../RemoveExistingSPSProcessor.cs | 13 +------------ .../ResetDatabaseSchemaProcessor.cs | 7 +------ .../InstallPublishingService/SPSProcessor.cs | 5 ----- .../SetActualConnectionStringsProcessor.cs | 6 +----- .../SetAdminConnectionStringsProcessor.cs | 6 +----- .../UnzipSPSPackageProcessor.cs | 12 +----------- .../UpgradeDatabaseSchemaProcessor.cs | 7 +------ .../VerifyInstallationProcessor.cs | 9 +-------- .../UninstallSPSProcessorArgs.cs | 7 ------- .../Buttons/InstallPublishingServiceButton.cs | 19 ++++++------------- .../UninstallPublishingServiceButton.cs | 17 ++++++++--------- .../SelectServiceToUninstall.xaml.cs | 15 +++++++++++---- 15 files changed, 34 insertions(+), 111 deletions(-) diff --git a/src/SIM.Pipelines/InstallPublishingService/Commands.cs b/src/SIM.Pipelines/InstallPublishingService/Commands.cs index 78df4e8f..d0f0253b 100644 --- a/src/SIM.Pipelines/InstallPublishingService/Commands.cs +++ b/src/SIM.Pipelines/InstallPublishingService/Commands.cs @@ -1,10 +1,4 @@ -using MongoDB.Driver.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Management.Automation; -using System.Text; -using System.Threading.Tasks; +using System.Management.Automation; namespace SIM.Pipelines.InstallPublishingService { diff --git a/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs index 5ae7dcbd..a4522ee6 100644 --- a/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/CreateIISiteProcessor.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SIM.Pipelines.InstallPublishingService +namespace SIM.Pipelines.InstallPublishingService { public class CreateIISiteProcessor : SPSProcessor { diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs index 3540bf20..b3b9275a 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs +++ b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs @@ -1,11 +1,6 @@ using SIM.Pipelines.Processors; -using System; using System.Collections.Generic; using System.Data.SqlClient; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SIM.Pipelines.InstallPublishingService { diff --git a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs index 3c896749..b2073938 100644 --- a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs @@ -1,15 +1,4 @@ -using JetBrains.Annotations; -using Microsoft.Web.Administration; -using SIM.Adapters.WebServer; -using SIM.Pipelines.UninstallPublishingService; -using Sitecore.Diagnostics.Logging; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; +using SIM.Pipelines.UninstallPublishingService; namespace SIM.Pipelines.InstallPublishingService { diff --git a/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs index 3473ae75..849490b0 100644 --- a/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; namespace SIM.Pipelines.InstallPublishingService { diff --git a/src/SIM.Pipelines/InstallPublishingService/SPSProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SPSProcessor.cs index cdc45077..ad2c806b 100644 --- a/src/SIM.Pipelines/InstallPublishingService/SPSProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SPSProcessor.cs @@ -2,11 +2,6 @@ using SIM.Pipelines.Processors; using Sitecore.Diagnostics.Logging; using System; -using System.Collections.Generic; -using System.Deployment.Internal; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SIM.Pipelines.InstallPublishingService { diff --git a/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs index 69c09d7d..a1b25a23 100644 --- a/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SetActualConnectionStringsProcessor.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Data.SqlClient; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SIM.Pipelines.InstallPublishingService { diff --git a/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs index 0b6c4dea..0910333c 100644 --- a/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Data.SqlClient; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SIM.Pipelines.InstallPublishingService { diff --git a/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs index 6d623ab2..a83ad6ed 100644 --- a/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs @@ -1,14 +1,4 @@ -using JetBrains.Annotations; -using SIM.Pipelines.Processors; -using Sitecore.Diagnostics.Logging; -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; +using System.IO.Compression; namespace SIM.Pipelines.InstallPublishingService { diff --git a/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs index b286bbc7..7be32896 100644 --- a/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; namespace SIM.Pipelines.InstallPublishingService { diff --git a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs index 489cb7c2..c9c0bfcb 100644 --- a/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/VerifyInstallationProcessor.cs @@ -1,14 +1,7 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using SIM.Pipelines.Processors; +using Newtonsoft.Json.Linq; using Sitecore.Diagnostics.Logging; -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Net; -using System.Text; -using System.Threading.Tasks; namespace SIM.Pipelines.InstallPublishingService { diff --git a/src/SIM.Pipelines/UninstallPublishingService/UninstallSPSProcessorArgs.cs b/src/SIM.Pipelines/UninstallPublishingService/UninstallSPSProcessorArgs.cs index ca3e4587..02662a95 100644 --- a/src/SIM.Pipelines/UninstallPublishingService/UninstallSPSProcessorArgs.cs +++ b/src/SIM.Pipelines/UninstallPublishingService/UninstallSPSProcessorArgs.cs @@ -1,11 +1,4 @@ using SIM.Pipelines.Processors; -using System; -using System.Collections.Generic; -using System.Data.SqlClient; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SIM.Pipelines.UninstallPublishingService { diff --git a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs index 8e4aede4..4d4c6628 100644 --- a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs +++ b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs @@ -1,18 +1,11 @@ -using System; -using System.Collections.Generic; -using Microsoft.VisualBasic.Logging; -using SIM.Tool.Base; - +using System.Windows; +using SIM.Instances; +using SIM.Tool.Base.Plugins; +using JetBrains.Annotations; +using SIM.Tool.Base.Pipelines; +using SIM.Tool.Base.Wizards; namespace SIM.Tool.Windows.MainWindowComponents.Buttons { - using System.Windows; - using SIM.Core.Common; - using SIM.Instances; - using SIM.Tool.Base.Plugins; - using JetBrains.Annotations; - using SIM.Tool.Base.Pipelines; - using SIM.Tool.Base.Wizards; - [UsedImplicitly] public class InstallSPSButton : IMainWindowButton { diff --git a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/UninstallPublishingServiceButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/UninstallPublishingServiceButton.cs index 01134ac3..9789dfc4 100644 --- a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/UninstallPublishingServiceButton.cs +++ b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/UninstallPublishingServiceButton.cs @@ -1,13 +1,12 @@ -namespace SIM.Tool.Windows.MainWindowComponents.Buttons -{ - using System.Windows; - using SIM.Core.Common; - using SIM.Instances; - using SIM.Tool.Base.Plugins; - using JetBrains.Annotations; - using SIM.Tool.Base.Pipelines; - using SIM.Tool.Base.Wizards; +using System.Windows; +using SIM.Instances; +using SIM.Tool.Base.Plugins; +using JetBrains.Annotations; +using SIM.Tool.Base.Pipelines; +using SIM.Tool.Base.Wizards; +namespace SIM.Tool.Windows.MainWindowComponents.Buttons +{ [UsedImplicitly] public class UninstallSPSButton : IMainWindowButton { diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs index d116b5eb..89a6c9dc 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs @@ -61,8 +61,15 @@ public bool OnMovingNext(WizardArgs wizardArgs) if (site == null && !args.SkipSPSSite) { - WindowHelper.ShowMessage($"The site {SiteNameTextBox.Text} was not found in IIS"); - return false; + if (!args.SkipSPSSite) + { + WindowHelper.ShowMessage($"The site {SiteNameTextBox.Text} was not found in IIS"); + return false; + } + else + { + + } } if (appPool == null && !args.SkipSPSAppPool) @@ -77,8 +84,8 @@ public bool OnMovingNext(WizardArgs wizardArgs) return false; } - args.SPSSiteName = site.Name; - args.SPSAppPoolName = appPool.Name; + args.SPSSiteName = site?.Name ?? ""; + args.SPSAppPoolName = appPool?.Name ?? ""; args.SPSWebroot = webroot; return true; } From 3310e937497a7d8887f408305c52245103a40991 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sun, 7 Mar 2021 17:01:02 -0500 Subject: [PATCH 32/51] Removed code that was intended only for debugging --- .../PublishingService/SelectServiceToUninstall.xaml.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs index 89a6c9dc..a9f4aeab 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectServiceToUninstall.xaml.cs @@ -61,15 +61,8 @@ public bool OnMovingNext(WizardArgs wizardArgs) if (site == null && !args.SkipSPSSite) { - if (!args.SkipSPSSite) - { WindowHelper.ShowMessage($"The site {SiteNameTextBox.Text} was not found in IIS"); return false; - } - else - { - - } } if (appPool == null && !args.SkipSPSAppPool) From 311b4666d226d13d78b1971afee043141632f472 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sun, 7 Mar 2021 17:22:10 -0500 Subject: [PATCH 33/51] Removed install/uninstall buttons from context menu --- src/SIM.Tool.Windows/MainWindowData.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/SIM.Tool.Windows/MainWindowData.cs b/src/SIM.Tool.Windows/MainWindowData.cs index d22b500d..a0b2965c 100644 --- a/src/SIM.Tool.Windows/MainWindowData.cs +++ b/src/SIM.Tool.Windows/MainWindowData.cs @@ -1170,9 +1170,6 @@ private static GroupDefinition GetManageGroupDefinition() new ButtonDefinition { Label = "Reinstall instance", Image = "/Images/$sm/redo.png, SIM.Tool.Windows", Handler = new ReinstallInstanceButton() }, new ButtonDefinition { Handler = new DeleteInstanceButton() }, new ButtonDefinition { Label = "Delete", Image = "/Images/$sm/uninstall.png, SIM.Tool.Windows", Handler = new DeleteInstanceButton() }, - new ButtonDefinition(), - new ButtonDefinition { Label = "Install Publishing Service", Image = "/Images/$sm/install.png, SIM.Tool.Windows", Handler = new InstallSPSButton() }, - new ButtonDefinition { Label = "Uninstall Publishing Service", Image = "/Images/$sm/uninstall.png, SIM.Tool.Windows", Handler = new UninstallSPSButton() }, }; public static TabDefinition[] Tabs { get; } = { From bef901234dbdd9a7b098bcf9f0c8cdc8ead44939 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sun, 7 Mar 2021 17:39:21 -0500 Subject: [PATCH 34/51] Made install/uninstall wizard arg titles shorter --- src/SIM.Tool.Windows/WizardPipelinesConfig.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs index bc711ddd..e12c77ff 100644 --- a/src/SIM.Tool.Windows/WizardPipelinesConfig.cs +++ b/src/SIM.Tool.Windows/WizardPipelinesConfig.cs @@ -450,7 +450,7 @@ By clicking 'Next' you accept the License Agreement."" /> - Control Panel > ADMINISTRATION > Install a package @@ -465,7 +465,7 @@ A response with a status of 0 means your publishing service is running without a type=""SIM.Tool.Windows.UserControls.Install.PublishingService.ConfigureParameters, SIM.Tool.Windows"" /> - Date: Sun, 7 Mar 2021 17:50:14 -0500 Subject: [PATCH 35/51] Initial sps name generated from cm instance name --- .../Install/PublishingService/ConfigureParameters.xaml.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs index 5c22c1cf..1ddbd850 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs @@ -24,7 +24,7 @@ public void InitializeStep(WizardArgs wizardArgs) InstallSPSWizardArgs args = (InstallSPSWizardArgs)wizardArgs; InitConnectrionStringsListBox(args); - InitSiteName(); + InitSiteName(args.InstanceName); InitPort(); } @@ -107,11 +107,11 @@ private void InitConnectrionStringsListBox(InstallSPSWizardArgs args) } } - private void InitSiteName() + private void InitSiteName(string instanceName) { if (string.IsNullOrEmpty(SiteNameTextBox.Text.Trim())) { - SiteNameTextBox.Text = "sitecore.publishing"; + SiteNameTextBox.Text = $"{instanceName}.publishing"; } } From e2721e59266a75c015aad9a3e2c2dad5c4853c6a Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sun, 7 Mar 2021 17:53:07 -0500 Subject: [PATCH 36/51] Removed empty region --- .../Buttons/InstallPublishingServiceButton.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs index 4d4c6628..be44d10e 100644 --- a/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs +++ b/src/SIM.Tool.Windows/MainWindowComponents/Buttons/InstallPublishingServiceButton.cs @@ -32,12 +32,5 @@ public void OnClick(Window mainWindow, Instance instance) #endregion - #region Private Methods - - - - #endregion - - } } \ No newline at end of file From 6b69cbd2d9c2e4423bfa3f09e69e0997774d834e Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 20 Mar 2021 12:08:06 -0400 Subject: [PATCH 37/51] Added special case for SPS 312 package name, wrapped IsCompatible body in try-catch with meaningful message and error on exception --- .../SelectPublishingServicePackage.xaml | 8 +-- .../SelectPublishingServicePackage.xaml.cs | 56 ++++++++++++++----- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml index b3c768b5..84fc640d 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml @@ -20,18 +20,18 @@ - You can + Get - get publishing service packages here. + publishing service packages - Then place them into + and put them in SIM's local repository to populate the dropdown. - Please check the compatibility tables to ensure your selected version is compatible with your instance: + Sitecore publishing service compatibility tables: Sitecore Publishing Service – compatibility tables (for SPS prior to 4.1.0) diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs index 5e0a00b1..46b6e945 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs @@ -9,7 +9,9 @@ using System.Text.RegularExpressions; using System.Windows.Controls; using System.Windows.Navigation; +using Microsoft.VisualBasic.Logging; using SIM.Tool.Base; +using Log = Sitecore.Diagnostics.Logging.Log; namespace SIM.Tool.Windows.UserControls.Install.PublishingService { @@ -94,23 +96,49 @@ private void Initialize() private bool IsCompatible(string spsPackageName, int cmsVersionInt) { - Regex versionPattern = new Regex("\\d+\\.\\d+\\.\\d+"); - int spsPackageVersionInt = int.Parse(versionPattern.Match(spsPackageName).Value.Replace(".", "")); - - //sps version 410 and above - if (spsPackageVersionInt >= 410) + try { - /* - * If cmsVersionInt is negative, it means there was an error getting the version, and we should not restrict options. - * This can happen if a new version of Sitecore is released and SIM cannot parse its version number yet. - * Since we are assuming this is a new version of Sitecore, it is still safe to allow compatibility for SPS version 4.1.0 and above - */ - return cmsVersionInt >= 910 || cmsVersionInt < 0; + int spsPackageVersionInt = -1; + + //Check for special cases in naming convention + if (spsPackageName.StartsWith("Sitecore Publishing Service 312")) + { + spsPackageVersionInt = 312; + } + else + { + Regex versionPattern = new Regex("\\d+\\.\\d+\\.\\d+"); + spsPackageVersionInt = int.Parse(versionPattern.Match(spsPackageName).Value.Replace(".", "")); + } + + //sps version 410 and above + if (spsPackageVersionInt >= 410) + { + /* + * If cmsVersionInt is negative, it means there was an error getting the version, and we should not restrict options. + * This can happen if a new version of Sitecore is released and SIM cannot parse its version number yet. + * Since we are assuming this is a new version of Sitecore, it is still safe to allow compatibility for SPS version 4.1.0 and above + */ + return cmsVersionInt >= 910 || cmsVersionInt < 0; + } + + //sps version 400 and below + return (from pair in LegacySPSCompatibilityTable + where spsPackageVersionInt == pair.Key //Get the array of compatible cms versions for the given sps version + select pair.Value.Any(i => i == cmsVersionInt)) + .FirstOrDefault(); //Check if the selected instance's version is in this array } + catch (Exception ex) + { + string message = $"Something went wrong while trying to resolve compatible SPS versions.\nThe package '{spsPackageName}' may not be valid.\n" + + $"As a result all options are shown. Consult the compatibility tables to ensure your SPS and Sitecore version are compatible."; - //sps version 400 and below - return (from pair in LegacySPSCompatibilityTable where spsPackageVersionInt == pair.Key //Get the array of compatible cms versions for the given sps version - select pair.Value.Any(i => i == cmsVersionInt)).FirstOrDefault(); //Check if the selected instance's version is in this array + WindowHelper.ShowMessage(message); + Log.Error($"{message}\n{ex}"); + + return true; //If we can't determine compatibility, let's not restrict anything + } + } private static Dictionary LegacySPSCompatibilityTable From ba829ca6def37e205c4445d8bc8711159d151cb4 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 20 Mar 2021 12:44:46 -0400 Subject: [PATCH 38/51] Filtered connectionstring selection options and fixed typo --- .../InstallPublishingService/Commands.cs | 4 ++-- .../Pipelines/InstallSPSWizardArgs.cs | 4 +++- .../ConfigureParameters.xaml.cs | 23 +++++++++++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/SIM.Pipelines/InstallPublishingService/Commands.cs b/src/SIM.Pipelines/InstallPublishingService/Commands.cs index d0f0253b..b9ec5232 100644 --- a/src/SIM.Pipelines/InstallPublishingService/Commands.cs +++ b/src/SIM.Pipelines/InstallPublishingService/Commands.cs @@ -9,9 +9,9 @@ public static class Commands private const string SCHEMA_RESET = "schema reset --force"; private const string IIS_INSTALL = "iis install --sitename \"{0}\" --apppool \"{1}\" --port \"{2}\" --hosts --force"; - public static void SetConnectionString(string connectionStringName, string connectrionStringValue) + public static void SetConnectionString(string connectionStringName, string connectionStringValue) { - ExecuteCommand(SET_CONNECTION_STRING, connectionStringName, connectrionStringValue); + ExecuteCommand(SET_CONNECTION_STRING, connectionStringName, connectionStringValue); } public static void SchemaUpgrade() diff --git a/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs index a0b665b0..b9a629ea 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs @@ -1,4 +1,6 @@ -namespace SIM.Tool.Base.Pipelines +using System.Linq; + +namespace SIM.Tool.Base.Pipelines { using System.Collections.Generic; using System.Data.SqlClient; diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs index 1ddbd850..b9b7b834 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs @@ -1,4 +1,5 @@ -using SIM.Adapters.WebServer; +using System.Collections.Generic; +using SIM.Adapters.WebServer; using SIM.Tool.Base; using SIM.Tool.Base.Pipelines; using SIM.Tool.Base.Wizards; @@ -92,7 +93,7 @@ private void InitConnectrionStringsListBox(InstallSPSWizardArgs args) { if (ConnectionStringsListBox.Items.Count < 1) { - foreach (var connString in args.InstanceConnectionStrings) + foreach (var connString in GetSPSConnectionStringCandidates(args.InstanceConnectionStrings)) { switch (connString.Name.ToLower().Trim()) { @@ -123,6 +124,24 @@ private void InitPort() } } + private IEnumerable GetSPSConnectionStringCandidates(ConnectionStringCollection connectionStrings) + { + return connectionStrings.Where(cs => cs.IsSqlConnectionString && IsAllowedConnectionStringName(cs.Name)); + } + + private bool IsAllowedConnectionStringName(string name) + { + string[] disallowedPrefixes = new string[] { "xdb.", "exm.", "security", "messaging", "reporting", "experienceforms" }; + foreach (string prefix in disallowedPrefixes) + { + if (name.StartsWith(prefix)) + { + return false; + } + } + + return true; + } #endregion } } From 5b3310a7bda91b905a57f7d38bfefb94bdb6db50 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 20 Mar 2021 14:13:16 -0400 Subject: [PATCH 39/51] Removed overwrite functionality --- .../InstallSPSProcessorArgs.cs | 1 - .../RemoveExistingSPSProcessor.cs | 29 ------------------- src/SIM.Pipelines/SIM.Pipelines.csproj | 1 - .../RemoveAppPoolProcessor.cs | 2 +- .../Pipelines/InstallSPSWizardArgs.cs | 12 ++++---- .../ConfigureParameters.xaml | 10 ++----- .../ConfigureParameters.xaml.cs | 27 +++++++++++++---- 7 files changed, 30 insertions(+), 52 deletions(-) delete mode 100644 src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs diff --git a/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs index b3b9275a..cab77df7 100644 --- a/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs +++ b/src/SIM.Pipelines/InstallPublishingService/InstallSPSProcessorArgs.cs @@ -19,7 +19,6 @@ public class InstallSPSProcessorArgs : ProcessorArgs public string SPSWebroot { get; set; } public int SPSPort { get; set; } public Dictionary SPSConnectionStrings { get; set; } - public bool OverwriteExisting { get; set; } #endregion } diff --git a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs deleted file mode 100644 index b2073938..00000000 --- a/src/SIM.Pipelines/InstallPublishingService/RemoveExistingSPSProcessor.cs +++ /dev/null @@ -1,29 +0,0 @@ -using SIM.Pipelines.UninstallPublishingService; - -namespace SIM.Pipelines.InstallPublishingService -{ - public class RemoveExistingSPSProcessor : SPSProcessor - { - protected override void ProcessCore(InstallSPSProcessorArgs args) - { - if (!args.OverwriteExisting) - { - return; - } - - UninstallSPSProcessorArgs uninstallArgs = new UninstallSPSProcessorArgs() - { - SPSSiteName = args.SPSSiteName, - SPSAppPoolName = args.SPSAppPoolName, - SPSWebroot = args.SPSWebroot, - SkipSPSSite = false, - SkipSPSAppPool = false, - SkipSPSWebroot = false - }; - - new RemoveIISSiteProcessor().DoProcess(uninstallArgs); - new RemoveAppPoolProcessor().DoProcess(uninstallArgs); - new RemoveWebrootFolderProcessor().DoProcess(uninstallArgs); - } - } -} diff --git a/src/SIM.Pipelines/SIM.Pipelines.csproj b/src/SIM.Pipelines/SIM.Pipelines.csproj index f399618b..513593b9 100644 --- a/src/SIM.Pipelines/SIM.Pipelines.csproj +++ b/src/SIM.Pipelines/SIM.Pipelines.csproj @@ -112,7 +112,6 @@ - diff --git a/src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs b/src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs index e4e0e777..fa537bc9 100644 --- a/src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs +++ b/src/SIM.Pipelines/UninstallPublishingService/RemoveAppPoolProcessor.cs @@ -18,7 +18,7 @@ protected override void ProcessCore([NotNull] UninstallSPSProcessorArgs args) using (ServerManager sm = new ServerManager()) { - ApplicationPool spsAppPool = sm.ApplicationPools.FirstOrDefault(s => s.Name.Equals(args.SPSAppPoolName)); + ApplicationPool spsAppPool = sm.ApplicationPools.FirstOrDefault(a => a.Name.Equals(args.SPSAppPoolName)); if (!DeleteAppPool(sm, spsAppPool, args.MaxRetries, args.RetryInterval)) { diff --git a/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs index b9a629ea..5c604fb4 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs @@ -38,13 +38,12 @@ public InstallSPSWizardArgs(Instance instance) //From User Input - public bool OverwriteExisting { get; set; } public string SPSPackage { get { return Path.GetFileNameWithoutExtension(_spsPackagePath); } set { _spsPackagePath = value; } } - public string SPSSiteName { get; set; } + public string SPSName { get; set; } public int SPSPort { get; set; } public Dictionary SPSConnectionStrings { get; set; } = new Dictionary(); @@ -69,17 +68,16 @@ public override ProcessorArgs ToProcessorArgs() return new InstallSPSProcessorArgs() { InstanceName = this.InstanceName, - SPSSiteName = this.SPSSiteName, - SPSAppPoolName = this.SPSSiteName, - SPSWebroot = Path.Combine(this.SPSInstanceFolder, this.SPSSiteName), + SPSSiteName = this.SPSName, + SPSAppPoolName = this.SPSName, + SPSWebroot = Path.Combine(this.SPSInstanceFolder, this.SPSName), SPSPort = this.SPSPort, InstanceFolder = this.InstanceFolder, SPSInstanceFolder = this.SPSInstanceFolder, SPSPackagePath = this._spsPackagePath, SqlAdminUsername = this.SqlAdminUsername, SqlAdminPassword = this.SqlAdminPassword, - SPSConnectionStrings = this.SPSConnectionStrings, - OverwriteExisting = this.OverwriteExisting + SPSConnectionStrings = this.SPSConnectionStrings }; } diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml index 6aa84b67..4c27b993 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml @@ -15,20 +15,16 @@ - + - - - diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs index b9b7b834..3c5c0904 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using System.Windows.Controls; +using Microsoft.Web.Administration; namespace SIM.Tool.Windows.UserControls.Install.PublishingService { @@ -54,15 +55,29 @@ public bool SaveChanges(WizardArgs wizardArgs) #region Private methods private void ValidateAndSetSiteName(InstallSPSWizardArgs args, ref bool isValid) { - args.SPSSiteName = SiteNameTextBox.Text.Trim(); - args.OverwriteExisting = OverwriteIfExistsCheckBox.IsChecked ?? false; + args.SPSName = SiteNameTextBox.Text.Trim(); - string newWebroot = Path.Combine(args.SPSInstanceFolder, args.SPSSiteName); - if (Directory.Exists(newWebroot) && !args.OverwriteExisting) + string newWebroot = Path.Combine(args.SPSInstanceFolder, args.SPSName); + if (Directory.Exists(newWebroot)) { - WindowHelper.ShowMessage($"{newWebroot} already exists, please delete the existing instance, choose a different name, or select the" + - $"\"Overwrite\" checkbox to replace the existing solution"); + WindowHelper.ShowMessage($"The webroot path '{newWebroot}' already exists. Stop the instance using this path and uninstall it, or choose a different name"); isValid = false; + return; + } + + using (ServerManager sm = new ServerManager()) + { + if (sm.Sites.FirstOrDefault(s => s.Name.Equals(args.SPSName)) != null) + { + WindowHelper.ShowMessage($"The site '{args.SPSName}' already exists. Stop the instance using this site and uninstall it, or choose a different name"); + isValid = false; + } + + else if (sm.ApplicationPools.FirstOrDefault(a => a.Name.Equals(args.SPSName)) != null) + { + WindowHelper.ShowMessage($"The application pool '{args.SPSName}' already exists. Stop the instance using this application pool and uninstall it, or choose a different name"); + isValid = false; + } } } From 491247da76b861f56d19f98716b05aba4e44fd34 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 20 Mar 2021 14:19:15 -0400 Subject: [PATCH 40/51] Removed overwrite functionality (last commit, committed too early, now complete). --- src/SIM.Pipelines/PipelinesConfig.cs | 2 -- .../Install/PublishingService/ConfigureParameters.xaml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/SIM.Pipelines/PipelinesConfig.cs b/src/SIM.Pipelines/PipelinesConfig.cs index 5e538214..2831b316 100644 --- a/src/SIM.Pipelines/PipelinesConfig.cs +++ b/src/SIM.Pipelines/PipelinesConfig.cs @@ -267,8 +267,6 @@ public static class PipelinesConfig - - + From e99315598a57f6ab5aeefc1f1206fcea8faef4ef Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 20 Mar 2021 15:11:44 -0400 Subject: [PATCH 41/51] Updated instance roles logic --- src/SIM.Base/XmlDocumentEx.cs | 6 +++ src/SIM.Instances/Instance.cs | 75 +++++++++++++++++++++++------------ 2 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/SIM.Base/XmlDocumentEx.cs b/src/SIM.Base/XmlDocumentEx.cs index 6bbb3627..d66bbb65 100644 --- a/src/SIM.Base/XmlDocumentEx.cs +++ b/src/SIM.Base/XmlDocumentEx.cs @@ -212,6 +212,12 @@ public void SetElementValue(string xpath, string value) element.InnerText = value; } + public bool ElementAttributeContains(string xpath, string attributeName, string substring) + { + string value = this.GetElementAttributeValue(xpath, attributeName).ToLower(); + return !string.IsNullOrEmpty(value) && value.Contains(substring.ToLower()); + } + #endregion #region Private methods diff --git a/src/SIM.Instances/Instance.cs b/src/SIM.Instances/Instance.cs index 298b6b6c..265634fc 100644 --- a/src/SIM.Instances/Instance.cs +++ b/src/SIM.Instances/Instance.cs @@ -29,6 +29,8 @@ public class Instance : Website, IXmlSerializable private Product _Product; + private ICollection _instanceRoles; + #endregion #region Constructors @@ -501,66 +503,86 @@ public ICollection Roles { get { - ICollection InstanceRoles = new List(); + if (_instanceRoles != null) + { + return _instanceRoles; + } - //Find role by name - string instanceName = this.Name.ToLower(); - if (instanceName.Contains("identityserver")) + _instanceRoles = new List(); + + //Check if sitecore identity server + if (this.GetWebConfig().ElementAttributeContains("/configuration/system.webServer/aspNetCore", "arguments", "sitecore.identityServer.host")) { - InstanceRoles.Add(InstanceRole.IdentityServer); - return InstanceRoles; + _instanceRoles.Add(InstanceRole.IdentityServer); + return _instanceRoles; } - if (instanceName.Contains("xconnect")) + + //Check if xconnect + string instanceName = this.Name.ToLower(); + if (instanceName.Contains(".xconnect")) { - InstanceRoles.Add(InstanceRole.XConnect); - return InstanceRoles; + _instanceRoles.Add(InstanceRole.XConnect); + return _instanceRoles; } //Check if sitecore publishing service - string spsRole = this.GetWebConfig().GetElementAttributeValue("/configuration/system.webServer/aspNetCore", "processPath").ToLower(); - if (!spsRole.IsNullOrEmpty() && spsRole.Contains("sitecore.framework.publishing.host")) + if (this.GetWebConfig().ElementAttributeContains("/configuration/system.webServer/aspNetCore", "processPath", "sitecore.framework.publishing.host")) { - InstanceRoles.Add(InstanceRole.PublishingService); - return InstanceRoles; + _instanceRoles.Add(InstanceRole.PublishingService); + return _instanceRoles; } //Find role by 'role:define' key in web.config string roleDefine = this.GetWebConfig().GetElementAttributeValue("/configuration/appSettings/add[@key='role:define']", "value").ToLower(); if (string.IsNullOrEmpty(roleDefine)) { - InstanceRoles.Add((InstanceRole.Unknown)); //If 'role:define' is not present, this is likely a pre-version 9 solution, and we don't know the role - return InstanceRoles; + _instanceRoles.Add((InstanceRole.Unknown)); //If 'role:define' is not present, this is likely a pre-version 9 solution, and we don't know the role + return _instanceRoles; } - //Add any many roles that apply + //Add any and all roles that apply + foreach (InstanceRole role in Enum.GetValues(typeof(InstanceRole)).Cast()) + { + if (roleDefine.Contains(role.ToString().ToLower())) + { + _instanceRoles.Add(role); + } + } + + /* if (roleDefine.Contains("standalone")) { - InstanceRoles.Add(InstanceRole.Standalone); + _instanceRoles.Add(InstanceRole.Standalone); } if (roleDefine.Contains("contentmanagement")) { - InstanceRoles.Add(InstanceRole.ContentManagement); + _instanceRoles.Add(InstanceRole.ContentManagement); } if (roleDefine.Contains("contentdelivery")) { - InstanceRoles.Add(InstanceRole.ContentDelivery); + _instanceRoles.Add(InstanceRole.ContentDelivery); } if (roleDefine.Contains("reporting")) { - InstanceRoles.Add(InstanceRole.Reporting); + _instanceRoles.Add(InstanceRole.Reporting); } if (roleDefine.Contains("processing")) { - InstanceRoles.Add(InstanceRole.Processing); + _instanceRoles.Add(InstanceRole.Processing); } if (roleDefine.Contains("indexing")) { - InstanceRoles.Add(InstanceRole.Indexing); + _instanceRoles.Add(InstanceRole.Indexing); } - - return InstanceRoles; + if (roleDefine.Contains("dedicateddispatch")) + { + _instanceRoles.Add(InstanceRole.DedicatedDispatch); + } + */ + return _instanceRoles; } } + public bool IsContentManagementInstance => this.Roles.Contains(InstanceRole.Standalone) || this.Roles.Contains(InstanceRole.ContentManagement) || this.Roles.Contains(InstanceRole.Unknown); @@ -582,10 +604,11 @@ public enum InstanceRole Reporting, Processing, Indexing, + DedicatedDispatch, XConnect, IdentityServer, - Unknown, - PublishingService + PublishingService, + Unknown } #endregion From a33dbed837070c17cc4900ab30d1cbaf99e29742 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 20 Mar 2021 16:42:58 -0400 Subject: [PATCH 42/51] Changed auto generated SPS name --- .../Pipelines/InstallSPSWizardArgs.cs | 2 ++ .../ConfigureParameters.xaml.cs | 8 ++++--- .../SelectPublishingServicePackage.xaml.cs | 24 +++++++++++++++---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs b/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs index 5c604fb4..0a2f1b0b 100644 --- a/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs +++ b/src/SIM.Tool.Base/Pipelines/InstallSPSWizardArgs.cs @@ -43,6 +43,8 @@ public string SPSPackage get { return Path.GetFileNameWithoutExtension(_spsPackagePath); } set { _spsPackagePath = value; } } + + public int SPSVersionInt { get; set; } public string SPSName { get; set; } public int SPSPort { get; set; } public Dictionary SPSConnectionStrings { get; set; } = new Dictionary(); diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs index 3c5c0904..c5899495 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/ConfigureParameters.xaml.cs @@ -26,7 +26,7 @@ public void InitializeStep(WizardArgs wizardArgs) InstallSPSWizardArgs args = (InstallSPSWizardArgs)wizardArgs; InitConnectrionStringsListBox(args); - InitSiteName(args.InstanceName); + InitSiteName(args.InstanceName, args.SPSVersionInt); InitPort(); } @@ -123,11 +123,13 @@ private void InitConnectrionStringsListBox(InstallSPSWizardArgs args) } } - private void InitSiteName(string instanceName) + private void InitSiteName(string instanceName, int spsVersion) { if (string.IsNullOrEmpty(SiteNameTextBox.Text.Trim())) { - SiteNameTextBox.Text = $"{instanceName}.publishing"; + string prefix = instanceName.Contains(".") ? instanceName.Substring(0, instanceName.IndexOf(".")) : instanceName; + string version = spsVersion > 0 ? spsVersion.ToString() : ""; + SiteNameTextBox.Text = $"{prefix}.sps{version}"; } } diff --git a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs index 46b6e945..8ef88a45 100644 --- a/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs +++ b/src/SIM.Tool.Windows/UserControls/Install/PublishingService/SelectPublishingServicePackage.xaml.cs @@ -68,6 +68,8 @@ public bool OnMovingNext(WizardArgs wizardArgs) return false; } + args.SPSVersionInt = GetSPSVersionInt(args.SPSPackage); + return true; } @@ -94,11 +96,12 @@ private void Initialize() return; } - private bool IsCompatible(string spsPackageName, int cmsVersionInt) + private int GetSPSVersionInt(string spsPackageName) { + int spsPackageVersionInt = -1; + try { - int spsPackageVersionInt = -1; //Check for special cases in naming convention if (spsPackageName.StartsWith("Sitecore Publishing Service 312")) @@ -110,6 +113,20 @@ private bool IsCompatible(string spsPackageName, int cmsVersionInt) Regex versionPattern = new Regex("\\d+\\.\\d+\\.\\d+"); spsPackageVersionInt = int.Parse(versionPattern.Match(spsPackageName).Value.Replace(".", "")); } + } + catch (Exception ex) + { + Log.Error(ex, $"The version of the package '{spsPackageName}' could not be resolved"); + } + + return spsPackageVersionInt; + } + + private bool IsCompatible(string spsPackageName, int cmsVersionInt) + { + try + { + int spsPackageVersionInt = GetSPSVersionInt(spsPackageName); //sps version 410 and above if (spsPackageVersionInt >= 410) @@ -130,8 +147,7 @@ select pair.Value.Any(i => i == cmsVersionInt)) } catch (Exception ex) { - string message = $"Something went wrong while trying to resolve compatible SPS versions.\nThe package '{spsPackageName}' may not be valid.\n" + - $"As a result all options are shown. Consult the compatibility tables to ensure your SPS and Sitecore version are compatible."; + string message = "Something went wrong while trying to resolve compatible SPS versions.\nAs a result all options are shown. Consult the compatibility tables to ensure your SPS and Sitecore version are compatible."; WindowHelper.ShowMessage(message); Log.Error($"{message}\n{ex}"); From e446ee062593dc2ada5350b8f8d30e2511156dc6 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 20 Mar 2021 17:13:29 -0400 Subject: [PATCH 43/51] updated abstract SPSProcessor class --- .../InstallPublishingService/SPSProcessor.cs | 32 ++----------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/src/SIM.Pipelines/InstallPublishingService/SPSProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SPSProcessor.cs index ad2c806b..3f25969d 100644 --- a/src/SIM.Pipelines/InstallPublishingService/SPSProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SPSProcessor.cs @@ -1,43 +1,15 @@ using JetBrains.Annotations; using SIM.Pipelines.Processors; -using Sitecore.Diagnostics.Logging; -using System; namespace SIM.Pipelines.InstallPublishingService { public abstract class SPSProcessor : Processor where T : ProcessorArgs { - protected static bool AbortPipeline = false; - protected override void Process([NotNull] ProcessorArgs args) - { - T processorArgs = args as T; - - if (AbortPipeline) - { - Log.Warn($"The {this.GetType().Name} processor was skipped."); - this.Skip(); - return; - } - - try - { - this.ProcessCore(processorArgs); - } - catch (Exception ex) - { - AbortPipeline = true; - Log.Error($"Publishing Service Pipeline was aborted. The remaining steps were skipped."); - throw ex; - } + { + this.ProcessCore((T)args); } protected abstract void ProcessCore([NotNull] T args); - - //Kind of a hack so I can resure some of the uninstall sps processors in the RemoveExistingSPSProcessor class - internal void DoProcess([NotNull] T args) - { - this.Process(args); - } } } From 15e38575f0037af9c730161222a696e234a43899 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 20 Mar 2021 17:44:30 -0400 Subject: [PATCH 44/51] Changed directory in the powershell context instead of changing the application's directory --- src/SIM.Pipelines/InstallPublishingService/Commands.cs | 3 +++ ...pSPSPackageProcessor.cs => PrepareInstallationProcessor.cs} | 3 ++- .../InstallPublishingService/ResetDatabaseSchemaProcessor.cs | 1 - .../SetActualConnectionStringsProcessor.cs | 1 - .../SetAdminConnectionStringsProcessor.cs | 1 - .../InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs | 1 - src/SIM.Pipelines/PipelinesConfig.cs | 2 +- src/SIM.Pipelines/SIM.Pipelines.csproj | 2 +- 8 files changed, 7 insertions(+), 7 deletions(-) rename src/SIM.Pipelines/InstallPublishingService/{UnzipSPSPackageProcessor.cs => PrepareInstallationProcessor.cs} (65%) diff --git a/src/SIM.Pipelines/InstallPublishingService/Commands.cs b/src/SIM.Pipelines/InstallPublishingService/Commands.cs index b9ec5232..092433ec 100644 --- a/src/SIM.Pipelines/InstallPublishingService/Commands.cs +++ b/src/SIM.Pipelines/InstallPublishingService/Commands.cs @@ -9,6 +9,8 @@ public static class Commands private const string SCHEMA_RESET = "schema reset --force"; private const string IIS_INSTALL = "iis install --sitename \"{0}\" --apppool \"{1}\" --port \"{2}\" --hosts --force"; + public static string CommandRoot { get; set; } + public static void SetConnectionString(string connectionStringName, string connectionStringValue) { ExecuteCommand(SET_CONNECTION_STRING, connectionStringName, connectionStringValue); @@ -33,6 +35,7 @@ private static void ExecuteCommand(string commandArgs, params object[] args) { using (PowerShell PS = PowerShell.Create()) { + PS.AddScript($"Set-Location {CommandRoot}").Invoke(); PS.AddScript(string.Format(".\\Sitecore.Framework.Publishing.Host.exe " + commandArgs, args)).Invoke(); } } diff --git a/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/PrepareInstallationProcessor.cs similarity index 65% rename from src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs rename to src/SIM.Pipelines/InstallPublishingService/PrepareInstallationProcessor.cs index a83ad6ed..fb257c30 100644 --- a/src/SIM.Pipelines/InstallPublishingService/UnzipSPSPackageProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/PrepareInstallationProcessor.cs @@ -2,11 +2,12 @@ namespace SIM.Pipelines.InstallPublishingService { - public class UnzipSPSPackageProcessor : SPSProcessor + public class PrepareInstallationProcessor : SPSProcessor { protected override void ProcessCore(InstallSPSProcessorArgs args) { ZipFile.ExtractToDirectory(args.SPSPackagePath, args.SPSWebroot); + Commands.CommandRoot = args.SPSWebroot; } } } diff --git a/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs index 849490b0..2ce7c239 100644 --- a/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/ResetDatabaseSchemaProcessor.cs @@ -7,7 +7,6 @@ public class ResetDatabaseSchemaProcessor : SPSProcessor connString in args.SPSConnectionStrings) { Commands.SetConnectionString(connString.Key, connString.Value.ToString()); diff --git a/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs index 0910333c..f8caeebd 100644 --- a/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/SetAdminConnectionStringsProcessor.cs @@ -9,7 +9,6 @@ public class SetAdminConnectionStringsProcessor : SPSProcessor connString in args.SPSConnectionStrings) { string AdminConnString = new SqlConnectionStringBuilder(connString.Value.ToString()) diff --git a/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs index 7be32896..8a2e5a78 100644 --- a/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs +++ b/src/SIM.Pipelines/InstallPublishingService/UpgradeDatabaseSchemaProcessor.cs @@ -6,7 +6,6 @@ public class UpgradeDatabaseSchemaProcessor : SPSProcessor - diff --git a/src/SIM.Pipelines/SIM.Pipelines.csproj b/src/SIM.Pipelines/SIM.Pipelines.csproj index 513593b9..a989ddbd 100644 --- a/src/SIM.Pipelines/SIM.Pipelines.csproj +++ b/src/SIM.Pipelines/SIM.Pipelines.csproj @@ -114,7 +114,7 @@ - + From 4cdb9f12bc799c4ca38ea9474609b566712f5d01 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sat, 20 Mar 2021 17:55:07 -0400 Subject: [PATCH 45/51] added try-catch around instance role resolving logic --- src/SIM.Instances/Instance.cs | 99 ++++++++++++++--------------------- 1 file changed, 40 insertions(+), 59 deletions(-) diff --git a/src/SIM.Instances/Instance.cs b/src/SIM.Instances/Instance.cs index 265634fc..b34daf87 100644 --- a/src/SIM.Instances/Instance.cs +++ b/src/SIM.Instances/Instance.cs @@ -510,75 +510,56 @@ public ICollection Roles _instanceRoles = new List(); - //Check if sitecore identity server - if (this.GetWebConfig().ElementAttributeContains("/configuration/system.webServer/aspNetCore", "arguments", "sitecore.identityServer.host")) - { - _instanceRoles.Add(InstanceRole.IdentityServer); - return _instanceRoles; - } - - //Check if xconnect - string instanceName = this.Name.ToLower(); - if (instanceName.Contains(".xconnect")) + try { - _instanceRoles.Add(InstanceRole.XConnect); - return _instanceRoles; - } + //Check if sitecore identity server + if (this.GetWebConfig().ElementAttributeContains("/configuration/system.webServer/aspNetCore", "arguments", + "sitecore.identityServer.host")) + { + _instanceRoles.Add(InstanceRole.IdentityServer); + return _instanceRoles; + } - //Check if sitecore publishing service - if (this.GetWebConfig().ElementAttributeContains("/configuration/system.webServer/aspNetCore", "processPath", "sitecore.framework.publishing.host")) - { - _instanceRoles.Add(InstanceRole.PublishingService); - return _instanceRoles; - } + //Check if xconnect + string instanceName = this.Name.ToLower(); + if (instanceName.Contains(".xconnect")) + { + _instanceRoles.Add(InstanceRole.XConnect); + return _instanceRoles; + } - //Find role by 'role:define' key in web.config - string roleDefine = this.GetWebConfig().GetElementAttributeValue("/configuration/appSettings/add[@key='role:define']", "value").ToLower(); - if (string.IsNullOrEmpty(roleDefine)) - { - _instanceRoles.Add((InstanceRole.Unknown)); //If 'role:define' is not present, this is likely a pre-version 9 solution, and we don't know the role - return _instanceRoles; - } + //Check if sitecore publishing service + if (this.GetWebConfig().ElementAttributeContains("/configuration/system.webServer/aspNetCore", "processPath", + "sitecore.framework.publishing.host")) + { + _instanceRoles.Add(InstanceRole.PublishingService); + return _instanceRoles; + } - //Add any and all roles that apply - foreach (InstanceRole role in Enum.GetValues(typeof(InstanceRole)).Cast()) - { - if (roleDefine.Contains(role.ToString().ToLower())) + //Find role by 'role:define' key in web.config + string roleDefine = this.GetWebConfig() + .GetElementAttributeValue("/configuration/appSettings/add[@key='role:define']", "value").ToLower(); + if (string.IsNullOrEmpty(roleDefine)) { - _instanceRoles.Add(role); + _instanceRoles.Add((InstanceRole + .Unknown)); //If 'role:define' is not present, this is likely a pre-version 9 solution, and we don't know the role + return _instanceRoles; } - } - /* - if (roleDefine.Contains("standalone")) - { - _instanceRoles.Add(InstanceRole.Standalone); - } - if (roleDefine.Contains("contentmanagement")) - { - _instanceRoles.Add(InstanceRole.ContentManagement); - } - if (roleDefine.Contains("contentdelivery")) - { - _instanceRoles.Add(InstanceRole.ContentDelivery); - } - if (roleDefine.Contains("reporting")) - { - _instanceRoles.Add(InstanceRole.Reporting); - } - if (roleDefine.Contains("processing")) - { - _instanceRoles.Add(InstanceRole.Processing); - } - if (roleDefine.Contains("indexing")) - { - _instanceRoles.Add(InstanceRole.Indexing); + //Add any and all roles that are found in the role:define key + foreach (InstanceRole role in Enum.GetValues(typeof(InstanceRole)).Cast()) + { + if (roleDefine.Contains(role.ToString().ToLower())) + { + _instanceRoles.Add(role); + } + } } - if (roleDefine.Contains("dedicateddispatch")) + catch (Exception ex) { - _instanceRoles.Add(InstanceRole.DedicatedDispatch); + _instanceRoles.Add(InstanceRole.Unknown); + Log.Error(ex, "Instance role could not be resolved and was set to 'Unknown'"); } - */ return _instanceRoles; } } From bf0f52ad7720bb2e1f248dce96880bbfe14a96c9 Mon Sep 17 00:00:00 2001 From: Tyler Jass Date: Sun, 28 Mar 2021 12:57:30 -0400 Subject: [PATCH 46/51] Moved old compatibility to globalsettings config file --- .../Configuration/Configuration.cs | 64 +++++++++++++++++++ src/SIM.Tool.Base/SIM.Tool.Base.csproj | 5 ++ src/SIM.Tool.Base/packages.config | 1 + .../SelectPublishingServicePackage.xaml.cs | 49 ++++---------- .../GlobalParamsConfig/GlobalSettings.json | 16 +++++ 5 files changed, 99 insertions(+), 36 deletions(-) create mode 100644 src/SIM.Tool.Base/Configuration/Configuration.cs diff --git a/src/SIM.Tool.Base/Configuration/Configuration.cs b/src/SIM.Tool.Base/Configuration/Configuration.cs new file mode 100644 index 00000000..5bcc48b2 --- /dev/null +++ b/src/SIM.Tool.Base/Configuration/Configuration.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; +using System.IO; +using Newtonsoft.Json.Linq; + +namespace SIM.Tool.Base.Configuration +{ + public class Configuration + { + private JObject settingsDoc; + #region Singleton + private static Configuration instance; + private Configuration() + { + string globalSettings = string.Empty; + using (StreamReader reader = + new StreamReader(Path.Combine(Directory.GetCurrentDirectory(), "GlobalParamsConfig/GlobalSettings.json"))) + { + globalSettings = reader.ReadToEnd(); + } + + this.settingsDoc = JObject.Parse(globalSettings); + + } + public static Configuration Instance + { + get + { + if (instance == null) + { + instance = new Configuration(); + } + + return instance; + } + } + #endregion + + public Dictionary SolrMap + { + get + { + return this.settingsDoc["SolrVersionsMap"].ToObject>(); + } + } + + public Dictionary GlobalFilesMap + { + get + { + return this.settingsDoc["GlobalFilesMap"].ToObject>(); + } + } + + public IEnumerable ExcludedUninstallParams + { + get + { + return settingsDoc["ExcludeUninstallParams"].Values(); + } + } + + public Dictionary LegacySPSCompatibilityTable => this.settingsDoc["LegacySPSCompatibilityTable"].ToObject>(); + } +} diff --git a/src/SIM.Tool.Base/SIM.Tool.Base.csproj b/src/SIM.Tool.Base/SIM.Tool.Base.csproj index dd502e19..e3fbd03a 100644 --- a/src/SIM.Tool.Base/SIM.Tool.Base.csproj +++ b/src/SIM.Tool.Base/SIM.Tool.Base.csproj @@ -47,6 +47,9 @@ False True + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + ..\packages\Sitecore.Diagnostics.Base.2.0.1.171\lib\Sitecore.Diagnostics.Base.dll @@ -75,6 +78,7 @@ + @@ -203,6 +207,7 @@ +