GetUpdateStatus() public static method

Gets the update status of a component.
This method only works in Full Trust.
public static GetUpdateStatus ( string url, string currentVersion, string &newVersion, string &newAssemblyUrl ) : UpdateStatus
url string The version file URL.
currentVersion string The current version.
newVersion string The new version, if any.
newAssemblyUrl string The URL of the new assembly, if applicable and available.
return UpdateStatus
コード例 #1
0
        /// <summary>
        /// Gets the update status of a provider.
        /// </summary>
        /// <param name="info">The component information.</param>
        /// <returns>The update status.</returns>
        private string GetUpdateStatus(ComponentInformation info)
        {
            if (!Settings.DisableAutomaticVersionCheck)
            {
                if (string.IsNullOrEmpty(info.UpdateUrl))
                {
                    return("n/a");
                }
                string       newVersion     = null;
                string       newAssemblyUrl = null;
                UpdateStatus status         = Tools.GetUpdateStatus(info.UpdateUrl, info.Version, out newVersion, out newAssemblyUrl);

                if (status == UpdateStatus.Error)
                {
                    return("<span class=\"resulterror\">" + Properties.Messages.Error + "</span>");
                }
                if (status == UpdateStatus.NewVersionFound)
                {
                    return("<span class=\"resulterror\">" + Properties.Messages.NewVersion + " <b>" + newVersion + "</b>" +
                           (string.IsNullOrEmpty(newAssemblyUrl) ? "" : " (" + Properties.Messages.AutoUpdateAvailable + ")") + "</span>");
                }
                if (status == UpdateStatus.UpToDate)
                {
                    return("<span class=\"resultok\">" + Properties.Messages.UpToDate + "</span>");
                }
                throw new NotSupportedException();
            }
            return("n/a");
        }
コード例 #2
0
        /// <summary>
        /// Updates all the providers.
        /// </summary>
        /// <returns>The number of updated DLLs.</returns>
        public int UpdateAll()
        {
            Log.LogEntry("Starting automatic providers update", EntryType.General, Log.SystemUsername, null);

            int updatedDlls = 0;

            foreach (IFormatterProviderV40 plugin in plugins)
            {
                if (string.IsNullOrEmpty(plugin.Information.UpdateUrl))
                {
                    continue;
                }

                string       newVersion;
                string       newDllUrl;
                UpdateStatus status = Tools.GetUpdateStatus(plugin.Information.UpdateUrl,
                                                            plugin.Information.Version, out newVersion, out newDllUrl);

                if (status == UpdateStatus.NewVersionFound && !string.IsNullOrEmpty(newDllUrl))
                {
                    // Update is possible

                    // Case insensitive check
                    if (!visitedUrls.Contains(newDllUrl.ToLowerInvariant()))
                    {
                        string dllName = null;

                        if (!fileNamesForProviders.TryGetValue(plugin.GetType().FullName, out dllName))
                        {
                            Log.LogEntry("Could not determine DLL name for provider " + plugin.GetType().FullName, EntryType.Error, Log.SystemUsername, null);
                            continue;
                        }

                        // Download DLL and install
                        if (DownloadAndUpdateDll(plugin, newDllUrl, dllName))
                        {
                            visitedUrls.Add(newDllUrl.ToLowerInvariant());
                            updatedDlls++;
                            foreach (PluginFramework.Wiki wiki in globalSettingsProvider.GetAllWikis())
                            {
                                ProviderLoader.SetUp <IFormatterProviderV40>(plugin.GetType(), Settings.GetProvider(wiki.WikiName).GetPluginConfiguration(plugin.GetType().FullName));
                            }
                        }
                    }
                    else
                    {
                        // Skip DLL (already updated)
                        Log.LogEntry("Skipping provider " + plugin.GetType().FullName + ": DLL already updated", EntryType.General, Log.SystemUsername, null);
                    }
                }
            }

            Log.LogEntry("Automatic providers update completed: updated " + updatedDlls.ToString() + " DLLs", EntryType.General, Log.SystemUsername, null);

            return(updatedDlls);
        }
コード例 #3
0
        /// <summary>
        /// Updates all the providers.
        /// </summary>
        /// <returns>The number of updated DLLs.</returns>
        public int UpdateAll( )
        {
            Log.LogEntry("Starting automatic providers update", EntryType.General, Log.SystemUsername);

            int updatedDlls = 0;

            foreach (IProviderV30 prov in _providers)
            {
                if (string.IsNullOrEmpty(prov.Information.UpdateUrl))
                {
                    continue;
                }

                string       newVersion;
                string       newDllUrl;
                UpdateStatus status = Tools.GetUpdateStatus(prov.Information.UpdateUrl,
                                                            prov.Information.Version, out newVersion, out newDllUrl);

                if (status == UpdateStatus.NewVersionFound && !string.IsNullOrEmpty(newDllUrl))
                {
                    // Update is possible

                    // Case insensitive check
                    if (!_visitedUrls.Contains(newDllUrl.ToLowerInvariant( )))
                    {
                        string dllName = null;

                        if (!_fileNamesForProviders.TryGetValue(prov.GetType( ).FullName, out dllName))
                        {
                            Log.LogEntry("Could not determine DLL name for provider " + prov.GetType( ).FullName, EntryType.Error, Log.SystemUsername);
                            continue;
                        }

                        // Download DLL and install
                        if (DownloadAndUpdateDll(prov, newDllUrl, dllName))
                        {
                            _visitedUrls.Add(newDllUrl.ToLowerInvariant( ));
                            updatedDlls++;
                        }
                    }
                    else
                    {
                        // Skip DLL (already updated)
                        Log.LogEntry("Skipping provider " + prov.GetType( ).FullName + ": DLL already updated", EntryType.General, Log.SystemUsername);
                    }
                }
            }

            Log.LogEntry("Automatic providers update completed: updated " + updatedDlls + " DLLs", EntryType.General, Log.SystemUsername);

            return(updatedDlls);
        }
コード例 #4
0
        private string CheckVersion()
        {
            if (GlobalSettings.DisableAutomaticVersionCheck)
            {
                return("");
            }

            StringBuilder sb = new StringBuilder(100);

            sb.Append("(");

            string       newVersion = null;
            string       ignored    = null;
            UpdateStatus status     = Tools.GetUpdateStatus("http://www.screwturn.eu/Version4.0/Wiki/4.htm",
                                                            GlobalSettings.WikiVersion, out newVersion, out ignored);

            if (status == UpdateStatus.Error)
            {
                sb.Append(@"<span class=""resulterror"">" + Properties.Messages.VersionCheckError + "</span>");
            }
            else if (status == UpdateStatus.NewVersionFound)
            {
                sb.Append(@"<span class=""resulterror"">" + Properties.Messages.NewVersionFound + ": <b>" + newVersion + "</b></span>");
            }
            else if (status == UpdateStatus.UpToDate)
            {
                sb.Append(@"<span class=""resultok"">" + Properties.Messages.WikiUpToDate + "</span>");
            }
            else
            {
                throw new NotSupportedException();
            }

            sb.Append(")");
            return(sb.ToString());
        }
コード例 #5
0
        private string CheckVersion()
        {
            if (Settings.DisableAutomaticVersionCheck)
            {
                return("");
            }

            StringBuilder sb = new StringBuilder(100);

            sb.Append("(");

            string       newVersion = null;
            string       ignored    = null;
            UpdateStatus status     = Tools.GetUpdateStatus("https://raw.githubusercontent.com/MarkZither/ScrewTurnWiki/master/RELEASE",
                                                            Settings.WikiVersion, out newVersion, out ignored);

            if (status == UpdateStatus.Error)
            {
                sb.Append(@"<span class=""resulterror"">" + Properties.Messages.VersionCheckError + "</span>");
            }
            else if (status == UpdateStatus.NewVersionFound)
            {
                sb.Append(@"<span class=""resulterror"">" + Properties.Messages.NewVersionFound + ": <b>" + newVersion + "</b></span>");
            }
            else if (status == UpdateStatus.UpToDate)
            {
                sb.Append(@"<span class=""resultok"">" + Properties.Messages.WikiUpToDate + "</span>");
            }
            else
            {
                throw new NotSupportedException();
            }

            sb.Append(")");
            return(sb.ToString());
        }