public AppUpdateControl(IEnumerable<IAppVersion> appVersions, Action<IAppVersion> updateAction) { this.NewestVersion = appVersions.First(); InitializeComponent(); this.AppIconImage.ImageFailed += (sender, e) => { this.AppIconImage.Source = new BitmapImage(new Uri("/Assets/windows_phone.png", UriKind.RelativeOrAbsolute)); }; this.AppIconImage.Source = new BitmapImage(new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + NewestVersion.PublicIdentifier + ".png")); this.ReleaseNotesBrowser.Opacity = 0; this.ReleaseNotesBrowser.Navigated += (sender, e) => { (this.ReleaseNotesBrowser.Resources["fadeIn"] as Storyboard).Begin(); }; this.ReleaseNotesBrowser.NavigateToString(WebBrowserHelper.WrapContent(NewestVersion.Notes)); this.ReleaseNotesBrowser.Navigating += (sender, e) => { e.Cancel = true; WebBrowserTask browserTask = new WebBrowserTask(); browserTask.Uri = e.Uri; browserTask.Show(); }; this.InstallAETX.Click += (sender, e) => { WebBrowserTask webBrowserTask = new WebBrowserTask(); webBrowserTask.Uri = new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + NewestVersion.PublicIdentifier + ".aetx", UriKind.Absolute); webBrowserTask.Show(); }; this.InstallOverApi.Click += (sender, e) => { this.Overlay.Visibility = Visibility.Visible; updateAction.Invoke(NewestVersion); }; }
public async Task <bool> CheckForUpdatesAsync(bool autoShowUi, Func <bool> shutdownActions = null, Action <IAppVersion> updateAvailableAction = null) { this._autoShowUi = autoShowUi; this._shutdownActions = shutdownActions; if (autoShowUi && shutdownActions == null) { throw new ArgumentException("You have to provide a shutdownRequest-Action if using autoUi == true!"); } try { IAppVersion newestVersion = await CheckForUpdates(); if (newestVersion != null) { if (updateAvailableAction != null) { updateAvailableAction(newestVersion); } if (this._autoShowUi) { this.StartUi(newestVersion); } return(true); } } catch (Exception ex) { this._logger.Warn("Exception in CheckForUpdatesAsync: " + ex.GetType().Name + "\n" + ex.Message); HockeyClient.Current.AsInternal().HandleInternalUnhandledException(ex); } return(false); }
public AppUpdateControl(IEnumerable <IAppVersion> appVersions, Action <IAppVersion> updateAction) { this.NewestVersion = appVersions.First(); InitializeComponent(); this.AppIconImage.ImageFailed += (sender, e) => { this.AppIconImage.Source = new BitmapImage(new Uri("/Assets/windows_phone.png", UriKind.RelativeOrAbsolute)); }; this.AppIconImage.Source = new BitmapImage(new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + NewestVersion.PublicIdentifier + ".png")); this.ReleaseNotesBrowser.Opacity = 0; this.ReleaseNotesBrowser.Navigated += (sender, e) => { (this.ReleaseNotesBrowser.Resources["fadeIn"] as Storyboard).Begin(); }; this.ReleaseNotesBrowser.NavigateToString(WebBrowserHelper.WrapContent(NewestVersion.Notes)); this.ReleaseNotesBrowser.Navigating += (sender, e) => { e.Cancel = true; WebBrowserTask browserTask = new WebBrowserTask(); browserTask.Uri = e.Uri; browserTask.Show(); }; this.InstallAETX.Click += (sender, e) => { WebBrowserTask webBrowserTask = new WebBrowserTask(); webBrowserTask.Uri = new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + NewestVersion.PublicIdentifier + ".aetx", UriKind.Absolute); webBrowserTask.Show(); }; this.InstallOverApi.Click += (sender, e) => { this.Overlay.Visibility = Visibility.Visible; updateAction.Invoke(NewestVersion); }; }
public static string getVersion() { if (_versao == null) { _versao = DependencyService.Get <IAppVersion>(); } return(_versao.GetVersion()); }
public static int getBuild() { if (_versao == null) { _versao = DependencyService.Get <IAppVersion>(); } return(_versao.GetBuild()); }
/// <summary> /// Initializes a new instance of the <see cref="VersionEnricher"/> class. /// </summary> /// <param name="appVersion">The instance to retrieve the current application version.</param> /// <param name="propertyName">The name of the property to enrich the log event with the current runtime version.</param> /// <exception cref="ArgumentNullException">Thrown when the <paramref name="appVersion"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when the <paramref name="propertyName"/> is blank.</exception> public VersionEnricher(IAppVersion appVersion, string propertyName) { Guard.NotNull(appVersion, nameof(appVersion), "Requires an application version implementation to enrich the log event with the application version"); Guard.NotNullOrWhitespace(propertyName, nameof(propertyName), "Requires a non-blank property name to enrich the log event with the current runtime version"); _appVersion = appVersion; _propertyName = propertyName; }
#pragma warning restore 1998 /// <summary> /// Installs the app. If not downloaded, the download will start implicitly. /// After starting the install process a call to Environment.Exit is done. /// </summary> /// <param name="this"></param> public static void InstallVersion(this IAppVersion @this) { if (!_downloadFilesnames.ContainsKey(@this.AppId)) { throw new Exception("Download the msi first!"); } var msiFilename = _downloadFilesnames[@this.AppId]; Process.Start(msiFilename); Environment.Exit(0); }
/// <summary> /// Adds the <see cref="VersionEnricher"/> to the logger enrichment configuration which adds the current application version retrieved via the given <paramref name="appVersion"/>. /// </summary> /// <param name="enrichmentConfiguration">The configuration to add the enricher.</param> /// <param name="appVersion">The instance to retrieve the current application version.</param> /// <param name="propertyName">The name of the property to enrich the log event with the current application version.</param> /// <exception cref="ArgumentNullException">Thrown when the <paramref name="enrichmentConfiguration"/> or <paramref name="appVersion"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when the <paramref name="propertyName"/> is blank.</exception> public static LoggerConfiguration WithVersion( this LoggerEnrichmentConfiguration enrichmentConfiguration, IAppVersion appVersion, string propertyName = VersionEnricher.DefaultPropertyName) { Guard.NotNull(enrichmentConfiguration, nameof(enrichmentConfiguration), "Requires an enrichment configuration to add the version enricher"); Guard.NotNull(appVersion, nameof(appVersion), "Requires an application version implementation to enrich the log event with the application version"); Guard.NotNullOrWhitespace(propertyName, nameof(propertyName), "Requires a non-blank property name to enrich the log event with the current runtime version"); return(enrichmentConfiguration.With(new VersionEnricher(appVersion, propertyName))); }
/// <summary> /// Adds the <see cref="VersionEnricher"/> to the logger enrichment configuration which adds the current application version retrieved via the given <paramref name="serviceProvider"/>. /// </summary> /// <param name="enrichmentConfiguration">The configuration to add the enricher.</param> /// <param name="serviceProvider">The instance to retrieve the current application version.</param> /// <param name="propertyName">The name of the property to enrich the log event with the current application version.</param> /// <exception cref="ArgumentNullException">Thrown when the <paramref name="enrichmentConfiguration"/> or <paramref name="serviceProvider"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when the <paramref name="propertyName"/> is blank.</exception> public static LoggerConfiguration WithVersion( this LoggerEnrichmentConfiguration enrichmentConfiguration, IServiceProvider serviceProvider, string propertyName = VersionEnricher.DefaultPropertyName) { Guard.NotNull(enrichmentConfiguration, nameof(enrichmentConfiguration), "Requires an enrichment configuration to add the version enricher"); Guard.NotNull(serviceProvider, nameof(serviceProvider), $"Requires a services provider collection to look for registered '{nameof(IAppVersion)}' implementations"); Guard.NotNullOrWhitespace(propertyName, nameof(propertyName), "Requires a non-blank property name to enrich the log event with the current runtime version"); IAppVersion appVersion = serviceProvider.GetService <IAppVersion>() ?? new AssemblyAppVersion(); return(enrichmentConfiguration.With(new VersionEnricher(appVersion, propertyName))); }
/// <summary> /// Initializes a new instance of the <see cref="VersionTrackingMiddleware"/> class. /// </summary> /// <param name="appVersion">The instance to retrieve the current application version.</param> /// <param name="options">The configurable options to specify how the version should be tracked in the response.</param> /// <param name="next">The next functionality in the request pipeline to be executed.</param> /// <param name="logger">The logger to write diagnostic trace messages during the addition of the application version to the response.</param> /// <exception cref="ArgumentNullException">Thrown when the <paramref name="appVersion"/>, <paramref name="options"/>, or <paramref name="next"/> is <c>null</c>.</exception> public VersionTrackingMiddleware( IAppVersion appVersion, VersionTrackingOptions options, RequestDelegate next, ILogger <VersionTrackingMiddleware> logger) { Guard.NotNull(appVersion, nameof(appVersion), "Requires an instance to retrieve the current application version to add the version to the response"); Guard.NotNull(next, nameof(next), "Requires a continuation delegate to move towards the next functionality in the request pipeline"); Guard.NotNull(options, nameof(options), "Requires version tracking options to specify how the application version should be tracked in the response"); _appVersion = appVersion; _options = options; _next = next; _logger = logger ?? NullLogger <VersionTrackingMiddleware> .Instance; }
/// <summary> /// Initializes a new instance of the <see cref="UpdateWindow"/> class. /// </summary> /// <param name="newVersion">New Version.</param> /// <param name="currentVersion">Current Version.</param> public UpdateWindow(IAppVersion newVersion, System.Version currentVersion) { this.InitializeComponent(); MouseDown += delegate { DragMove(); }; this._newVersion = newVersion; this.txtTopic.Text = String.Format(LocalizedStrings.LocalizedResources.UpdateHeader, newVersion.Title); this.txtText.Text = String.Format(LocalizedStrings.LocalizedResources.UpdateText, newVersion.Title, currentVersion.ToString(), newVersion.Version); this.txtReleaseNotes.Text = LocalizedStrings.LocalizedResources.ReleaseNotes; if (!string.IsNullOrWhiteSpace(newVersion.Notes)) { this.releaseNotes.NavigateToString(newVersion.Notes); this.releaseNotes.Navigating += (sender, args) => { Process.Start(args.Uri.ToString()); args.Cancel = true; }; } }
#pragma warning disable 1998 /// <summary> /// Downloads the new version to a temporary folder and provides the generated filename. /// The progress delegate returns, if the download process should be canceled. Return false, if not. /// </summary> /// <param name="this">The this.</param> /// <param name="progress">The progress.</param> /// <param name="completed">callbakc when download is completed.</param> /// <returns> /// Filename of the msi-file /// </returns> public static async Task <string> DownloadMsi(this IAppVersion @this, Func <DownloadProgressInformation, bool> progress = null, Action completed = null) { var tmpFilenameWithPath = Path.GetTempFileName(); var msiFilenameWithPath = Path.GetFileNameWithoutExtension(tmpFilenameWithPath); msiFilenameWithPath += ".msi"; msiFilenameWithPath = Path.Combine(Path.GetDirectoryName(tmpFilenameWithPath), msiFilenameWithPath); File.Move(tmpFilenameWithPath, msiFilenameWithPath); var uri = new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + HockeyClient.Current.AsInternal().AppIdentifier + "/app_versions/" + @this.Id + ".msi"); WebClient wc = new WebClient(); if (progress != null) { wc.DownloadProgressChanged += (a, b) => { if (progress(new DownloadProgressInformation(b.ProgressPercentage, b.BytesReceived, b.TotalBytesToReceive))) { wc.CancelAsync(); } ; }; } if (completed != null) { wc.DownloadFileCompleted += (a, b) => completed(); } wc.DownloadFileAsync(uri, msiFilenameWithPath); if (_downloadFilesnames.ContainsKey(@this.AppId)) { _downloadFilesnames[@this.AppId] = msiFilenameWithPath; } else { _downloadFilesnames.Add(@this.AppId, msiFilenameWithPath); } return(msiFilenameWithPath); }
internal async void DoUpdate(IAppVersion availableUpdate) { var aetxUri = new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + HockeyClient.Current.AsInternal().AppIdentifier + ".aetx", UriKind.Absolute); var downloadUri = new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + HockeyClient.Current.AsInternal().AppIdentifier + "/app_versions/" + availableUpdate.Id + ".appx", UriKind.Absolute); Exception installError = null; try { var result = await InstallationManager.AddPackageAsync(availableUpdate.Title, downloadUri); } catch (Exception e) { installError = e; HockeyClient.Current.AsInternal().HandleInternalUnhandledException(e); } if (installError != null) { await new MessageDialog(String.Format(LocalizedStrings.LocalizedResources.UpdateAPIError, installError.Message)).ShowAsync(); await Launcher.LaunchUriAsync(downloadUri).AsTask(); } }
private async Task <IAppVersion> CheckForUpdates() { if (System.Version.TryParse(HockeyClient.Current.AsInternal().VersionInfo, out this._localVersion)) { var appVersions = await HockeyClient.Current.AsInternal().GetAppVersionsAsync(); IAppVersion newest = appVersions.FirstOrDefault(); if (newest != null) { this._logger.Info("Found remote version. Version = " + newest.Version); Version remoteVersion = null; if (Version.TryParse(newest.Version, out remoteVersion)) { if (remoteVersion > this._localVersion) { this._logger.Info("Remote version is newer than local version."); return(newest); } else { this._logger.Info("Local version is up to date."); } } else { this._logger.Warn("Remote version cannot be formatted to System.Version. CheckForUpdates canceled. Remote version: " + newest.Version); } } else { this._logger.Warn("No remote version found!"); } } else { this._logger.Warn("Local version cannot be formatted to System.Version. CheckForUpdates canceled. Local version: " + HockeyClient.Current.AsInternal().VersionInfo); } return(null); }
private void StartUi(IAppVersion newVersion) { UpdateWindow window = new UpdateWindow(newVersion, this._localVersion); Dispatcher.CurrentDispatcher.Invoke((Action) (() => { window.Show(); }) ); }
/// <summary> /// Initializes a new instance of the <see cref="VersionEnricher"/> class. /// </summary> /// <param name="appVersion">The instance to retrieve the current application version.</param> /// <exception cref="ArgumentNullException">Thrown when the <paramref name="appVersion"/> is <c>null</c>.</exception> public VersionEnricher(IAppVersion appVersion) : this(appVersion, DefaultPropertyName) { }
public ValuesController(IAppVersion appVersion, IHttpContextAccessor accessor) { _AppVersion = appVersion; _accessor = accessor; }
private void StartUi(IAppVersion newVersion) { UpdateWindow window = new UpdateWindow(newVersion, this._localVersion); Dispatcher.CurrentDispatcher.Invoke((Action)(() => { window.Show(); })); }
internal async void DoUpdate(IAppVersion availableUpdate) { var aetxUri = new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + HockeyClient.Current.AsInternal().AppIdentifier + ".aetx", UriKind.Absolute); var downloadUri = new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + HockeyClient.Current.AsInternal().AppIdentifier + "/app_versions/" + availableUpdate.Id + ".xap", UriKind.Absolute); Exception installError = null; try { var result = await InstallationManager.AddPackageAsync(availableUpdate.Title, downloadUri); } catch (Exception e) { installError = e; HockeyClient.Current.AsInternal().HandleInternalUnhandledException(e); } if (installError != null) { MessageBox.Show(String.Format(LocalizedStrings.LocalizedResources.UpdateAPIError, installError.Message)); WebBrowserTask webBrowserTask = new WebBrowserTask(); webBrowserTask.Uri = downloadUri; webBrowserTask.Show(); } }