Merge pull request #1609 from letsboogey/REQ-411

CA-252871 - Updates order is not preserved on Exporting updates to a …
This commit is contained in:
Mihaela Stoica 2017-05-30 10:31:33 +01:00 committed by GitHub
commit b896aaabd3

View File

@ -271,23 +271,7 @@ namespace XenAdmin.TabPages
updates.RemoveAll(FilterAlert); updates.RemoveAll(FilterAlert);
tableLayoutPanel3.Visible = false; tableLayoutPanel3.Visible = false;
sortUpdates(updates);
if (dataGridViewUpdates.SortedColumn != null)
{
if (dataGridViewUpdates.SortedColumn.Index == ColumnMessage.Index)
updates.Sort(Alert.CompareOnTitle);
else if (dataGridViewUpdates.SortedColumn.Index == ColumnDate.Index)
updates.Sort(Alert.CompareOnDate);
else if (dataGridViewUpdates.SortedColumn.Index == ColumnLocation.Index)
updates.Sort(Alert.CompareOnAppliesTo);
if (dataGridViewUpdates.SortOrder == SortOrder.Descending)
updates.Reverse();
}
else
{
updates.Sort(new NewVersionPriorityAlertComparer());
}
var rowList = new List<DataGridViewRow>(); var rowList = new List<DataGridViewRow>();
@ -948,7 +932,9 @@ namespace XenAdmin.TabPages
if (exportAll) if (exportAll)
{ {
foreach (Alert a in Updates.UpdateAlerts) var updates = new List<Alert>(Updates.UpdateAlerts);
sortUpdates(updates);
foreach (Alert a in updates)
stream.WriteLine(a.GetUpdateDetailsCSVQuotes()); stream.WriteLine(a.GetUpdateDetailsCSVQuotes());
} }
else else
@ -986,6 +972,26 @@ namespace XenAdmin.TabPages
} }
} }
private void sortUpdates(List<Alert> updatesList)
{
if (dataGridViewUpdates.SortedColumn != null)
{
if (dataGridViewUpdates.SortedColumn.Index == ColumnMessage.Index)
updatesList.Sort(Alert.CompareOnTitle);
else if (dataGridViewUpdates.SortedColumn.Index == ColumnDate.Index)
updatesList.Sort(Alert.CompareOnDate);
else if (dataGridViewUpdates.SortedColumn.Index == ColumnLocation.Index)
updatesList.Sort(Alert.CompareOnAppliesTo);
if (dataGridViewUpdates.SortOrder == SortOrder.Descending)
updatesList.Reverse();
}
else
{
updatesList.Sort(new NewVersionPriorityAlertComparer());
}
}
private void checkForUpdatesNowButton_Click(object sender, EventArgs e) private void checkForUpdatesNowButton_Click(object sender, EventArgs e)
{ {
checkForUpdatesNowButton.Visible = false; checkForUpdatesNowButton.Visible = false;