localsynchronizationsetup_p.../LocalSynchronizationSetup/Program.cs

114 lines
5.9 KiB
C#

using System;
using System.Windows.Forms;
namespace LocalSynchronizationSetup
{
static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
private static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string str1 = "Usage: LocalSynchronizationSetup.exe <Startup Directory> <Computer Type> <Connection Type>\r\n\r\n" + "Example use: LocalSynchronizationSetup.exe\r\n" + "or:\t LocalSynchronizationSetup.exe M:\\NX\r\n" + "or:\t LocalSynchronizationSetup.exe M:\\NX -desktop\r\n" + "or:\t LocalSynchronizationSetup.exe M:\\NX -laptop -internal\r\n" + "or:\t LocalSynchronizationSetup.exe M:\\NX -laptop -external\r\n\r\n" + "\t LocalSynchronizationSetup.exe -h shows this help dialog.\r\n\r\n" + "Parameters:\r\n" + "Startup Directory:\r\n" + "\tDirectory, which contains the folders NX_Environment and Modul_3D.\r\n" + "Computer Type:\r\n" + "\t-laptop: Use this parameter to define the computer type.\r\n" + "\t-desktop: Use this parameter to define the computer type. If -desktop is used, the parameter Connection Type is not necessary.\r\n" + "Connection Type:\r\n" + "\t-internal: Use this parameter, if the computer is connected to the ENGEL network.\r\n" + "\t-external: Use this parameter, if the computer is not connected to the ENGEL network\r\n" + "Don't use -internal and -external at the same time.\r\n" + "Don't use -desktop and -laptop at the same time.\r\n" + "If the parameter Connection Type or Computer Type is used, the program doesn't show a dialog.";
string variable = "COMPUTER_TYPE";
string str2 = "LAPTOP_INT";
string str3 = "LAPTOP_EXT";
string str4 = "DESKTOP";
string strAppStartup = "";
bool flag1 = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
foreach (string str5 in args)
{
if (str5.Equals("-h", StringComparison.InvariantCultureIgnoreCase))
{
int num = (int)MessageBox.Show(str1, "Usage of Local Synchronization Setup", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
else if (str5.Equals("-laptop", StringComparison.InvariantCultureIgnoreCase))
{
flag3 = true;
flag1 = true;
}
else if (str5.Equals("-desktop", StringComparison.InvariantCultureIgnoreCase))
{
flag3 = false;
flag1 = true;
}
else if (str5.Equals("-internal", StringComparison.InvariantCultureIgnoreCase))
{
flag4 = true;
flag2 = true;
}
else if (str5.Equals("-external", StringComparison.InvariantCultureIgnoreCase))
{
flag4 = false;
flag2 = true;
}
else
{
strAppStartup = str5;
}
}
if (strAppStartup != null && strAppStartup != "" && (args.Length != 0 && args.Length != 1 || (flag1 || flag2)) && ((args.Length != 2 || !flag1 || (flag3 || flag2)) && (args.Length != 3 || !flag1 || !flag2)))
{
int num1 = (int)MessageBox.Show(str1, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
else if (flag1 && !flag3)
{
if (Environment.GetEnvironmentVariable(variable, EnvironmentVariableTarget.Machine) != null)
{
return;
}
Environment.SetEnvironmentVariable(variable, str4, EnvironmentVariableTarget.Machine);
}
else if (flag2 && flag1)
{
if (flag3 && flag4)
{
if (Environment.GetEnvironmentVariable(variable, EnvironmentVariableTarget.Machine) == null)
{
Environment.SetEnvironmentVariable(variable, str2, EnvironmentVariableTarget.Machine);
}
string summary = "";
new Synchronization(strAppStartup).CreateRemoveSynchronisation(true, false, false, false, false, false, true, false, false, out summary);
}
else
{
if (!flag3 || flag4 || Environment.GetEnvironmentVariable(variable, EnvironmentVariableTarget.Machine) != null)
{
return;
}
Environment.SetEnvironmentVariable(variable, str3, EnvironmentVariableTarget.Machine);
}
}
else
{
string str5 = Environment.GetEnvironmentVariable(variable, EnvironmentVariableTarget.Machine);
if (str5 == null)
{
Environment.SetEnvironmentVariable(variable, str2, EnvironmentVariableTarget.Machine);
str5 = str2;
}
Synchronization synchronization = new Synchronization(strAppStartup);
if (str5.Equals(str2, StringComparison.InvariantCultureIgnoreCase) || str5.Equals(str3, StringComparison.InvariantCultureIgnoreCase))
{
string summary = "";
synchronization.CreateRemoveSynchronisation(true, false, false, false, false, false, true, false, false, out summary);
}
synchronization.StrAppStartupContainsFolderNx(true, str1);
Application.Run(args.Length != 1 ? (Form)new DlgLocalSynchronizationSetup() : (Form)new DlgLocalSynchronizationSetup(args[0]));
}
}
}
}