MainWindow.cs
2.66 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using AutoMapper.Configuration.Conventions;
using Hh.Mes.POJO.Entity;
using HH.Data.Excel.Services;
using HH.Data.Excel.SqlHelp;
using System;
using System.Configuration;
using System.IO;
namespace HH.Data.Excel
{
public partial class MainWindow : Form
{
#region 属性
public readonly MainService _appService;
public readonly DatabaseService _dataService;
public Guid selectProjectKey;
public string? selectFactoryCode;
public readonly string _sysIpFileName = "IP地址表.xlsx";
/// <summary>项目信息
/// </summary>
public List<KeyValuePair<Guid, string>>? ProjectKeyValueList { get; set; }
/// <summary>
/// 设备类型 数据源
/// </summary>
public Dictionary<int, string> EqTypeDataSource { get; set; }
/// <summary> 事件注册 处理
/// </summary>
public MainEventHandlers _eventHandlers;
#region 公共属性返回控件的值
public TabControl _tabControl1 => tabControl1;
public ComboBox _cb_project => cb_project;
public ComboBox _cb_factory => cb_factory;
public Panel _panel2 => panel2;
/// <summary>设备复选框
/// </summary>
public CheckedListBox _ccb_type => ccb_type;
public Button _btn_read => btn_read;
public Button _btn_read_save => btn_read_save;
public Button _btnDefaule => btnDefaule;
#endregion
#endregion
public MainWindow()
{
InitializeComponent();
_appService = new MainService();
_eventHandlers = new MainEventHandlers(this);
Init();
}
void Init()
{
this.Text = "IOT平台数据地址协议解析 " + GetAppVersion();
this.MaximizeBox = false; // 禁止最大化
this.FormBorderStyle = FormBorderStyle.FixedSingle; // 禁止调整大小
ProjectKeyValueList = new List<KeyValuePair<Guid, string>>();
InitControl();
}
/// <summary>初始化 项目、厂房、设备类型 控件
/// </summary>
void InitControl()
{
ProjectKeyValueList = _appService.InitProject(cb_project);
_appService.InitFactory(cb_factory, ProjectKeyValueList[0].Key);
EqTypeDataSource = _appService.InitEqType(ccb_type, panel2);
}
public string GetAppVersion()
{
// 读取版本号
var version = ConfigurationManager.AppSettings["ver"];
// 空值验证
if (string.IsNullOrEmpty(version))
{
throw new ConfigurationErrorsException("未找到版本号配置");
}
return version;
}
}
}