106 lines
3.5 KiB
C#
106 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
using svnsync.Controllers;
|
|
using BlubbFish.Utils;
|
|
using svnsync.Libraries;
|
|
|
|
namespace svnsync
|
|
{
|
|
static class Program
|
|
{
|
|
private static Boolean LoopStarted = false;
|
|
|
|
/// <summary>
|
|
/// Der Haupteinstiegspunkt für die Anwendung.
|
|
/// </summary>
|
|
[STAThread]
|
|
static void Main(String[] args)
|
|
{
|
|
Update();
|
|
if (!Cmd(args)) {
|
|
Updater.Instance.WaitForExit();
|
|
return;
|
|
}
|
|
FileMutex.Instance.SetName(CmdArgs.Instance.GetArgumentData("-d"));
|
|
#if !DEBUG
|
|
if (!FileMutex.Instance.Create()) {
|
|
return;
|
|
}
|
|
#endif
|
|
ControllersTray t = null;
|
|
try {
|
|
Svn.Instance.SetDirectory(CmdArgs.Instance.GetArgumentData("-d"));
|
|
t = new ControllersTray();
|
|
ControllersTray.StartLoop += T_StartLoop;
|
|
t.Execute();
|
|
} catch (Exception e) {
|
|
t.HideToolTip();
|
|
String text = e.Message + "\n\n" + e.StackTrace;
|
|
String title = "Exception in SVNSync: " + CmdArgs.Instance.GetArgumentData("-d");
|
|
MessageBox.Show(text, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
#if !DEBUG
|
|
FileMutex.Instance.Delete();
|
|
#endif
|
|
return;
|
|
}
|
|
if (!CmdArgs.Instance.HasArgumentType("-cron")) {
|
|
T_StartLoop();
|
|
}
|
|
#if !DEBUG
|
|
FileMutex.Instance.Delete();
|
|
#endif
|
|
return;
|
|
/*Application.Run();*/
|
|
/*Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
try {
|
|
Application.Run(new Form1(args));
|
|
} catch(NotImplementedException e) {
|
|
System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
} catch(Exception e) {
|
|
//System.Windows.Forms.MessageBox.Show("In: " + e.Source + "\n\n" + e.Message, "Fehler!", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
Application.Exit();
|
|
}*/
|
|
}
|
|
|
|
private static void Update() {
|
|
Updater.Instance.SetPath("https://svn.blubbfish.net:18082/");
|
|
Updater.Instance.UpdateResult += Instance_UpdateResult;
|
|
}
|
|
|
|
private static void Instance_UpdateResult(Object sender, Updater.UpdaterEventArgs e) {
|
|
if(e.HasUpdates) {
|
|
((Updater)sender).Update("SvnSync.exe", "https://");
|
|
}
|
|
}
|
|
|
|
static void T_StartLoop()
|
|
{
|
|
if (!LoopStarted) {
|
|
LoopStarted = true;
|
|
Application.Run();
|
|
}
|
|
|
|
}
|
|
|
|
private static Boolean Cmd(String[] args)
|
|
{
|
|
Dictionary<String, CmdArgs.VaildArguments> pargs = new Dictionary<String, CmdArgs.VaildArguments> {
|
|
{ "-d", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Touple, true) },
|
|
{ "-cron", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) },
|
|
{ "-autoadd", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) },
|
|
{ "-autodelete", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) },
|
|
{ "-externals-own", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) },
|
|
{ "-externals", new CmdArgs.VaildArguments(CmdArgs.ArgLength.Single) }
|
|
};
|
|
CmdArgs.Instance.SetArguments(pargs, args);
|
|
if (!CmdArgs.Instance.HasAllRequiredArguments()) {
|
|
MessageBox.Show(CmdArgs.Instance.GetUsageList("syncsvn.exe:"), "Fehlende Argumente auf der Komandozeile", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|