private static void PatchWebsite_2_1_1(Session session) { // This patch adds /PersonMasterService12 to the address of existing person master data providers for versions prior to 2.1.1 try { // Load connection string and encryption keys var webInstallationInfo = WebInstallationInfo.CreateFromFeature(session, "CPR"); var configFilePath = webInstallationInfo.GetWebConfigFilePath(EventBrokerCustomActions.PathConstants.CprBrokerWebsiteDirectoryRelativePath); var config = CprBroker.Installers.Installation.OpenConfigFile(configFilePath); DataProvider.EncryptionAlgorithm = DataProviderKeysSection.GetFromConfig(config); var connectionString = config.ConnectionStrings.ConnectionStrings["CprBroker.Config.Properties.Settings.CprBrokerConnectionString"].ConnectionString; using (var dataContext = new CprBroker.Data.DataProviders.DataProvidersDataContext(connectionString)) { var providers = dataContext.DataProviders.ToArray(); providers = providers .Where(dp => { var type = Type.GetType(dp.TypeName, false, true); return (type != null && string.Equals(type.Name, typeof(CprBroker.Providers.PersonMaster.PersonMasterDataProvider).Name)); } ).ToArray(); foreach (var prov in providers) { var adr = prov["Address"]; if (!string.IsNullOrEmpty(adr)) { if (!adr.EndsWith("/PersonMasterService12", StringComparison.InvariantCultureIgnoreCase)) { prov["Address"] += "/PersonMasterService12"; } } } dataContext.SubmitChanges(); } } finally { // Unload encryption keys DataProvider.EncryptionAlgorithm = null; } }
public static ActionResult CreateWebsite(Session session) { try { var allOptions = new Dictionary <string, WebInstallationOptions>(); Dictionary <string, string> connectionStrings = new Dictionary <string, string>(); connectionStrings["CprBroker.Config.Properties.Settings.CprBrokerConnectionString"] = DatabaseSetupInfo.CreateFromFeature(session, "CPR").CreateConnectionString(false, true); WebInstallationOptions cprOptions = new WebInstallationOptions() { EncryptConnectionStrings = true, ConnectionStrings = new Dictionary <string, string>(connectionStrings), InitializeFlatFileLogging = true, WebsiteDirectoryRelativePath = EventBrokerCustomActions.PathConstants.CprBrokerWebsiteDirectoryRelativePath, ConfigSectionGroupEncryptionOptions = new ConfigSectionGroupEncryptionOptions[] { new ConfigSectionGroupEncryptionOptions() { ConfigSectionGroupName = Constants.DataProvidersSectionGroupName, ConfigSectionEncryptionOptions = new ConfigSectionEncryptionOptions[] { new ConfigSectionEncryptionOptions() { SectionName = DataProviderKeysSection.SectionName, SectionType = typeof(DataProviderKeysSection), CustomMethod = config => DataProviderKeysSection.RegisterInConfig(config) }, new ConfigSectionEncryptionOptions() { SectionName = DataProvidersConfigurationSection.SectionName, SectionType = typeof(DataProvidersConfigurationSection), CustomMethod = null } } } } }; allOptions["CPR"] = cprOptions; connectionStrings["CprBroker.Config.Properties.Settings.EventBrokerConnectionString"] = DatabaseSetupInfo.CreateFromFeature(session, "EVENT").CreateConnectionString(false, true); WebInstallationOptions eventOptions = new WebInstallationOptions() { EncryptConnectionStrings = false, ConnectionStrings = connectionStrings, InitializeFlatFileLogging = true, WebsiteDirectoryRelativePath = EventBrokerCustomActions.PathConstants.EventBrokerWebsiteDirectoryRelativePath, ConfigSectionGroupEncryptionOptions = new ConfigSectionGroupEncryptionOptions[] { new ConfigSectionGroupEncryptionOptions() { ConfigSectionGroupName = Constants.DataProvidersSectionGroupName, ConfigSectionEncryptionOptions = new ConfigSectionEncryptionOptions[] { new ConfigSectionEncryptionOptions() { SectionName = DataProviderKeysSection.SectionName, SectionType = typeof(DataProviderKeysSection), CustomMethod = config => DataProviderKeysSection.RegisterInConfig(config) }, new ConfigSectionEncryptionOptions() { SectionName = DataProvidersConfigurationSection.SectionName, SectionType = typeof(DataProvidersConfigurationSection), CustomMethod = null } } } } }; allOptions["EVENT"] = eventOptions; return(WebsiteCustomAction.DeployWebsite(session, allOptions)); } catch (Exception ex) { session.ShowErrorMessage(ex); throw ex; } }