This repository was archived by the owner on Jul 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
76 lines (71 loc) · 2.25 KB
/
Copy pathProgram.cs
File metadata and controls
76 lines (71 loc) · 2.25 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using _3S_eShop.BLL.DTOs;
using _3S_eShop.GUI.ComponentForm;
using _3S_eShop.PatternDistinctive.Singleton;
using _3S_eShop.Resources;
using _3S_eShop.Utilities;
using DotNetEnv;
using System;
using System.IO;
using System.Windows.Forms;
namespace _3S_eShop
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
EntryPoint();
}
private static void CheckFile()
{
if (!File.Exists(".recent"))
{
File.Create(".recent").Close();
}
if (!File.Exists(".cart"))
{
File.Create(".cart").Close();
}
if (!Directory.Exists("log"))
{
Directory.CreateDirectory("log");
}
}
private static void CheckConnection()
{
if (!NetWorking.IsNetworkAvailable())
{
Logger.Instance.LogError("Không tìm thấy kết nối mạng hoặc kết nối bị gián đoạn -> Buộc dừng chương trình.");
MessageBox.Show("Không có kết nối mạng!\nBuộc dừng chương trình", "Báo cáo", MessageBoxButtons.OK, MessageBoxIcon.Error);
MySystem.Terminate();
}
}
private static void LogEntry()
{
Logger.Instance.LogInfo("KHỞI CHẠY PHIÊN MỚI -----");
}
static void EntryPoint()
{
// Ghi log phiên mới
LogEntry();
// Kiểm tra kết nối mạng
CheckConnection();
// Kiểm tra tập tin
CheckFile();
// Tải biến môi trường
Env.Load("secret_data/.env");
// Tạo instance của MainForm
MainForm mainForm = new MainForm();
// Thiết lập MainForm cho MySystem
MySystem.SetMainForm(mainForm);
// Khởi động ứng dụng
Application.Run(mainForm);
//Application.Run(new TestForm());
}
}
}