Exemple #1
0
 private static void UnInstallService(Session session, UpdateDetectionVariables updateDetectionVariables)
 {
     CprBroker.Installers.Installation.RunCommand(
         string.Format("{0}installutil.exe", CprBroker.Installers.Installation.GetNetFrameworkDirectory(new Version(4, 0))),
         string.Format("/u \"{0}bin\\{1}\"", session.GetInstallDirProperty(), updateDetectionVariables.ServiceExeFileName)
         );
 }
 public static ActionResult RemoveUpdatesService(Session session, UpdateDetectionVariables updateDetectionVariables)
 {
     try
     {
         UnregisterApplicationInCprBroker(session);
     }
     catch (Exception ex)
     {
         session.ShowErrorMessage(ex);
     }
     try
     {
         StopService(session, updateDetectionVariables);
     }
     catch (Exception ex)
     {
         session.ShowErrorMessage(ex);
     }
     try
     {
         UnInstallService(session, updateDetectionVariables);
     }
     catch (Exception ex)
     {
         session.ShowErrorMessage(ex);
     }
     return(ActionResult.Success);
 }
        // -----------------------------------------------------------------------------
        public UpdatedStagingBatch(UpdateDetectionVariables updateDetectionVariables, IsStopRequestedFunc shouldIStop)
        {
            _UpdateDetectionVariables = updateDetectionVariables;
            _shouldIStop = shouldIStop;

            GetBatchFromDB();
        }
Exemple #4
0
 private static void UninstallServiceByName(Session session, UpdateDetectionVariables updateDetectionVariables)
 {
     if (CprBroker.Installers.Installation.ServiceExists(updateDetectionVariables.ServiceName, updateDetectionVariables.ServiceDisplayName))
     {
         UnInstallService(session, updateDetectionVariables);
     }
 }
Exemple #5
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
                );
        }
Exemple #6
0
 public UpdatesProjectInstaller(UpdateDetectionVariables updateDetectionVariables)
     : this()
 {
     serviceInstaller1.Description = updateDetectionVariables.ServiceDescription;
     serviceInstaller1.ServiceName = updateDetectionVariables.ServiceName;
     serviceInstaller1.DisplayName = updateDetectionVariables.ServiceDisplayName;
 }
Exemple #7
0
 private static void InstallAndStartService(Session session, UpdateDetectionVariables updateDetectionVariables)
 {
     CprBroker.Installers.Installation.RunCommand(
         string.Format("{0}installutil.exe", CprBroker.Installers.Installation.GetNetFrameworkDirectory(new Version(4, 0))),
         string.Format("/i \"{0}bin\\{1}\"", session.GetInstallDirProperty(), updateDetectionVariables.ServiceExeFileName)
         );
     new System.ServiceProcess.ServiceController(updateDetectionVariables.ServiceName).Start();
 }
Exemple #8
0
        private static void StopService(Session session, UpdateDetectionVariables updateDetectionVariables)
        {
            var controller = new System.ServiceProcess.ServiceController(updateDetectionVariables.ServiceName);

            if (controller.CanStop)
            {
                controller.Stop();
            }
        }
Exemple #9
0
        // -----------------------------------------------------------------------------
        public UpdatesNotificationService(UpdateDetectionVariables updateDetectionVariables)
        {
            AutoLog = true;

            ServiceName = updateDetectionVariables.ServiceName;
            run         = new Runner(updateDetectionVariables, HaltOperation);

            run.SetCPRBrokerServiceURL(Properties.Settings.Default.CPRBrokerPartServiceUrl);
            run.SetCPRBrokerAppToken(Properties.Settings.Default.ApplicationToken);
        }
 public static ActionResult RollbackUpdatesService(Session session, UpdateDetectionVariables updateDetectionVariables)
 {
     try
     {
         return(RemoveUpdatesService(session, updateDetectionVariables));
     }
     catch (Exception ex)
     {
         session.ShowErrorMessage(ex);
         throw ex;
     }
 }
 public static ActionResult InstallUpdatesService(Session session, UpdateDetectionVariables updateDetectionVariables)
 {
     try
     {
         string appToken = RegisterApplicationInCprBroker(session);
         UpdateConfigFile(session, updateDetectionVariables, appToken);
         UpdateRegistry(session, appToken);
         UninstallServiceByName(session, updateDetectionVariables);
         InstallAndStartService(session, updateDetectionVariables);
         return(ActionResult.Success);
     }
     catch (Exception ex)
     {
         session.ShowErrorMessage(ex);
         throw ex;
     }
 }
        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;
            }
        }
 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;
     }
 }
Exemple #14
0
 // -----------------------------------------------------------------------------
 public Runner(UpdateDetectionVariables updateDetectionVariables, HaltOperationDelegate haltOperationFunc)
 {
     _UpdateDetectionVariables = updateDetectionVariables;
     SetHaltOperation(haltOperationFunc);
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
 }
Exemple #15
0
 private static string GetConfigFileName(Session session, UpdateDetectionVariables updateDetectionVariables)
 {
     return(string.Format("{0}bin\\{1}.config", session.GetInstallDirProperty(), updateDetectionVariables.ServiceExeFileName));
 }