Program.cs 2.2 KB
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Model;

namespace AGVControl
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Common.log = new LogOut("AGVControl_SMD");
            Common.log.Info("=====程序开始=====");
            ReadChargingPile();
            Application.Run(new FrmMain());
            Common.log.Info("=====程序结束=====\r\n");
        }

        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Common.log.Error("CurrentDomain_UnhandledException", (Exception)e.ExceptionObject);
        }

        private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            Common.log.Error("Application_ThreadException", e.Exception);
        }

        /// <summary>
        /// 读取充电桩配置
        /// </summary>
        private static void ReadChargingPile()
        {
            Common.chargingPile = new List<ChargingPile>();
            string[] lines = System.IO.File.ReadAllLines(Common.PATH_CHARGING_PILE, System.Text.Encoding.UTF8);
            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].StartsWith("//")) continue;
                string[] str = lines[i].Split(',');
                if (str.Length <= 1) continue;
                ChargingPile pile = new ChargingPile(str[0]) { User = new string[str.Length - 1] };
                Array.Copy(str, 1, pile.User, 0, pile.User.Length);
                Common.chargingPile.Add(pile);
            }
            Common.log.Info("读取配置文件 " + Common.PATH_CHARGING_PILE);
        }




    }
}