private void LoadSubscriptionsDetails()
{
this.Invoke((MethodInvoker)delegate
{
// File is not more than 10kb.
using (WaitingDialog waitingDialog = new WaitingDialog("Please wait while we get subscription details"))
{
waitingDialog.ShowInTaskbar = false;
waitingDialog.StartPosition = FormStartPosition.CenterParent;
try
{
this.Enabled = false;
if (cbxSubscriptions.SelectedValue != null)
{
string selectedItem = cbxSubscriptions.SelectedValue.ToString();
// Some fix to overcome anonymous object
string subscriptionID = selectedItem.Split(' ').Count() > 1 ? selectedItem.Split(' ')[3].Trim(' ', ',') : selectedItem;
Dictionary<string, string> locations = null;
List<string> hostedServices = null;
List<string> storageNames = null;
do
{
waitingDialog.ShowDialog(this);
locations = CloudDeploymentTasks.ListLocationsForSubscription(subscriptionID, new X509Certificate2(Convert.FromBase64String(this.managementCertificateBase64)), "2011-10-01");
if (locations != null)
{
this.cbxLocations.DataSource = locations.ToList();
this.cbxLocations.DisplayMember = "value";
this.cbxLocations.ValueMember = "key";
}
hostedServices = CloudDeploymentTasks.ListHostedServicesForSubscription(subscriptionID, new X509Certificate2(Convert.FromBase64String(this.managementCertificateBase64)), "2011-10-01");
if (hostedServices != null)
{
this.cbxHostedNames.DataSource = hostedServices;
this.cbxHostedNames.SelectedIndex = -1;
}
storageNames = CloudDeploymentTasks.ListStorageAccountsForSubscription(subscriptionID, new X509Certificate2(Convert.FromBase64String(this.managementCertificateBase64)), "2011-10-01");
if (storageNames != null)
{
this.cbxStorageNames.DataSource = storageNames;
this.cbxStorageNames.SelectedIndex = -1;
}
}
while (locations == null && hostedServices == null && storageNames == null);
}
}
finally
{
this.Enabled = true;
}
}
});
}