static void Main(string[] args)
        {
            try{
                if (args.Length == 0 | args[0].Equals("?"))
                {
                    LogManager.Global = new LogManager(true, new TextLogger(null, LogLevel.Everything, "Wiffzack", Console.Out));
                    printTypes();
                    return;
                }
                Starter.logger = args[0];
                Starter.result = args[1];
                String   type = args[2];
                String[] newargs;
                if (args.Length - 3 <= 0)
                {
                    newargs = null;
                }
                else
                {
                    newargs = new String[args.Length - 3];
                    for (int i = 3; i < args.Length; i++)
                    {
                        newargs[i - 3] = args[i];
                    }
                }
                switch (type)
                {
                case "reset":
                    ResetStarter.Main(newargs);
                    break;

                case "eod":
                    EndOfDayStarter.Main(newargs);
                    break;

                case "network":
                    NetworkDiagnosisStarter.Main(newargs);
                    break;

                case "register":
                    RegistrationStarter.Main(newargs);
                    break;

                case "report":
                    ReportStarter.Main(newargs);
                    break;

                case "reversal":
                    ReversalStarter.Main(newargs);
                    break;

                case "payment":
                    PaymentStarter.Main(newargs);
                    break;

                case "telepayment":
                    TelePaymentStarter.Main(newargs);
                    break;

                case "abort":
                    AbortStarter.Main(newargs);
                    break;

                case "repeat":
                    RepeatReceiptStarter.Main(newargs);
                    break;

                default:
                    printTypes();
                    return;
                }
            }catch (IndexOutOfRangeException) {
                LogManager.Global = new LogManager(true, new TextLogger(null, LogLevel.Everything, "Wiffzack", Console.Out));
                printTypes();
                return;
            }catch (Exception e) {
                LogManager.Global = new LogManager(true, new TextLogger(null, LogLevel.Everything, "Wiffzack", Starter.getFileLoggerStream()));
                Logger _log = LogManager.Global.GetLogger("Wiffzack");
                _log.Info("Start up error");
                _log.Info(e.Message);
                _log.Info(e.StackTrace);
                _log.Info(e.GetType().ToString());
            }
        }
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name='args'>
        /// The command-line arguments.
        /// </param>
        public static void Main(string[] args)
        {
            LogManager.Global = new LogManager(true, new TextLogger(null, LogLevel.Everything, "Wiffzack", Starter.getFileLoggerStream()));
            //create XML file with result message
            XmlDocument resultXML = new XmlDocument();
            XmlElement  rootNode  = resultXML.CreateElement("Result");

            resultXML.AppendChild(rootNode);
            //check if the first argument is a file
            if (args == null || args.Length != 1 || !File.Exists(args[0]))
            {
                LogManager.Global.GetLogger("Wiffzack").Info("Please pass a XML configuration file as first argument!");
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -1);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", "Please pass a XML configuration file as first argument!");
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }
            if (args[0].Equals("?"))
            {
                LogManager.Global = new LogManager(true, new TextLogger(null, LogLevel.Everything, "Wiffzack", Console.Out));
                Console.WriteLine("repeat <config.xml>");
                printHelp();
                return;
            }

            //load the XML file
            XmlDocument config = new XmlDocument();

            try {
                config.Load(args[0]);
            }
            //if any exception occur, the XML file could not be read and thus the program stops
            catch (Exception) {
                LogManager.Global.GetLogger("Wiffzack").Info("Your XML was probably bad...");
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -2);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", "Your XML was probably bad.");
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }
            //initialise environment with the configuration file and execute command
            try{
                ICommandEnvironment environment = new ZVTCommandEnvironment(config.DocumentElement);
                environment.StatusReceived += new IntermediateStatusDelegate(environment_StatusReceived);
                RepeatReceiptResult result = (RepeatReceiptResult)environment.CreateRepeatReceiptCommand((XmlElement)config.DocumentElement.SelectSingleNode("RepeatReceipt")).Execute();
                //create XML file with result message
                if (result.Success == true && result.Data != null)
                {
                    LogManager.Global.GetLogger("Wiffzack").Info("Writing Data");
                    result.Data.WriteXml(resultXML.DocumentElement);
                }
                result.SerializeToXml(resultXML.DocumentElement);
                //save file in /tmp/result.xml
                resultXML.Save(Starter.result);
                //debug message --> remove later
                LogManager.Global.GetLogger("Wiffzack").Info("XML file created");
            }catch (System.ArgumentException) {
                LogManager.Global.GetLogger("Wiffzack").Info("Bad Xml Argument");
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -3);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", "Bad Xml Argument");
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }catch (System.FormatException fe) {
                LogManager.Global.GetLogger("Wiffzack").Info("Bad Xml Argument");
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -3);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", fe.Message);
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }catch (System.Net.Sockets.SocketException ce) {
                LogManager.Global.GetLogger("Wiffzack").Info("Connection Error: " + ce.Message);
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -4);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", ce.Message);
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }catch (ConnectionTimeOutException ce) {
                LogManager.Global.GetLogger("Wiffzack").Info("Network Error:" + ce.Message);
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -150);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", ce.Message);
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
            }catch (Exception e) {
                LogManager.Global.GetLogger("Wiffzack").Info("System Error:" + e.Message);
                XmlHelper.WriteBool(rootNode, "Success", false);
                XmlHelper.WriteInt(rootNode, "ProtocolSpecificErrorCode", -255);
                XmlHelper.WriteString(rootNode, "ProtocolSpecificErrorDescription", e.Message);
                //save file in /tmp/result.xml
                try{
                    resultXML.Save(Starter.result);
                }catch (Exception saving) {
                    LogManager.Global.GetLogger("Wiffzack").Info("Error Saving Result");
                    LogManager.Global.GetLogger("Wiffzack").Info(saving.Message);
                }
                return;
            }
        }