|
|
@@ -12,6 +12,8 @@ using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Web.Services.Description;
|
|
|
using System.Windows.Forms;
|
|
|
+using UAS_MES_NEW.Entity;
|
|
|
+using UAS_MES_NEW.DataOperate;
|
|
|
|
|
|
namespace UAS_MES_NEW.Make
|
|
|
{
|
|
|
@@ -22,7 +24,30 @@ namespace UAS_MES_NEW.Make
|
|
|
InitializeComponent();
|
|
|
}
|
|
|
|
|
|
+ StringBuilder SQL = new StringBuilder();
|
|
|
+ DataTable dt;
|
|
|
+ DataHelper dh;
|
|
|
+
|
|
|
SocketHandle client;
|
|
|
+ string saveFile, sendFile;
|
|
|
+
|
|
|
+ private void Make_ListenSocket_Load(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ dh = SystemInf.dh;
|
|
|
+
|
|
|
+ string currentPath = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).FullName;
|
|
|
+ saveFile = Path.Combine(currentPath, $"Received.txt");
|
|
|
+ sendFile = Path.Combine(currentPath, $"Send.txt");
|
|
|
+
|
|
|
+ if (!File.Exists(saveFile))
|
|
|
+ {
|
|
|
+ File.Create(saveFile).Dispose();
|
|
|
+ }
|
|
|
+ if (!File.Exists(sendFile))
|
|
|
+ {
|
|
|
+ File.Create(sendFile).Dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
private void Connet_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
@@ -70,8 +95,7 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
ShowMsg(1, msg);
|
|
|
|
|
|
- string savePath = @"C:\Users\MI\Desktop\testEquiment\ReceivedFiles\received_file.txt";
|
|
|
- msg = await client.ReceiveFileAsync(savePath);
|
|
|
+ msg = await client.ReceiveFileAsync(saveFile);
|
|
|
if (!msg.StartsWith("OK"))
|
|
|
{
|
|
|
ShowMsg(0, msg);
|
|
|
@@ -79,25 +103,26 @@ namespace UAS_MES_NEW.Make
|
|
|
ShowMsg(1, msg);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
private async void OnFileReceived(string fileName, string savePath)
|
|
|
{
|
|
|
- Console.WriteLine("文件接收完成: " + fileName + " 保存到: " + savePath);
|
|
|
-
|
|
|
- string localFilePath = @"C:\Users\MI\Desktop\testEquiment\ReceivedFiles\send_file.txt";
|
|
|
- string msg = await client.SendFileAsync(localFilePath);
|
|
|
+ ShowMsg(1, "文件接收完成: " + fileName + " 保存到: " + savePath);
|
|
|
+ string msg = await client.SendFileAsync(sendFile);
|
|
|
if (msg.StartsWith("NG"))
|
|
|
{
|
|
|
ShowMsg(0, msg);
|
|
|
}
|
|
|
ShowMsg(1, "文件发送成功");
|
|
|
}
|
|
|
+
|
|
|
private void OnMessageReceived(string message)
|
|
|
{
|
|
|
- Console.WriteLine("收到服务器消息: " + message);
|
|
|
+ ShowMsg(1, "收到服务器消息: " + message);
|
|
|
}
|
|
|
+
|
|
|
private void OnConnectionStatusChanged(string status)
|
|
|
{
|
|
|
- Console.WriteLine("连接状态: " + status);
|
|
|
+ ShowMsg(0, "连接状态已变: " + status);
|
|
|
}
|
|
|
|
|
|
private void ShowMsg(int type, string msg)
|
|
|
@@ -115,6 +140,35 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void UpdateSN(string type, string sn)
|
|
|
+ {
|
|
|
+ if (type == "C")
|
|
|
+ {
|
|
|
+ serialNumber.Text = "";
|
|
|
+ workOrder.Text = "";
|
|
|
+ productCode.Text = "";
|
|
|
+ productName.Text = "";
|
|
|
+ }
|
|
|
+ else if (type == "L")
|
|
|
+ {
|
|
|
+ SQL.Clear();
|
|
|
+ SQL.Append($@"SELECT ms_sncode,ma_code,pr_code,pr_spec FROM makeserial,make,product
|
|
|
+ WHERE ms_sncode = '{sn}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
|
|
|
+ dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ serialNumber.Text = dt.Rows[0]["ms_sncode"].ToString();
|
|
|
+ workOrder.Text = dt.Rows[0]["ma_code"].ToString();
|
|
|
+ productCode.Text = dt.Rows[0]["pr_code"].ToString();
|
|
|
+ productName.Text = dt.Rows[0]["pr_spec"].ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ UpdateSN("C", sn);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public class SocketHandle
|
|
|
{
|
|
|
private Socket clientSocket;
|