mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-12-05 01:21:07 +01:00
CP-6093: Remove update alerts from the Alerts page, part 1/3: some code simplification
and efficiency improvements. Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
361b49066c
commit
fcc627113d
@ -69,7 +69,7 @@ namespace XenAdmin.Alerts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Can we apply this alert. Calling this sets the CannotApplyReason where applicable
|
/// Can we apply this alert. Calling this sets the CannotApplyReason where applicable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool CanApply
|
public bool CanApply
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -40,9 +40,7 @@ namespace XenAdmin.Core
|
|||||||
{
|
{
|
||||||
class ManualCheckForUpdates
|
class ManualCheckForUpdates
|
||||||
{
|
{
|
||||||
private static List<XenCenterVersion> XenCenterVersions = new List<XenCenterVersion>();
|
private readonly List<Alert> updateAlerts = new List<Alert>();
|
||||||
private static List<XenServerVersion> XenServerVersions = new List<XenServerVersion>();
|
|
||||||
private static List<XenServerPatch> XenServerPatches = new List<XenServerPatch>();
|
|
||||||
|
|
||||||
public event Action<bool, string> CheckForUpdatesCompleted;
|
public event Action<bool, string> CheckForUpdatesCompleted;
|
||||||
|
|
||||||
@ -53,35 +51,7 @@ namespace XenAdmin.Core
|
|||||||
|
|
||||||
public List<Alert> UpdateAlerts
|
public List<Alert> UpdateAlerts
|
||||||
{
|
{
|
||||||
get
|
get { return updateAlerts; }
|
||||||
{
|
|
||||||
List<Alert> updateAlerts = new List<Alert>();
|
|
||||||
XenCenterUpdateAlert xenCenterAlert = Updates.NewXenCenterVersionAlert(XenCenterVersions, false);
|
|
||||||
if (xenCenterAlert != null)
|
|
||||||
{
|
|
||||||
updateAlerts.Add(xenCenterAlert);
|
|
||||||
}
|
|
||||||
|
|
||||||
XenServerUpdateAlert xenServerUpdateAlert = Updates.NewServerVersionAlert(XenServerVersions, false);
|
|
||||||
if (xenServerUpdateAlert != null)
|
|
||||||
{
|
|
||||||
updateAlerts.Add(xenServerUpdateAlert);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<XenServerPatchAlert> xenServerPatchAlerts = Updates.NewServerPatchesAlerts(XenServerVersions,
|
|
||||||
XenServerPatches,
|
|
||||||
false);
|
|
||||||
|
|
||||||
if (xenServerPatchAlerts != null)
|
|
||||||
{
|
|
||||||
foreach (var xenServerPatchAlert in xenServerPatchAlerts)
|
|
||||||
{
|
|
||||||
updateAlerts.Add(xenServerPatchAlert);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return updateAlerts;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void actionCompleted(ActionBase sender)
|
private void actionCompleted(ActionBase sender)
|
||||||
@ -95,18 +65,27 @@ namespace XenAdmin.Core
|
|||||||
if (action != null)
|
if (action != null)
|
||||||
{
|
{
|
||||||
succeeded = action.Succeeded;
|
succeeded = action.Succeeded;
|
||||||
|
updateAlerts.Clear();
|
||||||
|
|
||||||
if (succeeded)
|
if (succeeded)
|
||||||
{
|
{
|
||||||
XenCenterVersions = action.XenCenterVersions;
|
var xenCenterAlert = Updates.NewXenCenterVersionAlert(action.XenCenterVersions, false);
|
||||||
XenServerVersions = action.XenServerVersions;
|
if (xenCenterAlert != null)
|
||||||
XenServerPatches = action.XenServerPatches;
|
updateAlerts.Add(xenCenterAlert);
|
||||||
|
|
||||||
|
var xenServerUpdateAlert = Updates.NewServerVersionAlert(action.XenServerVersions, false);
|
||||||
|
if (xenServerUpdateAlert != null)
|
||||||
|
updateAlerts.Add(xenServerUpdateAlert);
|
||||||
|
|
||||||
|
var xenServerPatchAlerts = Updates.NewServerPatchesAlerts(action.XenServerVersions, action.XenServerPatches, false);
|
||||||
|
if (xenServerPatchAlerts != null)
|
||||||
|
{
|
||||||
|
foreach (var xenServerPatchAlert in xenServerPatchAlerts)
|
||||||
|
updateAlerts.Add(xenServerPatchAlert);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
XenCenterVersions.Clear();
|
|
||||||
XenServerVersions.Clear();
|
|
||||||
XenServerPatches.Clear();
|
|
||||||
|
|
||||||
if (action.Exception != null)
|
if (action.Exception != null)
|
||||||
{
|
{
|
||||||
if (action.Exception is System.Net.Sockets.SocketException)
|
if (action.Exception is System.Net.Sockets.SocketException)
|
||||||
|
@ -33,8 +33,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using XenAdmin.Actions;
|
using XenAdmin.Actions;
|
||||||
using System.Windows.Forms;
|
|
||||||
using XenAdmin.Dialogs;
|
|
||||||
using XenAPI;
|
using XenAPI;
|
||||||
using XenAdmin.Alerts;
|
using XenAdmin.Alerts;
|
||||||
using XenAdmin.Network;
|
using XenAdmin.Network;
|
||||||
@ -349,13 +347,5 @@ namespace XenAdmin.Core
|
|||||||
|
|
||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Equivalent to CheckForUpdates().
|
|
||||||
/// </summary>
|
|
||||||
internal static void Tick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
AutomaticCheckForUpdates();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -550,13 +550,18 @@ namespace XenAdmin
|
|||||||
|
|
||||||
// start checkforupdates thread
|
// start checkforupdates thread
|
||||||
CheckForUpdatesTimer.Interval = 1000 * 60 * 60 * 24; // 24 hours
|
CheckForUpdatesTimer.Interval = 1000 * 60 * 60 * 24; // 24 hours
|
||||||
CheckForUpdatesTimer.Tick += Updates.Tick;
|
CheckForUpdatesTimer.Tick += CheckForUpdatesTimer_Tick;
|
||||||
CheckForUpdatesTimer.Start();
|
CheckForUpdatesTimer.Start();
|
||||||
Updates.AutomaticCheckForUpdates();
|
Updates.AutomaticCheckForUpdates();
|
||||||
}
|
}
|
||||||
ProcessCommand(CommandLineArgType, CommandLineParam);
|
ProcessCommand(CommandLineArgType, CommandLineParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckForUpdatesTimer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Updates.AutomaticCheckForUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadTasksAsMeddlingActions(IXenConnection connection)
|
private void LoadTasksAsMeddlingActions(IXenConnection connection)
|
||||||
{
|
{
|
||||||
if (!connection.IsConnected || connection.Session == null)
|
if (!connection.IsConnected || connection.Session == null)
|
||||||
|
@ -48,11 +48,6 @@ namespace XenAdmin.Alerts
|
|||||||
|
|
||||||
public bool Dismissing;
|
public bool Dismissing;
|
||||||
|
|
||||||
public virtual bool CanApply
|
|
||||||
{
|
|
||||||
get { return true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string CannotApplyReason { get; set; }
|
public string CannotApplyReason { get; set; }
|
||||||
|
|
||||||
public static void AddAlert(Alert a)
|
public static void AddAlert(Alert a)
|
||||||
|
Loading…
Reference in New Issue
Block a user