SafeDispatch/SubscriberAndUserManager/Program.cs
2024-02-22 18:43:59 +02:00

80 lines
2.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;
using System.IO;
using Nini.Config;
using System.Diagnostics;
using SafeMobileLib;
using SafeMobileLib.Helpers;
namespace SubscriberAndUserManager
{
static class Program
{
public static IConfigSource source = null;
static String filename = "";
public const int GoogleZoomLevel = 18;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread()]
static void Main(string[] args)
{
Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
Console.WriteLine("Version: " + v.ToString());
MainForm.radioType = RADIOTYPE.UNKNOWN;
Console.Title = "SUMconsole";
// parse the command line args
CommandLineHelper clh = new CommandLineHelper(args, Console.Title);
MainForm.radioType = clh.ConfigurationType;
if (MainForm.radioType == RADIOTYPE.UNKNOWN)
{
Application.Exit();
}
else
{
// Test if app if allready working
if (Utils.testIfAlreadyRunning(true))
{
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (!AppDomain.CurrentDomain.FriendlyName.EndsWith("vshost.exe"))
{
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
// Set the unhandled exception mode to force all Windows Forms errors
// to go through our handler.
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
}
Application.Run(new MainForm());
}
}
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
//MessageBox.Show(e.Exception.Message, "ThreadException Dispatch.Please restart the application.");
Utils.WriteLine("Application_ThreadException: " + e.Exception.ToString(), ConsoleColor.Red);
// here you can log the exception ...
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
//MessageBox.Show((e.ExceptionObject as Exception).Message, "Unhandled UI Exception Dispatch.Please restart the application.");
Utils.WriteLine("CurrentDomain_UnhandledException: " + e.ToString(), ConsoleColor.Red);
// here you can log the exception ...
}
}
}