public override void initializeData() { lvwPublishWith.ItemChecked -= lvwPublishWith_ItemChecked; _package = (updatePackage)Argument; pageName = _package.ToString(); Title = string.Format("Updatepaket Version {0}", _package); lblSize.Text = string.Format("Größe: {0}", updateSystemDotNet.Core.Helper.GetFileSize(_package.packageSize)); lblLastPublishedDescription.Text = string.Format("{0}{1}", lblLastPublishedBase, _package.publishDate == DateTime.MinValue ? "Noch nie" : string.Format("{0} (am {1} um {2})", Session.relativeDate(_package.publishDate), _package.publishDate.ToShortDateString(), _package.publishDate.ToShortTimeString())); //Veröffentlichungsschnittstellen lvwPublishWith.Items.Clear(); foreach(var pbProvider in Session.currentProject.publishProvider) { if(!pbProvider.Settings.isActive) continue; var item = new ListViewItem { Text = string.Format("{0} (via {1})", pbProvider.Settings.Name, Session.publishFactory.availableProvider[ pbProvider.GetType()].Name), Checked = Session.updateFactory.isUpdateLinked(_package, pbProvider), Tag = pbProvider }; lvwPublishWith.Items.Add(item); } lvwPublishWith.ItemChecked += lvwPublishWith_ItemChecked; }
/// <summary>Überprüft ob die ausgewählten Filterkriterien an einem Updatepaket.</summary> /// <param name="package">Das Updatepaket was überprüft werden soll.</param> /// <returns>Gibt True zurück wenn die Filterkriterien erfüllt werden, andernfalls False.</returns> public bool appliesFilter(updatePackage package) { if(!string.IsNullOrEmpty(filterTerm)) { var comparsionText = (package.Description + package.releaseInfo.Version).ToLower(); return comparsionText.Contains(filterTerm.ToLower()); } if (hideNonReleasedPackages && !package.Published) return false; if (showOnlyServicePacks && !package.isServicePack) return false; return true; }
/// <summary> /// Gibt ein <see cref="changelogDocument"/> passend zum übergebenen Updatepaket zurück. /// </summary> /// <param name="package">Das Updatepaket zu welchem der Changelog gesucht werden soll.</param> /// <returns>Gibt ein <see cref="changelogDocument"/> zurück.</returns> public changelogDocument this[updatePackage package] { get { foreach (var item in this) { if (package.releaseInfo.Equals(item.Key.releaseInfo) && package.TargetArchitecture == item.Key.Architecture) { return(item.Value); } } return(null); } }
public override void initializeData() { lvwPublishWith.ItemChecked -= lvwPublishWith_ItemChecked; _package = (updatePackage)Argument; //Load Publishinterfaces lvwPublishWith.Items.Clear(); foreach(var pbProvider in Session.currentProject.publishProvider) { if(!pbProvider.Settings.isActive) continue; var item = new ListViewItem { Text = string.Format("{0} (via {1})", pbProvider.Settings.Name, Session.publishFactory.availableProvider[ pbProvider.GetType()].Name), Checked = Session.updateFactory.isUpdateLinked(_package, pbProvider), Tag = pbProvider }; lvwPublishWith.Items.Add(item); } lvwPublishWith.ItemChecked += lvwPublishWith_ItemChecked; }
/// <summary>Überprüft ob ein Update mit einer Veröffentlichungsschnittstelle verknüpft ist.</summary> public bool isUpdateLinked(updatePackage update, IPublishProvider provider) { //Erstmal prüfen ob die LinkListe zum passenden Updatepaket nicht null ist. if (!_session.currentProject.linkedPublishProvider.ContainsKey(update.ID) || _session.currentProject.linkedPublishProvider[update.ID] == null) return false; //Und jetzt prüfen ob die ID des Providers schon in der LinkListe vorhanden ist. return _session.currentProject.linkedPublishProvider[update.ID].Contains(provider.Settings.Id); }
/// <summary>Entfernt die Verknüpfung zwischen einem Update und einer Veröffentlichungsschnittstelle.</summary> public void unlinkUpdate(updatePackage update, IPublishProvider provider) { //Ist nicht verlinkt, also gibts auch nichts zum löschen if (!isUpdateLinked(update, provider)) return; //Linkeintrag entfernen _session.currentProject.linkedPublishProvider[update.ID].Remove(provider.Settings.Id); }
/// <summary>Verknüoft ein Updatepaket mit einer Veröffentlichungsschnittstelle.</summary> public void linkUpdate(updatePackage update, IPublishProvider provider) { //Bereits verlinkte Provider braucht man nicht nochmal verlinken if (isUpdateLinked(update, provider)) return; if (!_session.currentProject.linkedPublishProvider.ContainsKey(update.ID)) _session.currentProject.linkedPublishProvider.Add(update.ID, new List<string>(new[] {provider.Settings.Id})); else _session.currentProject.linkedPublishProvider[update.ID].Add(provider.Settings.Id); }
private readonly TimeSpan m_timeout = new TimeSpan(0, 0, 10); //Timeout für den Service Start/Stopp public applyStartServiceAction(actionBase Action, InternalConfig config, updatePackage currentPackage) : base(Action, config, currentPackage) { }
private string getReleaseDateByVersion(releaseInfo rInfo, updatePackage.SupportedArchitectures target) { foreach (updatePackage package in m_result) { if (package.releaseInfo.Equals(rInfo) && package.TargetArchitecture.Equals(target)) { DateTime releaseDate; DateTime.TryParse(package.ReleaseDate, out releaseDate); return releaseDate.ToShortDateString(); } } return string.Empty; }
/// <summary>Ermittelt aus einer ID die dazugehörige updateAction aus einem bestimmten Updatepaket.</summary> public KeyValuePair<actionBase, administrationEditorAttribute> findActionById(string id, updatePackage package) { foreach (PropertyInfo property in package.GetType().GetProperties()) { if (!property.Name.ToLower().Contains("actions")) continue; Type propertyType = property.PropertyType; if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof (List<>)) { //Anzahl aktionen in der Liste auslesen object instance = property.GetValue(package, null); var count = (int) instance.GetType().GetProperty("Count").GetValue(instance, null); //Alle aktionen auslesen und ID vergleichen if (count > 0) { for (int i = 0; i < count; i++) { var action = (actionBase) instance.GetType().GetProperty("Item").GetValue(instance, new object[] {i}); if (action == null) continue; if (action.ID.Equals(id)) { return new KeyValuePair<actionBase, administrationEditorAttribute>( action, action.GetType().GetCustomAttributes(typeof (administrationEditorAttribute), true)[0] as administrationEditorAttribute); } } } } } throw new Exception(string.Format("Die Aktion mit der ID '{0}' konnte im Updatepaket nicht gefunden werden.", id)); }
public prepareEditPackageResult prepareEditUpdatePackage(updatePackage package) { var result = new prepareEditPackageResult(); //Temporäres Verzeichnis für die Updatedaten erstellen string tempPackagePath = Path.Combine(Environment.GetEnvironmentVariable("tmp"), package.ID); result.tempPackagePath = tempPackagePath; result.updatePackage = package; if (!Directory.Exists(tempPackagePath)) Directory.CreateDirectory(tempPackagePath); //Pfad zum Updatepaket ermitteln string packagePath = Path.Combine(Path.Combine(_session.currentProjectDirectory, "Updates"), package.getFilename()); if (!File.Exists(packagePath)) throw new FileNotFoundException("Das Updatepaket konnte nicht gefunden werden.", packagePath); //Updatepaket öffnen using(var fsPackage = File.OpenRead(packagePath)) { using(var packageReader = new ResourceReader(fsPackage)) { //Dateien entpacken und im Tempverzeichnis abspeichern foreach (var copyAction in package.fileCopyActions) { foreach (var file in copyAction.Files) { string newFilename = string.Format("{0}.{1}", file.ID, file.Filename); using(var fsFileOut = new FileStream(Path.Combine(tempPackagePath, newFilename), FileMode.Create)) { byte[] resourceData; string tempType; //ungenutzt aber trotzdem notwendig packageReader.GetResourceData(file.ID, out tempType, out resourceData); byte[] decompressedData = decompressData(resourceData); fsFileOut.Write(decompressedData, 0, decompressedData.Length); } //Neuen Dateinamen in Updatepaket übernehmen file.Fullpath = Path.Combine(tempPackagePath, newFilename); } } } } //Changelog lesen string changelogPath = Path.Combine(Path.Combine(_session.currentProjectDirectory, "Updates"), package.getChangelogFilename()); if(!File.Exists(changelogPath)) throw new FileNotFoundException("Der Changelog konnte nicht gefunden werden", changelogPath); using(var fsChangelog = new StreamReader(changelogPath, Encoding.UTF8)) { var xmlChangelog = new XmlDocument(); xmlChangelog.Load(fsChangelog); XmlNodeList changelogItems = xmlChangelog.SelectNodes("updateSystemDotNet.Changelog/Items/Item"); if(changelogItems == null) throw new InvalidOperationException("Es konnte im Changelog keine Änderungseinträge gefunden werden."); if (changelogItems.Count >= 1 && changelogItems[0].SelectSingleNode("Change") != null) result.changelogGerman = changelogItems[0].SelectSingleNode("Change").InnerText; if (changelogItems.Count >= 2 && changelogItems[1].SelectSingleNode("Change") != null) result.changelogEnglish = changelogItems[1].SelectSingleNode("Change").InnerText; } return result; }
/// <summary> /// Funktion welche die UpdateAction zu einer ID sucht. /// </summary> /// <param name="ID">Die ID nach der gesucht werden soll.</param> /// <param name="currentPackage">Das aktuelle Updatepaket.</param> /// <returns>Gibt die applyUpdateAction zu der ID zurück.</returns> private applyUpdateBase getActionById(string ID, updatePackage currentPackage) { foreach (closeProcessAction closeProcessActionItem in currentPackage.closeProcessActions) { if (closeProcessActionItem.ID.Equals(ID)) { return new applyCloseProcessAction(closeProcessActionItem, m_config, currentPackage); } } foreach (startProcessAction startProcessActionItem in currentPackage.startProcessActions) { if (startProcessActionItem.ID.Equals(ID)) { return new applyStartProcessAction(startProcessActionItem, m_config, currentPackage); } } foreach (fileCopyAction fileCopyActionItem in currentPackage.fileCopyActions) { if (fileCopyActionItem.ID.Equals(ID)) { return new applyFileCopyAction(fileCopyActionItem, m_config, currentPackage); } } foreach (renameFileAction renameFileActionItem in currentPackage.renameFileActions) { if (renameFileActionItem.ID.Equals(ID)) { return new applyRenameFileAction(renameFileActionItem, m_config, currentPackage); } } foreach (deleteFilesAction deleteFileActionItem in currentPackage.deleteFilesActions) { if (deleteFileActionItem.ID.Equals(ID)) { return new applyDeleteFileAction(deleteFileActionItem, m_config, currentPackage); } } foreach (startServiceAction startServiceActionItem in currentPackage.startServiceActions) { if (startServiceActionItem.ID.Equals(ID)) { return new applyStartServiceAction(startServiceActionItem, m_config, currentPackage); } } foreach (stopServiceAction stopServiceActionItem in currentPackage.stopServiceActions) { if (stopServiceActionItem.ID.Equals(ID)) { return new applyStopServiceAction(stopServiceActionItem, m_config, currentPackage); } } foreach (addRegistryKeyAction addRegistryKeyActionItem in currentPackage.addRegistryKeyActions) { if (addRegistryKeyActionItem.ID.Equals(ID)) { return new applyAddRegistryKeyAction(addRegistryKeyActionItem, m_config, currentPackage); } } foreach (addRegistryValueAction addRegistryValueActionItem in currentPackage.addRegistryValueActions) { if (addRegistryValueActionItem.ID.Equals(ID)) { return new applyAddRegistryValueAction(addRegistryValueActionItem, m_config, currentPackage); } } foreach (removeRegistryKeyAction removeRegistryKeyActionItem in currentPackage.removeRegistryKeyActions) { if (removeRegistryKeyActionItem.ID.Equals(ID)) { return new applyRemoveRegistryKeyAction(removeRegistryKeyActionItem, m_config, currentPackage); } } foreach (removeRegistryValuesAction removeRegistryValueActionItem in currentPackage.removeRegistryValueActions) { if (removeRegistryValueActionItem.ID.Equals(ID)) { return new applyRemoveRegistryValueAction(removeRegistryValueActionItem, m_config, currentPackage); } } foreach (userInteractionAction userInteractionActionItem in currentPackage.userInteractionActions) { if (userInteractionActionItem.ID.Equals(ID)) { return new applyUserInteractionAction(userInteractionActionItem, m_config, currentPackage); } } return null; }
/// <summary> /// Initialisiert eine neue Instanz von <see cref="enhancedVersion"/>. /// </summary> /// <param name="rInfo">Das Versionsobjekt welches für diese Instanz verwendeten werden soll.</param> /// <param name="architecture">Die Prozessorarchitektur für welche dieses Versionsobjekt gültig ist.</param> internal enhancedVersion(releaseInfo rInfo, updatePackage.SupportedArchitectures architecture) { releaseInfo = rInfo; Architecture = architecture; }
internal confirmUpdatePackageEventArgs(updatePackage package) { updatePackage = package; }
private updatePackage createNewUpdatePackage() { var package = new updatePackage { ID = _onEdit ? _packageId : Guid.NewGuid().ToString(), releaseInfo = new releaseInfo( string.Format("{0}.{1}.{2}.{3}", new[] { nmMajor.Value.ToString(CultureInfo.InvariantCulture), nmMinor.Value.ToString(CultureInfo.InvariantCulture), nmBuild.Value.ToString(CultureInfo.InvariantCulture), nmRevision.Value.ToString(CultureInfo.InvariantCulture) }), (releaseTypes) cboReleaseState.SelectedIndex, (int) nmPreviewState.Value), Description = txtDescription.Text, Published = chkPublished.Checked, isServicePack = chkServicePack.Checked, ReleaseDate = DateTime.Now.ToString(new CultureInfo("de-de")), TargetArchitecture = (updatePackage.SupportedArchitectures) cboTargetArchitecture.SelectedIndex, useNewFileFormat = true }; //Verfügbarkeit if (rbCustomVersions.Checked) { package.UseOwnVersionList = true; foreach (string item in lstCustomVersions.Items) package.OwnVersionList.Add(new VersionEx(item)); } //CustomFields foreach (ListViewItem lviCF in lvwCustomFields.Items) package.customFields.Add(lviCF.Text, lviCF.SubItems[1].Text); //Link/Unlink Publishprovider foreach (ListViewItem lvwItem in lvwPublishWith.Items) { if (lvwItem.Checked) Session.updateFactory.linkUpdate(package, (IPublishProvider)lvwItem.Tag); else Session.updateFactory.unlinkUpdate(package, (IPublishProvider) lvwItem.Tag); } //Updateaktionen foreach (TreeNode node in tvwContent.Nodes["nodeActions"].Nodes) { var action = (KeyValuePair<actionBase, administrationEditorAttribute>) node.Tag; package.actionOrder.Add(action.Key.ID); Session.updateFactory.addActionToPackage(action.Key, package); } return package; }
/// <summary>Lädt ein Projekt zum bearbeiten in den Dialog</summary> public void loadUpdatePackage(updatePackage package, string changesGerman, string changesEnglish, bool setEditFlag) { //Texte setzen if (setEditFlag) { Text = string.Format("{0} - Updatepaket bearbeiten", Strings.applicationName); btnOk.Text = "Updatepaket bearbeiten"; _onEdit = true; _packageId = package.ID; } //Allgemeine Daten if (!string.IsNullOrEmpty(package.releaseInfo.Version)) { var packageVersion = new Version(package.releaseInfo.Version); nmMajor.Value = packageVersion.Major; nmMinor.Value = packageVersion.Minor; nmBuild.Value = packageVersion.Build; nmRevision.Value = packageVersion.Revision; } cboReleaseState.SelectedIndex = (int) package.releaseInfo.Type; nmPreviewState.Value = package.releaseInfo.Step; cboTargetArchitecture.SelectedIndex = (int) package.TargetArchitecture; txtDescription.Text = package.Description; chkPublished.Checked = package.Published; chkServicePack.Checked = package.isServicePack; //Verfügbarkeit if (package.UseOwnVersionList) rbCustomVersions.Checked = true; else rbAllVersions.Checked = true; foreach (VersionEx version in package.OwnVersionList) { lstCustomVersions.Items.Add(version.ToString()); } //Changelogs txtChanges.Text = changesGerman; _changelogDe = changesGerman; _changelogEn = changesEnglish; //CustomFields foreach (var customField in package.customFields) { lvwCustomFields.Items.Add( new ListViewItem(new[] {customField.Key, customField.Value})); } //Link PublishProvider foreach (ListViewItem lvwItem in lvwPublishWith.Items) { var provider = (IPublishProvider) lvwItem.Tag; lvwItem.Checked = Session.updateFactory.isUpdateLinked(package, provider); } //Aktionen laden Session.updateFactory.availableUpdateActions(); foreach (string id in package.actionOrder) { addAction(Session.updateFactory.findActionById(id, package), false); } }
public applyRenameFileAction(actionBase Action, InternalConfig config, updatePackage currentPackage) : base(Action, config, currentPackage) { }
/// <summary> /// Initialisiert eine neue Instanz der <see cref="applyUpdateBase"/>Action. /// </summary> /// <param name="Action">Die Updateaction</param> /// <param name="Config">Die Konfiguration.</param> public applyUpdateBase(actionBase Action, InternalConfig Config, updatePackage currentPackage) : this(Action) { m_config = Config; m_currentPackage = currentPackage; }
/// <summary>Entfernt ein Updatepaket aus dem Projekt.</summary> public void removeUpdatePackage(updatePackage package) { //Updatepaket löschen string packagePath = Path.Combine(Path.Combine(Path.GetDirectoryName(_session.currentProjectPath), "Updates"), package.getFilename()); if(File.Exists(packagePath)) File.Delete(packagePath); //Changelog löschen string changelogPath = Path.Combine(Path.Combine(Path.GetDirectoryName(_session.currentProjectPath), "Updates"), package.getChangelogFilename()); if(File.Exists(changelogPath)) File.Delete(changelogPath); //Von allen Providern die Verknüpfung zu diesem Projekt entfernen foreach (var provider in _session.currentProject.publishProvider) unlinkUpdate(package, provider); //Paket aus dem Projekt werfen _session.currentProject.updatePackages.Remove(package); }
public void buildUpdatePackage(updatePackage package, string changesDe, string changesEn) { //Argumente prüfen if (package == null) throw new ArgumentException("package"); if (string.IsNullOrEmpty(changesDe) && string.IsNullOrEmpty(changesEn)) throw new ArgumentException("changesDe und changesEn"); //Prüfen ob das Projekt schon gespeichert wurde (notwendig!) if (string.IsNullOrEmpty(_session.currentProjectPath)) throw new Exception("Das Projekt muss gespeichert werden bevor Updatepakete erstellt werden können."); //Lokales Basisverzeichnis für die Aktualisieren bestimmen. string updateDirectory = Path.Combine(Path.GetDirectoryName(_session.currentProjectPath), _projectStructure[0]); //Updatepaket für die Dateien erstellen using (var fsUpdatePackage = new FileStream(Path.Combine(updateDirectory, package.getFilename()), FileMode.Create)) { using (var writer = new ResourceWriter(fsUpdatePackage)) { //Jede Datei ins Paket schreiben und vorher komprimieren foreach (var fcAction in package.fileCopyActions) foreach (var fileData in fcAction.Files) if (File.Exists(fileData.Fullpath)) writer.AddResourceData(fileData.ID, "fileCopyActionData", compressData(File.ReadAllBytes(fileData.Fullpath))); writer.Generate(); } } //Paketgröße setzen package.packageSize = new FileInfo(Path.Combine(updateDirectory, package.getFilename())).Length; string packageHash = Convert.ToBase64String( SHA512.Create().ComputeHash(File.ReadAllBytes(Path.Combine(updateDirectory, package.getFilename())))); package.packageSignature = updateSystemDotNet.Core.RSA.Sign(packageHash, _session.currentProject.keyPair.privateKey); //Changelog erstellen und speichern XmlDocument xChangelog = createChangelogs(changesDe, changesEn); using(var xWriter = new StreamWriter(Path.Combine(updateDirectory,package.getChangelogFilename()), false,Encoding.UTF8)) { xChangelog.Save(xWriter); } }
private void beginEditPackage() { //Updatepaket für das Bearbeiten vorbeiten var prepareResult = Session.updateFactory.prepareEditUpdatePackage(_package); //Dialog zur Bearbeitung des Updatepaketes anzeigen if (Session.showDialog<Dialogs.updatePackageDialog>(ParentForm, prepareResult) == DialogResult.OK) { //Den alten Paketverweis aus dem Projekt entfernen Session.currentProject.updatePackages.Remove(_package); _package = (updatePackage)Session.dialogResultCache[typeof(Dialogs.updatePackageDialog)]; Session.currentProject.updatePackages.Add(_package); Session.saveProject(); } //Temporär erzeugte Daten verwerfen Session.updateFactory.cleanupEditUpdatePackage(prepareResult); }
/// <summary>Fügt einem Updatepaket eine beliebige Updateaction hinzu.</summary> /// <param name="action">Die updateAction die hinzugefügt werden soll.</param> /// <param name="package">Das Updatepaket in welche die updateAction hinzugefügt werden soll.</param> /// <returns>Gibt True zurück wenn die updateAction erfolgreich hinzugefügt wurde, andernfalls False.</returns> public bool addActionToPackage(actionBase action, updatePackage package) { foreach (PropertyInfo property in package.GetType().GetProperties()) { if (!property.Name.ToLower().Contains(action.GetType().Name.ToLower())) continue; object instance = property.GetValue(package, null); MethodInfo mInfo = instance.GetType().GetMethod("Add"); mInfo.Invoke(instance, new object[] {action}); return true; } return false; }
public applyCloseProcessAction(actionBase Action, InternalConfig config, updatePackage currentPackage) : base(Action, config, currentPackage) { }
public applyFileCopyAction(actionBase action, InternalConfig config, updatePackage currentPackage) : base(action, config, currentPackage) { }
public applyValidatePackageSignature(actionBase action, InternalConfig config, updatePackage package) : base(action, config, package) { }
/// <summary> /// Gibt den Packagepräfix an Hand der Zielarchitektur zurück /// </summary> /// <param name="architecure">Zielarchitektur</param> /// <returns></returns> public static string getPraefix(updatePackage.SupportedArchitectures architecure) { switch (architecure) { case updatePackage.SupportedArchitectures.Both: return "bth_"; case updatePackage.SupportedArchitectures.x86: return "x86_"; case updatePackage.SupportedArchitectures.x64: return "x64_"; } return "bth_"; }
public applyUserInteractionAction(actionBase action, InternalConfig config, updatePackage currentPackage) : base(action, config, currentPackage) { }
public applyAddRegistryValueAction(actionBase Action, InternalConfig config, updatePackage currentPackage) : base(Action, config, currentPackage) { }
public applyStartProcessAction(actionBase action, InternalConfig config, updatePackage currentPackage) : base(action, config, currentPackage) { }
public updatePackageBuiltEventArgs(updatePackage package, Exception ex) { Package = package; Exception = ex; }
private void beginEditPackage() { //Prepare Package for editing (unpack files, etc...) var prepareResult = Session.updateFactory.prepareEditUpdatePackage(_package); //show Dialog and wait until it's closed if (Session.showDialog<Dialogs.updatePackageDialog>(ParentForm, prepareResult) == DialogResult.OK) { Session.currentProject.updatePackages.Remove(_package); _package = (updatePackage)Session.dialogResultCache[typeof(Dialogs.updatePackageDialog)]; Session.currentProject.updatePackages.Add(_package); Session.saveProject(); } //Remove cached files Session.updateFactory.cleanupEditUpdatePackage(prepareResult); }