commit 9d3e1f28cea6d8d7bab11fbf550d7cc8fff83c26 Author: Eugen Höglinger Date: Mon Feb 22 08:26:13 2021 +0100 Initialized - Von SharpDevelop konvertiert - Localized für Englisch und Deutsch diff --git a/.vs/RunNxUpdate.git/v16/.suo b/.vs/RunNxUpdate.git/v16/.suo new file mode 100644 index 0000000..4c37386 Binary files /dev/null and b/.vs/RunNxUpdate.git/v16/.suo differ diff --git a/Daten/RunNxUpdate-ReadMe.txt b/Daten/RunNxUpdate-ReadMe.txt new file mode 100644 index 0000000..3ff82c7 --- /dev/null +++ b/Daten/RunNxUpdate-ReadMe.txt @@ -0,0 +1,19 @@ +RunNxUpdate +----------- + + +RunNxUpdate Updatet NX auf ein bestimmtes Maintenance Pack + + +RunNxUpdate.exe -updatefolder= -updateNr= + +-updatefolder Pfad in dem das Update liegt. + Vollständiger Pfad. In diesem Verzeichnis liegt die Datei + 'ugs_update.bat'. +-updateNr Bezeichnung die Eingetragen wird wenn das Update durch- + geführt wurde. + Die Nummer wird gebildet aus 'engel_' und dem Freigabedatum + des Updates. + +Beispiel: +RunNxUpdate.exe -updatefolder=\\engel.int\nx\ea\ug\NX10_install\nx-10.0.3.mp11 -updateNr=engel_20170115 \ No newline at end of file diff --git a/Daten/RunNxUpdate.ico b/Daten/RunNxUpdate.ico new file mode 100644 index 0000000..2722e31 Binary files /dev/null and b/Daten/RunNxUpdate.ico differ diff --git a/RunNxUpdate.git.sln b/RunNxUpdate.git.sln new file mode 100644 index 0000000..54c187e --- /dev/null +++ b/RunNxUpdate.git.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31005.135 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunNxUpdate", "RunNxUpdate\RunNxUpdate.csproj", "{D0F3AF58-FFAA-43C8-AB98-C3EE8396B4AA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D0F3AF58-FFAA-43C8-AB98-C3EE8396B4AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D0F3AF58-FFAA-43C8-AB98-C3EE8396B4AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D0F3AF58-FFAA-43C8-AB98-C3EE8396B4AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D0F3AF58-FFAA-43C8-AB98-C3EE8396B4AA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3628967E-E361-474D-8B5D-8B781F33600A} + EndGlobalSection +EndGlobal diff --git a/RunNxUpdate/App.config b/RunNxUpdate/App.config new file mode 100644 index 0000000..8324aa6 --- /dev/null +++ b/RunNxUpdate/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/RunNxUpdate/AppResources.Designer.cs b/RunNxUpdate/AppResources.Designer.cs new file mode 100644 index 0000000..751b7c3 --- /dev/null +++ b/RunNxUpdate/AppResources.Designer.cs @@ -0,0 +1,207 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.42000 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace RunNxUpdate { + using System; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class AppResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal AppResources() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RunNxUpdate.AppResources", typeof(AppResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Schwerer Fehler ähnelt. + /// + internal static string msgHeadline001 { + get { + return ResourceManager.GetString("msgHeadline001", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Warnung ähnelt. + /// + internal static string msgHeadline002 { + get { + return ResourceManager.GetString("msgHeadline002", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Information ähnelt. + /// + internal static string msgHeadline003 { + get { + return ResourceManager.GetString("msgHeadline003", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Bitte informieren sie ihren NX Administrator. ähnelt. + /// + internal static string msgText000 { + get { + return ResourceManager.GetString("msgText000", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Die für das Update notwendigen Dateien konnten nicht gefunden werden! Das Update wurde nicht vollständig installiert. ähnelt. + /// + internal static string msgText001 { + get { + return ResourceManager.GetString("msgText001", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Es ist ein unerwarteter schwerer Fehler passiert! Das Update wurde nicht vollständig installiert. ähnelt. + /// + internal static string msgText002 { + get { + return ResourceManager.GetString("msgText002", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Notwendige Umgebungswerte konnten nicht ausgelesen werden! ähnelt. + /// + internal static string msgText003 { + get { + return ResourceManager.GetString("msgText003", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Die Versionsdatei konnte nicht geschrieben werden! ähnelt. + /// + internal static string msgText004 { + get { + return ResourceManager.GetString("msgText004", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Zugriff verweigert! Eine Datei konnte nicht gelesen oder geschrieben werden. ähnelt. + /// + internal static string msgText005 { + get { + return ResourceManager.GetString("msgText005", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Es ist ein unbekannter Fehler passiert! Das Update konnte nicht ausgeführt werden. ähnelt. + /// + internal static string msgText006 { + get { + return ResourceManager.GetString("msgText006", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Die von ihnen verwendete Version von NX ist neuer als die offiziell bei ENGEL freigegebene Version. Wenn Sie diese Version weiterverwenden, kann es zu Dateninkompatibilität kommen. Eventuell können andere NX Anwender die von ihnen erzeugten Dateien nicht mehr verwenden. ähnelt. + /// + internal static string msgText007 { + get { + return ResourceManager.GetString("msgText007", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Sie benutzen eine veraltete Version von NX. Die aktuell bei ENGEL freigegebene Version ist ähnelt. + /// + internal static string msgText008 { + get { + return ResourceManager.GetString("msgText008", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Wenn sie das Update ablehnen, kann es zu Dateninkompatibilität kommen. Eventuell können sie Dateien von anderen NX Anwendern nicht mehr öffnen. ähnelt. + /// + internal static string msgText009 { + get { + return ResourceManager.GetString("msgText009", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Der Updatevorgang dauert bei normaler Netzwerklast max. 5 Minuten. ähnelt. + /// + internal static string msgText010 { + get { + return ResourceManager.GetString("msgText010", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Möchten sie das Update jetzt ausführen? ähnelt. + /// + internal static string msgText011 { + get { + return ResourceManager.GetString("msgText011", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die NX wird noch ausgeführt!\nBitte beenden sie NX und bestätigen dann diesen Dialog. ähnelt. + /// + internal static string msgText012 { + get { + return ResourceManager.GetString("msgText012", resourceCulture); + } + } + } +} diff --git a/RunNxUpdate/AppResources.de.resx b/RunNxUpdate/AppResources.de.resx new file mode 100644 index 0000000..56033b5 --- /dev/null +++ b/RunNxUpdate/AppResources.de.resx @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Schwerer Fehler + + + Warnung + + + Information + + + Bitte informieren sie ihren NX Administrator. + + + Die für das Update notwendigen Dateien konnten nicht gefunden werden! Das Update wurde nicht vollständig installiert. + + + Es ist ein unerwarteter schwerer Fehler passiert! Das Update wurde nicht vollständig installiert. + + + Notwendige Umgebungswerte konnten nicht ausgelesen werden! + + + Die Versionsdatei konnte nicht geschrieben werden! + + + Zugriff verweigert! Eine Datei konnte nicht gelesen oder geschrieben werden. + + + Es ist ein unbekannter Fehler passiert! Das Update konnte nicht ausgeführt werden. + + + Die von ihnen verwendete Version von NX ist neuer als die offiziell bei ENGEL freigegebene Version. Wenn Sie diese Version weiterverwenden, kann es zu Dateninkompatibilität kommen. Eventuell können andere NX Anwender die von ihnen erzeugten Dateien nicht mehr verwenden. + + + Sie benutzen eine veraltete Version von NX. Die aktuell bei ENGEL freigegebene Version ist + + + Wenn sie das Update ablehnen, kann es zu Dateninkompatibilität kommen. Eventuell können sie Dateien von anderen NX Anwendern nicht mehr öffnen. + + + Der Updatevorgang dauert bei normaler Netzwerklast max. 5 Minuten. + + + Möchten sie das Update jetzt ausführen? + + + NX wird noch ausgeführt!\nBitte beenden sie NX und bestätigen dann diesen Dialog. + + \ No newline at end of file diff --git a/RunNxUpdate/AppResources.en.resx b/RunNxUpdate/AppResources.en.resx new file mode 100644 index 0000000..707a592 --- /dev/null +++ b/RunNxUpdate/AppResources.en.resx @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Fatal Error + + + Warning + + + Information + + + Please inform your NX administrator. + + + The necessary files for the update could not be found! The update has not been fully installed. + + + There is an unexpected serious error happened! The update has not been fully installed. + + + Necessary environmental values could not be read out! + + + The version file could not be written! + + + Access denied! A file could not be read or written. + + + There is an unknown error happened! The update could not be executed. + + + The version of NX you use is newer than the version officially released by ENGEL. If you use this version longer, data incompatibility may occur. Other NX users may not be able to use the files you create. + + + You are using an outdated version of NX. The version released at ENGEL is currently + + + If you reject the update, data incompatibility may occur. You may not be able to open files from other NX users. + + + The update process takes a max. 5 minutes. + + + Would you like to run the update now? + + + NX is still running!\nPlease finish NX and confirm this dialog. + + \ No newline at end of file diff --git a/RunNxUpdate/AppResources.resx b/RunNxUpdate/AppResources.resx new file mode 100644 index 0000000..56033b5 --- /dev/null +++ b/RunNxUpdate/AppResources.resx @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Schwerer Fehler + + + Warnung + + + Information + + + Bitte informieren sie ihren NX Administrator. + + + Die für das Update notwendigen Dateien konnten nicht gefunden werden! Das Update wurde nicht vollständig installiert. + + + Es ist ein unerwarteter schwerer Fehler passiert! Das Update wurde nicht vollständig installiert. + + + Notwendige Umgebungswerte konnten nicht ausgelesen werden! + + + Die Versionsdatei konnte nicht geschrieben werden! + + + Zugriff verweigert! Eine Datei konnte nicht gelesen oder geschrieben werden. + + + Es ist ein unbekannter Fehler passiert! Das Update konnte nicht ausgeführt werden. + + + Die von ihnen verwendete Version von NX ist neuer als die offiziell bei ENGEL freigegebene Version. Wenn Sie diese Version weiterverwenden, kann es zu Dateninkompatibilität kommen. Eventuell können andere NX Anwender die von ihnen erzeugten Dateien nicht mehr verwenden. + + + Sie benutzen eine veraltete Version von NX. Die aktuell bei ENGEL freigegebene Version ist + + + Wenn sie das Update ablehnen, kann es zu Dateninkompatibilität kommen. Eventuell können sie Dateien von anderen NX Anwendern nicht mehr öffnen. + + + Der Updatevorgang dauert bei normaler Netzwerklast max. 5 Minuten. + + + Möchten sie das Update jetzt ausführen? + + + NX wird noch ausgeführt!\nBitte beenden sie NX und bestätigen dann diesen Dialog. + + \ No newline at end of file diff --git a/RunNxUpdate/Languages.cs b/RunNxUpdate/Languages.cs new file mode 100644 index 0000000..5c5f3cc --- /dev/null +++ b/RunNxUpdate/Languages.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace RunNxUpdate +{ + /// + /// Description of Languages. + /// + class Languages + { + public enum Language + { + German, + English, + French, + Spanish, + Russian + } + + public static void SetLanguage(Language language) + { + switch (language) + { + case Language.German: + Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE"); + break; + case Language.English: + Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); + break; + case Language.French: + Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR"); + break; + case Language.Spanish: + Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-ES"); + break; + case Language.Russian: + Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-RU"); + break; + default: + break; + } + } + } +} diff --git a/RunNxUpdate/Locations.cs b/RunNxUpdate/Locations.cs new file mode 100644 index 0000000..b864bee --- /dev/null +++ b/RunNxUpdate/Locations.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RunNxUpdate +{ + /// + /// Description of Locations. + /// + class Locations + { + public enum Location + { + EA = 1, + EAZ, + EMCC, + EMCN, + EMCZ, + EMK, + EUS, + UNKNOWN + } + + public static Locations.Location GetOwnLocation() + { + try + { + string plant = Environment.GetEnvironmentVariable("PLANT"); + + if (String.IsNullOrEmpty(plant)) + { + plant = "UNKNOWN"; + } + + Locations.Location location = (Location)Enum.Parse(typeof(Location), plant); + + return location; + } + catch (Exception) + { + MessageBox.Show("Die Sprache konnte nicht eingestellt werden, weil der Standort nicht ermittelt werden konnte.\n\nBitte informieren sie ihren NX Administrator.\n\n\n\nThe language could not be set, because the location could not be determined.\n\nPlease inform your NX administrator", + "Schwerer Fehler / Fatal Error", + MessageBoxButtons.OK, + MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1); + + return 0; + } + } + } +} diff --git a/RunNxUpdate/NxVersion.cs b/RunNxUpdate/NxVersion.cs new file mode 100644 index 0000000..80a3fa9 --- /dev/null +++ b/RunNxUpdate/NxVersion.cs @@ -0,0 +1,546 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RunNxUpdate +{ + /// + /// Description of NX_Version. + /// + class NxVersion + { + #region Define Type + /// + /// NX Version. E.g.: NX 10.0.3.5 + /// + public string NXversion { get; set; } + + /// + /// NX Phase. E.g.: 5 of NX 10.0.3.5 + /// + public int NXphase { get; set; } + + /// + /// NX Patch. E.g.: NX 10.0.3.5 MP4 + /// + public string NXpatch { get; set; } + + + /// + /// UGII_PRODUCT_NAME. E.g.: NX of NX 10.0.3.5 + /// + public string UgiiProductName { get; set; } + + /// + /// UGII_VERSION. E.g.: v10 of NX 10.0.3.5 + /// + public string UgiiVersion { get; set; } + + /// + /// UGII_FULL_VERSION. E.g.: v10.0.3.5 + /// + public string UgiiFullVersion { get; set; } + + /// + /// UGII_MAJOR_VERSION. E.g.: 10 of NX 10.0.3.5 + /// + public int UgiiMajorVersion { get; set; } + + /// + /// UGII_MINOR_VERSION. E.g.: 0 of NX 10.0.3.5 + /// + public int UgiiMinorVersion { get; set; } + + /// + /// UGII_SUBMINOR_VERSION. E.g.: 3 of NX 10.0.3.5 + /// + public int UgiiSubminorVersion { get; set; } + + + /// + /// NX_VERSION_STRING. E.g.: V28.0.3.5 instead of NX 10.0.3.5 MP4 + /// + public string NxVersionString { get; set; } + + /// + /// NX_MAJOR_STRING. E.g.: V28 of V28.0.3.5 + /// + public string NxMajorVersionString { get; set; } + + /// + /// NX_MINOR_STRING. E.g.: 0 of V28.0.3.5 + /// + public int NxMinorVersionString { get; set; } + + /// + /// NX_SUBMINOR_STRING. E.g.: 3 of V28.0.3.5 + /// + public int NxSubminorVersionString { get; set; } + + /// + /// NX_PHASE_STRING. E.g.: 5 of V28.0.3.5 + /// + public int NxPhaseString { get; set; } + + + /// + /// Maintenance Release. E.g.: 10.0.3.5 of NX 10.0.3.5 MP4 + /// + public string MaintenanceRelease { get; set; } + + /// + /// Maintenance Pack. E.g.: MP4 of NX 10.0.3.5 MP4 + /// + public string MaintenancePack { get; set; } + + /// + /// Maintenance Pack Number. E.g.: 4 of NX 10.0.3.5 MP4 + /// + public int MaintenancePackNumber { get; set; } + #endregion + + #region GetVersion + public NxVersion GetNxVersion(string ugii_base_dir) + { + //Version die als Updatedatei übergeben wurde + string RefVer = Program.UpdateDir.Remove(0, Program.UpdateDir.IndexOf("nx-") + 3); + RefVer = RefVer.Remove(RefVer.IndexOf(".")); + if (String.IsNullOrEmpty(RefVer)) + { + //NX Version ist neuer als 'NX12' + //TODO: Was hier passieren muss ist noch nicht bekannt, weil es für 'NX1847' noch kein Update gibt + } + + //Version die in UGII_BASE_DIR übergeben wurde + string CompVer = ugii_base_dir.Remove(0, ugii_base_dir.IndexOf("NX") + 2); + if (String.IsNullOrEmpty(CompVer)) + { + //NX Version ist neuer als 'NX12' + //TODO: Was hier passieren muss noch nicht bekannt, weil es für 'NX1847' noch kein Update gibt + } + else + { + //NX Version ist bis 'NX12' + if (CompVer.Contains(".")) + { + CompVer = CompVer.Remove(CompVer.IndexOf(".")); + } + } + + //Wenn eine andere UGII_BASE_DIR gesetzt ist als upgedatet werden soll, dann UGII_BASE_DIR zur Laufzeit richtig stellen + if (RefVer != CompVer) + { + //UGII_BASE_DIR neu aufbauen + string baseDir = ugii_base_dir; + if (ugii_base_dir.EndsWith("NX")) + { + //UGII_BASE_DIR ist neuer gesetzt als 'NX12', das muss geändert werden + baseDir = String.Concat(ugii_base_dir, RefVer); + } + + if (Convert.ToUInt16(RefVer) < Convert.ToUInt16(CompVer)) + { + //UGII_BASE_DIR ist neuer als die Updatedateien + baseDir = String.Concat(ugii_base_dir.Remove(ugii_base_dir.LastIndexOf("NX") + 2), RefVer); + } + + Environment.SetEnvironmentVariable("UGII_BASE_DIR", baseDir); + ugii_base_dir = baseDir; + } + + NxVersion nxVersion = new NxVersion(); + string tempVersion = ""; + + if (Directory.Exists(ugii_base_dir)) + { + //Wenn 'ugii_base_dir' existiert, dann die Werte ermitteln} + tempVersion = ReadProcessOutput(ugii_base_dir, "-m"); + if (tempVersion != null) + { + //Wert auflösen + string[] versionSegments = new string[6]; + versionSegments = SeperateVersionCode(tempVersion); + if (versionSegments != null) + { + //NX-Version setzen + nxVersion = AssignVersionSegments(versionSegments); + + if (nxVersion == null) + { + //Fehler passiert + throw new NoNXversionException("It was inpossible to generate NX Version."); + } + } + else + { + //Fehler passiert + throw new NoNXversionException("It was inpossible to generate NX Version."); + } + } + + return nxVersion; + } + else + { + return null; //Wenn 'ugii_base_dir' nicht existiert, dann 'null' zurückgeben + } + } + + public NxVersion GetNxVersion(int majorVersion, int minorVersion, int subminorVersion, int phase, int mp) + { + NxVersion nxVersion = new NxVersion(); + + string[] versionSegments = new string[6]; + versionSegments[0] = "NX"; + versionSegments[1] = majorVersion.ToString(); + versionSegments[2] = minorVersion.ToString(); + versionSegments[3] = subminorVersion.ToString(); + versionSegments[4] = phase.ToString(); + versionSegments[5] = "MP" + mp.ToString(); + + //NX-Version setzen + return AssignVersionSegments(versionSegments); + } + #endregion + + #region Compare + /// + /// Compares two NX-Versions. + /// + /// A valid NX-Version. + /// 0 = equal, 1 = first version newer, 2 = second version newer, -1 = An error is happened. + public int Compare(NxVersion version) + { + return Compare(this, version); + } + + /// + /// Compares two NX-Versions. + /// + /// A valid major version. E.g.: 10 of NX 10.0.3.5 MP4 + /// A valid minor version. E.g.: 0 of NX 10.0.3.5 MP4 + /// A valid subminor version. E.g.: 3 of NX 10.0.3.5 MP4 + /// A valid phase. E.g.: 5 of NX 10.0.3.5 MP4 + /// A valid maintenance pack number. E.g.: 4 of NX 10.0.3.5 MP4 + /// + public int Compare(int majorVersion, int minorVersion, int subminorVersion, int phase, int mp) + { + NxVersion nxVersion = new NxVersion(); + + string[] versionSegments = new string[6]; + versionSegments[0] = "NX"; + versionSegments[1] = majorVersion.ToString(); + versionSegments[2] = minorVersion.ToString(); + versionSegments[3] = subminorVersion.ToString(); + versionSegments[4] = phase.ToString(); + versionSegments[5] = "MP" + mp.ToString(); + + //NX-Version setzen + return Compare(this, AssignVersionSegments(versionSegments)); + } + + private int Compare(NxVersion version1, NxVersion version2) + { + if (version1.NXpatch == version2.NXpatch) + { + return 0; //Versionen gleich + } + if (version1.UgiiMajorVersion < version2.UgiiMajorVersion) + { + return 2; //Version 1 ist älter als Version 2 + } + if (version1.UgiiMajorVersion > version2.UgiiMajorVersion) + { + return 1; //Version 1 ist neuer als Version 2 + } + if (version1.UgiiMinorVersion < version2.UgiiMinorVersion) + { + return 2; //Version 1 ist älter als Version 2 + } + if (version1.UgiiMinorVersion > version2.UgiiMinorVersion) + { + return 1; //Version 1 ist neuer als Version 2 + } + if (version1.UgiiSubminorVersion < version2.UgiiSubminorVersion) + { + return 2; //Version 1 ist älter als Version 2 + } + if (version1.UgiiSubminorVersion > version2.UgiiSubminorVersion) + { + return 1; //Version 1 ist neuer als Version 2 + } + if (version1.NXphase < version2.NXphase) + { + return 2; //Version 1 ist älter als Version 2 + } + if (version1.NXphase > version2.NXphase) + { + return 1; //Version 1 ist neuer als Version 2 + } + if (version1.MaintenancePackNumber < version2.MaintenancePackNumber) + { + return 2; //Version 1 ist älter als Version 2 + } + if (version1.MaintenancePackNumber > version2.MaintenancePackNumber) + { + return 1; //Version 1 ist neuer als Version 2 + } + + return -1; //Fehler passiert + } + #endregion + + #region CommonMethodes + static string ReadProcessOutput(string ugii_base_dir, string arguments) + { + // Liest die Daten nach beenden der Prozess-Ausgabe aus + // Tritt ein Fehler auf, liefert die Funktion null zurück + + //Überprüfen ob auf alle notwendigen Dateien (env_print.exe, libpatch.dll, libsyss.dll) zugegriffen werden kann + ExecutablesExists(ugii_base_dir); + + string stdOut; + + Process process = new Process(); + + try + { + if (ugii_base_dir.EndsWith("\\")) + { + process.StartInfo.FileName = "\"" + ugii_base_dir + "UGII\\env_print.exe\""; + } + else + { + process.StartInfo.FileName = "\"" + ugii_base_dir + "\\UGII\\env_print.exe\""; + } + process.StartInfo.Arguments = arguments; + process.StartInfo.UseShellExecute = false; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.CreateNoWindow = true; + + process.Start(); + process.WaitForExit(); + + stdOut = process.StandardOutput.ReadToEnd(); + } + catch + { + stdOut = null; + } + finally + { + process.Close(); + } + + return stdOut; + } + + static void ExecutablesExists(string ugii_base_dir) + { + //Wenn eine der drei Dateien nicht existiert, dann eine Exception werfen + if (!File.Exists(String.Concat(ugii_base_dir, "\\UGII\\env_print.exe"))) throw new NoEnvPrintExeException("Unable to find EnvPrint.exe"); + if (!ugii_base_dir.EndsWith("NX")) + { + if (Convert.ToInt32(ugii_base_dir.Remove(0, ugii_base_dir.LastIndexOf("NX") + 2)) < 12) + { + if (!File.Exists(String.Concat(ugii_base_dir, "\\UGII\\libpatch.dll"))) throw new NoLibPatchDllException("Unable to find LibPatch.dll"); + } + } + if (!File.Exists(String.Concat(ugii_base_dir, "\\UGII\\libsyss.dll"))) throw new NoLibSysDllException("Unable to find LibSys.dll"); + } + + private string[] SeperateVersionCode(string tempVersion) + { + if (tempVersion.Contains(",")) + { + //Den restlichen Text von der Version abtrennen (NX 10.0.3.5 MP4, 30Mar16. See Maintenance Pack letter for detailed list of fixes.\r\n) + tempVersion = tempVersion.Remove(tempVersion.IndexOf(",")); + } + + //Alle Trennzeichen durch ',' ersetzen + tempVersion = tempVersion.Replace(" ", "."); + + //Die einzelnen Segmente herauslösen + string[] versionSegments = tempVersion.Split(new Char[] { '.' }); + + if (versionSegments.Length != 6) + { + if (versionSegments.Length == 4) + { + //Phase und MP fehlen + versionSegments[4] = "0"; + versionSegments[5] = "MP0"; + } + else if (versionSegments.Length == 5) + { + //Phase oder MP fehlen + if (versionSegments[4].StartsWith("MP")) + { + //Phase fehlt + versionSegments[5] = versionSegments[4]; + versionSegments[4] = "0"; + } + else + { + //MP fehlt + versionSegments[5] = "MP0"; + } + } + else + { + //Unbekannte Version + versionSegments = null; + } + } + + return versionSegments; + } + + private NxVersion AssignVersionSegments(string[] versionSegments) + { + NxVersion nxVersion = new NxVersion(); + + // NX_VERSION. E.g.: NX 10.0.3.5 + nxVersion.NXversion = versionSegments[0] + " " + versionSegments[1] + "." + versionSegments[2] + "." + versionSegments[3] + "." + versionSegments[4]; + NXversion = nxVersion.NXversion; + + // NX_PHASE. E.g.: 5 of NX 10.0.3.5 + nxVersion.NXphase = Convert.ToInt16(versionSegments[4]); + NXphase = nxVersion.NXphase; + + // NX_PATCH. E.g.: NX 10.0.3.5 MP4 + nxVersion.NXpatch = nxVersion.NXversion + " " + versionSegments[5]; + NXpatch = nxVersion.NXpatch; + if (NXpatch.Contains("MP0")) + { + NXpatch = NXpatch.Replace("MP0", "MP"); + } + + + // UGII_PRODUCT_NAME. E.g.: NX of NX 10.0.3.5 + nxVersion.UgiiProductName = versionSegments[0]; + UgiiProductName = nxVersion.UgiiProductName; + + // UGII_VERSION. E.g.: v10 of NX 10.0.3.5 + nxVersion.UgiiVersion = "v" + versionSegments[1]; + UgiiVersion = nxVersion.UgiiVersion; + + // UGII_FULL_VERSION. E.g.: v10.0.3.5 + nxVersion.UgiiFullVersion = "v" + versionSegments[1] + "." + versionSegments[2] + "." + versionSegments[3] + "." + versionSegments[4]; + UgiiFullVersion = nxVersion.UgiiFullVersion; + + // UGII_MAJOR_VERSION. E.g.: 10 of NX 10.0.3.5 + nxVersion.UgiiMajorVersion = Convert.ToInt16(versionSegments[1]); + UgiiMajorVersion = nxVersion.UgiiMajorVersion; + + // UGII_MINOR_VERSION. E.g.: 0 of NX 10.0.3.5 + nxVersion.UgiiMinorVersion = Convert.ToInt16(versionSegments[2]); + UgiiMinorVersion = nxVersion.UgiiMinorVersion; + + // UGII_SUBMINOR_VERSION. E.g.: 3 of NX 10.0.3.5 + nxVersion.UgiiSubminorVersion = Convert.ToInt16(versionSegments[3]); + UgiiSubminorVersion = nxVersion.UgiiSubminorVersion; + + + // NX_VERSION_STRING. E.g.: V28.0.3.5 instead of NX 10.0.3.5 MP4 + nxVersion.NxVersionString = "v" + (Convert.ToInt16(versionSegments[1]) + 18).ToString() + "." + versionSegments[2] + "." + versionSegments[3] + "." + versionSegments[4]; + NxVersionString = nxVersion.NxVersionString; + + // NX_MAJOR_STRING. E.g.: V28 of V28.0.3.5 + nxVersion.NxMajorVersionString = "v" + (Convert.ToInt16(versionSegments[1]) + 18).ToString(); + NxMajorVersionString = nxVersion.NxMajorVersionString; + + // NX_MINOR_STRING. E.g.: 0 of V28.0.3.5 + nxVersion.NxMinorVersionString = Convert.ToInt16(versionSegments[2]); + NxMinorVersionString = nxVersion.NxMinorVersionString; + + // NX_SUBMINOR_STRING. E.g.: 3 of V28.0.3.5 + nxVersion.NxSubminorVersionString = Convert.ToInt16(versionSegments[3]); + NxSubminorVersionString = nxVersion.NxSubminorVersionString; + + // NX_PHASE_STRING. E.g.: 5 of V28.0.3.5 + nxVersion.NxPhaseString = Convert.ToInt16(versionSegments[4]); + NxPhaseString = nxVersion.NxPhaseString; + + + // Maintenance Release. E.g.: 10.0.3.5 of NX 10.0.3.5 MP4 + nxVersion.MaintenanceRelease = versionSegments[1] + "." + versionSegments[2] + "." + versionSegments[3] + "." + versionSegments[4]; + MaintenanceRelease = nxVersion.MaintenanceRelease; + + // Maintenance Pack. E.g.: MP4 of NX 10.0.3.5 MP4 + nxVersion.MaintenancePack = versionSegments[5]; + MaintenancePack = nxVersion.MaintenancePack; + + // Maintenance Pack Number. E.g.: 4 of NX 10.0.3.5 MP4 + nxVersion.MaintenancePackNumber = Convert.ToInt16(nxVersion.MaintenancePack.Remove(0, nxVersion.MaintenancePack.IndexOf("MP") + 2)); + MaintenancePackNumber = nxVersion.MaintenancePackNumber; + + return nxVersion; + } + + /// + /// Converts a NxPatch string to NxVersion + /// + /// A valid NxPatch. E.g.: NX 10.0.3.5 MP4 + /// + public NxVersion ConvertStringPatchToNxVersionPatch(string nxPatch) + { + return AssignVersionSegments(SeperateVersionCode(nxPatch)); + } + #endregion + } + + #region Exception + class NoNXversionException : ApplicationException + { + public NoNXversionException() + { } + + public NoNXversionException(string message) : base(message) + { } + + public NoNXversionException(string message, Exception inner) : base(message, inner) + { } + } + + class NoEnvPrintExeException : ApplicationException + { + public NoEnvPrintExeException() + { } + + public NoEnvPrintExeException(string message) : base(message) + { } + + public NoEnvPrintExeException(string message, Exception inner) : base(message, inner) + { } + } + + class NoLibPatchDllException : ApplicationException + { + public NoLibPatchDllException() + { } + + public NoLibPatchDllException(string message) : base(message) + { } + + public NoLibPatchDllException(string message, Exception inner) : base(message, inner) + { } + } + + class NoLibSysDllException : ApplicationException + { + public NoLibSysDllException() + { } + + public NoLibSysDllException(string message) : base(message) + { } + + public NoLibSysDllException(string message, Exception inner) : base(message, inner) + { } + } + #endregion +} diff --git a/RunNxUpdate/Program.cs b/RunNxUpdate/Program.cs new file mode 100644 index 0000000..2f81b84 --- /dev/null +++ b/RunNxUpdate/Program.cs @@ -0,0 +1,456 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using DisplLanguage = RunNxUpdate.Languages.Language; +using EngelLocation = RunNxUpdate.Locations.Location; + +namespace RunNxUpdate +{ + class Program + { + #region Version und Copyright + // Version und Copyright + static string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen + static string programVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + static string copyright = GenerateCopyright(); + string icon = Application.StartupPath + "\\Info.bmp"; + //Assembly Datum und Zeit + static DateTime value = AssemblyDateTime(); + string date = value.ToShortDateString(); + string time = value.ToLongTimeString(); + private static DateTime AssemblyDateTime() + { + var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; + var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision)); + //Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original) + return buildDateTime; + } + + private static string CurrentYear() + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + + private static string StartYear() + { + string startYear = ""; + if (((AssemblyCopyrightAttribute)attributes[0]).Copyright.Contains("Copyright © ")) + { + startYear = ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace("Copyright © ", ""); + while (startYear.StartsWith(" ")) + { + startYear = startYear.Remove(0, 1); + } + startYear = startYear.Remove(startYear.IndexOf(" ")); + return startYear; + } + else + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + } + + private static string GenerateCopyright() + { + string startYear = StartYear(); + string currentYear = CurrentYear(); + + if (startYear == currentYear) + { + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + } + else + { + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace(startYear, String.Concat(startYear, "-", currentYear)); + } + } + #endregion + + #region Programm-Info + /// + /// Contains the name of the program file + /// + public static string ProgramName { private set; get; } + + /// + /// Contains the version of the program file + /// + public static string ProgramVersion { private set; get; } + + /// + /// Contains the copyright notice + /// + public static string Copyright { private set; get; } + + private static void SetProgramInfo() + { + //Name, Version und Copyright setzen + ProgramName = programName; + ProgramVersion = programVersion; + Copyright = copyright; + } + #endregion + + //Globale Variablen + public static string UpdateDir { get; set; } + public static string UpdateNo { get; set; } + public static Languages.Language Language { get; set; } + + //--- Möglicher Aufruf aus einem Script heraus: + //----- set UPDATEFOLDER=M:\ug\NX12_install\nx-12.0.2.mp14 + //----- set UPDATEDATE=20210222 + //----- call M:\ug\Tools\RunNxUpdate\RunNxUpdate.exe -updatefolder=%UPDATEFOLDER% -updateNr=engel_%UPDATEDATE% + + static void Main(string[] args) + { + SetProgramInfo(); + + //Variablen vorbelegen falls kein Wert gesetzt wurde + UpdateDir = ""; + UpdateNo = ""; + + try + { + //Übergabeparameter auswerten + new Program().Transfer(args); + + //Sprache setzen + new Program().SetLanguage(); + + //Programm starten + new Program().Start(UpdateDir, UpdateNo, "run_ugsupdate.exe"); + } + catch (UpdateFilesNotExistException) + { + MessageBox.Show(String.Concat(AppResources.msgText001, Environment.NewLine, AppResources.msgText000), + AppResources.msgHeadline001, + MessageBoxButtons.OK, + MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1); + } + catch (UpdateException) + { + MessageBox.Show(String.Concat(AppResources.msgText002, Environment.NewLine, AppResources.msgText000), + AppResources.msgHeadline001, + MessageBoxButtons.OK, + MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1); + } + catch (EnvironmentFileException) + { + MessageBox.Show(String.Concat(AppResources.msgText003, Environment.NewLine, AppResources.msgText000), + AppResources.msgHeadline001, + MessageBoxButtons.OK, + MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1); + } + catch (VersionFileIOException) + { + MessageBox.Show(String.Concat(AppResources.msgText004, Environment.NewLine, AppResources.msgText000), + AppResources.msgHeadline001, + MessageBoxButtons.OK, + MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1); + } + catch (IOException) + { + MessageBox.Show(String.Concat(AppResources.msgText005, Environment.NewLine, AppResources.msgText000), + AppResources.msgHeadline001, + MessageBoxButtons.OK, + MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1); + } + catch (Exception) + { + MessageBox.Show(String.Concat(AppResources.msgText006, Environment.NewLine, AppResources.msgText000), + AppResources.msgHeadline001, + MessageBoxButtons.OK, + MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1); + } + } + + private void Transfer(string[] args) + { + foreach (var element in args) + { + if (element.ToUpper().StartsWith("-UPDATEFOLDER")) + { + UpdateDir = element.Remove(0, element.LastIndexOf("=") + 1); + if (!Directory.Exists(UpdateDir)) + { + throw new UpdateFilesNotExistException(); + } + } + + if (element.ToUpper().StartsWith("-UPDATENR")) + { + UpdateNo = element.Remove(0, element.LastIndexOf("=") + 1); + } + } + } + + private void SetLanguage() + { + Language = DisplLanguage.English; + Languages.SetLanguage(DisplLanguage.English); + + //Wenn der Standort 'EA' oder 'EAZ' ist dann ist die Sprache deutsch + EngelLocation location = Locations.GetOwnLocation(); + if (location == 0) + { + Application.Exit(); + } + else if (location == EngelLocation.EA || location == EngelLocation.EAZ) + { + Language = DisplLanguage.German; + Languages.SetLanguage(DisplLanguage.German); + } + } + + private void Start(string folder, string updateNo, string batchFile) + { + NxVersion nxVer = new NxVersion(); + nxVer.GetNxVersion(Environment.GetEnvironmentVariable("UGII_BASE_DIR")); + + NxVersion currentVersion = GetCurrentVersion(folder); //Zu installierende Version + + string installedVersion = nxVer.NXpatch; //Installierte Version + + int installationStatus = nxVer.Compare(currentVersion); + + switch (installationStatus) + { + case 0: + VersionEqual(updateNo); + break; + case 1: + InstalledVersionNewer(); + break; + case 2: + InstalledVersionOlder(currentVersion.NXpatch.ToString(), folder, updateNo); + break; + default: + ErrorOccurred(); + break; + } + } + + private NxVersion GetCurrentVersion(string folder) + { + NxVersion nxVer = new NxVersion(); + nxVer.GetNxVersion(Environment.GetEnvironmentVariable("UGII_BASE_DIR")); + + string nxPatch = folder.Remove(0, folder.LastIndexOf("\\") + 1).ToUpper().Replace("-", " "); + if (nxPatch.Contains("MP0")) + { + nxPatch = nxPatch.Replace("MP0", "MP"); + } + string nxPatchTemp = nxPatch.Remove(nxPatch.LastIndexOf(".") + 1); + string mp = nxPatch.Remove(0, nxPatch.LastIndexOf("MP")); + + nxPatch = String.Concat(nxPatchTemp, nxVer.NXphase, " ", mp); + + return nxVer.ConvertStringPatchToNxVersionPatch(nxPatch); + } + + private void VersionEqual(string nxVersion) + { + //Ist die aktuelle Version gleich der installierten Version und das Programm + //'RunNxUpdate' wurde gestartet, dann fehlt die Versionsdatei in 'C:\CAD\Update'. + //Es ist kein Update notwendig, aber die Versionsdatei muss geschrieben werden. + SetVersionFile(nxVersion); + } + + private void InstalledVersionNewer() + { + MessageBox.Show(String.Concat(AppResources.msgText007, Environment.NewLine, AppResources.msgText000), + AppResources.msgHeadline002, + MessageBoxButtons.OK, + MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button1); + } + + private void InstalledVersionOlder(string currentVersion, string folder, string nxVersion) + { + if (IsStartDate(nxVersion)) + { + DialogResult result = MessageBox.Show(String.Concat(AppResources.msgText008, currentVersion, ".", Environment.NewLine, AppResources.msgText009, Environment.NewLine, AppResources.msgText010, Environment.NewLine, Environment.NewLine, AppResources.msgText011), + AppResources.msgHeadline002, + MessageBoxButtons.YesNo, + MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button1); + + if (result == DialogResult.Yes) + { + //Update ausführen + RunUpdate(folder, nxVersion); + } + } + } + + private void ErrorOccurred() + { + MessageBox.Show(String.Concat(AppResources.msgText002, Environment.NewLine, AppResources.msgText000), + AppResources.msgHeadline001, + MessageBoxButtons.OK, + MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1); + } + + private void RunUpdate(string folder, string nxVersion) + { + while (CheckIfAProcessIsRunning("ugraf")) + { + MessageBox.Show(AppResources.msgText012, + AppResources.msgHeadline003, + MessageBoxButtons.OK, + MessageBoxIcon.Information, + MessageBoxDefaultButton.Button1); + } + + string fileName = String.Concat(folder, "\\run_ugsupdate.exe"); + try + { + Update(fileName); + } + catch (Exception) + { + throw new UpdateException(); + } + + SetVersionFile(nxVersion); + } + + private bool CheckIfAProcessIsRunning(string processname) + { + return Process.GetProcessesByName(processname).Length > 0; + } + + private void Update(string fileName) + { + Process P = new Process(); + P.StartInfo.FileName = fileName; + // Hier können noch Argumente übergeben werden + //P.StartInfo.Arguments = ""; + P.Start(); + P.WaitForExit(); + } + + private void SetVersionFile(string nxVersion) + { + string fileName = ""; + string userName = ""; + string computerName = ""; + + try + { + fileName = String.Concat("C:\\CAD\\Update\\", nxVersion, ".txt"); + userName = Environment.GetEnvironmentVariable("USERNAME"); + computerName = Environment.GetEnvironmentVariable("COMPUTERNAME"); + } + catch (Exception) + { + throw new EnvironmentFileException(); + } + + if (userName == null) + { + userName = "noUSERNAME"; + } + + if (computerName == null) + { + computerName = "noCOMPUTERNAME"; + } + + DateTime now = DateTime.Now; + string dateTime = now.ToString(); + + try + { + File.WriteAllText(fileName, String.Concat(userName, " ", computerName, " ", dateTime)); + } + catch (Exception) + { + throw new VersionFileIOException(); + } + } + + private bool IsStartDate(string updateNo) + { + //Updatedatum ermitteln + string updateDate = updateNo.Replace("engel_", ""); + DateTime dtud = new DateTime(Convert.ToUInt16(updateDate.Remove(4)), Convert.ToUInt16(updateDate.Remove(0, 4).Remove(2)), Convert.ToUInt16(updateDate.Remove(0, 6))); + + //Aktuelles Datum ermitteln + DateTime dtcd = DateTime.Now; + + //Ist das aktuelle Datum gleich oder neuer als das Updatedatum, dann gib 'true' sonst 'false' zurück + if (dtcd >= dtud) + { + return true; + } + else + { + return false; + } + } + } + + #region Exceptions + class UpdateFilesNotExistException : ApplicationException + { + public UpdateFilesNotExistException() + { } + + public UpdateFilesNotExistException(string message) : base(message) + { } + + public UpdateFilesNotExistException(string message, Exception inner) : base(message, inner) + { } + } + class UpdateException : ApplicationException + { + public UpdateException() + { } + + public UpdateException(string message) : base(message) + { } + + public UpdateException(string message, Exception inner) : base(message, inner) + { } + } + class EnvironmentFileException : ApplicationException + { + public EnvironmentFileException() + { } + + public EnvironmentFileException(string message) : base(message) + { } + + public EnvironmentFileException(string message, Exception inner) : base(message, inner) + { } + } + class VersionFileIOException : ApplicationException + { + public VersionFileIOException() + { } + + public VersionFileIOException(string message) : base(message) + { } + + public VersionFileIOException(string message, Exception inner) : base(message, inner) + { } + } + #endregion +} diff --git a/RunNxUpdate/Properties/AssemblyInfo.cs b/RunNxUpdate/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..227a4e7 --- /dev/null +++ b/RunNxUpdate/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("RunNxUpdate")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RunNxUpdate")] +[assembly: AssemblyCopyright("Copyright © 2017 by Eugen Höglinger")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("d0f3af58-ffaa-43c8-ab98-c3ee8396b4aa")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +// indem Sie "*" wie unten gezeigt eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RunNxUpdate/RunNxUpdate.csproj b/RunNxUpdate/RunNxUpdate.csproj new file mode 100644 index 0000000..d84092c --- /dev/null +++ b/RunNxUpdate/RunNxUpdate.csproj @@ -0,0 +1,70 @@ + + + + + Debug + AnyCPU + {D0F3AF58-FFAA-43C8-AB98-C3EE8396B4AA} + Exe + RunNxUpdate + RunNxUpdate + v4.6 + 512 + true + false + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + True + True + AppResources.resx + + + + + + + + + + + + + + + ResXFileCodeGenerator + AppResources.Designer.cs + + + + \ No newline at end of file diff --git a/RunNxUpdate/RunNxUpdate.csproj.user b/RunNxUpdate/RunNxUpdate.csproj.user new file mode 100644 index 0000000..2dc1a51 --- /dev/null +++ b/RunNxUpdate/RunNxUpdate.csproj.user @@ -0,0 +1,6 @@ + + + + -updatefolder=M:\ug\NX12_install\nx-12.0.2.mp14 -updateNr=engel_20210222 + + \ No newline at end of file diff --git a/RunNxUpdate/bin/Debug/RunNxUpdate.exe b/RunNxUpdate/bin/Debug/RunNxUpdate.exe new file mode 100644 index 0000000..4a07e24 Binary files /dev/null and b/RunNxUpdate/bin/Debug/RunNxUpdate.exe differ diff --git a/RunNxUpdate/bin/Debug/RunNxUpdate.exe.config b/RunNxUpdate/bin/Debug/RunNxUpdate.exe.config new file mode 100644 index 0000000..8324aa6 --- /dev/null +++ b/RunNxUpdate/bin/Debug/RunNxUpdate.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/RunNxUpdate/bin/Debug/RunNxUpdate.pdb b/RunNxUpdate/bin/Debug/RunNxUpdate.pdb new file mode 100644 index 0000000..0088195 Binary files /dev/null and b/RunNxUpdate/bin/Debug/RunNxUpdate.pdb differ diff --git a/RunNxUpdate/bin/Debug/de/RunNxUpdate.resources.dll b/RunNxUpdate/bin/Debug/de/RunNxUpdate.resources.dll new file mode 100644 index 0000000..531c0f9 Binary files /dev/null and b/RunNxUpdate/bin/Debug/de/RunNxUpdate.resources.dll differ diff --git a/RunNxUpdate/bin/Debug/en/RunNxUpdate.resources.dll b/RunNxUpdate/bin/Debug/en/RunNxUpdate.resources.dll new file mode 100644 index 0000000..14a9fea Binary files /dev/null and b/RunNxUpdate/bin/Debug/en/RunNxUpdate.resources.dll differ diff --git a/RunNxUpdate/obj/Debug/.NETFramework,Version=v4.6.AssemblyAttributes.cs b/RunNxUpdate/obj/Debug/.NETFramework,Version=v4.6.AssemblyAttributes.cs new file mode 100644 index 0000000..a216cb0 --- /dev/null +++ b/RunNxUpdate/obj/Debug/.NETFramework,Version=v4.6.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] diff --git a/RunNxUpdate/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/RunNxUpdate/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..0c37ca9 Binary files /dev/null and b/RunNxUpdate/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/RunNxUpdate/obj/Debug/RunNxUpdate.AppResources.de.resources b/RunNxUpdate/obj/Debug/RunNxUpdate.AppResources.de.resources new file mode 100644 index 0000000..2f9e1d7 Binary files /dev/null and b/RunNxUpdate/obj/Debug/RunNxUpdate.AppResources.de.resources differ diff --git a/RunNxUpdate/obj/Debug/RunNxUpdate.AppResources.en.resources b/RunNxUpdate/obj/Debug/RunNxUpdate.AppResources.en.resources new file mode 100644 index 0000000..e517d53 Binary files /dev/null and b/RunNxUpdate/obj/Debug/RunNxUpdate.AppResources.en.resources differ diff --git a/RunNxUpdate/obj/Debug/RunNxUpdate.AppResources.resources b/RunNxUpdate/obj/Debug/RunNxUpdate.AppResources.resources new file mode 100644 index 0000000..817e178 Binary files /dev/null and b/RunNxUpdate/obj/Debug/RunNxUpdate.AppResources.resources differ diff --git a/RunNxUpdate/obj/Debug/RunNxUpdate.csproj.CoreCompileInputs.cache b/RunNxUpdate/obj/Debug/RunNxUpdate.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..b916649 --- /dev/null +++ b/RunNxUpdate/obj/Debug/RunNxUpdate.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +7bc577114769f4498b5f7646d4e2d69085bab002 diff --git a/RunNxUpdate/obj/Debug/RunNxUpdate.csproj.FileListAbsolute.txt b/RunNxUpdate/obj/Debug/RunNxUpdate.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..eb454d6 --- /dev/null +++ b/RunNxUpdate/obj/Debug/RunNxUpdate.csproj.FileListAbsolute.txt @@ -0,0 +1,15 @@ +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\bin\Debug\RunNxUpdate.exe.config +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\bin\Debug\RunNxUpdate.exe +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\bin\Debug\RunNxUpdate.pdb +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\obj\Debug\RunNxUpdate.csprojAssemblyReference.cache +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\obj\Debug\RunNxUpdate.csproj.CoreCompileInputs.cache +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\obj\Debug\RunNxUpdate.exe +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\obj\Debug\RunNxUpdate.pdb +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\bin\Debug\de\RunNxUpdate.resources.dll +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\bin\Debug\en\RunNxUpdate.resources.dll +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\obj\Debug\RunNxUpdate.AppResources.resources +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\obj\Debug\RunNxUpdate.AppResources.de.resources +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\obj\Debug\RunNxUpdate.AppResources.en.resources +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\obj\Debug\RunNxUpdate.csproj.GenerateResource.cache +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\obj\Debug\de\RunNxUpdate.resources.dll +H:\Programmieren\Git-WorkRepository\VisualStudio\_PROJEKTE\RunNxUpdate.git\RunNxUpdate\obj\Debug\en\RunNxUpdate.resources.dll diff --git a/RunNxUpdate/obj/Debug/RunNxUpdate.csproj.GenerateResource.cache b/RunNxUpdate/obj/Debug/RunNxUpdate.csproj.GenerateResource.cache new file mode 100644 index 0000000..b2e9911 Binary files /dev/null and b/RunNxUpdate/obj/Debug/RunNxUpdate.csproj.GenerateResource.cache differ diff --git a/RunNxUpdate/obj/Debug/RunNxUpdate.csprojAssemblyReference.cache b/RunNxUpdate/obj/Debug/RunNxUpdate.csprojAssemblyReference.cache new file mode 100644 index 0000000..9f61b7e Binary files /dev/null and b/RunNxUpdate/obj/Debug/RunNxUpdate.csprojAssemblyReference.cache differ diff --git a/RunNxUpdate/obj/Debug/RunNxUpdate.exe b/RunNxUpdate/obj/Debug/RunNxUpdate.exe new file mode 100644 index 0000000..4a07e24 Binary files /dev/null and b/RunNxUpdate/obj/Debug/RunNxUpdate.exe differ diff --git a/RunNxUpdate/obj/Debug/RunNxUpdate.pdb b/RunNxUpdate/obj/Debug/RunNxUpdate.pdb new file mode 100644 index 0000000..0088195 Binary files /dev/null and b/RunNxUpdate/obj/Debug/RunNxUpdate.pdb differ diff --git a/RunNxUpdate/obj/Debug/TempPE/AppResources.Designer.cs.dll b/RunNxUpdate/obj/Debug/TempPE/AppResources.Designer.cs.dll new file mode 100644 index 0000000..951a919 Binary files /dev/null and b/RunNxUpdate/obj/Debug/TempPE/AppResources.Designer.cs.dll differ diff --git a/RunNxUpdate/obj/Debug/de/RunNxUpdate.resources.dll b/RunNxUpdate/obj/Debug/de/RunNxUpdate.resources.dll new file mode 100644 index 0000000..531c0f9 Binary files /dev/null and b/RunNxUpdate/obj/Debug/de/RunNxUpdate.resources.dll differ diff --git a/RunNxUpdate/obj/Debug/en/RunNxUpdate.resources.dll b/RunNxUpdate/obj/Debug/en/RunNxUpdate.resources.dll new file mode 100644 index 0000000..14a9fea Binary files /dev/null and b/RunNxUpdate/obj/Debug/en/RunNxUpdate.resources.dll differ