Пример #1
0
        /// <summary>
        /// Validates the user inputs
        /// </summary>
        private void Validate()
        {
            bool nameCheck = (!string.IsNullOrWhiteSpace(ServiceName) && !ServiceName.Any(Char.IsWhiteSpace) && ServiceName.Length > 3);
            Uri  serviceUri;
            bool addressCheck = Uri.TryCreate(ServiceAddress, UriKind.Absolute, out serviceUri);

            ButtonEnabled = nameCheck && addressCheck;
        }
Пример #2
0
        public override bool Execute()
        {
#if DEBUG
            Thread.Sleep(10000);
#endif
            if (!(AppServers == null || AppServers.Any()) && ((ServiceName != null && ServiceName.Any()) || (ComputerName != null && ComputerName.Any())))
            {
                throw new ArgumentException("You must specify either the AppServers parameter or both the ServiceName and ComputerName parameters");
            }

            if (AppServers != null && AppServers.Any())
            {
                var appServers       = MsBuild.DeserializeServers <AppServer>(AppServers);
                var computerServices =
                    appServers.Select(s => new { s.ServiceName, s.HostName })
                    .Distinct()
                    .GroupBy(s => s.HostName)
                    .ToDictionary(c => c.Key, c => c.Select(s => s.ServiceName).ToArray());
                var returnValue = 0;
                computerServices.AsParallel().ForAll(computerService =>
                {
                    returnValue += Run(computerService.Value, new [] { computerService.Key });
                });
                return(returnValue == 0);
            }

            return(Run(ServiceName, ComputerName) == 0);
        }