From af89a7e540b67934750c789799149811366065e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eugen=20H=C3=B6glinger?= Date: Thu, 27 Feb 2020 14:24:24 +0100 Subject: [PATCH] Projekt neu angelegt. --- .gitignore | 32 +++ NxEnvironment.sln | 31 +++ NxEnvironment/Language.Designer.cs | 81 +++++++ NxEnvironment/Language.de.resx | 126 ++++++++++ NxEnvironment/Language.en.resx | 126 ++++++++++ NxEnvironment/Language.resx | 126 ++++++++++ NxEnvironment/NxEnvironment.cs | 151 ++++++++++++ NxEnvironment/NxEnvironment.csproj | 67 ++++++ NxEnvironment/Properties/AssemblyInfo.cs | 36 +++ NxEnvironment/VaribleThroughString.cs | 176 ++++++++++++++ Test_NxEnvironment/App.config | 6 + Test_NxEnvironment/Form1.Designer.cs | 74 ++++++ Test_NxEnvironment/Form1.cs | 123 ++++++++++ Test_NxEnvironment/Form1.en.resx | 123 ++++++++++ Test_NxEnvironment/Form1.resx | 222 ++++++++++++++++++ Test_NxEnvironment/Program.cs | 22 ++ Test_NxEnvironment/Properties/AssemblyInfo.cs | 36 +++ .../Properties/Resources.Designer.cs | 71 ++++++ Test_NxEnvironment/Properties/Resources.resx | 117 +++++++++ .../Properties/Settings.Designer.cs | 30 +++ .../Properties/Settings.settings | 7 + Test_NxEnvironment/Test_NxEnvironment.csproj | 92 ++++++++ 22 files changed, 1875 insertions(+) create mode 100644 .gitignore create mode 100644 NxEnvironment.sln create mode 100644 NxEnvironment/Language.Designer.cs create mode 100644 NxEnvironment/Language.de.resx create mode 100644 NxEnvironment/Language.en.resx create mode 100644 NxEnvironment/Language.resx create mode 100644 NxEnvironment/NxEnvironment.cs create mode 100644 NxEnvironment/NxEnvironment.csproj create mode 100644 NxEnvironment/Properties/AssemblyInfo.cs create mode 100644 NxEnvironment/VaribleThroughString.cs create mode 100644 Test_NxEnvironment/App.config create mode 100644 Test_NxEnvironment/Form1.Designer.cs create mode 100644 Test_NxEnvironment/Form1.cs create mode 100644 Test_NxEnvironment/Form1.en.resx create mode 100644 Test_NxEnvironment/Form1.resx create mode 100644 Test_NxEnvironment/Program.cs create mode 100644 Test_NxEnvironment/Properties/AssemblyInfo.cs create mode 100644 Test_NxEnvironment/Properties/Resources.Designer.cs create mode 100644 Test_NxEnvironment/Properties/Resources.resx create mode 100644 Test_NxEnvironment/Properties/Settings.Designer.cs create mode 100644 Test_NxEnvironment/Properties/Settings.settings create mode 100644 Test_NxEnvironment/Test_NxEnvironment.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5a5f80a --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ + +#Ignore thumbnails created by Windows +Thumbs.db +#Ignore files built by Visual Studio +*.obj +*.exe +*.pdb +*.user +*.aps +*.pch +*.vspscc +*_i.c +*_p.c +*.ncb +*.suo +*.tlb +*.tlh +*.bak +*.cache +*.ilk +*.log +[Bb]in +[Dd]ebug*/ +*.lib +*.sbr +obj/ +[Rr]elease*/ +_ReSharper*/ +[Tt]est[Rr]esult* +.vs/ +#Nuget packages folder +packages/ diff --git a/NxEnvironment.sln b/NxEnvironment.sln new file mode 100644 index 0000000..f378027 --- /dev/null +++ b/NxEnvironment.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.572 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NxEnvironment", "NxEnvironment\NxEnvironment.csproj", "{7A39F73A-94E7-4BA5-8617-366A2CD83053}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_NxEnvironment", "Test_NxEnvironment\Test_NxEnvironment.csproj", "{79529505-C79E-466D-B854-02D95689ADD0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7A39F73A-94E7-4BA5-8617-366A2CD83053}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A39F73A-94E7-4BA5-8617-366A2CD83053}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A39F73A-94E7-4BA5-8617-366A2CD83053}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A39F73A-94E7-4BA5-8617-366A2CD83053}.Release|Any CPU.Build.0 = Release|Any CPU + {79529505-C79E-466D-B854-02D95689ADD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79529505-C79E-466D-B854-02D95689ADD0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79529505-C79E-466D-B854-02D95689ADD0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79529505-C79E-466D-B854-02D95689ADD0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B7096D66-030E-4958-8FB9-5E386069933C} + EndGlobalSection +EndGlobal diff --git a/NxEnvironment/Language.Designer.cs b/NxEnvironment/Language.Designer.cs new file mode 100644 index 0000000..124ff51 --- /dev/null +++ b/NxEnvironment/Language.Designer.cs @@ -0,0 +1,81 @@ +//------------------------------------------------------------------------------ +// +// 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 Eugen.NX { + 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", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Language { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Language() { + } + + /// + /// 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("NxEnvironment.Language", typeof(Language).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 Die Umgebungsvariable ' ähnelt. + /// + internal static string message001seg01 { + get { + return ResourceManager.GetString("message001seg01", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die ' wurde nicht gefunden! ähnelt. + /// + internal static string message001seg02 { + get { + return ResourceManager.GetString("message001seg02", resourceCulture); + } + } + } +} diff --git a/NxEnvironment/Language.de.resx b/NxEnvironment/Language.de.resx new file mode 100644 index 0000000..b6d0409 --- /dev/null +++ b/NxEnvironment/Language.de.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Die Umgebungsvariable ' + + + ' wurde nicht gefunden! + + \ No newline at end of file diff --git a/NxEnvironment/Language.en.resx b/NxEnvironment/Language.en.resx new file mode 100644 index 0000000..a99e19f --- /dev/null +++ b/NxEnvironment/Language.en.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + The environment variable ' + + + ' was not found! + + \ No newline at end of file diff --git a/NxEnvironment/Language.resx b/NxEnvironment/Language.resx new file mode 100644 index 0000000..b6d0409 --- /dev/null +++ b/NxEnvironment/Language.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Die Umgebungsvariable ' + + + ' wurde nicht gefunden! + + \ No newline at end of file diff --git a/NxEnvironment/NxEnvironment.cs b/NxEnvironment/NxEnvironment.cs new file mode 100644 index 0000000..b02100c --- /dev/null +++ b/NxEnvironment/NxEnvironment.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Eugen.NX +{ + public class NxEnvironment + { + /// + /// UGII_BASE_DIR. E.g.: C:\Program Files\Siemens\NX10.0 + /// + public static string Ugii_Base_Dir { get; set; } + + /// + /// UGII_ROOT_DIR. E.g.: C:\Program Files\Siemens\NX10.0\ugii\ + /// + public static string Ugii_Root_Dir { get; set; } + + /// + /// UGII_LANG. E.g.: engl + /// + public static string Ugii_Lang { get; set; } + + /// + /// UGII_PATDIR. E.g.: V:\NX_Konfig\NX10\Global\Pattern + /// + public static string Ugii_Patdir { get; set; } + + /// + /// UGII_TMP_DIR. E.g.: C:\Users\Public\temp\NX10 + /// + public static string Ugii_Tmp_Dir { get; set; } + + /// + /// UGII_JAVA_HOME. E.g.: C:\Program Files\Java\jre1.8.0_74 + /// + public static string Ugii_Java_Home { get; set; } + + /// + /// UGII_MAX_FIT_BOX_SIZE. Max. Value = 1000000. E.g.: 900000 + /// + public static string Ugii_Max_Fit_Box_Size { get; set; } + + /// + /// UGII_SUPPORT_XLSM_SPREADSHEET. E.g.: 1 + /// + public static string Ugii_Support_Xlsm_Spreadsheet { get; set; } + + /// + /// UGII_SITE_DIR. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\customer_defaults\SITE + /// + public static string Ugii_Site_Dir { get; set; } + + /// + /// UGII_GROUP_DIR. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\customer_defaults\GROUP_0 + /// + public static string Ugii_Group_Dir { get; set; } + + /// + /// UGII_LOCAL_USER_DEFAULTS. E.g.: %LOCALAPPDATA%\Siemens\NX100\NX100_user.dpv + /// + public static string Ugii_Local_User_Defaults { get; set; } + + /// + /// UGII_ENV_FILE. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\UGII\ugii_env.dat + /// + public static string Ugii_Env_File { get; set; } + + /// + /// LOCAL_UGII_ENV_FILE. Is equal to UGII_ENV_FILE. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\UGII\ugii_env.dat + /// + public static string LOCAL_UGII_ENV_FILE { get; set; } //Wird benötigt, damit beim TeamCenter Start 'UGII_ENV_FILE' richtig gesetzt wird + + /// + /// UGII_CUSTOM_DIRECTORY_FILE. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\UGII\menus\custom_dirs.dat + /// + public static string Ugii_Custom_Directory_File { get; set; } + + /// + /// UGII_BACKGROUND_URL. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\UG_TIPS\index.html + /// + public static string Ugii_Background_Url { get; set; } + + + /// + /// SPLM_LICENSE_SERVER. E.g.: 28000@volkeav + /// + public static string Splm_License_Server { get; set; } + + /// + /// UGS_LICENSE_SERVER. E.g.: 28000@volkeav + /// + public static string Ugs_License_Server { get; set; } + + /// + /// UGS_LICENSE_BUNDLE. E.g: NX11110 + /// + public static string Ugs_License_Bundle { get; set; } + + /// + /// NXTOOLS_SYSDIR. E.g.: %NX_ONLINE%\NXNX-Tools\NxTools10.0 + /// + public static string NxTools_Sysdir { get; set; } + + /// + /// NX_APPS. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Apps + /// + public static string NX_Apps { get; set; } + + /// + /// NX_APPS_MACHINE. E.g.: 64bit + /// + public static string Machine { get; set; } + + /// + /// NX_SERVER_DIR. E.g: %NX_ONLINE%\NX-Environment\NX10 + /// + public static string Nx_Server_Dir { get; set; } + + /// + /// UGII_HTML_UGDOC. E.g.: https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_help/#uid:index + /// + public static string Ugii_Html_Ugdoc { get; set; } + + /// + /// UGII_HELP_WHATS_NEW. E.g.: https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_help/#uid:index_whatsnew + /// + public static string Ugii_Help_Whats_New { get; set; } + + /// + /// UGII_CSHELP_DOCS. E.g.: https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_help + /// + public static string Ugii_Cshelp_Docs { get; set; } + + #region Methoden + public static string ReplaceVariable(string text) + { + try + { + return VaribleThroughString.Replace(text, true); + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + #endregion + } +} diff --git a/NxEnvironment/NxEnvironment.csproj b/NxEnvironment/NxEnvironment.csproj new file mode 100644 index 0000000..a3b8871 --- /dev/null +++ b/NxEnvironment/NxEnvironment.csproj @@ -0,0 +1,67 @@ + + + + + Debug + AnyCPU + {7A39F73A-94E7-4BA5-8617-366A2CD83053} + Library + Properties + NxEnvironment + NxEnvironment + v4.6.1 + 512 + false + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + True + True + Language.resx + + + + + + + + Eugen.NX + + + Eugen.NX + + + ResXFileCodeGenerator + Language.Designer.cs + Eugen.NX + + + + \ No newline at end of file diff --git a/NxEnvironment/Properties/AssemblyInfo.cs b/NxEnvironment/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..921e067 --- /dev/null +++ b/NxEnvironment/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("NxEnvironment")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("NxEnvironment")] +[assembly: AssemblyCopyright("Copyright © 2019 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("7a39f73a-94e7-4ba5-8617-366a2cd83053")] + +// 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/NxEnvironment/VaribleThroughString.cs b/NxEnvironment/VaribleThroughString.cs new file mode 100644 index 0000000..8769543 --- /dev/null +++ b/NxEnvironment/VaribleThroughString.cs @@ -0,0 +1,176 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Resources; +using System.Text; +using System.Threading.Tasks; + +namespace Eugen.NX +{ + public class VaribleThroughString + { + const string repStart = "<§<§<§<"; + const string repEnd = ">§>§>§>"; + + /// + /// Replaces variables with the pattern ${variable} or %variable% with their value. + /// + /// The environment variable containing text. If a variable was not found, then the variable name is not replaced. + /// The edited text. + public static string Replace(string text) + { + if (!(text.Contains("${") || text.Contains("%")) || String.IsNullOrEmpty(text)) + { + return text; + } + + while (text.Contains("${")) + { + text = ReplaceVarible(text, "${", "}"); + } + + //Wenn die Umgebungsvariable nicht gefunden wurde, dann die Ursprüngliche Umgebungsvariable wieder herstellen + if (text.Contains(repStart)) + { + text.Replace(repStart, "${"); + text.Replace(repEnd, "}"); + } + + while (text.Contains("%")) + { + text = ReplaceVarible(text, "%", "%"); + } + + //Wenn die Umgebungsvariable nicht gefunden wurde, dann die Ursprüngliche Umgebungsvariable wieder herstellen + if (text.Contains(repStart)) + { + text = text.Replace(repStart, "%"); + text = text.Replace(repEnd, "%"); + } + + return text; + } + + /// + /// Replaces variables with the pattern ${variable} or %variable% with their value. + /// + /// The environment variable containing text. + /// Behavior if variable was not found. True=An exception is thrown. False=The variable is not replaced. + /// The edited text + public static string Replace(string text, bool messageWhenError) + { + if (!(text.Contains("${") || text.Contains("%")) || String.IsNullOrEmpty(text)) + { + return text; + } + + while (text.Contains("${")) + { + text = ReplaceVarible(text, "${", "}"); + } + + //Wenn die Umgebungsvariable nicht gefunden wurde, dann die Ursprüngliche Umgebungsvariable wieder herstellen + if (text.Contains(repStart)) + { + if (messageWhenError) + { + string varName = text.Remove(0, text.IndexOf(repStart) + 7); + varName = varName.Remove(varName.IndexOf(repEnd)); + + text.Replace(repStart, "${"); + text.Replace(repEnd, "}"); + + throw new NoEnvironmentVariableFoundException(String.Concat(Language.message001seg01, varName, Language.message001seg02)); + } + else + { + text.Replace(repStart, "${"); + text.Replace(repEnd, "}"); + } + } + + while (text.Contains("%")) + { + text = ReplaceVarible(text, "%", "%"); + } + + //Wenn die Umgebungsvariable nicht gefunden wurde, dann die Ursprüngliche Umgebungsvariable wieder herstellen + if (text.Contains(repStart)) + { + if (messageWhenError) + { + string varName = text.Remove(0, text.IndexOf(repStart) + 7); + varName = varName.Remove(varName.IndexOf(repEnd)); + + text = text.Replace(repStart, "%"); + text = text.Replace(repEnd, "%"); + + throw new NoEnvironmentVariableFoundException(String.Concat(Language.message001seg01, varName, Language.message001seg02)); + } + else + { + text = text.Replace(repStart, "%"); + text = text.Replace(repEnd, "%"); + } + } + + return text; + } + + private static string ReplaceVarible(string text, string startSign, string endSign) + { + //Wert vor der Variablen sichern + string temp = text.Remove(text.IndexOf(startSign)); + + //Variable extrahieren + text = text.Remove(0, text.IndexOf(startSign)); //'temp' entfernen + text = text.Remove(0, startSign.Length); //'startSign' entfernen + string variableName = text.Remove(text.IndexOf(endSign)); //'endSign' und nachfolgenden Text entfernen + + //Restlicher Text (hinter 'endSign') erzeugen + text = text.Remove(0, text.IndexOf(endSign) + 1); + + //Variable umwandeln und Text wieder zusammenbauen + string variable = ReplaceEnvironmentVariable(variableName); + text = temp + variable + text; //Text wieder zusammensetzen + + return text; + } + + private static string ReplaceEnvironmentVariable(string variableName) + { + string variableValue = ""; + + //Wenn im Text eine bekannte Umgebungsvariable enthalten ist, dann gegen den aktuellen Wert tauschen + variableValue = Environment.GetEnvironmentVariable(variableName); + + if (String.IsNullOrEmpty(variableValue)) + { + variableValue = String.Concat(repStart, variableName, repEnd); //Wird keine Umgebungsvariable gefunden, dann wieder den Variblen Namen zurückgeben + } + + return variableValue; + } + } + + #region Exceptions + class NoEnvironmentVariableFoundException : ApplicationException + { + public NoEnvironmentVariableFoundException() + { + } + + public NoEnvironmentVariableFoundException(string message) + : base(message) + { + } + + public NoEnvironmentVariableFoundException(string message, Exception inner) + : base(message, inner) + { + } + } + #endregion +} diff --git a/Test_NxEnvironment/App.config b/Test_NxEnvironment/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/Test_NxEnvironment/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Test_NxEnvironment/Form1.Designer.cs b/Test_NxEnvironment/Form1.Designer.cs new file mode 100644 index 0000000..e86df67 --- /dev/null +++ b/Test_NxEnvironment/Form1.Designer.cs @@ -0,0 +1,74 @@ +namespace Eugen.NX +{ + partial class Form1 + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + this.buttonStart = new System.Windows.Forms.Button(); + this.labelEnvironment = new System.Windows.Forms.Label(); + this.labelReplace = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // buttonStart + // + resources.ApplyResources(this.buttonStart, "buttonStart"); + this.buttonStart.Name = "buttonStart"; + this.buttonStart.UseVisualStyleBackColor = true; + this.buttonStart.Click += new System.EventHandler(this.buttonStart_Click); + // + // labelEnvironment + // + resources.ApplyResources(this.labelEnvironment, "labelEnvironment"); + this.labelEnvironment.Name = "labelEnvironment"; + // + // labelReplace + // + resources.ApplyResources(this.labelReplace, "labelReplace"); + this.labelReplace.Name = "labelReplace"; + // + // Form1 + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.labelReplace); + this.Controls.Add(this.labelEnvironment); + this.Controls.Add(this.buttonStart); + this.Name = "Form1"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonStart; + private System.Windows.Forms.Label labelEnvironment; + private System.Windows.Forms.Label labelReplace; + } +} + diff --git a/Test_NxEnvironment/Form1.cs b/Test_NxEnvironment/Form1.cs new file mode 100644 index 0000000..005bd99 --- /dev/null +++ b/Test_NxEnvironment/Form1.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Eugen.NX +{ + public partial class Form1 : Form + { + #region Version und Copyright + // Version und Copyright + string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen + string programVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + string copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + 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; + } + #endregion + + #region Programm-Info + /// + /// Contains the name of the program file + /// + public static string ProgramName { set; get; } + + /// + /// Contains the version of the program file + /// + public static string ProgramVersion { set; get; } + + /// + /// Contains the copyright notice + /// + public static string Copyright { set; get; } + + private void SetProgramInfo() + { + //Name, Version und Copyright setzen + ProgramName = programName; + ProgramVersion = programVersion; + Copyright = copyright; + } + #endregion + + public Form1() + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + } + + private void buttonStart_Click(object sender, EventArgs e) + { + SetEnv(); + + labelEnvironment.Text = ShowEnv(); + + labelReplace.Text = String.Concat("Aus ", NxEnvironment.Nx_Server_Dir, " wird ", NxEnvironment.ReplaceVariable(NxEnvironment.Nx_Server_Dir)); + } + + private void SetEnv() + { + NxEnvironment.Ugii_Base_Dir = @"C:\Program Files\Siemens\NX10.0"; + NxEnvironment.Ugii_Root_Dir = @"C:\Program Files\Siemens\NX10.0\ugii\"; + NxEnvironment.Ugii_Lang = "engl"; + NxEnvironment.Ugii_Patdir = @"V:\NX_Config\NX10\Global\Pattern"; + NxEnvironment.Ugii_Tmp_Dir = @"C:\Users\Public\temp\NX10"; + NxEnvironment.Ugii_Java_Home = @"C:\Program Files\Java\jre1.8.0_74"; + NxEnvironment.Ugii_Max_Fit_Box_Size = "900000"; + NxEnvironment.Ugii_Support_Xlsm_Spreadsheet = "1"; + NxEnvironment.Ugii_Site_Dir = @"%NX_ONLINE%\NX-Environment\NX10\NX-Config\customer_defaults\SITE"; + NxEnvironment.Ugii_Group_Dir = @"%NX_ONLINE%\NX-Environment\NX10\NX-Config\customer_defaults\GROUP_0"; + NxEnvironment.Ugii_Local_User_Defaults = @"%LOCALAPPDATA%\Siemens\NX100\NX100_user.dpv"; + NxEnvironment.Ugii_Env_File = @"%NX_ONLINE%\NX-Environment\NX10\NX-Config\UGII\ugii_env.dat"; + NxEnvironment.LOCAL_UGII_ENV_FILE = NxEnvironment.Ugii_Env_File; + NxEnvironment.Ugii_Custom_Directory_File = @"%NX_ONLINE%\NX-Environment\NX10\NX-Config\UGII\menus\custom_dirs.dat"; + NxEnvironment.Ugii_Background_Url = @"%NX_ONLINE%\NX-Environment\NX10\NX-Config\UG_TIPS\index.html"; + NxEnvironment.Splm_License_Server = "28000@volkeav"; + NxEnvironment.Ugs_License_Server = "28000@volkeav"; + NxEnvironment.Ugs_License_Bundle = "NX11110"; + NxEnvironment.NxTools_Sysdir = @"%NX_ONLINE%\NXNX-Tools\NxTools10.0"; + NxEnvironment.NX_Apps = @"%NX_ONLINE%\NX-Environment\NX10\NX-Apps"; + NxEnvironment.Machine = "64bit"; + NxEnvironment.Nx_Server_Dir = @"%NX_ONLINE%\NX-Environment\NX10"; + NxEnvironment.Ugii_Html_Ugdoc = "https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_help/#uid:index"; + NxEnvironment.Ugii_Help_Whats_New = "https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_help/#uid:index_whatsnew"; + NxEnvironment.Ugii_Cshelp_Docs = "https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_help"; + } + + private string ShowEnv() + { + return String.Concat("UGII_BASE_DIR: ",NxEnvironment.Ugii_Base_Dir, "\nUGII_ROOT_DIR: ", NxEnvironment.Ugii_Root_Dir, + "\nUGII_LANG: ", NxEnvironment.Ugii_Lang, "\nUGII_PATDIR: ", NxEnvironment.Ugii_Patdir, + "\nUGII_TMP_DIR: ", NxEnvironment.Ugii_Tmp_Dir, "\nUGII_JAVA_HOME: ", NxEnvironment.Ugii_Java_Home, + "\nUGII_MAX_FIT_BOX_SIZE: ", NxEnvironment.Ugii_Max_Fit_Box_Size, "\nUGII_SUPPORT_XLSM_SPREADSHEET: ", NxEnvironment.Ugii_Support_Xlsm_Spreadsheet, + "\nUGII_SITE_DIR: ", NxEnvironment.Ugii_Site_Dir, "\nUGII_GROUP_DIR: ", NxEnvironment.Ugii_Group_Dir, + "\nUGII_LOCAL_USER_DEFAULT: ", NxEnvironment.Ugii_Local_User_Defaults, "\nUGII_ENV_FILE: ", NxEnvironment.Ugii_Env_File, + "\nLOCAL_ENV_FILE: ", NxEnvironment.LOCAL_UGII_ENV_FILE, "\nUGII_CUSTOM_DIRECTORY_FILE: ", NxEnvironment.Ugii_Custom_Directory_File, + "\nUGII_BACKGROUND_URL: ", NxEnvironment.Ugii_Background_Url, "\nSPLM_LICENSE_SERVER: ", NxEnvironment.Splm_License_Server, + "\nUGS:LICENSE_SERVER: ", NxEnvironment.Ugs_License_Server, "\nUGS_LICENSE_BUNDLE: ", NxEnvironment.Ugs_License_Bundle, + "\nNXTOOLS_SYSDIR: ", NxEnvironment.NxTools_Sysdir, "\nNX_APPS: ", NxEnvironment.NX_Apps, + "\nMACHINE: ", NxEnvironment.Machine, "\nNX_SERVER_DIR: ", NxEnvironment.Nx_Server_Dir, + "\nUGII_HTML_UGDOC: ", NxEnvironment.Ugii_Html_Ugdoc, "\nUGII_HELP_WHATS_NEW: ", NxEnvironment.Ugii_Help_Whats_New, + "\nUGII_CSHELP_DOCS: ", NxEnvironment.Ugii_Cshelp_Docs); + } + } +} diff --git a/Test_NxEnvironment/Form1.en.resx b/Test_NxEnvironment/Form1.en.resx new file mode 100644 index 0000000..2945b98 --- /dev/null +++ b/Test_NxEnvironment/Form1.en.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Show environment variable + + \ No newline at end of file diff --git a/Test_NxEnvironment/Form1.resx b/Test_NxEnvironment/Form1.resx new file mode 100644 index 0000000..a34c249 --- /dev/null +++ b/Test_NxEnvironment/Form1.resx @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + Bottom, Left, Right + + + + 304, 415 + + + 193, 23 + + + + 0 + + + Umgebungsvariablen anzeigen + + + buttonStart + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + True + + + 13, 13 + + + 16, 13 + + + 1 + + + ... + + + labelEnvironment + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + 13, 362 + + + 16, 13 + + + 2 + + + ... + + + labelReplace + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + True + + + 6, 13 + + + 800, 450 + + + Umgebungsvariablen anzeigen + + + Form1 + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Test_NxEnvironment/Program.cs b/Test_NxEnvironment/Program.cs new file mode 100644 index 0000000..5899007 --- /dev/null +++ b/Test_NxEnvironment/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Eugen.NX +{ + static class Program + { + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Test_NxEnvironment/Properties/AssemblyInfo.cs b/Test_NxEnvironment/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5ce8d47 --- /dev/null +++ b/Test_NxEnvironment/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("Test_NxEnvironment")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Test_NxEnvironment")] +[assembly: AssemblyCopyright("Copyright © 2019 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("79529505-c79e-466d-b854-02d95689add0")] + +// 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, +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.*")] +//[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Test_NxEnvironment/Properties/Resources.Designer.cs b/Test_NxEnvironment/Properties/Resources.Designer.cs new file mode 100644 index 0000000..af7aa45 --- /dev/null +++ b/Test_NxEnvironment/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion: 4.0.30319.42000 +// +// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn +// der Code neu generiert wird. +// +//------------------------------------------------------------------------------ + +namespace Test_NxEnvironment.Properties +{ + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder-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 Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 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 ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test_NxEnvironment.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenlookups, 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; + } + } + } +} diff --git a/Test_NxEnvironment/Properties/Resources.resx b/Test_NxEnvironment/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Test_NxEnvironment/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Test_NxEnvironment/Properties/Settings.Designer.cs b/Test_NxEnvironment/Properties/Settings.Designer.cs new file mode 100644 index 0000000..274a755 --- /dev/null +++ b/Test_NxEnvironment/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Test_NxEnvironment.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Test_NxEnvironment/Properties/Settings.settings b/Test_NxEnvironment/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Test_NxEnvironment/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Test_NxEnvironment/Test_NxEnvironment.csproj b/Test_NxEnvironment/Test_NxEnvironment.csproj new file mode 100644 index 0000000..f2305e7 --- /dev/null +++ b/Test_NxEnvironment/Test_NxEnvironment.csproj @@ -0,0 +1,92 @@ + + + + + Debug + AnyCPU + {79529505-C79E-466D-B854-02D95689ADD0} + WinExe + Test_NxEnvironment + Test_NxEnvironment + v4.6.1 + 512 + true + false + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + {7a39f73a-94e7-4ba5-8617-366a2cd83053} + NxEnvironment + + + + \ No newline at end of file