Exemplo n.º 1
0
 public void cleanupEditUpdatePackage(prepareEditPackageResult prepareResult)
 {
     //Temporäre Daten löschen
     if (Directory.Exists(prepareResult.tempPackagePath))
     {
         Directory.Delete(prepareResult.tempPackagePath, true);
     }
 }
Exemplo n.º 2
0
		public void cleanupEditUpdatePackage(prepareEditPackageResult prepareResult) {
			
			//Temporäre Daten löschen
			if (Directory.Exists(prepareResult.tempPackagePath))
				Directory.Delete(prepareResult.tempPackagePath, true);

		}
Exemplo n.º 3
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;
		}
Exemplo n.º 4
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);
        }