/// <summary>
        /// Repairs the users default settings.
        /// </summary>
        private void ResetUserDefaultSettings()
        {
            var configuration = new UserConfiguration();

            FileHelpers.WriteFileJson(FileNames.UserData, configuration);
        }
        public void OnImport()
        {
            var accountData   = this.LoadAccountData();
            var configuration = this.LoadUserConfiguration();

            AzureDevOpsConfiguration.Config.Accounts      = accountData;
            AzureDevOpsConfiguration.Config.Configuration = configuration;

            if ((configuration.DefaultAccount != null) & (configuration.DefaultProject != null))
            {
                AzureDevOpsAccount  defaultAccount  = null;
                AzureDevOpsPatToken defaultPatToken = null;

                try
                {
                    defaultAccount  = accountData.Accounts.First(a => a.FriendlyName == configuration.DefaultAccount);
                    defaultPatToken = accountData.PatTokens.First(a => defaultAccount.LinkedPatTokens.Contains(a.Id));
                }
                catch (InvalidOperationException ioe) when(ioe.Message == "Sequence contains no matching element")
                {
                    this.ResetUserDefaultSettings();

                    var warningParams = new Dictionary <string, string>()
                    {
                        {
                            "Message",
                            "Corruption encountered well loading user default settings!  Settings have been reset to default (empty) values and will need to be configured again."
                        }
                    };

                    this.InvokePsCommand("Write-Warning", warningParams);
                }

                if (defaultAccount != null && defaultPatToken != null)
                {
                    AzureDevOpsConfiguration.Config.CurrentConnection = new CurrentConnection(defaultAccount, defaultPatToken, configuration.DefaultProject);

                    var outputParams = new Dictionary <string, string>()
                    {
                        {
                            "Message",
                            $"Default Account Settings Loaded Successfully.\r\nAccount Name: {configuration.DefaultAccount}\r\nProject Name: {configuration.DefaultProject}"
                        }
                    };
                    this.InvokePsCommand("Write-Host", outputParams);
                }
            }

            if (!AzureDevOpsConfiguration.Config.Accounts.HasCompleted1905Upgrade)
            {
                foreach (var token in AzureDevOpsConfiguration.Config.Accounts.PatTokens)
                {
                    ModuleStartup.ProcessCredentials(token);
                }

                AzureDevOpsConfiguration.Config.Accounts.HasCompleted1905Upgrade = true;
                FileHelpers.WriteFileJson(FileNames.AccountData, AzureDevOpsConfiguration.Config.Accounts);
            }

            var setVariableParams = new Dictionary <string, object>()
            {
                { "Name", "AzureDevOpsConfiguration" },
                { "Value", AzureDevOpsConfiguration.Config }
            };

            this.InvokePsCommand("Set-Variable", setVariableParams);
        }