247 lines
8.5 KiB
C#
247 lines
8.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using Eugen.ESystem;
|
|
|
|
namespace Eugen.NX
|
|
{
|
|
public class NxEnvironment
|
|
{
|
|
#region Version und Copyright
|
|
// Version und Copyright
|
|
static string dllName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen
|
|
static string dllVersion = 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 DLL-Info
|
|
/// <summary>
|
|
/// Contains the name of the program file
|
|
/// </summary>
|
|
public static string DllName { set; get; }
|
|
|
|
/// <summary>
|
|
/// Contains the version of the program file
|
|
/// </summary>
|
|
public static string DllVersion { set; get; }
|
|
|
|
/// <summary>
|
|
/// Contains the copyright notice
|
|
/// </summary>
|
|
public static string Copyright { set; get; }
|
|
|
|
private static void SetDllInfo()
|
|
{
|
|
//Name, Version und Copyright setzen
|
|
DllName = dllName;
|
|
DllVersion = dllVersion;
|
|
Copyright = copyright;
|
|
}
|
|
#endregion
|
|
|
|
static NxEnvironment()
|
|
{
|
|
SetDllInfo();
|
|
}
|
|
|
|
/// <summary>
|
|
/// UGII_BASE_DIR. E.g.: C:\Program Files\Siemens\NX10.0
|
|
/// </summary>
|
|
public static string Ugii_Base_Dir { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_ROOT_DIR. E.g.: C:\Program Files\Siemens\NX10.0\ugii\
|
|
/// </summary>
|
|
public static string Ugii_Root_Dir { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_LANG. E.g.: engl
|
|
/// </summary>
|
|
public static string Ugii_Lang { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_PATDIR. E.g.: V:\NX_Konfig\NX10\Global\Pattern
|
|
/// </summary>
|
|
public static string Ugii_Patdir { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_TMP_DIR. E.g.: C:\Users\Public\temp\NX10
|
|
/// </summary>
|
|
public static string Ugii_Tmp_Dir { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_JAVA_HOME. E.g.: C:\Program Files\Java\jre1.8.0_74
|
|
/// </summary>
|
|
public static string Ugii_Java_Home { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_MAX_FIT_BOX_SIZE. Max. Value = 1000000. E.g.: 900000
|
|
/// </summary>
|
|
public static string Ugii_Max_Fit_Box_Size { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_SUPPORT_XLSM_SPREADSHEET. E.g.: 1
|
|
/// </summary>
|
|
public static string Ugii_Support_Xlsm_Spreadsheet { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_SITE_DIR. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\customer_defaults\SITE
|
|
/// </summary>
|
|
public static string Ugii_Site_Dir { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_GROUP_DIR. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\customer_defaults\GROUP_0
|
|
/// </summary>
|
|
public static string Ugii_Group_Dir { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_LOCAL_USER_DEFAULTS. E.g.: %LOCALAPPDATA%\Siemens\NX100\NX100_user.dpv
|
|
/// </summary>
|
|
public static string Ugii_Local_User_Defaults { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_ENV_FILE. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\UGII\ugii_env.dat
|
|
/// </summary>
|
|
public static string Ugii_Env_File { get; set; }
|
|
|
|
/// <summary>
|
|
/// LOCAL_UGII_ENV_FILE. Is equal to UGII_ENV_FILE. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\UGII\ugii_env.dat
|
|
/// </summary>
|
|
public static string LOCAL_UGII_ENV_FILE { get; set; } //Wird benötigt, damit beim TeamCenter Start 'UGII_ENV_FILE' richtig gesetzt wird
|
|
|
|
/// <summary>
|
|
/// UGII_CUSTOM_DIRECTORY_FILE. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\UGII\menus\custom_dirs.dat
|
|
/// </summary>
|
|
public static string Ugii_Custom_Directory_File { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_BACKGROUND_URL. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Config\UG_TIPS\index.html
|
|
/// </summary>
|
|
public static string Ugii_Background_Url { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// SPLM_LICENSE_SERVER. E.g.: 28000@volkeav
|
|
/// </summary>
|
|
public static string Splm_License_Server { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGS_LICENSE_SERVER. E.g.: 28000@volkeav
|
|
/// </summary>
|
|
public static string Ugs_License_Server { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGS_LICENSE_BUNDLE. E.g: NX11110
|
|
/// </summary>
|
|
public static string Ugs_License_Bundle { get; set; }
|
|
|
|
/// <summary>
|
|
/// NXTOOLS_SYSDIR. E.g.: %NX_ONLINE%\NXNX-Tools\NxTools10.0
|
|
/// </summary>
|
|
public static string NxTools_Sysdir { get; set; }
|
|
|
|
/// <summary>
|
|
/// NX_APPS. E.g.: %NX_ONLINE%\NX-Environment\NX10\NX-Apps
|
|
/// </summary>
|
|
public static string NX_Apps { get; set; }
|
|
|
|
/// <summary>
|
|
/// NX_APPS_MACHINE. E.g.: 64bit
|
|
/// </summary>
|
|
public static string Machine { get; set; }
|
|
|
|
/// <summary>
|
|
/// NX_SERVER_DIR. E.g: %NX_ONLINE%\NX-Environment\NX10
|
|
/// </summary>
|
|
public static string Nx_Server_Dir { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_HTML_UGDOC. E.g.: https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_help/#uid:index
|
|
/// </summary>
|
|
public static string Ugii_Html_Ugdoc { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_HELP_WHATS_NEW. E.g.: https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_help/#uid:index_whatsnew
|
|
/// </summary>
|
|
public static string Ugii_Help_Whats_New { get; set; }
|
|
|
|
/// <summary>
|
|
/// UGII_CSHELP_DOCS. E.g.: https://docs.plm.automation.siemens.com/tdoc/nx/10/nx_help
|
|
/// </summary>
|
|
public static string Ugii_Cshelp_Docs { get; set; }
|
|
|
|
#region Methoden
|
|
public static string ReplaceVariable(string text)
|
|
{
|
|
try
|
|
{
|
|
return ReplaceVariableByValue.Replace(text, true);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|