Example #1
0
        private Interfaces.ICommandResult UpdateAccount(ServiceToUpdate serviceToUpdate)
        {
            string windowsServiceName = string.Empty;

            switch (serviceToUpdate)
            {
            case ServiceToUpdate.IntegrationService:
                windowsServiceName = Microsoft.TeamFoundation.Migration.Toolkit.Constants.TfsIntegrationServiceName;
                break;

            case ServiceToUpdate.JobService:
                windowsServiceName = Microsoft.TeamFoundation.Migration.Toolkit.Constants.TfsIntegrationJobServiceName;
                break;

            default:
                throw new InvalidOperationException();
            }

            switch (m_mode)
            {
            case Mode.Add:
                return(AddAccount(windowsServiceName));

            case Mode.Update:
                return(UpdatePassword(windowsServiceName));

            default:
                throw new InvalidOperationException();
            }
        }
Example #2
0
        private bool TryParseServiceSwitch(
            string arg,
            string serviceSwitch,
            out ServiceToUpdate serviceToUpdate)
        {
            serviceToUpdate = ServiceToUpdate.None;

            string serverOption;

            if (TryParseArg(arg, serviceSwitch, out serverOption) &&
                !string.IsNullOrEmpty(serverOption))
            {
                if (serverOption.Equals(ServiceToUpdate.JobService.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    serviceToUpdate = ServiceToUpdate.JobService;
                    return(true);
                }
                else if (serverOption.Equals(ServiceToUpdate.IntegrationService.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    serviceToUpdate = ServiceToUpdate.IntegrationService;
                    return(true);
                }
            }

            return(false);
        }
        void OnSelectedService(object obj)
        {
            ServiceToUpdate = obj as Service;

            Name          = ServiceToUpdate.Name;
            Description   = ServiceToUpdate.Description;
            LaborCost     = ServiceToUpdate.LaborCost.ToString();
            TaxPercentage = ServiceToUpdate.TaxPercentage.ToString();
            Materials     = ServiceToUpdate.Materials;

            _modifiedService = new Service();
            ServiceToUpdate.Update(_modifiedService);
        }
Example #4
0
        private bool TryParseAsUpdateServiceAccount(string[] cmdSpecificArgs)
        {
            bool serviceOptionFound = false;
            bool accountOptionFound = false;
            bool modeIsFound        = false;

            m_serviceToUpdate = ServiceToUpdate.IntegrationService; // default to update both services
            foreach (string arg in cmdSpecificArgs)
            {
                if (arg.StartsWith(ServiceSwitchL, StringComparison.OrdinalIgnoreCase))
                {
                    if (serviceOptionFound)
                    {
                        // same switch used twice
                        return(false);
                    }

                    if (!TryParseServiceSwitch(arg, ServiceSwitchL, out m_serviceToUpdate))
                    {
                        return(false);
                    }
                    else
                    {
                        serviceOptionFound = true;
                    }
                }
                else if (arg.StartsWith(ServiceSwitchS, StringComparison.OrdinalIgnoreCase))
                {
                    if (serviceOptionFound)
                    {
                        // same switch used twice
                        return(false);
                    }

                    if (!TryParseServiceSwitch(arg, ServiceSwitchS, out m_serviceToUpdate))
                    {
                        return(false);
                    }
                    else
                    {
                        serviceOptionFound = true;
                    }
                }
                else if (arg.StartsWith(AccountSwitchL, StringComparison.OrdinalIgnoreCase))
                {
                    if (accountOptionFound)
                    {
                        // same switch used twice
                        return(false);
                    }

                    if (!TryParseArg(arg, AccountSwitchL, out m_account))
                    {
                        return(false);
                    }
                    else
                    {
                        accountOptionFound = true;
                    }
                }
                else if (arg.StartsWith(AccountSwitchS, StringComparison.OrdinalIgnoreCase))
                {
                    if (accountOptionFound)
                    {
                        // same switch used twice
                        return(false);
                    }

                    if (!TryParseArg(arg, AccountSwitchS, out m_account))
                    {
                        return(false);
                    }
                    else
                    {
                        accountOptionFound = true;
                    }
                }
                else if (arg.StartsWith(UpdateSwitchL, StringComparison.OrdinalIgnoreCase) ||
                         arg.StartsWith(UpdateSwitchS, StringComparison.OrdinalIgnoreCase))
                {
                    if (modeIsFound)
                    {
                        // same switch used twice
                        return(false);
                    }
                    m_mode      = Mode.Update;
                    modeIsFound = true;
                }
                else if (arg.StartsWith(AddSwitchL, StringComparison.OrdinalIgnoreCase) ||
                         arg.StartsWith(AddSwitchS, StringComparison.OrdinalIgnoreCase))
                {
                    if (modeIsFound)
                    {
                        // same switch used twice
                        return(false);
                    }
                    m_mode      = Mode.Add;
                    modeIsFound = true;
                }
                else
                {
                    return(false);
                }
            }

            if (modeIsFound)
            {
                switch (m_mode)
                {
                case Mode.Add:
                    return(!string.IsNullOrEmpty(m_account));

                case Mode.Update:
                    return(true);

                default:
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }