Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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));
            }
        }