Skip to content

Commit b1852df

Browse files
committed
网络组件更新,日志组件重新设计,查看日志更方便,网络类名称重新组织
1 parent b0f81c4 commit b1852df

File tree

12 files changed

+1966
-1523
lines changed

12 files changed

+1966
-1523
lines changed

ClientsLibrary/ClientsLibrary.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
<Compile Include="FormDownloading.Designer.cs">
5656
<DependentUpon>FormDownloading.cs</DependentUpon>
5757
</Compile>
58-
<Compile Include="FormLog.cs">
58+
<Compile Include="FormLogView.cs">
5959
<SubType>Form</SubType>
6060
</Compile>
61-
<Compile Include="FormLog.Designer.cs">
62-
<DependentUpon>FormLog.cs</DependentUpon>
61+
<Compile Include="FormLogView.Designer.cs">
62+
<DependentUpon>FormLogView.cs</DependentUpon>
6363
</Compile>
6464
<Compile Include="FormRegisterAccount.cs">
6565
<SubType>Form</SubType>
@@ -81,8 +81,8 @@
8181
<EmbeddedResource Include="FormDownloading.resx">
8282
<DependentUpon>FormDownloading.cs</DependentUpon>
8383
</EmbeddedResource>
84-
<EmbeddedResource Include="FormLog.resx">
85-
<DependentUpon>FormLog.cs</DependentUpon>
84+
<EmbeddedResource Include="FormLogView.resx">
85+
<DependentUpon>FormLogView.cs</DependentUpon>
8686
</EmbeddedResource>
8787
<EmbeddedResource Include="FormRegisterAccount.resx">
8888
<DependentUpon>FormRegisterAccount.cs</DependentUpon>

ClientsLibrary/FormLog.Designer.cs renamed to ClientsLibrary/FormLogView.Designer.cs

Lines changed: 266 additions & 360 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ClientsLibrary/FormLog.cs renamed to ClientsLibrary/FormLogView.cs

Lines changed: 19 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,53 @@
1-
using System;
1+
using CommonLibrary;
2+
using HslCommunication;
3+
using HslCommunication.Enthernet;
4+
using System;
25
using System.Collections.Generic;
36
using System.ComponentModel;
47
using System.Data;
58
using System.Drawing;
69
using System.Linq;
710
using System.Text;
811
using System.Windows.Forms;
9-
using CommonLibrary;
10-
using System.Text.RegularExpressions;
11-
12-
using HslCommunication;
13-
using HslCommunication.Enthernet;
14-
1512

1613
namespace ClientsLibrary
1714
{
18-
public partial class FormLog : Form
15+
public partial class FormLogView : Form
1916
{
20-
public FormLog()
17+
public FormLogView()
2118
{
2219
InitializeComponent();
2320
net_simplify_client = UserClient.Net_simplify_client;
2421
}
2522

26-
private Net_Simplify_Client net_simplify_client = null;
27-
28-
private void FormLog_Load(object sender, EventArgs e)
23+
private void FormLogView_Load(object sender, EventArgs e)
2924
{
3025

3126
}
3227

28+
private NetSimplifyClient net_simplify_client = null;
29+
3330
private void ReadFromServer(int head_code)
3431
{
3532
OperateResultString result = net_simplify_client.ReadFromServer(head_code);
3633
if (result.IsSuccess)
3734
{
38-
textBox1.Text = result.Content;
39-
LogTemp = result.Content;
35+
logNetAnalysisControl1.SetLogNetSource(result.Content);
36+
}
37+
else
38+
{
39+
MessageBox.Show(result.ToMessageShowString());
4040
}
41-
else textBox1.Text = result.ToMessageShowString();
4241
}
42+
4343
private void ClearFromServer(int head_code)
4444
{
4545
OperateResultString result = net_simplify_client.ReadFromServer(head_code);
46-
if (result.IsSuccess) textBox1.Text = "清除成功";
47-
else textBox1.Text = result.ToMessageShowString();
46+
if (result.IsSuccess) MessageBox.Show("清除成功");
47+
else MessageBox.Show(result.ToMessageShowString());
4848
}
4949

50+
5051
private void userButton_login_Click(object sender, EventArgs e)
5152
{
5253
ReadFromServer(CommonHeadCode.SimplifyHeadCode.网络日志查看);
@@ -135,52 +136,9 @@ private void userButton16_Click(object sender, EventArgs e)
135136
ClearFromServer(CommonHeadCode.SimplifyHeadCode.头像日志清空);
136137
}
137138

138-
/// <summary>
139-
/// 查询日志的缓存
140-
/// </summary>
141-
private string LogTemp = string.Empty;
142-
143-
/// <summary>
144-
/// 筛选出符合需求的日志
145-
/// </summary>
146-
/// <param name="filter"></param>
147-
/// <returns></returns>
148-
private string FilterString(string filter)
149-
{
150-
StringBuilder sb = new StringBuilder();
151-
MatchCollection mc = Regex.Matches(LogTemp, @"\u0002\[" + filter + @"[^\u0002]+");
152-
foreach (Match m in mc)
153-
{
154-
sb.Append(m.Value);
155-
}
156-
return sb.ToString();
157-
}
158-
159-
private void userButton_log1_Click(object sender, EventArgs e)
160-
{
161-
textBox1.Text = FilterString(HslCommunication.BasicFramework.SoftLogHelper.Normal);
162-
}
163-
164-
private void userButton_log2_Click(object sender, EventArgs e)
139+
private void logNetAnalysisControl1_Load(object sender, EventArgs e)
165140
{
166-
textBox1.Text = FilterString(HslCommunication.BasicFramework.SoftLogHelper.Information);
167-
}
168141

169-
private void userButton_log3_Click(object sender, EventArgs e)
170-
{
171-
textBox1.Text = FilterString(HslCommunication.BasicFramework.SoftLogHelper.Warnning);
172142
}
173-
174-
private void userButton_log4_Click(object sender, EventArgs e)
175-
{
176-
textBox1.Text = FilterString(HslCommunication.BasicFramework.SoftLogHelper.Error);
177-
}
178-
179-
private void userButton_log_Click(object sender, EventArgs e)
180-
{
181-
textBox1.Text = LogTemp;
182-
}
183-
184-
185143
}
186144
}
File renamed without changes.

ClientsLibrary/FormRegisterAccount.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private void FormRegisterAccount_Load(object sender, EventArgs e)
3232
textBox4.Text = (new UserAccount()).ForbidMessage;
3333
}
3434

35-
private Net_Simplify_Client net_client = null;
35+
private NetSimplifyClient net_client = null;
3636

3737
private void userButton_login_Click(object sender, EventArgs e)
3838
{

ClientsLibrary/UserClient.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public class UserClient
2525
public static SystemVersion CurrentVersion { get; } = new SystemVersion("1.0.0");
2626

2727
/// <summary>
28-
/// 服务器的IP地址,默认为127.0.0.1,可用于单机调试
28+
/// 服务器的IP地址,默认为127.0.0.1,可用于单机调试,云端:117.48.203.204
2929
/// </summary>
30-
public static string ServerIp { get; } = "117.48.203.204";//用于测试的云服务器地址
30+
public static string ServerIp { get; } = "127.0.0.1";//用于测试的云服务器地址
3131

3232
/// <summary>
3333
/// 所有版本更新信息的对象
@@ -66,7 +66,7 @@ public class UserClient
6666
/// <summary>
6767
/// 用于访问服务器数据的网络对象类,必须修改这个端口参数,否则运行失败
6868
/// </summary>
69-
public static Net_Simplify_Client Net_simplify_client = new Net_Simplify_Client(
69+
public static NetSimplifyClient Net_simplify_client = new NetSimplifyClient(
7070
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(ServerIp),
7171
CommonLibrary.CommonLibrary.Port_Second_Net))
7272
{
@@ -77,7 +77,7 @@ public class UserClient
7777
/// <summary>
7878
/// 用于使用udp向服务器进行发送即时可丢失数据的对象
7979
/// </summary>
80-
public static Net_Udp_Client Net_Udp_Client = new Net_Udp_Client(
80+
public static NetUdpClient Net_Udp_Client = new NetUdpClient(
8181
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(ServerIp),
8282
CommonLibrary.CommonLibrary.Port_Udp_Server))
8383
{
@@ -90,12 +90,8 @@ public static void CurrentDomain_UnhandledException(object sender, UnhandledExce
9090
if (e.ExceptionObject is Exception ex)
9191
{
9292
//使用UDP方法传送会服务器
93-
string info = $"{Environment.NewLine}信息:{ex.Message}" +
94-
$"{Environment.NewLine}类型:{ex.GetType().ToString()}" +
95-
$"{Environment.NewLine}堆栈:{ex.StackTrace}" +
96-
$"{Environment.NewLine}方法:{ex.TargetSite.Name}" +
97-
$"{Environment.NewLine}" + "=".PadLeft(50, '=');
98-
UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.异常消息, info);
93+
string info = HslCommunication.LogNet.LogNetManagment.GetSaveStringFromException(null, ex);
94+
Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.异常消息, info);
9995
}
10096
}
10197
}

CommonLibrary/AccountSupport/ServerAccount.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void UpdatePassword(string name, string password)
4747
if (name == all_list_accounts[i].UserName)
4848
{
4949
all_list_accounts[i].Password = password;
50-
LogHelper?.SaveInformation(Resource.StringResouce.AccountModifyPassword + name);
50+
ILogNet?.WriteInfo(Resource.StringResouce.AccountModifyPassword + name);
5151
break;
5252
}
5353
}
@@ -146,7 +146,7 @@ public bool AddNewAccount(T account)
146146
}
147147
}
148148
all_list_accounts.Add(account);
149-
LogHelper?.SaveInformation(Resource.StringResouce.AccountAddSuccess + account.UserName);
149+
ILogNet?.WriteInfo(Resource.StringResouce.AccountAddSuccess + account.UserName);
150150
}
151151
return true;
152152
}
@@ -164,7 +164,7 @@ public void DeleteAccount(string name)
164164
if (name == all_list_accounts[i].UserName)
165165
{
166166
all_list_accounts.RemoveAt(i);
167-
LogHelper?.SaveInformation(Resource.StringResouce.AccountDeleteSuccess + name);
167+
ILogNet?.WriteInfo(Resource.StringResouce.AccountDeleteSuccess + name);
168168
break;
169169
}
170170
}
@@ -212,7 +212,7 @@ public void LoadAllAccountsJson(string json)
212212
}
213213
catch (Exception ex)
214214
{
215-
LogHelper?.SaveError(Resource.StringResouce.AccountLoadFailed, ex);
215+
ILogNet?.WriteException(Resource.StringResouce.AccountLoadFailed, ex);
216216
}
217217
}
218218
}

Public/HslCommunication.dll

24.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)