182 lines
8.7 KiB
C#
182 lines
8.7 KiB
C#
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 = 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 = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
|
|
//return startYear.Remove(0, startYear.LastIndexOf(" ") + 1);
|
|
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 String.Concat(((AssemblyCopyrightAttribute)attributes[0]).Copyright, "-", currentYear);
|
|
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace(startYear, String.Concat(startYear, "-", currentYear));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Programm-Info
|
|
/// <summary>
|
|
/// Contains the name of the program file
|
|
/// </summary>
|
|
public static string ProgramName { set; get; }
|
|
|
|
/// <summary>
|
|
/// Contains the version of the program file
|
|
/// </summary>
|
|
public static string ProgramVersion { set; get; }
|
|
|
|
/// <summary>
|
|
/// Contains the copyright notice
|
|
/// </summary>
|
|
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 Form1_Load(object sender, EventArgs e)
|
|
{
|
|
ShowInformation(); //Programm- und DLL-Information anzeigen
|
|
}
|
|
|
|
private void ShowInformation()
|
|
{
|
|
labelProgramInfo.Text = String.Concat(ProgramName, "\n", ProgramVersion, "\n", Copyright); //Programm-Information anzeigen
|
|
|
|
// DLL-Information anzeigen
|
|
labelDLLInfo.Text = String.Concat(NxEnvironment.DllName, "\n", NxEnvironment.DllVersion, "\n", NxEnvironment.Copyright);
|
|
}
|
|
|
|
private void buttonStart_Click(object sender, EventArgs e)
|
|
{
|
|
SetEnv(); //Die Variablen setzten
|
|
|
|
labelEnvironment.Text = ShowEnv(); //Die Variablen anzeigen
|
|
|
|
//Umgebungsvariable durch Wert ersetzen
|
|
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);
|
|
}
|
|
}
|
|
}
|