diff --git a/XenAdmin/TabPages/ManageUpdatesPage.cs b/XenAdmin/TabPages/ManageUpdatesPage.cs index c84221b1e..daaf50f3e 100644 --- a/XenAdmin/TabPages/ManageUpdatesPage.cs +++ b/XenAdmin/TabPages/ManageUpdatesPage.cs @@ -271,23 +271,7 @@ namespace XenAdmin.TabPages updates.RemoveAll(FilterAlert); tableLayoutPanel3.Visible = false; - - 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()); - } + sortUpdates(updates); var rowList = new List(); @@ -948,7 +932,9 @@ namespace XenAdmin.TabPages if (exportAll) { - foreach (Alert a in Updates.UpdateAlerts) + var updates = new List(Updates.UpdateAlerts); + sortUpdates(updates); + foreach (Alert a in updates) stream.WriteLine(a.GetUpdateDetailsCSVQuotes()); } else @@ -985,6 +971,26 @@ namespace XenAdmin.TabPages } } } + + private void sortUpdates(List 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) {