public override void PageLoaded(PageLoadedDirection direction)
{
base.PageLoaded(direction);
try
{
label1.Text = IsInAutomaticMode ? Messages.PATCHINGWIZARD_SELECTSERVERPAGE_RUBRIC_AUTOMATED_MODE : Messages.PATCHINGWIZARD_SELECTSERVERPAGE_RUBRIC_DEFAULT;
// catch selected servers, in order to restore selection after the dataGrid is reloaded
List<Host> selectedServers = SelectedServers;
dataGridViewHosts.Rows.Clear();
if (IsInAutomaticMode)
{
//hides expand column
dataGridViewHosts.Columns[0].Visible = false;
}
else
{
dataGridViewHosts.Columns[0].Visible = true;
}
List<IXenConnection> xenConnections = ConnectionsManager.XenConnectionsCopy;
xenConnections.Sort();
foreach (IXenConnection xenConnection in xenConnections)
{
if (IsInAutomaticMode)
{
if (!xenConnection.IsConnected)
continue;
var pool = Helpers.GetPoolOfOne(xenConnection);
Host master = pool.Connection.Resolve(pool.master);
int index = -1;
if (Helpers.GetPool(xenConnection) != null) //pools
{
index = dataGridViewHosts.Rows.Add(new PatchingHostsDataGridViewRow(pool));
}
else //standalone hosts
{
index = dataGridViewHosts.Rows.Add(new PatchingHostsDataGridViewRow(master, false));
}
EnabledRow(master, SelectedUpdateType, index);
}
else
{
Pool pool = Helpers.GetPool(xenConnection);
bool hasPool = pool != null;
if (hasPool)
{
int index = dataGridViewHosts.Rows.Add(new PatchingHostsDataGridViewRow(pool));
Host master = pool.Connection.Resolve(pool.master);
EnabledRow(master, SelectedUpdateType, index);
}
Host[] hosts = xenConnection.Cache.Hosts;
Array.Sort(hosts);
foreach (Host host in hosts)
{
int index = dataGridViewHosts.Rows.Add(new PatchingHostsDataGridViewRow(host, hasPool));
EnabledRow(host, SelectedUpdateType, index);
}
}
}
// restore server selection
SelectServers(selectedServers);
}
catch (Exception e)
{
log.Error(e, e);
throw;//better throw an exception rather than closing the wizard suddenly and silently
}
}