Commit 1e2af832 LN

增加上传测试功能

1 个父辈 85ea501a
......@@ -100,6 +100,12 @@
<Compile Include="FrmLabelEdit.Designer.cs">
<DependentUpon>FrmLabelEdit.cs</DependentUpon>
</Compile>
<Compile Include="FrmUploadTest.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmUploadTest.Designer.cs">
<DependentUpon>FrmUploadTest.cs</DependentUpon>
</Compile>
<Compile Include="FrmLabelSettings.cs">
<SubType>Form</SubType>
</Compile>
......@@ -163,6 +169,9 @@
<EmbeddedResource Include="FrmLabelEdit.resx">
<DependentUpon>FrmLabelEdit.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmUploadTest.resx">
<DependentUpon>FrmUploadTest.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmLabelSettings.resx">
<DependentUpon>FrmLabelSettings.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -45,6 +45,7 @@ namespace AutoScanAndLabel
this.关于ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.退出ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.lastFile = new System.Windows.Forms.Label();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.btn_releaserightshelf = new System.Windows.Forms.Button();
this.btn_maulstart = new System.Windows.Forms.Button();
......@@ -62,7 +63,7 @@ namespace AutoScanAndLabel
this.listView1 = new System.Windows.Forms.ListView();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.panel1 = new System.Windows.Forms.Panel();
this.lastFile = new System.Windows.Forms.Label();
this.btnUploadTest = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox4.SuspendLayout();
......@@ -203,6 +204,7 @@ namespace AutoScanAndLabel
//
// tabPage1
//
this.tabPage1.Controls.Add(this.btnUploadTest);
this.tabPage1.Controls.Add(this.lastFile);
this.tabPage1.Controls.Add(this.groupBox4);
this.tabPage1.Controls.Add(this.groupBox3);
......@@ -217,6 +219,14 @@ namespace AutoScanAndLabel
this.tabPage1.Text = "状体";
this.tabPage1.UseVisualStyleBackColor = true;
//
// lastFile
//
this.lastFile.AutoSize = true;
this.lastFile.Location = new System.Drawing.Point(14, 435);
this.lastFile.Name = "lastFile";
this.lastFile.Size = new System.Drawing.Size(0, 21);
this.lastFile.TabIndex = 11;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.btn_releaserightshelf);
......@@ -406,13 +416,16 @@ namespace AutoScanAndLabel
this.panel1.Size = new System.Drawing.Size(1029, 619);
this.panel1.TabIndex = 6;
//
// lastFile
// btnUploadTest
//
this.lastFile.AutoSize = true;
this.lastFile.Location = new System.Drawing.Point(14, 435);
this.lastFile.Name = "lastFile";
this.lastFile.Size = new System.Drawing.Size(0, 21);
this.lastFile.TabIndex = 11;
this.btnUploadTest.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnUploadTest.Location = new System.Drawing.Point(390, 391);
this.btnUploadTest.Name = "btnUploadTest";
this.btnUploadTest.Size = new System.Drawing.Size(105, 37);
this.btnUploadTest.TabIndex = 12;
this.btnUploadTest.Text = "File Test";
this.btnUploadTest.UseVisualStyleBackColor = true;
this.btnUploadTest.Click += new System.EventHandler(this.btnUploadTest_Click);
//
// Form1
//
......@@ -483,6 +496,7 @@ namespace AutoScanAndLabel
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Label lastFile;
private System.Windows.Forms.Button btnUploadTest;
}
}
......@@ -802,5 +802,11 @@ namespace AutoScanAndLabel
tabControl1.TabPages[tc - i].Parent = null;
}
}
private void btnUploadTest_Click(object sender, EventArgs e)
{
FrmUploadTest frmUploadTest = new FrmUploadTest();
frmUploadTest.ShowDialog();
}
}
}
\ No newline at end of file
namespace AutoScanAndLabel
{
partial class FrmUploadTest
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmUploadTest));
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.btnUpload = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.txtRI = new System.Windows.Forms.TextBox();
this.txtPN = new System.Windows.Forms.TextBox();
this.txtQTY = new System.Windows.Forms.TextBox();
this.lblPath = new System.Windows.Forms.Label();
this.lblMsg = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label2
//
this.label2.Location = new System.Drawing.Point(50, 168);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(106, 20);
this.label2.TabIndex = 2;
this.label2.Text = "PartNumber:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label1
//
this.label1.Location = new System.Drawing.Point(50, 115);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(106, 20);
this.label1.TabIndex = 2;
this.label1.Text = "ReelID:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btnUpload
//
this.btnUpload.Location = new System.Drawing.Point(97, 274);
this.btnUpload.Name = "btnUpload";
this.btnUpload.Size = new System.Drawing.Size(107, 31);
this.btnUpload.TabIndex = 1;
this.btnUpload.Text = "Upload";
this.btnUpload.UseVisualStyleBackColor = true;
this.btnUpload.Click += new System.EventHandler(this.btnUpload_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(226, 273);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(107, 31);
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// label3
//
this.label3.Location = new System.Drawing.Point(50, 221);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(106, 20);
this.label3.TabIndex = 4;
this.label3.Text = "InitialQuantity:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtRI
//
this.txtRI.Location = new System.Drawing.Point(162, 111);
this.txtRI.Name = "txtRI";
this.txtRI.Size = new System.Drawing.Size(168, 23);
this.txtRI.TabIndex = 5;
//
// txtPN
//
this.txtPN.Location = new System.Drawing.Point(162, 165);
this.txtPN.Name = "txtPN";
this.txtPN.Size = new System.Drawing.Size(168, 23);
this.txtPN.TabIndex = 6;
//
// txtQTY
//
this.txtQTY.Location = new System.Drawing.Point(162, 219);
this.txtQTY.Name = "txtQTY";
this.txtQTY.Size = new System.Drawing.Size(168, 23);
this.txtQTY.TabIndex = 7;
//
// lblPath
//
this.lblPath.Location = new System.Drawing.Point(45, 21);
this.lblPath.Name = "lblPath";
this.lblPath.Size = new System.Drawing.Size(326, 20);
this.lblPath.TabIndex = 8;
this.lblPath.Text = "Path:";
this.lblPath.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblMsg
//
this.lblMsg.ForeColor = System.Drawing.Color.Red;
this.lblMsg.Location = new System.Drawing.Point(45, 58);
this.lblMsg.Name = "lblMsg";
this.lblMsg.Size = new System.Drawing.Size(326, 20);
this.lblMsg.TabIndex = 9;
this.lblMsg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// FrmUploadTest
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(444, 339);
this.Controls.Add(this.lblMsg);
this.Controls.Add(this.lblPath);
this.Controls.Add(this.txtQTY);
this.Controls.Add(this.txtPN);
this.Controls.Add(this.txtRI);
this.Controls.Add(this.label3);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnUpload);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmUploadTest";
this.Text = "UploadTest";
this.Load += new System.EventHandler(this.FrmUploadTest_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnUpload;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtRI;
private System.Windows.Forms.TextBox txtPN;
private System.Windows.Forms.TextBox txtQTY;
private System.Windows.Forms.Label lblPath;
private System.Windows.Forms.Label lblMsg;
}
}
\ No newline at end of file
using ConfigHelper;
using DeviceLibrary;
using OnlineStore;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoScanAndLabel
{
public partial class FrmUploadTest : Form
{
public FrmUploadTest()
{
InitializeComponent();
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
crc.LanguageProcess(this, this.GetType().Name);
RobotManage_LoadFinishEvent(true,"");
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
{
}
private void cb_printerselect_SelectedIndexChanged(object sender, EventArgs e)
{
Config.Set(Setting_Init.PrinterName, (sender as ComboBox).Text);
RobotManage.LoadPrintSetting();
}
private void cb_labelselect_SelectedIndexChanged(object sender, EventArgs e)
{
Config.Set(Setting_Init.LabelName, (sender as ComboBox).Text);
RobotManage.LoadPrintSetting();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void FrmUploadTest_Load(object sender, EventArgs e)
{
lblMsg.Text = "";
lblPath.Text = DataUploadUtil.smb_path;
if (DataUploadUtil.CanUpload())
{
btnUpload.Visible = true;
}
else
{
btnUpload.Visible = false;
lblMsg.Text = "Invalid shared directory, unable to upload";
}
}
private void btnUpload_Click(object sender, EventArgs e)
{
try
{
string ri=txtRI.Text;
string pn=txtPN.Text;
string qty=txtQTY.Text;
Dictionary<string, string> map = new Dictionary<string, string>();
map.Add(DataUploadUtil.title_pn, pn);
map.Add(DataUploadUtil.title_ri,ri);
map.Add(DataUploadUtil.title_qty, qty);
DialogResult result = MessageBox.Show("Sure Upload ?", "Tip", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if(result.Equals(DialogResult.Yes))
{
DataUploadUtil.LabelUpload(map);
}
}catch(Exception ex)
{
LogUtil.error(ex.ToString());
MessageBox.Show(ex.ToString());
}
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
......@@ -31,11 +32,20 @@ namespace OnlineStore
/// <returns></returns>
public bool IsValidConnection()
{
bool cRet = false;
using (var network = new NetworkConnection($"{networkPath}", networkCredential))
{
var result = network.Connect();
return result == 0;
cRet = result == 0;
}
if (!cRet)
{
if (Directory.Exists(networkPath))
{
return true;
}
}
return cRet;
}
/// <summary>
/// 创建文件
......
......@@ -125,7 +125,7 @@ namespace DeviceLibrary
Msg.add(msg, MsgLevel.warning);
return;
}
if (LabelMoveInfo.MoveParam.codeInfos==null&&LabelMoveInfo.MoveParam.codeInfos.Count==0)
if (LabelMoveInfo.MoveParam.codeInfos == null || LabelMoveInfo.MoveParam.codeInfos.Count == 0)
{
break;
}
......
......@@ -11,14 +11,14 @@ namespace DeviceLibrary
{
public class DataUploadUtil
{
private static string smb_path = ConfigAppSettings.GetValue(Setting_Init.SMB_Path);
public static string smb_path = ConfigAppSettings.GetValue(Setting_Init.SMB_Path);
private static string smb_uname = ConfigAppSettings.GetValue(Setting_Init.SMB_UserName);
private static string smb_pwd =ConfigAppSettings.GetValue(Setting_Init.SMB_Pwd);
private static string title_ri = ConfigAppSettings.GetValue(Setting_Init.FileTitle_RID);
private static string title_pn = ConfigAppSettings.GetValue(Setting_Init.FileTitle_PN);
private static string title_qty = ConfigAppSettings.GetValue(Setting_Init.FileTitle_QTY);
private static string storage_value = ConfigAppSettings.GetValue(Setting_Init.SMB_StorageUnitValue);
public static string title_ri = ConfigAppSettings.GetValue(Setting_Init.FileTitle_RID);
public static string title_pn = ConfigAppSettings.GetValue(Setting_Init.FileTitle_PN);
public static string title_qty = ConfigAppSettings.GetValue(Setting_Init.FileTitle_QTY);
public static string storage_value = ConfigAppSettings.GetValue(Setting_Init.SMB_StorageUnitValue);
//[2024-06-18 23:23:24,907][24] INFO 调用 PrintLabel 打印标签 StartPrintLabel
// ,[PON=101003292, POL=00050, QTY=10000, MPN=CL05B104KP5NNNC,
// MPG=SAMSUNG EM, D/C=31.01.20, P/N=1012004106, S/N=20230901, SHP=00052120, LOT=Y233466517, NB=SA001256] 开始
......@@ -71,14 +71,22 @@ namespace DeviceLibrary
}
return defV;
}
public static void LabelUpload(Dictionary<string, string> data )
public static bool CanUpload()
{
if (fileContainer != null && fileContainer.IsValidConnection())
{
return true;
}
return false;
}
public static void LabelUpload(Dictionary<string, string> data )
{
Task.Factory.StartNew(() =>
{
try
{
if (fileContainer != null)
if (fileContainer==null)
{
}
......@@ -98,20 +106,20 @@ namespace DeviceLibrary
int col = titleArray.Length;
for (int index = 0; index < col; index++)
{
string tilte = titleArray[index];
if (title == "ReelID")
string thisTitle = titleArray[index];
if (thisTitle== "ReelID")
{
rows.Add(rid);
}
else if (title == "PartNumber")
else if (thisTitle == "PartNumber")
{
rows.Add(pn);
}
else if (title == "InitialQuantity")
else if (thisTitle == "InitialQuantity")
{
rows.Add(qty);
}
else if (title == "StorageUnit")
else if (thisTitle == "StorageUnit")
{
rows.Add(storage_value);
}
......@@ -124,7 +132,7 @@ namespace DeviceLibrary
string con = title + "\r\n" + line;
fileContainer.CreateFile(fileName, con);
lastFileInfo="["+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]: " + fileName+"\t"+line;
LogUtil.error($"共享文件夹{smb_path} 创建文件{fileName}完成 ");
LogUtil.error($"共享文件夹{smb_path} 创建文件{fileName}完成 ");
}
else
......@@ -142,7 +150,7 @@ namespace DeviceLibrary
{
LogUtil.error("LabelDataProcess 出错:" + ex.ToString());
}
});
});
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!