public virtual string GetLastServicesUsage() { var usages = new[] { AFTime.HasValue ? new LastServicesUsage { Date = AFTime.Value, ShortServiceName = "AF" } : null, AOLTime.HasValue ? new LastServicesUsage { Date = AOLTime.Value, ShortServiceName = "AOL" } : null, CITime.HasValue ? new LastServicesUsage { Date = CITime.Value, ShortServiceName = "CI" } : null, IOLTime.HasValue ? new LastServicesUsage { Date = IOLTime.Value, ShortServiceName = "IOL" } : null, AFNetTime.HasValue ? new LastServicesUsage { Date = AFNetTime.Value, ShortServiceName = "AFNet" } : null, }; var usage = LastServicesUsage.GetLastUsage(usages); if (usage == null) { return(""); } return(String.Format("{0} ({1})", usage.Date, usage.ShortServiceName)); }
public static LastServicesUsage GetLastUsage(LastServicesUsage[] usages) { LastServicesUsage last = null; for (var i = 0; i < usages.Length; i++) { if (usages[i] == null) { continue; } if (last == null) { last = usages[i]; } if (last.Date.CompareTo(usages[i].Date) < 0) { last = usages[i]; } } return(last); }