public static void Execute(
            ITaskContext environment,
            string machineName,
            string serviceName,
            ControlWindowsServiceMode mode,
            TimeSpan timeout,
            bool failIfNotExist)
        {
            ControlWindowsServiceTask task = new ControlWindowsServiceTask(machineName, serviceName, mode, timeout)
            {
                FailIfNotExist = failIfNotExist
            };

            task.Execute(environment);
        }
Exemple #2
0
        /// <summary>
        /// Method defining the actual work for a task.
        /// </summary>
        /// <param name="environment">The script execution environment.</param>
        protected override void DoExecute(IScriptExecutionEnvironment environment)
        {
            string configSettingName = String.Format(
                System.Globalization.CultureInfo.InvariantCulture,
                "ServicesExist/{0}",
                serviceName);

            CheckIfServiceExistsTask.Execute(environment, serviceName, configSettingName);
            if (bool.Parse(environment.GetConfigSetting(configSettingName)) == true)
            {
                ControlWindowsServiceTask.Execute(
                    environment,
                    serviceName,
                    ControlWindowsServiceMode.Stop,
                    TimeSpan.FromSeconds(30));
            }
        }
Exemple #3
0
        /// <summary>
        /// Method defining the actual work for a task.
        /// </summary>
        /// <param name="context">The script execution environment.</param>
        protected override void DoExecute(ITaskContext context)
        {
            string configSettingName = String.Format(
                System.Globalization.CultureInfo.InvariantCulture,
                "ServicesExist/{0}",
                serviceName);

            CheckIfServiceExistsTask.Execute(context, serviceName, configSettingName);
            if (context.Properties.Get <bool>(configSettingName))
            {
                ControlWindowsServiceTask.Execute(
                    context,
                    serviceName,
                    ControlWindowsServiceMode.Stop,
                    TimeSpan.FromSeconds(30));
            }
        }