当前位置: 首页>>代码示例>>C#>>正文


C# UpdateManager.DownloadReleases方法代码示例

本文整理汇总了C#中Squirrel.UpdateManager.DownloadReleases方法的典型用法代码示例。如果您正苦于以下问题:C# UpdateManager.DownloadReleases方法的具体用法?C# UpdateManager.DownloadReleases怎么用?C# UpdateManager.DownloadReleases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Squirrel.UpdateManager的用法示例。


在下文中一共展示了UpdateManager.DownloadReleases方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

        private static async void Update(Task<string> result)
        {
            if (result.Result == null || result.Result != "1")
                return;

            try
            {
                using (var mgr = new UpdateManager(@"https://releases.noelpush.com/", "NoelPush"))
                {
                    var updates = await mgr.CheckForUpdate();

                    if (updates.ReleasesToApply.Any())
                    {
                        var lastVersion = updates.ReleasesToApply.OrderBy(x => x.Version).Last();

                        await mgr.DownloadReleases(updates.ReleasesToApply);
                        await mgr.ApplyReleases(updates);

                        var latestExe = Path.Combine(mgr.RootAppDirectory, string.Concat("app-", lastVersion.Version), "NoelPush.exe");
                        mgr.Dispose();

                        RestartAppEvent();
                        UpdateManager.RestartApp(latestExe);
                    }
                    mgr.Dispose();
                }
            }
            catch (Exception e)
            {
                LogManager.GetCurrentClassLogger().Error(e.Message);
            }
        }
开发者ID:noelpush,项目名称:noelpush,代码行数:32,代码来源:UpdatesService.cs

示例2: UpdateApp

        public async Task UpdateApp()
        {
            var updatePath = ConfigurationManager.AppSettings["UpdatePathFolder"];
            var packageId = ConfigurationManager.AppSettings["PackageID"];

            using (var mgr = new UpdateManager(updatePath, packageId, FrameworkVersion.Net45))
            {
                var updates = await mgr.CheckForUpdate();
                if (updates.ReleasesToApply.Any())
                {
                    var lastVersion = updates.ReleasesToApply.OrderBy(x => x.Version).Last();
                    await mgr.DownloadReleases(new[] { lastVersion });
                    await mgr.ApplyReleases(updates);
                    await mgr.UpdateApp();

                    MessageBox.Show("The application has been updated - please close and restart.");
                }
                else
                {
                    MessageBox.Show("No Updates are available at this time.");
                }
            }
        }
开发者ID:yovannyr,项目名称:SquirrelExample,代码行数:23,代码来源:Form1.cs

示例3: Download

        public async Task<string> Download(string updateUrl, string appName = null)
        {
            appName = appName ?? getAppNameFromDirectory();

            this.Log().Info("Fetching update information, downloading from " + updateUrl);
            using (var mgr = new UpdateManager(updateUrl, appName)) {
                var updateInfo = await mgr.CheckForUpdate(progress: x => Console.WriteLine(x / 3));
                await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3));

                var releaseNotes = updateInfo.FetchReleaseNotes();

                var sanitizedUpdateInfo = new {
                    currentVersion = updateInfo.CurrentlyInstalledVersion.Version.ToString(),
                    futureVersion = updateInfo.FutureReleaseEntry.Version.ToString(),
                    releasesToApply = updateInfo.ReleasesToApply.Select(x => new {
                        version = x.Version.ToString(),
                        releaseNotes = releaseNotes.ContainsKey(x) ? releaseNotes[x] : "",
                    }).ToArray(),
                };

                return SimpleJson.SerializeObject(sanitizedUpdateInfo);
            }
        }
开发者ID:Ribeiro,项目名称:Squirrel.Windows,代码行数:23,代码来源:Program.cs

示例4: Update

        public async Task Update(string updateUrl, string appName = null)
        {
            appName = appName ?? getAppNameFromDirectory();

            this.Log().Info("Starting update, downloading from " + updateUrl);

            using (var mgr = new UpdateManager(updateUrl, appName)) {
                bool ignoreDeltaUpdates = false;
                this.Log().Info("About to update to: " + mgr.RootAppDirectory);

            retry:
                try {
                    var updateInfo = await mgr.CheckForUpdate(ignoreDeltaUpdates: ignoreDeltaUpdates, progress: x => Console.WriteLine(x / 3));
                    await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3));
                    await mgr.ApplyReleases(updateInfo, x => Console.WriteLine(66 + x / 3));
                } catch (Exception ex) {
                    if (ignoreDeltaUpdates) {
                        this.Log().ErrorException("Really couldn't apply updates!", ex);
                        throw;
                    }

                    this.Log().WarnException("Failed to apply updates, falling back to full updates", ex);
                    ignoreDeltaUpdates = true;
                    goto retry;
                }

                var updateTarget = Path.Combine(mgr.RootAppDirectory, "Update.exe");

                await this.ErrorIfThrows(() =>
                    mgr.CreateUninstallerRegistryEntry(),
                    "Failed to create uninstaller registry entry");
            }
        }
开发者ID:Ribeiro,项目名称:Squirrel.Windows,代码行数:33,代码来源:Program.cs

示例5: ButtonUpdate_Click

        /// <summary>
        /// Handles the Click event of the buttonUpdate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private async void ButtonUpdate_Click(object sender, EventArgs e)
        {
            string updateUrl = @"http://journaley.s3.amazonaws.com/stable";

            string updateSrcFile = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "UpdateSource");

            if (File.Exists(updateSrcFile))
            {
                updateUrl = File.ReadAllText(updateSrcFile, System.Text.Encoding.UTF8).Trim();
            }

            // Update Check
            if (this.Owner is MainForm)
            {
                ++((MainForm)this.Owner).UpdateProcessCount;
            }

            try
            {
                using (var mgr = new UpdateManager(updateUrl))
                {
                    // Disable update check when in develop mode.
                    if (!mgr.IsInstalledApp)
                    {
                        MessageBox.Show("Checking for update is disabled in develop mode.", "Update Journaley");
                        return;
                    }

                    var updateInfo = await mgr.CheckForUpdate();

                    if (updateInfo == null)
                    {
                        MessageBox.Show("Failed to check for update.", "Update Journaley");
                        return;
                    }

                    if (updateInfo.ReleasesToApply.Any())
                    {
                        await mgr.DownloadReleases(updateInfo.ReleasesToApply);
                        await mgr.ApplyReleases(updateInfo);

                        MessageBox.Show(
                            "Journaley has been updated to v" +
                            updateInfo.ReleasesToApply.Max(x => x.Version) + ".\n" +
                            "Restart Journaley to use the new version.",
                            "Update Journaley");

                        this.UpdateAvailable = false;
                        if (this.Owner is MainForm)
                        {
                            ((MainForm)this.Owner).UpdateAvailable = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Journaley is already up to date!", "Update Journaley");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occurred while updating.", "Update Journaley");
                Logger.Log(ex.Message);
                Logger.Log(ex.StackTrace);
            }
            finally
            {
                if (this.Owner is MainForm)
                {
                    --((MainForm)this.Owner).UpdateProcessCount;
                }
            }
        }
开发者ID:gusper,项目名称:Journaley,代码行数:80,代码来源:SettingsForm.cs

示例6: DownloadReleasesAsync

        /// <summary>
        /// Download releases found by a previous update check using Squirrel UpdateManager and return true when finished.
        /// </summary>
        /// <returns></returns>
        public static async Task<bool> DownloadReleasesAsync(IEnumerable<ReleaseEntry> releases)
        {
            var appName = GetAppName();
            var updateLocation = GetUpdateLocation();

            _log.Debug("Download Releases. Called " + Utilities.GetCallerName() + " with UpdateLocation = \"" + updateLocation + "\" and AppName = " + appName + "\".");

            using (var mgr = new Squirrel.UpdateManager(updateLocation, appName, Squirrel.FrameworkVersion.Net45))
            {
                try
                {
                    await mgr.DownloadReleases(releases).ConfigureAwait(false);
                }
                catch (Exception e)
                {
                    _log.Error(Utilities.GetCallerName() + " error while downloading releases with UpdateLocation = \"" + updateLocation + "\" and AppName = " + appName + ", thrown " + e.GetType().ToString() + " with message \"" + e.Message + "\".", e);
                    throw;
                }
            }

            return true;
        }
开发者ID:yovannyr,项目名称:bigstash-windows,代码行数:26,代码来源:SquirrelHelper.cs

示例7: SquirrelUpdate

		private static async Task<bool> SquirrelUpdate(SplashScreenWindow splashScreenWindow, UpdateManager mgr, bool ignoreDelta = false)
		{
			try
			{
				Log.Info($"Checking for updates (ignoreDelta={ignoreDelta})");
				splashScreenWindow.StartSkipTimer();
				var updateInfo = await mgr.CheckForUpdate(ignoreDelta);
				if(!updateInfo.ReleasesToApply.Any())
				{
					Log.Info("No new updated available");
					return false;
				}
				var latest = updateInfo.ReleasesToApply.LastOrDefault()?.Version;
				var current = mgr.CurrentlyInstalledVersion();
				if(latest <= current)
				{
					Log.Info($"Installed version ({current}) is greater than latest release found ({latest}). Not downloading updates.");
					return false;
				}
				if(IsRevisionIncrement(current?.Version, latest?.Version))
				{
					Log.Info($"Latest update ({latest}) is revision increment. Updating in background.");
					splashScreenWindow.SkipUpdate = true;
				}
				Log.Info($"Downloading {updateInfo.ReleasesToApply.Count} {(ignoreDelta ? "" : "delta ")}releases, latest={latest?.Version}");
				await mgr.DownloadReleases(updateInfo.ReleasesToApply, splashScreenWindow.Updating);
				Log.Info("Applying releases");
				await mgr.ApplyReleases(updateInfo, splashScreenWindow.Installing);
				await mgr.CreateUninstallerRegistryEntry();
				Log.Info("Done");
				return true;
			}
			catch(Exception ex)
			{
				if(ignoreDelta)
					return false;
				if(ex is Win32Exception)
					Log.Info("Not able to apply deltas, downloading full release");
				return await SquirrelUpdate(splashScreenWindow, mgr, true);
			}
		}
开发者ID:Roy-Mayfield-REISYS,项目名称:Hearthstone-Deck-Tracker,代码行数:41,代码来源:Updater.Squirrel.cs

示例8: Download

        public async Task<string> Download(string updateUrl, string appName = null)
        {
            appName = appName ?? getAppNameFromDirectory();

            // NB: Always basing the rootAppDirectory relative to ours allows us to create Portable
            // Applications
            var ourDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..");

            this.Log().Info("Fetching update information, downloading from " + updateUrl);
            using (var mgr = new UpdateManager(updateUrl, appName, FrameworkVersion.Net45, ourDir)) {
                var updateInfo = await mgr.CheckForUpdate(progress: x => Console.WriteLine(x / 3));
                await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3));

                var releaseNotes = updateInfo.FetchReleaseNotes();

                var sanitizedUpdateInfo = new {
                    currentVersion = updateInfo.CurrentlyInstalledVersion.Version.ToString(),
                    futureVersion = updateInfo.FutureReleaseEntry.Version.ToString(),
                    releasesToApply = updateInfo.ReleasesToApply.Select(x => new {
                        version = x.Version.ToString(),
                        releaseNotes = releaseNotes.ContainsKey(x) ? releaseNotes[x] : "",
                    }).ToArray(),
                };

                return SimpleJson.SerializeObject(sanitizedUpdateInfo);
            }
        }
开发者ID:morefun0302,项目名称:Squirrel.Windows,代码行数:27,代码来源:Program.cs

示例9: Update

        public async Task Update(string updateUrl, string appName = null)
        {
            appName = appName ?? getAppNameFromDirectory();

            this.Log().Info("Starting update, downloading from " + updateUrl);

            // NB: Always basing the rootAppDirectory relative to ours allows us to create Portable
            // Applications
            var ourDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..");

            using (var mgr = new UpdateManager(updateUrl, appName, FrameworkVersion.Net45, ourDir)) {
                bool ignoreDeltaUpdates = false;

            retry:
                try {
                    var updateInfo = await mgr.CheckForUpdate(ignoreDeltaUpdates: ignoreDeltaUpdates, progress: x => Console.WriteLine(x / 3));
                    await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3));
                    await mgr.ApplyReleases(updateInfo, x => Console.WriteLine(66 + x / 3));
                } catch (Exception ex) {
                    if (ignoreDeltaUpdates) {
                        this.Log().ErrorException("Really couldn't apply updates!", ex);
                        throw;
                    }

                    this.Log().WarnException("Failed to apply updates, falling back to full updates", ex);
                    ignoreDeltaUpdates = true;
                    goto retry;
                }

                var updateTarget = Path.Combine(mgr.RootAppDirectory, "Update.exe");

                await this.ErrorIfThrows(() =>
                    mgr.CreateUninstallerRegistryEntry(),
                    "Failed to create uninstaller registry entry");
            }
        }
开发者ID:morefun0302,项目名称:Squirrel.Windows,代码行数:36,代码来源:Program.cs

示例10: CheckForUpdates

        private IObservable<UpdateAvailableNotification> CheckForUpdates()
        {
            return Observable.Create<UpdateAvailableNotification>(async obs =>
            {
                string updateUrl = AppModel.GetRegistrySetting("UpdateUrl");
                Log.DebugFormat("UpdateUrl = {0}", updateUrl);
                using (var updateManager = new UpdateManager(updateUrl ?? @"http://bradleygrainger.com/GitBlame/download", "GitBlame", FrameworkVersion.Net45))
                {
                    try
                    {
                        UpdateInfo updateInfo = await updateManager.CheckForUpdate();
                        var releases = updateInfo == null ? new List<ReleaseEntry>() : updateInfo.ReleasesToApply.ToList();
                        if (updateInfo == null)
                            Log.Info("CheckForUpdate returned (null)");
                        else
                            Log.InfoFormat("CheckForUpdate: Current=({0}), Future=({1}), {2} ReleasesToApply", ToLog(updateInfo.CurrentlyInstalledVersion), ToLog(updateInfo.FutureReleaseEntry), releases.Count);

                        if (releases.Count != 0)
                        {
                            await updateManager.DownloadReleases(releases);
                            Log.Info("Downloaded releases");
                            var newDirectory = await updateManager.ApplyReleases(updateInfo);
                            Log.InfoFormat("ApplyReleases: {0}", newDirectory);

                            if (!string.IsNullOrEmpty(newDirectory))
                            {
                                var newPath = Path.Combine(newDirectory, "GitBlame.exe");
                                VisualStudioIntegration.ReintegrateWithVisualStudio(newPath);
                                obs.OnNext(new UpdateAvailableNotification(newPath));
                            }
                        }
                    }
                    catch (TimeoutException ex)
                    {
                        // Failed to check for updates; try again the next time the app is run
                        Log.ErrorFormat("CheckForUpdates timed out: {0}", ex, ex.Message);
                    }
                    catch (Exception ex)
                    {
                        // Squirrel throws a new Exception in many failure scenarios
                        Log.ErrorFormat("CheckForUpdates failed: {0}", ex, ex.Message);
                        if (ex.InnerException != null)
                            Log.ErrorFormat("CheckForUpdates inner exception: {0}", ex.InnerException, ex.InnerException.Message);
                    }
                }
                obs.OnCompleted();
            });
        }
开发者ID:bgrainger,项目名称:GitBlame,代码行数:48,代码来源:MainWindowModel.cs

示例11: Download

        public async Task<string> Download(string updateUrl, string appName = null)
        {
            ensureConsole();
            appName = appName ?? getAppNameFromDirectory();

            this.Log().Info("Fetching update information, downloading from " + updateUrl);
            using (var mgr = new UpdateManager(updateUrl, appName, FrameworkVersion.Net45)) {
                var updateInfo = await mgr.CheckForUpdate(progress: x => Console.WriteLine(x / 3));
                await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3));

                return SimpleJson.SerializeObject(updateInfo);
            }
        }
开发者ID:christianrondeau,项目名称:Squirrel.Windows.Next,代码行数:13,代码来源:Program.cs

示例12: Update

        public async Task Update(string updateUrl, string appName = null)
        {
            appName = appName ?? getAppNameFromDirectory();

            this.Log().Info("Starting update, downloading from " + updateUrl);
            using (var mgr = new UpdateManager(updateUrl, appName, FrameworkVersion.Net45)) {
                var updateInfo = await mgr.CheckForUpdate(progress: x => Console.WriteLine(x / 3));
                await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3));
                await mgr.ApplyReleases(updateInfo, x => Console.WriteLine(66 + x / 3));
            }
            
            // TODO: Update our installer entry
        }
开发者ID:christianrondeau,项目名称:Squirrel.Windows.Next,代码行数:13,代码来源:Program.cs

示例13: MainForm_Shown

        /// <summary>
        /// Handles the Shown event of the MainForm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private async void MainForm_Shown(object sender, EventArgs e)
        {
            string updateUrl = @"http://journaley.s3.amazonaws.com/stable";

            string updateSrcFile = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "UpdateSource");

            if (File.Exists(updateSrcFile))
            {
                updateUrl = File.ReadAllText(updateSrcFile, System.Text.Encoding.UTF8).Trim();
            }

            // Update Check
            ++this.UpdateProcessCount;

            try
            {
                using (var mgr = new UpdateManager(updateUrl))
                {
                    // Disable update check when in develop mode.
                    if (!mgr.IsInstalledApp)
                    {
                        return;
                    }

                    this.CurrentlyInstalledVersion = mgr.CurrentlyInstalledVersion();

                    var updateInfo = await mgr.CheckForUpdate();

                    if (updateInfo == null)
                    {
                        return;
                    }

                    if (updateInfo.ReleasesToApply.Any())
                    {
                        await mgr.DownloadReleases(updateInfo.ReleasesToApply);

                        // First, if the user already checked the auto-update option,
                        // simply apply them.
                        if (this.Settings.AutoUpdate)
                        {
                            await mgr.ApplyReleases(updateInfo);
                            return;
                        }

                        // Save the updateInfo and indicate that there is an available update.
                        this.UpdateInfo = updateInfo;
                        this.UpdateAvailable = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message);
                Logger.Log(ex.StackTrace);
            }
            finally
            {
                --this.UpdateProcessCount;
            }
        }
开发者ID:gusper,项目名称:Journaley,代码行数:68,代码来源:MainForm.cs


注:本文中的Squirrel.UpdateManager.DownloadReleases方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。