/// <summary> /// Kontruktor /// </summary> /// <param name="Settings">Die lokalen Updateeinstellungen</param> /// <param name="Result">Das Suchresultat</param> /// <param name="Config">Die heruntergeladene Updatekonfiguration</param> /// <param name="changelogs">Die Changelogs</param> /// <param name="requestElevation">Gibt an, ob eine Elevation notwendig ist.</param> public updatePreviewDialog(UpdateSettings Settings, List <updatePackage> Result, updateConfiguration Config, changelogDictionary changelogs, bool requestElevation) { InitializeComponent(); Font = SystemFonts.MessageBoxFont; SizeChanged += UpdateDialog_SizeChanged; //Setze private Variablen m_settings = Settings; m_result = Result; m_config = Config; m_changelogs = changelogs; //Setze Sprachstrings lblStatus.Text = localizationHelper.Instance.controlText(lblStatus); btnCancel.Text = localizationHelper.Instance.controlText(btnCancel); btnStartUpdate.Text = localizationHelper.Instance.controlText(btnStartUpdate); lblCurrentVersion.Text = string.Format(localizationHelper.Instance.controlText(lblCurrentVersion), Settings.releaseInfo.Version); if (Settings.releaseInfo.Type != releaseTypes.Final) { lblCurrentVersion.Text += string.Format(" ({0} {1})", Settings.releaseInfo.Type.ToString(), Settings.releaseInfo.Step.ToString(CultureInfo.InvariantCulture)); } if (Result.Count > 0) { lblNewestVersion.Text = string.Format(localizationHelper.Instance.controlText(lblNewestVersion), Result[Result.Count - 1].releaseInfo.Version); if (Result[Result.Count - 1].releaseInfo.Type != releaseTypes.Final) { lblNewestVersion.Text += string.Format(" ({0} {1})", Result[Result.Count - 1].releaseInfo.Type.ToString(), Result[Result.Count - 1].releaseInfo.Step.ToString(CultureInfo.InvariantCulture)); } } Text = m_config.applicationName; //Updatedetails erstellen buildUpdateDetails(); //Setze vor den Start-Button ein Schild wenn der Benutzer nicht über Administratorrechte verfügt if (!IsAdmin() && Environment.OSVersion.Version.Major >= 6 && requestElevation) { SendMessage(new HandleRef(btnStartUpdate, btnStartUpdate.Handle), 0x160c, IntPtr.Zero, new IntPtr(1)); btnStartUpdate.MinimumSize = new Size( btnStartUpdate.Width + 20, //Etwas platz für das ShieldIcon schaffen btnStartUpdate.MinimumSize.Height); } //Setze Anwendungsbild try { imgApp.Image = Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location).ToBitmap(); } catch { imgApp.Image = SystemIcons.Application.ToBitmap(); } }
private void downloadUpdatePackages(updateConfiguration configuration, string destination, string updateUrl) { string updateDirectory = Path.Combine(destination, "Updates"); string downloadUrl = updateUrl; if (!downloadUrl.EndsWith("/")) { downloadUrl = downloadUrl + "/"; } downloadUrl = downloadUrl + "updates/"; var client = Session.createWebClient(); //Download Updatepackages and Changelogs foreach (var package in configuration.updatePackages) { //Download Updatepackage client.DownloadFile(string.Format("{0}{1}", downloadUrl, package.getFilename()), Path.Combine(updateDirectory, package.getFilename())); //Download Changelog client.DownloadFile(string.Format("{0}{1}", downloadUrl, package.getChangelogFilename()), Path.Combine(updateDirectory, package.getChangelogFilename())); } }
public updateDownloader(updateController instance, UpdateResult result) { _currentConfiguration = result.Configuration; _currentInstance = instance; _highestVersion = result.newUpdatePackages[result.newUpdatePackages.Count - 1].releaseInfo.Version; //WebClient initialisieren _wclDownload = new WebClient(); _wclDownload.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); //Proxyeinstellungen setzen if (instance.proxyEnabled) { _wclDownload.Proxy = new WebProxy(instance.proxyUrl, instance.proxyPort); if (!string.IsNullOrEmpty(instance.proxyUsername)) { _wclDownload.Proxy.Credentials = new NetworkCredential(instance.proxyUsername, instance.proxyPassword); } else if (instance.proxyUseDefaultCredentials) { _wclDownload.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials; } } //Falls eine Authentifizierung erforderlich ist if (instance.authenticationMode == authenticationModes.Credentials) { _wclDownload.Credentials = new NetworkCredential( instance.authenticationUsername, instance.authenticationPassword); } //SSLFehler umleiten und ignorieren ServicePointManager.ServerCertificateValidationCallback += OnCheckSSLCert; //Urls erzeugen //updateInstaller //UpdateInstaller - Manifest _urls = new List <string> { internalHelper.prepareUpdateLocation(instance.updateLocation) + "updateInstaller.zip", internalHelper.prepareUpdateLocation(instance.updateLocation) + "updateInstaller.xml" }; //Urls der Updatepakete erzeugen foreach (updatePackage package in result.newUpdatePackages) { _urls.Add(internalHelper.prepareUpdateLocation(instance.updateLocation, "updates") + package.getFilename()); } _wclDownload.DownloadFileCompleted += _wclDownload_DownloadFileCompleted; _wclDownload.DownloadProgressChanged += _wclDownload_DownloadProgressChanged; //Temporäres Verzeichnis erstellen _tempDirectory = instance.internalSettings.downloadLocation; if (!Directory.Exists(_tempDirectory)) { Directory.CreateDirectory(_tempDirectory); } }
/// <summary> /// Serialisiert die Konfigurationsdatei und gibt diese als String zurück /// </summary> /// <param name="Config">The Configurationinstance</param> /// <returns>string</returns> public static string Serialize(updateConfiguration Config) { using (var msData = new MemoryStream()) { using (var swData = new StreamWriter(msData, Encoding.UTF8)) { var xs = new XmlSerializer(typeof(updateConfiguration)); xs.Serialize(swData, Config); } return(Encoding.UTF8.GetString(msData.ToArray())); } }
/// <summary>Erstellt eine neue Updatekonfiguration mit den aktuellen Daten aus dem Projekt.</summary> protected byte[] buildConfiguration() { var configuration = new updateConfiguration { projectId = Session.currentProject.projectId, PublicKey = Session.currentProject.keyPair.publicKey, applicationName = Session.currentProject.projectName }; if (Session.currentProject.updateLogEnabled && Session.currentProject.updateLogUser.Verified) { configuration.linkedUpdateLogAccount = new updateLogLinkedAccount { serverUrl = Session.currentProject.updateLogUser.serverUrl } } ; else { configuration.linkedUpdateLogAccount = null; } configuration.generateNativeImages = Session.currentProject.generateNativeImages; configuration.startParameterSuccess = Session.currentProject.updateParameterSuccess; configuration.startParameterFailed = Session.currentProject.updateParameterFailed; configuration.setupId = Session.currentProject.updateSetupId; //Updatepakete hinzufügen foreach (var package in updatePackages) { configuration.updatePackages.Add(package); } //Konfiguration signieren und speichern var configurationContainer = new SecureContainer { Content = Serializer.Serialize(configuration) }; configurationContainer.Signature = RSA.Sign(configurationContainer.Content, Session.currentProject.keyPair.privateKey); return(configurationContainer.Save()); }
private void bgwSearch_DoWork(object sender, DoWorkEventArgs e) { try { /*Internal.Search.Provider provider = new updateSystemDotNet.Internal.Search.Provider((UpdateSettings)e.Argument); * provider.Search(); * m_config = provider.Configuration; * e.Result = provider.Result; * m_changelog = provider.Changelogs;*/ var sProvider = new searchProvider(_controller); sProvider.executeSearch(); var s = new ScheduledStart(_controller.projectId, _controller.updateCheckInterval, _controller.customUpdateCheckInterval); s.WriteCurrentDate(); m_config = sProvider.currentConfiguration; m_changelog = sProvider.correspondingChangelogs; e.Result = sProvider.foundUpdates; } catch (Exception ex) { e.Result = ex; } }
public updateLogRequest(updateController controller, updateConfiguration configuration) { _controller = controller; _configuration = configuration; }
/// <summary> /// Initialisiert eine neue Instanz des <see cref="UpdateResult"/>. /// </summary> /// <param name="Result">Das Suchresultat</param> /// <param name="Configuration">Die heruntergeladene Updatekonfiguration</param> /// <param name="changelogs">Ein Dictionary mit den Heruntergeladenen Changelogs.</param> public UpdateResult(List <updatePackage> Result, updateConfiguration Configuration, changelogDictionary changelogs) { m_newUpdates = Result; m_config = Configuration; Changelogs = changelogs; }
public downloadConfigurationCompletedEventArgs(updateConfiguration configuration) { Configuration = configuration; }