checkenvironment_projects_v.../CheckEnvironment/CheckEnvironment.cs

135 lines
4.5 KiB
C#

using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace CheckEnvironment
{
public partial class CheckEnvironment : Form
{
#region Version und Copyright
// Version und Copyright
string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen
string version = 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
public CheckEnvironment()
{
InitializeComponent();
}
private void buttonClose_Click(object sender, EventArgs e)
{
this.Close();
}
private string CheckEnv(string env)
{
return Environment.GetEnvironmentVariable(env);
}
private void Form1_Load(object sender, EventArgs e)
{
string result = "";
result = CheckEnv("NX_ONLINE");
if (String.IsNullOrEmpty(result))
{
textBoxNxOnline.Text = "";
labelNxOnlineResult.Text = "MISSING";
}
else
{
textBoxNxOnline.Text = result;
labelNxOnlineResult.Text = "OK";
}
result = CheckEnv("NX_OFFLINE");
if (String.IsNullOrEmpty(result))
{
textBoxNxOffline.Text = "";
labelNxOfflineResult.Text = "MISSING";
}
else
{
textBoxNxOffline.Text = result;
labelNxOfflineResult.Text = "OK";
}
result = CheckEnv("UGII_ENV_FILE");
if (String.IsNullOrEmpty(result))
{
textBoxUgiiEnvFile.Text = "";
labelUgiiEnvFileResult.Text = "MISSING";
}
else
{
textBoxUgiiEnvFile.Text = result;
labelUgiiEnvFileResult.Text = "OK";
}
result = CheckEnv("COMPSOLV_MACHINE");
if (String.IsNullOrEmpty(result))
{
textBoxCompsolveMachine.Text = "";
labelCompsolveMachineResult.Text = "MISSING";
}
else
{
textBoxCompsolveMachine.Text = result;
labelCompsolveMachineResult.Text = "OK";
}
result = CheckEnv("COMPSOLV_TOOLS");
if (String.IsNullOrEmpty(result))
{
textBoxCompsolvTools.Text = "";
labelCompsolvToolsResult.Text = "MISSING";
}
else
{
textBoxCompsolvTools.Text = result;
labelCompsolvToolsResult.Text = "OK";
}
result = CheckEnv("COMPSOLVE_STDLIB");
if (String.IsNullOrEmpty(result))
{
textBoxCompsolvStdLib.Text = "";
labelCompsolvStdLibResult.Text = "MISSING";
}
else
{
textBoxCompsolvStdLib.Text = result;
labelCompsolvStdLibResult.Text = "OK";
}
result = CheckEnv("COMPSOLV_UGII_SETTINGS");
if (String.IsNullOrEmpty(result))
{
textBoxCompsolvUgiiSettings.Text = "";
labelCompsolvUgiiSettingsResult.Text = "MISSING";
}
else
{
textBoxCompsolvUgiiSettings.Text = result;
labelCompsolvUgiiSettingsResult.Text = "OK";
}
}
}
}