コード例 #1
0
        /// <summary>
        /// Service class constructor.
        /// </summary>
        /// <param name="PHPSwitchConfigClass">The PHPSwitchConfig class.</param>
        public Services(PHPSwitchConfig PHPSwitchConfigClass)
        {
            this.MPHPSwitchConfig = PHPSwitchConfigClass;
            this.ConsoleStyle     = new ConsoleStyle(this.MPHPSwitchConfig);

            this.GetServices();
        }
コード例 #2
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="PHPSwitchConfigClass">The PHPSwitchConfig class.</param>
 public FileCopier(PHPSwitchConfig PHPSwitchConfigClass)
 {
     this.MPHPSwitchConfig = PHPSwitchConfigClass;
     this.LibFS            = new FileSystem(this.MPHPSwitchConfig);
     this.WSApache         = new WebServers.Apache(this.MPHPSwitchConfig);
     this.ConsoleStyle     = new ConsoleStyle(this.MPHPSwitchConfig);
 }
コード例 #3
0
ファイル: App.cs プロジェクト: Rundiz/phpswitch
        /// <summary>
        /// Run the application.
        /// </summary>
        /// <param name="phpversion">The PHP version to switch to.</param>
        /// <param name="configJson">Path to phpswitch.json config file.</param>
        /// <param name="verbose">Verbose value will be true or false.</param>
        public void Run(string phpversion, FileInfo configJson, bool verbose)
        {
            if (Privilege.IsAdmin() == false)
            {
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    try
                    {
                        Privilege.RelaunchAsAdmin(phpversion, configJson, verbose);
                    }
                    catch (Exception ex)
                    {
                        ConsoleStyle.ErrorMessage(ex.Message);
                        Environment.Exit(5);
                    }
                }
                else
                {
                    ConsoleStyle.ErrorMessage("Administrator privileges are required!");
                    Environment.Exit(403);
                }
            }

            // display program header.
            ConsoleStyle.ProgramHeader();

            this.MPHPSwitchConfig            = new PHPSwitchConfig();
            this.MPHPSwitchConfig.PhpVersion = phpversion;
            this.MPHPSwitchConfig.Verbose    = verbose;

            this.ConsoleStyle = new ConsoleStyle(this.MPHPSwitchConfig);

            // start to kill php processes.
            var processTask = new ProcessTask();

            processTask.killPHP();

            FileCopier FileCopierClass = new FileCopier(this.MPHPSwitchConfig);

            // validate required folders and files.
            FileCopierClass.ValidateRequired(configJson);

            // services tasks (stop services). -----------------
            Services ServicesClass = new Services(this.MPHPSwitchConfig);

            if (ServicesClass.IsServiceExists())
            {
                this.MPHPSwitchConfig.RunServiceTask = true;
                ServicesClass.StopServices();
            }
            else
            {
                this.ConsoleStyle.WriteVerbose("--The services are not specify." + Environment.NewLine);
                this.MPHPSwitchConfig.RunServiceTask = false;
            }
            // end services tasks (stop services). -------------

            // remove php-running files and copy from selected version.
            FileCopierClass.StartCopyFiles();

            // services tasks (start services). ----------------
            if (this.MPHPSwitchConfig.RunServiceTask == true)
            {
                ServicesClass.StartServices();
            }
            // end services tasks (start services). ------------

            // success message and exit.
            ConsoleStyle.SuccessExit();
        }
コード例 #4
0
ファイル: AdditionalCopier.cs プロジェクト: Rundiz/phpswitch
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="PHPSwitchConfigClass">The PHPSwitchConfig class.</param>
 public AdditionalCopier(PHPSwitchConfig PHPSwitchConfigClass)
 {
     this.MPHPSwitchConfig = PHPSwitchConfigClass;
     this.LibFS            = new FileSystem(this.MPHPSwitchConfig);
     this.ConsoleStyle     = new ConsoleStyle(this.MPHPSwitchConfig);
 }
コード例 #5
0
 /// <summary>
 /// Console style class constructor.
 /// </summary>
 /// <param name="PHPSwitchConfigClass">The PHPSwitchConfig class.</param>
 public ConsoleStyle(PHPSwitchConfig PHPSwitchConfigClass)
 {
     this.MPHPSwitchConfig = PHPSwitchConfigClass;
 }
コード例 #6
0
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="PHPSwitchConfigClass">The PHPSwitchConfig class.</param>
 public Apache(PHPSwitchConfig PHPSwitchConfigClass)
 {
     this.MPHPSwitchConfig = PHPSwitchConfigClass;
     this.ConsoleStyle     = new ConsoleStyle(this.MPHPSwitchConfig);
     this.LibFS            = new FileSystem(this.MPHPSwitchConfig);
 }