Пример #1
0
        protected override async Task OnTimer()
        {
            try
            {
                //Skip if network not available
                if (!NetworkStatus.CanDownload(_downloadNetworkPriority))
                {
                    _logger?.LogInformation($"Skip package download due to network not allowed to download.");
                    return;
                }

                _logger?.LogDebug($"Running package updater. Downloading {this.PackageVersion}.");
                PackageVersionInfo packageVersion = await GetPackageVersionInformation();

                var     desiredVersion   = UpdateUtility.ParseVersion(packageVersion.Version);
                Version installedVersion = GetInstalledVersion();
                if (desiredVersion.CompareTo(installedVersion) != 0)
                {
                    _logger?.LogInformation($"The desired version of {desiredVersion} is different to installed version {installedVersion}.");
                    await DownloadAndInstallNewVersionAsync(packageVersion);
                }
            }
            catch (Exception ex)
            {
                _logger?.LogError($"Error download {this.PackageVersion}. Exception: {ex.ToMinimized()}");
            }
        }
Пример #2
0
 /// <summary>
 /// Check for agent update. It will trigger agent update if the desired version is different than the current running version.
 /// </summary>
 internal async Task CheckAgentUpdates()
 {
     _logger?.LogDebug($"Running package updater. Downloading {this.PackageVersion}.");
     PackageVersionInfo packageVersion = await GetPackageVersionInformation();
     var desiredVersion = UpdateUtility.ParseVersion(packageVersion.Version);
     Version installedVersion = GetInstalledVersion();
     if (desiredVersion.CompareTo(installedVersion) != 0)
     {
         _logger?.LogInformation($"The desired version of {desiredVersion} is different to installed version {installedVersion}.");
         await this.packageInstaller.DownloadAndInstallNewVersionAsync(packageVersion);
     }
 }
Пример #3
0
 private Version GetInstalledVersion()
 {
     try
     {
         //Enhance this method if we want to use it to install program other than KinesisTap.
         //We will need a new mechanism to check if the package is installed and get the installed version
         return(UpdateUtility.ParseVersion(ProgramInfo.GetKinesisTapVersion().FileVersion));
     }
     catch (Exception e)
     {
         _logger?.LogError($"Failed to get installed version: '{e}'");
         return(new Version("1.0.0")); // This is for TestIntegrationWithAutoUpdateService Unit test to pass
     }
 }
Пример #4
0
        protected override async Task OnTimer()
        {
            try
            {
                _logger?.LogDebug($"Running package updater. Downloading {this.PackageVersion}.");
                PackageVersionInfo packageVersion = await GetPackageVersionInformation();

                var     desiredVersion   = UpdateUtility.ParseVersion(packageVersion.Version);
                Version installedVersion = GetInstalledVersion();
                if (desiredVersion.CompareTo(installedVersion) != 0)
                {
                    _logger?.LogInformation($"The desired version of {desiredVersion} is different to installed version {installedVersion}.");
                    await DownloadAndInstallNewVersionAsync(packageVersion);
                }
            }
            catch (Exception ex)
            {
                _logger?.LogError($"Error download {this.PackageVersion}. Exception: {ex.ToAsyncString()}");
            }
        }
Пример #5
0
 private Version GetInstalledVersion()
 {
     //Enhance this method if we want to use it to install program other than KinesisTap.
     //We will need a new mechanism to check if the package is installed and get the installed version
     return(UpdateUtility.ParseVersion(ProgramInfo.GetKinesisTapVersion().FileVersion));
 }