コード例 #1
0
        public Task Run()
        {
            CheckForAdminAccess.ValidateCurrentUserIsProcessAdmin();

            ScaleUnitInstance scaleUnit = Config.FindScaleUnitWithId(ScaleUnitContext.GetScaleUnitId());

            string cmd = $@"
                if (Get-Service '{scaleUnit.BatchServiceName()}' -ErrorAction SilentlyContinue) {{
                    Stop-Service -Name {scaleUnit.BatchServiceName()};
                }}

                .$env:systemroot\System32\inetsrv\appcmd.exe stop apppool /apppool.name:{scaleUnit.AppPoolName()};
                .$env:systemroot\System32\inetsrv\appcmd.exe stop site /site.name:{scaleUnit.SiteName()}; 
            ";

            var ce = new CommandExecutor();

            try
            {
                ce.RunCommand(cmd);
            }
            catch (Exception)
            {
                if (!Config.UseSingleOneBox())
                {
                    throw;
                }
            }

            return(Task.CompletedTask);
        }
コード例 #2
0
        public void Run()
        {
            CheckForAdminAccess.ValidateCurrentUserIsProcessAdmin();

            ScaleUnitInstance scaleUnit = Config.FindScaleUnitWithId(ScaleUnitContext.GetScaleUnitId());

            string cmd = $@"
                Stop-Service -Name {scaleUnit.BatchServiceName()};
                .$env:systemroot\System32\inetsrv\appcmd.exe stop apppool /apppool.name:{scaleUnit.AppPoolName()};
                .$env:systemroot\System32\inetsrv\appcmd.exe stop site /site.name:{scaleUnit.SiteName()}; 
            ";

            CommandExecutor ce = new CommandExecutor();

            try
            {
                ce.RunCommand(cmd);
            }
            catch (Exception)
            {
                if (!Config.UseSingleOneBox())
                {
                    throw;
                }
            }
        }
コード例 #3
0
        public static async Task Main(string[] args)
        {
            CheckForAdminAccess.ValidateCurrentUserIsProcessAdmin();

            var enableScaleUnitFeatureOption = new CLIOption()
            {
                Name = "Initialize the hybrid topology", Command = EnableScaleUnitFeature.SelectScaleUnit
            };
            var configureEnvironmentOption = new CLIOption()
            {
                Name = "Prepare environments for workload installation", Command = ConfigureEnvironment.Show
            };
            var installWorkloadsOption = new CLIOption()
            {
                Name = "Install workloads", Command = InstallWorkloads.Show
            };
            var workloadsInstallationStatusOption = new CLIOption()
            {
                Name = "Show workloads installation status", Command = WorkloadsInstallationStatus.Show
            };

            var options = new List <CLIOption>()
            {
                enableScaleUnitFeatureOption, configureEnvironmentOption, installWorkloadsOption, workloadsInstallationStatusOption
            };

            var screen = new CLIScreen(options, "Home", "Please select the operation you want to perform:\n", "\nOperation to perform: ");
            await CLIMenu.ShowScreen(screen);
        }
コード例 #4
0
        public override void Run()
        {
            if (!CheckForAdminAccess.IsCurrentProcessAdmin())
            {
                throw new NotSupportedException("Please run the tool from a shell that is running as administrator.");
            }

            string cmd = "Start-Service -Name DynamicsAxBatch; iisreset /start";

            CommandExecutor ce = new CommandExecutor();

            ce.RunCommand(cmd);
        }
コード例 #5
0
        public void Run()
        {
            CheckForAdminAccess.ValidateCurrentUserIsProcessAdmin();

            ScaleUnitInstance scaleUnit = Config.FindScaleUnitWithId(ScaleUnitContext.GetScaleUnitId());

            string cmd = $@"
                 Start-Service -Name {scaleUnit.BatchServiceName()};
                 .$env:systemroot\System32\inetsrv\appcmd.exe start apppool /apppool.name:{scaleUnit.AppPoolName()};
                 .$env:systemroot\System32\inetsrv\appcmd.exe start site /site.name:{scaleUnit.SiteName()}; 
            ";

            CommandExecutor ce = new CommandExecutor();

            ce.RunCommand(cmd);
        }
コード例 #6
0
        private static void CreateScaleUnitBatchService(ScaleUnitInstance scaleUnit)
        {
            CheckForAdminAccess.ValidateCurrentUserIsProcessAdmin();

            string cmd = $@"
                if (Get-Service '{scaleUnit.BatchServiceName()}' -ErrorAction SilentlyContinue) {{
                    .$env:systemroot\system32\sc.exe delete {scaleUnit.BatchServiceName()};
                }}

                $secpasswd = (new-object System.Security.SecureString);
                $creds = New-Object System.Management.Automation.PSCredential ('NT AUTHORITY\NETWORK SERVICE', $secpasswd);
                New-Service -Name '{scaleUnit.BatchServiceName()}' -BinaryPathName '{scaleUnit.DynamicsBatchExePath()} -service {scaleUnit.WebConfigPath()}' -credential $creds -startupType Manual;
            ";

            CommandExecutor ce = new CommandExecutor();

            ce.RunCommand(cmd);
        }