예제 #1
0
        /// <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);
        }
예제 #2
0
        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;
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        /// <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);
        }
예제 #6
0
        /// <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));
        }
예제 #7
0
        /// <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);
        }
예제 #8
0
        /// <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);
            }
        }
        /// <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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        public UpdateDialog(UpdateResult result, String oldVersion)
        {
            InitializeComponent();

            try
            {
                updatePackage update = result.newUpdatePackages[result.newUpdatePackages.Count - 1];
                string        str    = result.Changelogs[update].englishChanges;
                tbChangelog.AppendText(str + Environment.NewLine);
            }
            catch
            {
            }
            try
            {
                updatePackage update  = result.newUpdatePackages[result.newUpdatePackages.Count - 1];
                string        version = String.Format("{0}  to  {1}", oldVersion, update.Version);
                lbVersion.Text = version;
                Text           = "Update available " + version;
            }
            catch
            {
            }
        }
 public applyCloseProcessAction(actionBase Action, InternalConfig config, updatePackage currentPackage)
     : base(Action, config, currentPackage)
 {
 }
예제 #13
0
 public applyFileCopyAction(actionBase action, InternalConfig config, updatePackage currentPackage)
     : base(action, config, currentPackage)
 {
 }
 public applyValidatePackageSignature(actionBase action, InternalConfig config, updatePackage package)
     : base(action, config, package)
 {
 }
예제 #15
0
 /// <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;
 }
예제 #16
0
 internal confirmUpdatePackageEventArgs(updatePackage package)
 {
     updatePackage = package;
 }
 public updatePackageBuiltEventArgs(updatePackage package, Exception ex)
 {
     Package   = package;
     Exception = ex;
 }
예제 #18
0
        /// <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 applyAddRegistryKeyAction(actionBase Action, InternalConfig config, updatePackage currentPackage)
     : base(Action, config, currentPackage)
 {
 }
 public applyRenameFileAction(actionBase Action, InternalConfig config, updatePackage currentPackage)
     : base(Action, config, currentPackage)
 {
 }
예제 #21
0
 public applyStartProcessAction(actionBase action, InternalConfig config, updatePackage currentPackage)
     : base(action, config, currentPackage)
 {
 }
예제 #22
0
 public applyUserInteractionAction(actionBase action, InternalConfig config, updatePackage currentPackage)
     : base(action, config, currentPackage)
 {
 }
예제 #23
0
        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);
        }
예제 #24
0
 public applyRemoveRegistryValueAction(actionBase Action, InternalConfig config, updatePackage currentPackage)
     : base(Action, config, currentPackage)
 {
 }
예제 #25
0
 /// <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);
 }
예제 #26
0
 public applyStopServiceAction(actionBase Action, InternalConfig config, updatePackage currentPackage)
     : base(Action, config, currentPackage)
 {
 }
예제 #27
0
        /// <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));
        }