Пример #1
0
        public static XenCenterUpdateAlert NewXenCenterUpdateAlert(List <XenCenterVersion> xenCenterVersions, Version currentProgramVersion)
        {
            if (Helpers.CommonCriteriaCertificationRelease)
            {
                return(null);
            }

            XenCenterVersion toUse = null;

            if (xenCenterVersions.Count != 0 && currentProgramVersion != new Version(0, 0, 0, 0))
            {
                var latest = from v in xenCenterVersions where v.IsLatest select v;

                toUse = latest.FirstOrDefault(xcv => xcv.Lang == Program.CurrentLanguage) ??
                        latest.FirstOrDefault(xcv => string.IsNullOrEmpty(xcv.Lang));
            }

            if (toUse == null)
            {
                return(null);
            }

            if (toUse.Version > currentProgramVersion ||
                (toUse.Version == currentProgramVersion && toUse.Lang == Program.CurrentLanguage &&
                 !PropertyManager.IsCultureLoaded(Program.CurrentCulture)))
            {
                return(new XenCenterUpdateAlert(toUse));
            }

            log.Info(string.Format("Not alerting XenCenter update - lastest = {0}, detected = {1}",
                                   toUse.VersionAndLang, Program.VersionAndLanguage));
            return(null);
        }
Пример #2
0
        public static XenCenterUpdateAlert NewXenCenterVersionAlert(List <XenCenterVersion> xenCenterVersions, Version currentProgramVersion,
                                                                    bool checkAlertIsAlreadyDismissed)
        {
            if (Helpers.CommonCriteriaCertificationRelease)
            {
                return(null);
            }

            XenCenterVersion toUse = GetLatestPublishedXenCenterVersion(xenCenterVersions, currentProgramVersion);

            if (toUse == null)
            {
                return(null);
            }

            if (checkAlertIsAlreadyDismissed && (toUse.VersionAndLang == Properties.Settings.Default.LatestXenCenterSeen))
            {
                log.Info(string.Format("Version {0} detected but already dismissed", toUse.VersionAndLang));
                return(null);
            }

            if (toUse.Version > currentProgramVersion ||
                (toUse.Version == currentProgramVersion && toUse.Lang == Program.CurrentLanguage &&
                 !PropertyManager.IsCultureLoaded(Program.CurrentCulture)))
            {
                return(new XenCenterUpdateAlert(toUse));
            }

            log.Info(string.Format("Not alerting XenCenter update - lastest = {0}, detected = {1}",
                                   toUse.VersionAndLang, Program.VersionAndLanguage));
            return(null);
        }
Пример #3
0
        private static XenCenterVersion GetLatestPublishedXenCenterVersion(List <XenCenterVersion> xenCenterVersions, Version programVersion)
        {
            if (xenCenterVersions.Count == 0 || programVersion == new Version(0, 0, 0, 0))
            {
                return(null);
            }

            List <XenCenterVersion> latest = new List <XenCenterVersion>();

            foreach (XenCenterVersion v in xenCenterVersions)
            {
                if (v.IsLatest)
                {
                    latest.Add(v);
                }
            }

            XenCenterVersion to_use = latest.Find(new Predicate <XenCenterVersion>(delegate(XenCenterVersion xcv)
            {
                return(xcv.Lang == Program.CurrentLanguage);
            }));

            if (to_use == null)
            {
                to_use = latest.Find(new Predicate <XenCenterVersion>(delegate(XenCenterVersion xcv)
                {
                    return(string.IsNullOrEmpty(xcv.Lang));
                }));
            }

            return(to_use);
        }
Пример #4
0
        private static bool IsSuitableForXenCenterAlert(XenCenterVersion toUse, Version currentProgramVersion)
        {
            if (toUse == null)
            {
                return(false);
            }

            return(toUse.Version > currentProgramVersion ||
                   (toUse.Version == currentProgramVersion && toUse.Lang == Program.CurrentLanguage &&
                    !PropertyManager.IsCultureLoaded(Program.CurrentCulture)));
        }
Пример #5
0
        public static List <XenCenterUpdateAlert> NewXenCenterUpdateAlerts(List <XenCenterVersion> xenCenterVersions,
                                                                           Version currentProgramVersion)
        {
            if (Helpers.CommonCriteriaCertificationRelease)
            {
                return(new List <XenCenterUpdateAlert>());
            }

            var alerts = new List <XenCenterUpdateAlert>();
            XenCenterVersion latest = null, latestCr = null;

            if (xenCenterVersions.Count != 0 && currentProgramVersion != new Version(0, 0, 0, 0))
            {
                var latestVersions = from v in xenCenterVersions where v.Latest select v;
                latest = latestVersions.FirstOrDefault(xcv => xcv.Lang == Program.CurrentLanguage) ??
                         latestVersions.FirstOrDefault(xcv => string.IsNullOrEmpty(xcv.Lang));

                if (IsSuitableForXenCenterAlert(latest, currentProgramVersion))
                {
                    alerts.Add(new XenCenterUpdateAlert(latest));
                }

                var latestCrVersions = from v in xenCenterVersions where v.LatestCr select v;
                latestCr = latestCrVersions.FirstOrDefault(xcv => xcv.Lang == Program.CurrentLanguage) ??
                           latestCrVersions.FirstOrDefault(xcv => string.IsNullOrEmpty(xcv.Lang));

                if (latestCr != latest && IsSuitableForXenCenterAlert(latestCr, currentProgramVersion))
                {
                    alerts.Add(new XenCenterUpdateAlert(latestCr));
                }
            }

            if (alerts.Count == 0)
            {
                log.InfoFormat("Not alerting XenCenter update - latest = {0},  latestcr = {1}, detected = {2}",
                               latest != null ? latest.VersionAndLang : "", latestCr != null ? latestCr.VersionAndLang : "", Program.VersionAndLanguage);
            }

            return(alerts);
        }
Пример #6
0
 public XenCenterUpdateAlert(XenCenterVersion version)
 {
     NewVersion = version;
     _timestamp = NewVersion.TimeStamp;
 }