in src/PortingAssistantExtensionClientShared/Dialogs/AddProfileDialog.xaml.cs [43:97]
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
var errors = new Dictionary<string, string>();
var credentail = new AwsCredential(AccesskeyID.Text, secretAccessKey.Text);
try
{
this.TelemetryConfiguration = JsonConvert.DeserializeObject<PortingAssistantIDEConfiguration>(File.ReadAllText(ConfigurationPath)).TelemetryConfiguration;
errors = AwsUtils.ValidateProfile(ProfileName.Text, credentail);
if (errors.TryGetValue("profile", out string error1))
{
WarningProfileName.Content = error1;
}
else
{
WarningProfileName.Content = "";
}
if (errors.TryGetValue("accessKeyId", out string error2))
{
WarningAccessKeyID.Content = error2;
}
else
{
WarningAccessKeyID.Content = "";
}
if (errors.TryGetValue("secretKey", out string error3))
{
WarningSecretKey.Content = error3;
}
else
{
WarningSecretKey.Content = "";
}
if (errors.Count == 0)
{
WarningValidation.Content = "validating AWS profile, please wait";
var task = AwsUtils.ValidateProfile(ProfileName.Text, credentail, TelemetryConfiguration);
ThreadHelper.JoinableTaskFactory.Run(async delegate {
var result = await AwsUtils.ValidateProfile(ProfileName.Text, credentail, TelemetryConfiguration);
WarningValidation.Content = result;
});
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
if (errors.Count == 0 && WarningValidation.Content.Equals(""))
{
ClickResult = ProfileName.Text;
Close();
}
else return;
}