CP-36392: Avoid multiple enumerations in LicenseStatus.cs

Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
This commit is contained in:
Danilo Del Busso 2021-11-17 09:01:25 +00:00
parent 3e861411db
commit f2fdf31a5a
No known key found for this signature in database
GPG Key ID: 55F556F9A25CB037

View File

@ -207,13 +207,13 @@ namespace XenAdmin.Dialogs
if (freeCount == 0 || freeCount < xenObject.Connection.Cache.Hosts.Length)
return false;
var expiryGroups = from Host h in xenObject.Connection.Cache.Hosts
var expiryGroups = (from Host h in xenObject.Connection.Cache.Hosts
let exp = h.LicenseExpiryUTC()
group h by exp
into g
select new { ExpiryDate = g.Key, Hosts = g };
select new { ExpiryDate = g.Key, Hosts = g }).ToList();
if (expiryGroups.Count() > 1)
if (expiryGroups.Count > 1)
{
expiryGroups = expiryGroups.OrderBy(g => g.ExpiryDate).ToList();
if ((expiryGroups.ElementAt(1).ExpiryDate - expiryGroups.ElementAt(0).ExpiryDate).TotalDays > 30)