Separate client updates from lcm server updates so they don't appear on the Notifications tab page.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
Konstantina Chremmou 2023-08-09 02:29:43 +01:00
parent 2ec91b53c6
commit 2af72aae25
3 changed files with 23 additions and 35 deletions

View File

@ -58,8 +58,11 @@ namespace XenAdmin.Core
public static string UserAgent { get; } = $"{BrandManager.BrandConsole}/{Program.Version} ({IntPtr.Size * 8}-bit)";
private static readonly object downloadedUpdatesLock = new object();
private static readonly object _cfuDownloadedLock = new object();
private static readonly object _clientXmlDownloadedLock = new object();
private static readonly object updateAlertsLock = new object();
private static readonly object _clientUpdateAlertsLock = new object();
private static readonly object _cdnUpdatesLock = new object();
private static List<XenServerVersion> XenServerVersionsForAutoCheck = new List<XenServerVersion>();
@ -68,6 +71,7 @@ namespace XenAdmin.Core
public static List<XenServerVersion> XenServerVersions = new List<XenServerVersion>();
private static readonly List<Alert> updateAlerts = new List<Alert>();
private static readonly List<ClientUpdateAlert> _clientUpdateAlerts = new List<ClientUpdateAlert>();
private static readonly Dictionary<IXenConnection, CdnPoolUpdateInfo> _cdnUpdateInfoPerConnection = new Dictionary<IXenConnection, CdnPoolUpdateInfo>();
/// <summary>
@ -82,6 +86,18 @@ namespace XenAdmin.Core
}
}
/// <summary>
/// Locks and creates a new list of the client update alerts
/// </summary>
public static List<ClientUpdateAlert> ClientUpdateAlerts
{
get
{
lock (_clientUpdateAlertsLock)
return _clientUpdateAlerts.ToList();
}
}
/// <summary>
/// Locks and creates a new dictionary of the CDN update info per connection
/// </summary>
@ -238,31 +254,23 @@ namespace XenAdmin.Core
if (succeeded)
{
lock (downloadedUpdatesLock)
lock (_clientXmlDownloadedLock)
{
ClientVersions = action.ClientVersions;
}
}
lock (updateAlertsLock)
lock (_clientUpdateAlertsLock)
{
updateAlerts.Clear();
_clientUpdateAlerts.Clear();
if (succeeded)
{
var clientUpdateAlerts = NewClientUpdateAlerts(ClientVersions, Program.Version);
updateAlerts.AddRange(clientUpdateAlerts.Where(a => !a.IsDismissed()));
_clientUpdateAlerts.AddRange(clientUpdateAlerts.Where(a => !a.IsDismissed()));
}
var xenServerUpdateAlerts = NewXenServerVersionAlerts(XenServerVersionsForAutoCheck);
updateAlerts.AddRange(xenServerUpdateAlerts.Where(a => !a.CanIgnore));
var xenServerPatchAlerts = NewXenServerPatchAlerts(XenServerVersions, XenServerPatches);
updateAlerts.AddRange(xenServerPatchAlerts.Where(a => !a.CanIgnore));
}
UpdateAlertCollectionChanged?.Invoke(new CollectionChangeEventArgs(CollectionChangeAction.Refresh, UpdateAlerts));
CheckForClientUpdatesCompleted?.Invoke();
}
@ -275,7 +283,7 @@ namespace XenAdmin.Core
if (succeeded)
{
lock (downloadedUpdatesLock)
lock (_cfuDownloadedLock)
{
XenServerVersionsForAutoCheck = action.XenServerVersionsForAutoCheck;
XenServerVersions = action.XenServerVersions;
@ -287,9 +295,6 @@ namespace XenAdmin.Core
{
updateAlerts.Clear();
var clientUpdateAlerts = NewClientUpdateAlerts(ClientVersions, Program.Version);
updateAlerts.AddRange(clientUpdateAlerts.Where(a => !a.IsDismissed()));
if (succeeded)
{
var xenServerUpdateAlerts = NewXenServerVersionAlerts(XenServerVersionsForAutoCheck);

View File

@ -2690,8 +2690,6 @@ namespace XenAdmin
statusButtonUpdates.Text = updatesCount.ToString();
statusButtonUpdates.Visible = updatesCount > 0;
SetClientUpdateAlert();
if (updatesPage.Visible)
{
TitleLabel.Text = NotificationsSubModeItem.GetText(NotificationsSubMode.Updates, updatesCount);
@ -2713,7 +2711,7 @@ namespace XenAdmin
private void SetClientUpdateAlert()
{
updateAlert = Updates.UpdateAlerts.FirstOrDefault(update => update is ClientUpdateAlert) as ClientUpdateAlert;
updateAlert = Updates.ClientUpdateAlerts.FirstOrDefault();
if (updateAlert != null)
relNotesToolStripMenuItem.Text = string.Format(Messages.MAINWINDOW_UPDATE_RELEASE, updateAlert.NewVersion.Version);
updateClientToolStripMenuItem.Visible = updateAlert != null;

View File

@ -676,13 +676,6 @@ namespace XenAdmin.TabPages
items.Add(downloadNewXenCenter);
}
if (alert is ClientUpdateAlert)
{
var download = new ToolStripMenuItem(Messages.UPDATES_DOWNLOAD_AND_INSTALL);
download.Click += ToolStripMenuItemDownloadInstall_Click;
items.Add(download);
}
if (alert.AllowedToDismiss())
{
var dismiss = new ToolStripMenuItem(Messages.ALERT_DISMISS);
@ -821,14 +814,6 @@ namespace XenAdmin.TabPages
}
}
private void ToolStripMenuItemDownloadInstall_Click(object sender, EventArgs e)
{
DataGridViewRow clickedRow = FindAlertRow(sender as ToolStripMenuItem);
if (clickedRow?.Tag is ClientUpdateAlert alert)
ClientUpdateAlert.DownloadAndInstallNewClient(alert, Parent);
}
private void ToolStripMenuItemDismiss_Click(object sender, EventArgs e)
{
if (dataGridViewUpdates.SelectedRows.Count != 1)