diff --git a/XenAdmin/Alerts/Types/XenServerPatchAlert.cs b/XenAdmin/Alerts/Types/XenServerPatchAlert.cs index 05d9527c2..8324158dd 100644 --- a/XenAdmin/Alerts/Types/XenServerPatchAlert.cs +++ b/XenAdmin/Alerts/Types/XenServerPatchAlert.cs @@ -40,10 +40,8 @@ using XenAPI; namespace XenAdmin.Alerts { - public class XenServerPatchAlert : Alert + public class XenServerPatchAlert : XenServerUpdateAlert { - private readonly List connections = new List(); - private readonly List hosts = new List(); public List Hosts { get @@ -60,10 +58,6 @@ namespace XenAdmin.Alerts } } - private bool canIgnore; - public bool CanIgnore - { get { return canIgnore; } } - public XenServerPatch Patch; /// @@ -110,29 +104,6 @@ namespace XenAdmin.Alerts _timestamp = Patch.TimeStamp; canIgnore = true; } - - public void IncludeConnection(IXenConnection newConnection) - { - connections.Add(newConnection); - if (connections.Count > 0) - canIgnore = false; - } - - public void IncludeHosts(IEnumerable newHosts) - { - hosts.AddRange(newHosts); - if (hosts.Count > 0) - canIgnore = false; - } - - public void CopyConnectionsAndHosts(XenServerPatchAlert alert) - { - connections.Clear(); - connections.AddRange(alert.connections); - hosts.Clear(); - hosts.AddRange(alert.hosts); - canIgnore = connections.Count == 0 && hosts.Count == 0; - } public override string WebPageLabel { @@ -154,22 +125,6 @@ namespace XenAdmin.Alerts } } - public override string AppliesTo - { - get - { - List names = new List(); - - foreach (Host host in hosts) - names.Add(host.Name); - - foreach (IXenConnection connection in connections) - names.Add(Helpers.GetName(connection)); - - return string.Join(", ", names.ToArray()); - } - } - public override string Description { get { return Patch.Description; } @@ -218,9 +173,7 @@ namespace XenAdmin.Alerts { base.Dismiss(); foreach (IXenConnection connection in connections) - { new IgnorePatchAction(connection, Patch).RunAsync(); - } } public override bool Equals(Alert other) diff --git a/XenAdmin/Alerts/Types/XenServerUpdateAlert.cs b/XenAdmin/Alerts/Types/XenServerUpdateAlert.cs new file mode 100644 index 000000000..36dd71bbc --- /dev/null +++ b/XenAdmin/Alerts/Types/XenServerUpdateAlert.cs @@ -0,0 +1,93 @@ +/* Copyright (c) Citrix Systems Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, + * with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using XenAdmin.Network; +using XenAdmin.Actions; +using XenAdmin.Core; +using XenAPI; + + +namespace XenAdmin.Alerts +{ + public abstract class XenServerUpdateAlert : Alert + { + protected readonly List connections = new List(); + protected readonly List hosts = new List(); + + protected bool canIgnore; + public bool CanIgnore + { + get { return canIgnore; } + } + + public void IncludeConnection(IXenConnection newConnection) + { + connections.Add(newConnection); + if (connections.Count > 0) + canIgnore = false; + } + + public void IncludeHosts(IEnumerable newHosts) + { + hosts.AddRange(newHosts); + if (hosts.Count > 0) + canIgnore = false; + } + + public void CopyConnectionsAndHosts(XenServerUpdateAlert alert) + { + connections.Clear(); + connections.AddRange(alert.connections); + hosts.Clear(); + hosts.AddRange(alert.hosts); + canIgnore = connections.Count == 0 && hosts.Count == 0; + } + + public override string AppliesTo + { + get + { + List names = new List(); + + foreach (Host host in hosts) + names.Add(host.Name); + + foreach (IXenConnection connection in connections) + names.Add(Helpers.GetName(connection)); + + return string.Join(", ", names.ToArray()); + } + } + } +} diff --git a/XenAdmin/Alerts/Types/XenServerVersionAlert.cs b/XenAdmin/Alerts/Types/XenServerVersionAlert.cs index 1f265f189..262fdfd7a 100644 --- a/XenAdmin/Alerts/Types/XenServerVersionAlert.cs +++ b/XenAdmin/Alerts/Types/XenServerVersionAlert.cs @@ -40,15 +40,8 @@ using XenAPI; namespace XenAdmin.Alerts { - public class XenServerVersionAlert : Alert + public class XenServerVersionAlert : XenServerUpdateAlert { - private readonly List connections = new List(); - private readonly List hosts = new List(); - - private bool canIgnore; - public bool CanIgnore - { get { return canIgnore; } } - public XenServerVersion Version; public XenServerVersionAlert(XenServerVersion version) @@ -57,29 +50,6 @@ namespace XenAdmin.Alerts _timestamp = version.TimeStamp; canIgnore = true; } - - public void IncludeConnection(IXenConnection newConnection) - { - connections.Add(newConnection); - if (connections.Count > 0) - canIgnore = false; - } - - public void IncludeHosts(IEnumerable newHosts) - { - hosts.AddRange(newHosts); - if (hosts.Count > 0) - canIgnore = false; - } - - public void CopyConnectionsAndHosts(XenServerVersionAlert alert) - { - connections.Clear(); - connections.AddRange(alert.connections); - hosts.Clear(); - hosts.AddRange(alert.hosts); - canIgnore = connections.Count == 0 && hosts.Count == 0; - } public override string WebPageLabel { @@ -111,22 +81,6 @@ namespace XenAdmin.Alerts } } - public override string AppliesTo - { - get - { - List names = new List(); - - foreach (Host host in hosts) - names.Add(host.Name); - - foreach (IXenConnection connection in connections) - names.Add(Helpers.GetName(connection)); - - return string.Join(", ", names.ToArray()); - } - } - public override string FixLinkText { get diff --git a/XenAdmin/XenAdmin.csproj b/XenAdmin/XenAdmin.csproj index 3d5b0aba9..a16416555 100644 --- a/XenAdmin/XenAdmin.csproj +++ b/XenAdmin/XenAdmin.csproj @@ -113,6 +113,7 @@ +