-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmInit.cs
192 lines (167 loc) · 6.11 KB
/
frmInit.cs
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using DBJ.Divorced.Define;
using DBJ.Divorced.Helper;
namespace DBJ.Tool.Json
{
public partial class frmInit : Form
{
public frmInit()
{
InitializeComponent();
}
delegate void ShowMsg(string _msg);
private void WFInit_Load(object sender, EventArgs e)
{
//frmMain fm = new frmMain();
//Source.mainForm = fm;
Thread thread = new Thread(new ThreadStart(Init));
thread.Start();
}
private void WriteLog(string msg)
{
if (msg == "end")
{
this.label1.Text = "初始化完毕!";
StartPorgram();
}
else
{
this.label1.Text = msg;
}
}
//private void WriteErrorLog(string msg)
//{
// if (msg == "end")
// {
// this.label1.Text = "初始化完毕!";
// StartPorgram();
// }
// else
// {
// this.label2.Text = msg;
// }
//}
string fnLog = "system.log";
/// <summary>
/// 初始化某些参数
/// </summary>
private void Init()
{
string configError = string.Empty;
try
{
Thread.Sleep(100);
this.BeginInvoke(new ShowMsg(WriteLog), "开始切水果!");
}
catch
{
Thread.Sleep(100);
this.BeginInvoke(new ShowMsg(WriteLog), "服务器参数设定配置出错!");
configError += "\r\n服务器参数设定配置出错";
}
try
{
Thread.Sleep(100);
this.BeginInvoke(new ShowMsg(WriteLog), "今天有台风!");
//if (Source.remotingServerIP.ToLower() == "localhost")
//{
// Source.remotingServerIP = "0.0.0.0";
// Source.remotingServer = (URadio.LocatingService.RemotingEntry.IServiceApi)Activator.GetObject(typeof(URadio.LocatingService.RemotingEntry.IServiceApi), "http://0.0.0.0:10607/ServiceMarshal.soap");
//}
//else
//{
// Source.remotingServer = (URadio.LocatingService.RemotingEntry.IServiceApi)Activator.GetObject(typeof(URadio.LocatingService.RemotingEntry.IServiceApi), System.Configuration.ConfigurationManager.AppSettings["RemotingServer"].ToString());
//}
}
catch
{
Thread.Sleep(100);
this.BeginInvoke(new ShowMsg(WriteLog), "初始化远程服务器出错!");
configError += "\r\n初始化远程服务器出错!";
}
try
{
Thread.Sleep(100);
this.BeginInvoke(new ShowMsg(WriteLog), "瞎叔太帅了!");
//LoadSettingInfo();
}
catch
{
Thread.Sleep(100);
this.BeginInvoke(new ShowMsg(WriteLog), "初始化远程服务器出错!");
configError += "\r\n初始化远程服务器出错!";
}
var parameterList = new List<ParameterItem>();
try
{
LoadExcelFile();
Thread.Sleep(100);
this.BeginInvoke(new ShowMsg(WriteLog), "读取excel!");
}
catch
{
Thread.Sleep(100);
this.BeginInvoke(new ShowMsg(WriteLog), "读取EXCEL出错!");
configError += "\r\n读取EXCEL出错!";
}
//Source.marker = DateTime.Now.Ticks.ToString();
//Source.version = 1;
//ThreadPool.SetMaxThreads(10, 10);
if (configError != "")
{
this.BeginInvoke(new ShowMsg(WriteLog), configError);
}
Thread.Sleep(100);
this.BeginInvoke(new ShowMsg(WriteLog), "开始初始化主界面");
Thread.Sleep(100);
this.BeginInvoke(new ShowMsg(WriteLog), "记得付钱给瞎叔");
Thread.Sleep(100);
this.BeginInvoke(new ShowMsg(WriteLog),"end");
}
public List<List<KeyValue>> ParameterList { get; set; }
private bool isParameterExcelLoaded;
private void LoadExcelFile()
{
var path = $"{Environment.CurrentDirectory}\\JsonTemplate.xls";
//var instanceSheetName = "Default";
var trunkSheetName = "Trunk";
var n1SheetName = "N1";
var n2SheetName = "N2";
var commonSheetName = "Common";
var list = new List<List<KeyValue>>();
ReadExcel(path, commonSheetName, list);
ReadExcel(path, trunkSheetName, list, true);
ReadExcel(path, n1SheetName, list, true);
ReadExcel(path, n2SheetName, list, true);
ExcelHelper.KillProcess();
isParameterExcelLoaded = true;
ParameterList = list;
}
private void ReadExcel(string path, string instanceSheetName, List<List<KeyValue>> list, bool isV = false)
{
if (isV)
list.AddRange(ExcelHelper.GetContentVertical(path, instanceSheetName));
else
list.AddRange(ExcelHelper.GetContent(path, instanceSheetName));
}
private void StartPorgram()
{
this.Hide();
try
{
//var frm = new frmManageIIS();
var frm = new frmMain();
frm.ParaInExcel = this.ParameterList;
frm.ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
this.Close();
}
}
}