Esempio n. 1
0
 public VersionCheckEventArgs(int version, string ip, VersionCheckResult result)
 {
     _version = version;
     _ip      = ip;
     _time    = DateTime.Now;
     _result  = result;
 }
Esempio n. 2
0
        /// <summary>
        /// Checks the .NET Framework version and returns Pass, Fail, or Unknown which can be
        /// used to determine if it's safe to proceed.
        /// </summary>
        /// <returns>One of the values of the VersionCheckResult enum.</returns>
        private VersionCheckResult CheckFrameworkVersion()
        {
            VersionCheckResult result = VersionCheckResult.Fail;

            try
            {
                if (System.Environment.Version.Major > 4)
                {
                    result = VersionCheckResult.Pass;
                }
                else if (System.Environment.Version.Major == 4 && System.Environment.Version.Build > 30319)
                {
                    result = VersionCheckResult.Pass;
                }
                else if (System.Environment.Version.Major == 4 && System.Environment.Version.Build == 30319)
                {
                    // Once we get to 4.5 Microsoft recommends we test via the Registry...
                    result = Check45PlusFromRegistry();
                }
            }
            catch
            {
                // This would be pretty bad, but regardless we'll return
                // the Unknown result and let the caller proceed with caution.
                result = VersionCheckResult.Unknown;
            }

            return(result);
        }
Esempio n. 3
0
 /// <summary>
 /// Checks online to see if an updated version is available.
 /// </summary>
 /// <param name="displayErrors">Set to true to display an error message in case the update check fails</param>
 /// <returns>True if a newer version of Tabular Editor is available, false otherwise</returns>
 public static VersionCheckResult Check(bool displayErrors = false)
 {
     using (new Hourglass())
     {
         AvailableVersion = InternalCheck(displayErrors);
     }
     return(AvailableVersion);
 }
Esempio n. 4
0
        /// <summary>
        /// Invoked on page load.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            // Set timeout for up to 15 minutes (just like installer)
            Server.ScriptTimeout = 900;
            ScriptManager.GetCurrent(Page).AsyncPostBackTimeout = 900;

            DisplayRockVersion();
            if (!IsPostBack)
            {
                if (NuGetService == null)
                {
                    pnlNoUpdates.Visible = false;
                    pnlError.Visible     = true;
                    nbErrors.Text        = string.Format("Your UpdateServerUrl is not valid. It is currently set to: {0}", GlobalAttributesCache.Read().GetValue("UpdateServerUrl"));
                }
                else
                {
                    try
                    {
                        VersionCheckResult result = CheckFrameworkVersion();
                        if (result == VersionCheckResult.Pass)
                        {
                            _isOkToProceed = true;
                        }
                        else if (result == VersionCheckResult.Fail)
                        {
                            _isOkToProceed          = false;
                            nbVersionIssue.Visible  = true;
                            nbVersionIssue.Text    += "<p>You will need to upgrade your hosting server in order to proceed with the next update.</p>";
                            nbBackupMessage.Visible = false;
                        }
                        else
                        {
                            _isOkToProceed          = true;
                            nbVersionIssue.Visible  = true;
                            nbVersionIssue.Text    += "<p>You may need to upgrade your hosting server in order to proceed with the next update. We were <b>unable to determine which Framework version</b> your server is using.</p>";
                            nbVersionIssue.Details += "<div class='alert alert-warning'>We were unable to check your server to verify that the .Net 4.5.2 Framework is installed! <b>You MUST verify this manually before you proceed with the update</b> otherwise your Rock application will be broken until you update the server.</div>";
                            nbBackupMessage.Visible = false;
                        }

                        _availablePackages = NuGetService.SourceRepository.FindPackagesById(_rockPackageId).OrderByDescending(p => p.Version);
                        if (IsUpdateAvailable())
                        {
                            pnlUpdatesAvailable.Visible = true;
                            pnlNoUpdates.Visible        = false;
                            cbIncludeStats.Visible      = true;
                            BindGrid();
                        }

                        RemoveOldRDeleteFiles();
                    }
                    catch (System.InvalidOperationException ex)
                    {
                        HandleNuGetException(ex);
                    }
                }
            }
        }
Esempio n. 5
0
 public static async Task <Tuple <VersionCheckResult, SemanticVersioning.Version, string, string> > CheckVersionInternal()
 {
     try
     {
         Task <VersionSpecV1> t1 = new Task <VersionSpecV1>(GetVersionSpecV1);
         Task <SemanticVersioning.Version> t2 = new Task <SemanticVersioning.Version>(GetCurrentVersion);
         t1.Start();
         t2.Start();
         VersionSpecV1 spec = await t1;
         SemanticVersioning.Version local  = Local = await t2;
         SemanticVersioning.Version remote = Remote = spec.Version;
         string             changelog      = spec.Changelog.ContainsKey(remote.ToString()) ? spec.Changelog[remote.ToString()] : "No changelog provided";
         string             latestLink     = $"https://github.com/skyloutyr/VSCC/releases/download/{ remote }/VSCC.zip";
         VersionCheckResult result         = remote > local ? VersionCheckResult.Behind : remote < local ? VersionCheckResult.Ahead : VersionCheckResult.Current;
         return(new Tuple <VersionCheckResult, SemanticVersioning.Version, string, string>(result, remote, changelog, latestLink));
     }
     catch (Exception e)
     {
         return(new Tuple <VersionCheckResult, SemanticVersioning.Version, string, string>(VersionCheckResult.Error, new SemanticVersioning.Version(0, 0, 0), $"{ e.Message }:\n{ e.StackTrace }", string.Empty));
     }
 }
Esempio n. 6
0
        public static bool UpdateAvailable(this VersionCheckResult result, bool skipPatchUpdates = false)
        {
            switch (result)
            {
            case VersionCheckResult.PatchAvailable:
                if (skipPatchUpdates)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }

            case VersionCheckResult.MinorAvailable:
            case VersionCheckResult.MajorAvailable:
                return(true);

            default:
                return(false);
            }
        }
Esempio n. 7
0
 private static void ShowNewVersionMessage(VersionCheckResult checkResult, ILanguageProvider languageProvider)
 {
     System.Console.WriteLine("-------------------------------------");
     System.Console.WriteLine(languageProvider.GetString(LanguageSection.UiStrings, "NewVersionAvailable"));
     System.Console.WriteLine(string.Format(languageProvider.GetString(LanguageSection.UiStrings, "CurrentVersion"), checkResult.Release.CurrentVersion));
     System.Console.WriteLine(string.Format(languageProvider.GetString(LanguageSection.UiStrings, "NewVersion"), checkResult.Release.TagName));
     if (checkResult.Release.Assets != null && checkResult.Release.Assets.Any())
     {
         foreach (var asset in checkResult.Release.Assets)
         {
             System.Console.WriteLine(string.Format(languageProvider.GetString(LanguageSection.UiStrings, "DownloadAvailableHere"), asset.Name, asset.DownloadUrl));
         }
     }
     else
     {
         System.Console.WriteLine(string.Format(languageProvider.GetString(LanguageSection.UiStrings, "UpdateAvailableHere"), checkResult.Release.Url));
     }
     if (!string.IsNullOrEmpty(checkResult.Release.ChangeLog))
     {
         System.Console.WriteLine(languageProvider.GetString(LanguageSection.UiStrings, "ChangeLog"));
         System.Console.WriteLine(checkResult.Release.ChangeLog);
     }
     System.Console.WriteLine("-------------------------------------");
 }
Esempio n. 8
0
        protected override async Task ExecuteAsync(CommandLineApplication app)
        {
            _openshift.EnsureConnection();

            // Check if this is a community or RH supported version
            bool community = Community;

            var installOperations = new InstallOperations(_openshift, _s2iRepo);

            string ocNamespace = Global ? "openshift" : _openshift.GetCurrentNamespace();

            // Retrieve installed versions
            Print("Retrieving installed versions: ");
            string[] namespaceVersions = installOperations.GetInstalledVersions(ocNamespace);
            PrintLine(string.Join(", ", namespaceVersions));

            // Retrieve latest versions
            Print("Retrieving latest versions   : ");
            string[] s2iVersions = installOperations.GetLatestVersions(community);
            PrintLine(string.Join(", ", s2iVersions));

            PrintEmptyLine();

            // Compare installed and latest versions
            if (!Force)
            {
                VersionCheckResult result = installOperations.CompareVersions(community, ocNamespace);
                if (result == VersionCheckResult.UnknownVersions)
                {
                    Fail("Namespace has unknown versions. Use '--force' to overwrite.");
                }
                else if (result == VersionCheckResult.AlreadyUpToDate)
                {
                    PrintLine("Already up-to-date. Use '--force' to sync all metadata.");
                }
            }

            if (!community)
            {
                PrintLine("Checking registry.redhat.io are present...");
                bool isSecretSetup = _openshift.HasBuilderPullSecret(ocNamespace, "registry.redhat.io");
                if (!isSecretSetup)
                {
                    PrintLine("No credentials for registry.redhat.io are found.");
                    if (Username == null || Password == null)
                    {
                        Fail(@"Specify 'username' and 'password' arguments to configure authentication with registry.redhat.io.
You can verify your credentials using 'docker login redhat.registry.io'.
For more info see: https://access.redhat.com/RegistryAuthentication.
Alternatively, you can install CentOS based images by passing the 'community' argument.");
                    }
                    _openshift.CreateBuilderPullSecret(ocNamespace, "redhat-registry", "registry.redhat.io", Username, Password);
                    PrintLine("A secret for registry.redhat.io has been added.");
                }
                else
                {
                    PrintLine("A secret for registry.redhat.io is already present.");
                }
            }

            installOperations.UpdateToLatest(community, ocNamespace);

            PrintLine("Succesfully updated.");
        }
Esempio n. 9
0
        /// <summary>
        /// Invoked on page load.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            // Set timeout for up to 15 minutes (just like installer)
            Server.ScriptTimeout = 900;
            ScriptManager.GetCurrent(Page).AsyncPostBackTimeout = 900;

            DisplayRockVersion();
            if (!IsPostBack)
            {
                if (NuGetService == null)
                {
                    pnlNoUpdates.Visible = false;
                    pnlError.Visible     = true;
                    nbErrors.Text        = string.Format("Your UpdateServerUrl is not valid. It is currently set to: {0}", GlobalAttributesCache.Get().GetValue("UpdateServerUrl"));
                }
                else
                {
                    try
                    {
                        _isEarlyAccessOrganization = CheckEarlyAccess();

                        btnIssues.NavigateUrl = string.Format("http://www.rockrms.com/earlyaccessissues?RockInstanceId={0}", Rock.Web.SystemSettings.GetRockInstanceId());

                        if (_isEarlyAccessOrganization)
                        {
                            hlblEarlyAccess.LabelType = Rock.Web.UI.Controls.LabelType.Success;
                            hlblEarlyAccess.Text      = "Early Access: Enabled";

                            pnlEarlyAccessNotEnabled.Visible = false;
                            pnlEarlyAccessEnabled.Visible    = true;
                        }

                        VersionCheckResult result = CheckFrameworkVersion();
                        if (result == VersionCheckResult.Pass)
                        {
                            _isOkToProceed = true;
                        }
                        else if (result == VersionCheckResult.Fail)
                        {
                            _isOkToProceed          = false;
                            nbVersionIssue.Visible  = true;
                            nbVersionIssue.Text    += "<p>You will need to upgrade your hosting server in order to proceed with the next update.</p>";
                            nbBackupMessage.Visible = false;
                        }
                        else
                        {
                            _isOkToProceed          = true;
                            nbVersionIssue.Visible  = true;
                            nbVersionIssue.Text    += "<p>You may need to upgrade your hosting server in order to proceed with the next update. We were <b>unable to determine which Framework version</b> your server is using.</p>";
                            nbVersionIssue.Details += "<div class='alert alert-warning'>We were unable to check your server to verify that the .Net 4.5.2 Framework is installed! <b>You MUST verify this manually before you proceed with the update</b> otherwise your Rock application will be broken until you update the server.</div>";
                            nbBackupMessage.Visible = false;
                        }

                        _hasSqlServer14OrHigher = CheckSqlServerVersionGreaterThenSqlServer2012();
                        if (!_hasSqlServer14OrHigher)
                        {
                            nbSqlServerVersionIssue.Visible = true;
                        }

                        _releases          = GetReleasesList();
                        _availablePackages = NuGetService.SourceRepository.FindPackagesById(_rockPackageId).OrderByDescending(p => p.Version);
                        if (IsUpdateAvailable())
                        {
                            pnlUpdatesAvailable.Visible = true;
                            pnlUpdates.Visible          = true;
                            pnlNoUpdates.Visible        = false;
                            cbIncludeStats.Visible      = true;
                            BindGrid();
                        }

                        RemoveOldRDeleteFiles();
                    }
                    catch (System.InvalidOperationException ex)
                    {
                        HandleNuGetException(ex);
                    }
                }
            }
        }