Program.cs
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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);
}
}
}