﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace POSClient
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.Run(new MainPOS());
        }

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(e.Exception.Message + Environment.NewLine + e.Exception.StackTrace + DetectInnerException(e.Exception), "Error");
        }

        private static string DetectInnerException(Exception exception)
        {
            if (exception.InnerException != null)
                return exception.InnerException.Message + Environment.NewLine + exception.InnerException.StackTrace;
            else
                return String.Empty;
        }
    }
}
