Пример #1
0
        private static void UpdateConfigFile(Session session, UpdateDetectionVariables updateDetectionVariables, string appToken)
        {
            string configFileName = GetConfigFileName(session, updateDetectionVariables);
            // Connection string
            DatabaseSetupInfo databaseSetupInfo = DatabaseSetupInfo.CreateFromFeature(session, updateDetectionVariables.DatabaseFeatureName);

            CprBroker.Installers.Installation.SetConnectionStringInConfigFile(
                configFileName,
                updateDetectionVariables.ConnectionStringName,
                databaseSetupInfo.CreateConnectionString(false, true)
                );
            // Service url
            CprBroker.Installers.Installation.SetApplicationSettingInConfigFile(
                configFileName,
                "UpdateLib.Properties.Settings",
                "CPRBrokerPartServiceUrl",
                session.GetPropertyValue("PARTSERVICEURL")
                );
            // App token
            CprBroker.Installers.Installation.SetApplicationSettingInConfigFile(
                configFileName,
                "UpdateLib.Properties.Settings",
                "ApplicationToken",
                appToken
                );
        }
Пример #2
0
        private static Dictionary <string, WebInstallationOptions> GetWebInstallationOptions(Session session)
        {
            DatabaseSetupInfo           databaseSetupInfo = DatabaseSetupInfo.CreateFromFeature(session, "PM");
            Dictionary <string, string> connectionStrings = new Dictionary <string, string>();

            connectionStrings["CPRMapperDB"] = databaseSetupInfo.CreateConnectionString(false, true);

            WebInstallationOptions options = new WebInstallationOptions()
            {
                ConnectionStrings = connectionStrings,
                ConfigSectionGroupEncryptionOptions = new ConfigSectionGroupEncryptionOptions[0],
                EncryptConnectionStrings            = false,
                InitializeFlatFileLogging           = false,
                FrameworkVersion = new Version("4.0")
            };
            var allOptions = new Dictionary <string, WebInstallationOptions>();

            allOptions["PM"] = options;
            return(allOptions);
        }
Пример #3
0
        public static ActionResult RemoveDatabase(Session session, UpdateDetectionVariables updateDetectionVariables)
        {
            try
            {
                DatabaseSetupInfo databaseSetupInfo = DatabaseSetupInfo.CreateFromFeature(session, updateDetectionVariables.DatabaseFeatureName);
                DropDatabaseForm  dropDatabaseForm  = new DropDatabaseForm()
                {
                    SetupInfo    = databaseSetupInfo,
                    Text         = "Drop database objects",
                    QuestionText = "Should the database objects be removed?",
                    NoText       = "No, keep the database objects",
                    YesText      = "Yes, drop the database objects"
                };


                if (BaseForm.ShowAsDialog(dropDatabaseForm, session.InstallerWindowWrapper()) == DialogResult.Yes)
                {
                    var ddl = updateDetectionVariables.SubstituteDDL(Properties.Resources.drp_tbl);
                    if (updateDetectionVariables.TriggersEnabled)
                    {
                        ddl += updateDetectionVariables.SubstituteDDL(Properties.Resources.drp_trg);
                    }
                    if (!string.IsNullOrEmpty(updateDetectionVariables.ExtraDatabaseDropDDL))
                    {
                        ddl += updateDetectionVariables.ExtraDatabaseDropDDL;
                    }

                    DatabaseCustomAction.ExecuteDDL(ddl, databaseSetupInfo);
                    DatabaseCustomAction.DropDatabaseUser(databaseSetupInfo);
                }
                return(ActionResult.Success);
            }
            catch (Exception ex)
            {
                session.ShowErrorMessage(ex);
                throw ex;
            }
        }
Пример #4
0
        public static ActionResult DeployDatabase(Session session)
        {
            try
            {
                DatabaseSetupInfo databaseSetupInfo = DatabaseSetupInfo.CreateFromFeature(session, "PM");
                string            sql = Properties.Resources.crebas;
                sql = sql.Replace("<pm-cryptpassword>", databaseSetupInfo.EncryptionKey);
                sql = sql.Replace("<pm-namespace>", databaseSetupInfo.Domain);

                var sqlDictionary = new Dictionary <string, string>();
                sqlDictionary["PM"] = sql;

                var lookupDictinary = new Dictionary <string, KeyValuePair <string, string>[]>();
                lookupDictinary["PM"] = new KeyValuePair <string, string> [0];

                return(DatabaseCustomAction.DeployDatabase(session, sqlDictionary, lookupDictinary));
            }
            catch (Exception ex)
            {
                session.ShowErrorMessage(ex);
                throw ex;
            }
        }
Пример #5
0
 public static ActionResult RollbackDatabase(Session session, UpdateDetectionVariables updateDetectionVariables)
 {
     try
     {
         DatabaseSetupInfo databaseSetupInfo = DatabaseSetupInfo.CreateFromFeature(session, updateDetectionVariables.DatabaseFeatureName);
         var ddl = updateDetectionVariables.SubstituteDDL(Properties.Resources.drp_tbl);
         if (updateDetectionVariables.TriggersEnabled)
         {
             ddl += updateDetectionVariables.SubstituteDDL(Properties.Resources.drp_trg);
         }
         if (!string.IsNullOrEmpty(updateDetectionVariables.ExtraDatabaseDropDDL))
         {
             ddl += updateDetectionVariables.ExtraDatabaseDropDDL;
         }
         DatabaseCustomAction.ExecuteDDL(ddl, databaseSetupInfo);
         DatabaseCustomAction.DropDatabaseUser(databaseSetupInfo);
         return(ActionResult.Success);
     }
     catch (Exception ex)
     {
         session.ShowErrorMessage(ex);
         throw ex;
     }
 }
        public static ActionResult InstallBackendService(Session session)
        {
            try
            {
                Installation.SetConnectionStringInConfigFile(GetServiceExeConfigFullFileName(session), "CprBroker.Config.Properties.Settings.CprBrokerConnectionString", DatabaseSetupInfo.CreateFromFeature(session, "CPR").CreateConnectionString(false, true));
                Installation.SetConnectionStringInConfigFile(GetServiceExeConfigFullFileName(session), "CprBroker.Config.Properties.Settings.EventBrokerConnectionString", DatabaseSetupInfo.CreateFromFeature(session, "EVENT").CreateConnectionString(false, true));
                InstallService(GetServiceExeFullFileName(session), GetServiceExeFrameworkVersion());

                StartService(ServiceName);
                return(ActionResult.Success);
            }
            catch (Exception ex)
            {
                session.ShowErrorMessage(ex);
                throw ex;
            }
        }
Пример #7
0
        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;
            }
        }