Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Client.SamplePackages.V4.0
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶然
Kivii.Client.SamplePackages.V4.0
Commits
a0616726
Commit
a0616726
authored
May 25, 2023
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
195dfe53
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
371 additions
and
61 deletions
+371
-61
Configs.cs
Src/Configs.cs
+3
-0
Kivii.Rfid.D500.V4.0.dll
Src/Content/Kivii.Rfid.D500.V4.0.dll
+0
-0
FrmMain.Designer.cs
Src/FrmMain.Designer.cs
+57
-56
FrmMain.cs
Src/FrmMain.cs
+264
-4
Kivii.Client.SamplePackages.V4.0.csproj
Src/Kivii.Client.SamplePackages.V4.0.csproj
+8
-1
Program.cs
Src/Program.cs
+17
-0
RestfulRequests.cs
Src/Requests/RestfulRequests.cs
+22
-0
No files found.
Src/Configs.cs
View file @
a0616726
...
@@ -13,6 +13,9 @@ namespace Kivii.Client.SamplePackages
...
@@ -13,6 +13,9 @@ namespace Kivii.Client.SamplePackages
public
const
string
RouteLocationQuery
=
"/Restful/Kivii.Samples.Entities.Location/Query"
;
public
const
string
RouteLocationQuery
=
"/Restful/Kivii.Samples.Entities.Location/Query"
;
public
const
string
RouteSampleQuery
=
"/Restful/Kivii.Samples.Entities.Sample/Query"
;
public
const
string
RouteSampleQuery
=
"/Restful/Kivii.Samples.Entities.Sample/Query"
;
public
const
string
RouteSamplePrePackaging
=
"/Restful/Kivii.Samples.Entities.Sample/PrePackaging"
;
public
const
string
RouteSamplePackaging
=
"/Restful/Kivii.Samples.Entities.Sample/Packaging"
;
public
const
string
RouteSampleUnPackaging
=
"/Restful/Kivii.Samples.Entities.Sample/UnPackaging"
;
}
}
}
}
Src/Content/Kivii.Rfid.D500.V4.0.dll
0 → 100644
View file @
a0616726
File added
Src/FrmMain.Designer.cs
View file @
a0616726
...
@@ -51,15 +51,15 @@
...
@@ -51,15 +51,15 @@
this
.
tbxUserName
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbxUserName
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
plToolBar
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
plToolBar
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
gbTools
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
gbTools
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
btnClearCurrentPackage
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnScanRfid
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
cbSetCurrentPackageNode
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
lbSetPackageNode
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lbSetPackage
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lbSetPackage
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tbSetCurrentPackage
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
tbSetCurrentPackage
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
plMain
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
plMain
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
gbMain
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
gbMain
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
lbSetPackageNode
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
cbSetCurrentPackageNode
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
btnScanRfid
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
dgvSamples
=
new
System
.
Windows
.
Forms
.
DataGridView
();
this
.
dgvSamples
=
new
System
.
Windows
.
Forms
.
DataGridView
();
this
.
btnClearCurrentPackage
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
SampleAction
=
new
System
.
Windows
.
Forms
.
DataGridViewButtonColumn
();
this
.
SampleAction
=
new
System
.
Windows
.
Forms
.
DataGridViewButtonColumn
();
this
.
SampleBizId
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
SampleBizId
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
SampleOwnerName
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
SampleOwnerName
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
...
@@ -312,6 +312,57 @@
...
@@ -312,6 +312,57 @@
this
.
gbTools
.
TabStop
=
false
;
this
.
gbTools
.
TabStop
=
false
;
this
.
gbTools
.
Text
=
"操作台"
;
this
.
gbTools
.
Text
=
"操作台"
;
//
//
// btnClearCurrentPackage
//
this
.
btnClearCurrentPackage
.
Location
=
new
System
.
Drawing
.
Point
(
130
,
37
);
this
.
btnClearCurrentPackage
.
Name
=
"btnClearCurrentPackage"
;
this
.
btnClearCurrentPackage
.
Size
=
new
System
.
Drawing
.
Size
(
103
,
23
);
this
.
btnClearCurrentPackage
.
TabIndex
=
77
;
this
.
btnClearCurrentPackage
.
Text
=
"重设"
;
this
.
btnClearCurrentPackage
.
UseVisualStyleBackColor
=
true
;
this
.
btnClearCurrentPackage
.
Click
+=
new
System
.
EventHandler
(
this
.
btnClearCurrentPackage_Click
);
//
// btnScanRfid
//
this
.
btnScanRfid
.
BackColor
=
System
.
Drawing
.
Color
.
PapayaWhip
;
this
.
btnScanRfid
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Right
;
this
.
btnScanRfid
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
25F
,
System
.
Drawing
.
FontStyle
.
Bold
);
this
.
btnScanRfid
.
ForeColor
=
System
.
Drawing
.
Color
.
Chocolate
;
this
.
btnScanRfid
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
17
);
this
.
btnScanRfid
.
Name
=
"btnScanRfid"
;
this
.
btnScanRfid
.
Size
=
new
System
.
Drawing
.
Size
(
126
,
105
);
this
.
btnScanRfid
.
TabIndex
=
76
;
this
.
btnScanRfid
.
Text
=
"开始扫描"
;
this
.
btnScanRfid
.
UseVisualStyleBackColor
=
false
;
this
.
btnScanRfid
.
Click
+=
new
System
.
EventHandler
(
this
.
btnScanRfid_Click
);
//
// cbSetCurrentPackageNode
//
this
.
cbSetCurrentPackageNode
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
20F
);
this
.
cbSetCurrentPackageNode
.
FormattingEnabled
=
true
;
this
.
cbSetCurrentPackageNode
.
Items
.
AddRange
(
new
object
[]
{
"1号袋"
,
"2号袋"
,
"3号袋"
,
"4号袋"
,
"5号袋"
,
"6号袋"
});
this
.
cbSetCurrentPackageNode
.
Location
=
new
System
.
Drawing
.
Point
(
239
,
63
);
this
.
cbSetCurrentPackageNode
.
Name
=
"cbSetCurrentPackageNode"
;
this
.
cbSetCurrentPackageNode
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
35
);
this
.
cbSetCurrentPackageNode
.
TabIndex
=
30
;
this
.
cbSetCurrentPackageNode
.
TextChanged
+=
new
System
.
EventHandler
(
this
.
cbSetCurrentPackageNode_TextChanged
);
//
// lbSetPackageNode
//
this
.
lbSetPackageNode
.
AutoSize
=
true
;
this
.
lbSetPackageNode
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
18F
);
this
.
lbSetPackageNode
.
Location
=
new
System
.
Drawing
.
Point
(
235
,
36
);
this
.
lbSetPackageNode
.
Name
=
"lbSetPackageNode"
;
this
.
lbSetPackageNode
.
Size
=
new
System
.
Drawing
.
Size
(
118
,
24
);
this
.
lbSetPackageNode
.
TabIndex
=
28
;
this
.
lbSetPackageNode
.
Text
=
"袋子选择:"
;
//
// lbSetPackage
// lbSetPackage
//
//
this
.
lbSetPackage
.
AutoSize
=
true
;
this
.
lbSetPackage
.
AutoSize
=
true
;
...
@@ -352,46 +403,6 @@
...
@@ -352,46 +403,6 @@
this
.
gbMain
.
TabStop
=
false
;
this
.
gbMain
.
TabStop
=
false
;
this
.
gbMain
.
Text
=
"入箱列表"
;
this
.
gbMain
.
Text
=
"入箱列表"
;
//
//
// lbSetPackageNode
//
this
.
lbSetPackageNode
.
AutoSize
=
true
;
this
.
lbSetPackageNode
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
18F
);
this
.
lbSetPackageNode
.
Location
=
new
System
.
Drawing
.
Point
(
235
,
36
);
this
.
lbSetPackageNode
.
Name
=
"lbSetPackageNode"
;
this
.
lbSetPackageNode
.
Size
=
new
System
.
Drawing
.
Size
(
118
,
24
);
this
.
lbSetPackageNode
.
TabIndex
=
28
;
this
.
lbSetPackageNode
.
Text
=
"袋子选择:"
;
//
// cbSetCurrentPackageNode
//
this
.
cbSetCurrentPackageNode
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
20F
);
this
.
cbSetCurrentPackageNode
.
FormattingEnabled
=
true
;
this
.
cbSetCurrentPackageNode
.
Items
.
AddRange
(
new
object
[]
{
"1号袋"
,
"2号袋"
,
"3号袋"
,
"4号袋"
,
"5号袋"
,
"6号袋"
});
this
.
cbSetCurrentPackageNode
.
Location
=
new
System
.
Drawing
.
Point
(
239
,
63
);
this
.
cbSetCurrentPackageNode
.
Name
=
"cbSetCurrentPackageNode"
;
this
.
cbSetCurrentPackageNode
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
35
);
this
.
cbSetCurrentPackageNode
.
TabIndex
=
30
;
this
.
cbSetCurrentPackageNode
.
TextChanged
+=
new
System
.
EventHandler
(
this
.
cbSetCurrentPackageNode_TextChanged
);
//
// btnScanRfid
//
this
.
btnScanRfid
.
BackColor
=
System
.
Drawing
.
Color
.
PapayaWhip
;
this
.
btnScanRfid
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Right
;
this
.
btnScanRfid
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
25F
,
System
.
Drawing
.
FontStyle
.
Bold
);
this
.
btnScanRfid
.
ForeColor
=
System
.
Drawing
.
Color
.
Chocolate
;
this
.
btnScanRfid
.
Location
=
new
System
.
Drawing
.
Point
(
664
,
17
);
this
.
btnScanRfid
.
Name
=
"btnScanRfid"
;
this
.
btnScanRfid
.
Size
=
new
System
.
Drawing
.
Size
(
126
,
105
);
this
.
btnScanRfid
.
TabIndex
=
76
;
this
.
btnScanRfid
.
Text
=
"开始扫描"
;
this
.
btnScanRfid
.
UseVisualStyleBackColor
=
false
;
//
// dgvSamples
// dgvSamples
//
//
this
.
dgvSamples
.
AllowUserToAddRows
=
false
;
this
.
dgvSamples
.
AllowUserToAddRows
=
false
;
...
@@ -413,18 +424,9 @@
...
@@ -413,18 +424,9 @@
this
.
dgvSamples
.
RowTemplate
.
Height
=
23
;
this
.
dgvSamples
.
RowTemplate
.
Height
=
23
;
this
.
dgvSamples
.
Size
=
new
System
.
Drawing
.
Size
(
787
,
449
);
this
.
dgvSamples
.
Size
=
new
System
.
Drawing
.
Size
(
787
,
449
);
this
.
dgvSamples
.
TabIndex
=
0
;
this
.
dgvSamples
.
TabIndex
=
0
;
this
.
dgvSamples
.
CellContentClick
+=
new
System
.
Windows
.
Forms
.
DataGridViewCellEventHandler
(
this
.
dgvSamples_CellContentClick
);
this
.
dgvSamples
.
RowPostPaint
+=
new
System
.
Windows
.
Forms
.
DataGridViewRowPostPaintEventHandler
(
this
.
dgvSamples_RowPostPaint
);
this
.
dgvSamples
.
RowPostPaint
+=
new
System
.
Windows
.
Forms
.
DataGridViewRowPostPaintEventHandler
(
this
.
dgvSamples_RowPostPaint
);
//
//
// btnClearCurrentPackage
//
this
.
btnClearCurrentPackage
.
Location
=
new
System
.
Drawing
.
Point
(
130
,
37
);
this
.
btnClearCurrentPackage
.
Name
=
"btnClearCurrentPackage"
;
this
.
btnClearCurrentPackage
.
Size
=
new
System
.
Drawing
.
Size
(
103
,
23
);
this
.
btnClearCurrentPackage
.
TabIndex
=
77
;
this
.
btnClearCurrentPackage
.
Text
=
"重设"
;
this
.
btnClearCurrentPackage
.
UseVisualStyleBackColor
=
true
;
this
.
btnClearCurrentPackage
.
Click
+=
new
System
.
EventHandler
(
this
.
btnClearCurrentPackage_Click
);
//
// SampleAction
// SampleAction
//
//
dataGridViewCellStyle1
.
Alignment
=
System
.
Windows
.
Forms
.
DataGridViewContentAlignment
.
MiddleCenter
;
dataGridViewCellStyle1
.
Alignment
=
System
.
Windows
.
Forms
.
DataGridViewContentAlignment
.
MiddleCenter
;
...
@@ -459,13 +461,12 @@
...
@@ -459,13 +461,12 @@
//
//
// SampleName
// SampleName
//
//
this
.
SampleName
.
AutoSizeMode
=
System
.
Windows
.
Forms
.
DataGridViewAutoSizeColumnMode
.
None
;
this
.
SampleName
.
AutoSizeMode
=
System
.
Windows
.
Forms
.
DataGridViewAutoSizeColumnMode
.
Fill
;
this
.
SampleName
.
DataPropertyName
=
"Name"
;
this
.
SampleName
.
DataPropertyName
=
"Name"
;
this
.
SampleName
.
HeaderText
=
"样品名称"
;
this
.
SampleName
.
HeaderText
=
"样品名称"
;
this
.
SampleName
.
MinimumWidth
=
120
;
this
.
SampleName
.
MinimumWidth
=
120
;
this
.
SampleName
.
Name
=
"SampleName"
;
this
.
SampleName
.
Name
=
"SampleName"
;
this
.
SampleName
.
ReadOnly
=
true
;
this
.
SampleName
.
ReadOnly
=
true
;
this
.
SampleName
.
Width
=
120
;
//
//
// SampleDealTime
// SampleDealTime
//
//
...
...
Src/FrmMain.cs
View file @
a0616726
using
Kivii.Client.SamplePackages.Entities
;
using
Kivii.Client.SamplePackages.Entities
;
using
Kivii.Linq
;
using
Kivii.Linq
;
using
Kivii.Rfid.D500
;
using
Kivii.Samples.Entities
;
using
Kivii.Samples.Entities
;
using
Kivii.Samples.Transforms
;
using
Kivii.Samples.Transforms
;
using
System
;
using
System
;
...
@@ -10,6 +11,7 @@ using System.Drawing;
...
@@ -10,6 +11,7 @@ using System.Drawing;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading
;
using
System.Threading
;
using
System.Timers
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
namespace
Kivii.Client.SamplePackages
namespace
Kivii.Client.SamplePackages
...
@@ -22,6 +24,8 @@ namespace Kivii.Client.SamplePackages
...
@@ -22,6 +24,8 @@ namespace Kivii.Client.SamplePackages
private
Sample
_currentPackage
;
private
Sample
_currentPackage
;
private
List
<
Sample
>
_currentSamples
;
private
List
<
Sample
>
_currentSamples
;
private
AuthenticateResponse
_userInfo
;
private
AuthenticateResponse
_userInfo
;
internal
static
Reader
ReaderInstance
{
get
;
set
;
}
System
.
Timers
.
Timer
_tmr
=
null
;
//定时器
#
endregion
#
endregion
public
FrmMain
()
public
FrmMain
()
{
{
...
@@ -30,11 +34,23 @@ namespace Kivii.Client.SamplePackages
...
@@ -30,11 +34,23 @@ namespace Kivii.Client.SamplePackages
private
void
FrmMain_Load
(
object
sender
,
EventArgs
e
)
private
void
FrmMain_Load
(
object
sender
,
EventArgs
e
)
{
{
initControls
();
initControls
();
loadDefault
(
tbxServiceUrl
,
tbxUserName
,
tbxPassword
);
loadDefault
(
tbxServiceUrl
,
tbxUserName
,
tbxPassword
);
//initReader();
}
}
#
region
界面控件默认值及控制
#
region
界面控件默认值及控制
private
void
initReader
()
{
ReaderInstance
=
new
Reader
();
//加载事件
ReaderInstance
.
Connected
+=
new
EventHandler
<
ConnectionChangedEventArgs
>(
reader_Connected
);
ReaderInstance
.
ConnectionLost
+=
reader_ConnectionLost
;
ReaderInstance
.
Disconnected
+=
reader_Disconnected
;
}
private
void
initControls
()
private
void
initControls
()
{
{
dgvSamples
.
AutoGenerateColumns
=
false
;
dgvSamples
.
AutoGenerateColumns
=
false
;
...
@@ -143,7 +159,12 @@ namespace Kivii.Client.SamplePackages
...
@@ -143,7 +159,12 @@ namespace Kivii.Client.SamplePackages
return
;
return
;
}
}
var
request
=
new
LocationQuery
();
var
request
=
new
LocationQuery
();
request
.
OwnerKvid
=
_userInfo
.
DepartmentKvid
;
//request.OwnerKvid = _userInfo.DepartmentKvid;
//request.OwnerKvid = Guid.Parse("D4CE47D2-5FC8-479D-A0CA-BACDF1A891BF");//色牢度组
//request.OwnerKvid = Guid.Parse("9D026818-6E78-40F8-A715-2887F96F34DC");//纤检组
//request.OwnerKvid = Guid.Parse("208C24FB-1443-4B9E-9886-02ED3B9A8F45");//安全组
//request.OwnerKvid = Guid.Parse("7CF9CF7B-19F5-4A1A-A94C-5BC21EA8ED76");//纤维含量组
request
.
OwnerKvid
=
Guid
.
Parse
(
"BB355D5A-9D4E-4337-B577-7BB7A1625F68"
);
//羽绒组
var
task
=
_client
.
PostAsync
(
request
);
var
task
=
_client
.
PostAsync
(
request
);
task
.
Success
(
resp
=>
task
.
Success
(
resp
=>
{
{
...
@@ -173,7 +194,7 @@ namespace Kivii.Client.SamplePackages
...
@@ -173,7 +194,7 @@ namespace Kivii.Client.SamplePackages
MessageBox
.
Show
(
"请先登录!"
);
MessageBox
.
Show
(
"请先登录!"
);
return
;
return
;
}
}
if
(
_currentPackage
==
null
)
if
(
_currentPackage
==
null
)
{
{
MessageBox
.
Show
(
"请先设置箱号!"
);
MessageBox
.
Show
(
"请先设置箱号!"
);
return
;
return
;
...
@@ -199,6 +220,104 @@ namespace Kivii.Client.SamplePackages
...
@@ -199,6 +220,104 @@ namespace Kivii.Client.SamplePackages
});
});
}
}
private
void
samplePrepackaging
(
string
tid
)
{
if
(
tid
.
IsNullOrEmpty
())
return
;
var
request
=
new
SamplePrePackaging
();
request
.
Tid
=
tid
;
request
.
OwnerKvid
=
_currentLocation
.
OwnerKvid
;
try
{
var
resp
=
_client
.
Post
(
request
);
if
(
resp
.
Results
.
Count
<=
0
)
{
MessageBox
.
Show
(
"未找到样品,样品可能未涉及到当前组!"
,
"Rfid读取样品"
);
return
;
}
var
record
=
resp
.
Results
[
0
];
samplePackaging
(
record
);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
GetResponseStatus
().
Message
,
"Rfid读取样品"
);
}
}
private
void
samplePackaging
(
Sample
sample
)
{
if
(
sample
==
null
)
return
;
var
request
=
new
SamplePackaging
();
request
.
Package
=
_currentPackage
;
request
.
Kvid
=
sample
.
Kvid
;
request
.
Location
=
_currentLocation
;
//var task = _client.PostAsync(request);
try
{
var
resp
=
_client
.
Post
(
request
);
if
(
resp
.
Results
.
Count
<=
0
)
{
return
;
}
var
record
=
resp
.
Results
[
0
];
if
(
_currentSamples
==
null
)
_currentSamples
=
new
List
<
Sample
>();
if
(!
_currentSamples
.
Exists
(
o
=>
o
.
Kvid
==
record
.
Kvid
))
{
_currentSamples
.
Add
(
record
);
}
this
.
Invoke
(
new
Action
(
delegate
{
dgvSamples
.
DataSource
=
null
;
}));
this
.
Invoke
(
new
Action
(
delegate
{
dgvSamples
.
DataSource
=
_currentSamples
;
}));
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
GetResponseStatus
().
Message
,
"样品入箱"
);
}
}
private
void
sampleUnpackaging
(
Sample
sample
)
{
if
(
sample
==
null
)
return
;
if
(
_currentPackage
.
Status
==(
int
)
PackageStatus
.
Inbound
)
{
MessageBox
.
Show
(
"当前箱子已入库,请联系仓库!"
,
"撤销入箱"
);
return
;
}
var
request
=
new
SampleUnPackaging
();
request
.
Kvid
=
sample
.
Kvid
;
request
.
Location
=
_currentLocation
;
try
{
var
resp
=
_client
.
Post
(
request
);
if
(
resp
.
Results
.
Count
<=
0
)
{
return
;
}
var
record
=
resp
.
Results
[
0
];
if
(
_currentSamples
==
null
)
_currentSamples
=
new
List
<
Sample
>();
if
(
_currentSamples
.
Exists
(
o
=>
o
.
Kvid
==
record
.
Kvid
))
{
_currentSamples
.
RemoveAll
(
o
=>
o
.
Kvid
==
record
.
Kvid
);
}
this
.
Invoke
(
new
Action
(
delegate
{
dgvSamples
.
DataSource
=
null
;
}));
this
.
Invoke
(
new
Action
(
delegate
{
dgvSamples
.
DataSource
=
_currentSamples
;
}));
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
GetResponseStatus
().
Message
,
"撤销入箱"
);
}
}
private
void
searchPackage
()
private
void
searchPackage
()
{
{
if
(
_client
==
null
)
if
(
_client
==
null
)
...
@@ -229,8 +348,8 @@ namespace Kivii.Client.SamplePackages
...
@@ -229,8 +348,8 @@ namespace Kivii.Client.SamplePackages
tbSetCurrentPackage
.
Enabled
=
_currentPackage
==
null
;
tbSetCurrentPackage
.
Enabled
=
_currentPackage
==
null
;
tbCurrentPackage
.
Text
=
_currentPackage
.
Name
+
(
_currentPackage
.
PackageName
.
IsNullOrEmpty
()
?
""
:
$"(
{
_currentPackage
.
PackageName
}
)"
);
tbCurrentPackage
.
Text
=
_currentPackage
.
Name
+
(
_currentPackage
.
PackageName
.
IsNullOrEmpty
()
?
""
:
$"(
{
_currentPackage
.
PackageName
}
)"
);
btnClearCurrentPackage
.
Enabled
=
_currentPackage
!=
null
;
btnClearCurrentPackage
.
Enabled
=
_currentPackage
!=
null
;
cbSetCurrentPackageNode
.
Enabled
=
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Empty
||
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Full
;
;
cbSetCurrentPackageNode
.
Enabled
=
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Empty
||
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Full
;
btnScanRfid
.
Enabled
=
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Empty
;
btnScanRfid
.
Enabled
=
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Empty
||
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Full
;
if
(
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Full
||
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Inbound
)
if
(
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Full
||
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Inbound
)
{
{
querySampleInPackaged
();
querySampleInPackaged
();
...
@@ -238,7 +357,9 @@ namespace Kivii.Client.SamplePackages
...
@@ -238,7 +357,9 @@ namespace Kivii.Client.SamplePackages
if
(
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Inbound
)
if
(
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Inbound
)
{
{
MessageBox
.
Show
(
"当前箱子已入库,无法继续操作!"
,
"箱号设置"
);
MessageBox
.
Show
(
"当前箱子已入库,无法继续操作!"
,
"箱号设置"
);
return
;
}
}
cbSetCurrentPackageNode
.
SelectedIndex
=
0
;
});
});
task
.
Error
(
err
=>
task
.
Error
(
err
=>
{
{
...
@@ -253,6 +374,54 @@ namespace Kivii.Client.SamplePackages
...
@@ -253,6 +374,54 @@ namespace Kivii.Client.SamplePackages
});
});
}
}
private
void
reader_ConnectionLost
(
object
sender
,
ConnectionChangedEventArgs
e
)
{
_tmr
?.
Stop
();
_tmr
=
null
;
}
private
void
reader_Disconnected
(
object
sender
,
ConnectionChangedEventArgs
e
)
{
_tmr
?.
Stop
();
_tmr
=
null
;
}
private
void
reader_Connected
(
object
sender
,
ConnectionChangedEventArgs
e
)
{
//在这启动定时器
_tmr
=
new
System
.
Timers
.
Timer
(
500
);
_tmr
.
Elapsed
+=
new
System
.
Timers
.
ElapsedEventHandler
(
tmr_Elapsed
);
_tmr
.
Start
();
}
private
void
tmr_Elapsed
(
object
sender
,
ElapsedEventArgs
e
)
{
try
{
_tmr
?.
Stop
();
//先停止定时器,防止重复触发
var
tid
=
ReaderInstance
.
ReadTid
();
//先读取Tid,即RFID标签的唯一标识
if
(
string
.
IsNullOrEmpty
(
tid
))
//如果没有,那么就是没卡,直接返回
{
return
;
}
Thread
.
Sleep
(
500
);
//给下一个写卡让出时间
samplePrepackaging
(
tid
);
//var th = KiviiContext.NewThread(() =>
//{
// samplePrepackaging(tid);
//});
//th.Start();
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
Message
);
}
finally
{
_tmr
?.
Start
();
}
}
#
endregion
#
endregion
private
void
btnLogin_Click
(
object
sender
,
EventArgs
e
)
private
void
btnLogin_Click
(
object
sender
,
EventArgs
e
)
...
@@ -343,6 +512,7 @@ namespace Kivii.Client.SamplePackages
...
@@ -343,6 +512,7 @@ namespace Kivii.Client.SamplePackages
private
void
cbSetCurrentPackageNode_TextChanged
(
object
sender
,
EventArgs
e
)
private
void
cbSetCurrentPackageNode_TextChanged
(
object
sender
,
EventArgs
e
)
{
{
tbCurrentPackageNode
.
Text
=
cbSetCurrentPackageNode
.
Text
;
tbCurrentPackageNode
.
Text
=
cbSetCurrentPackageNode
.
Text
;
if
(
_currentPackage
!=
null
)
_currentPackage
.
PackageName
=
cbSetCurrentPackageNode
.
Text
;
}
}
private
void
dgvSamples_RowPostPaint
(
object
sender
,
DataGridViewRowPostPaintEventArgs
e
)
private
void
dgvSamples_RowPostPaint
(
object
sender
,
DataGridViewRowPostPaintEventArgs
e
)
...
@@ -360,5 +530,95 @@ namespace Kivii.Client.SamplePackages
...
@@ -360,5 +530,95 @@ namespace Kivii.Client.SamplePackages
dgvSamples
.
RowHeadersDefaultCellStyle
.
ForeColor
,
dgvSamples
.
RowHeadersDefaultCellStyle
.
ForeColor
,
TextFormatFlags
.
VerticalCenter
|
TextFormatFlags
.
Right
);
TextFormatFlags
.
VerticalCenter
|
TextFormatFlags
.
Right
);
}
}
private
void
btnScanRfid_Click
(
object
sender
,
EventArgs
e
)
{
#
region
验证
//if (ReaderInstance == null)
//{
// MessageBox.Show("当前读卡器未连接.");
// return;
//}
if
(
_client
==
null
)
{
MessageBox
.
Show
(
"请先登录."
);
return
;
}
if
(
_currentLocation
==
null
)
{
MessageBox
.
Show
(
"未获取当前位置."
);
return
;
}
if
(
_currentPackage
==
null
)
{
MessageBox
.
Show
(
"未获取当前箱号."
);
return
;
}
if
(
_currentPackage
.
Status
==
(
int
)
PackageStatus
.
Inbound
)
{
MessageBox
.
Show
(
"当前箱子已入库,无法继续操作!"
);
return
;
}
#
endregion
if
(
ReaderInstance
!=
null
&&
ReaderInstance
.
State
==
ApplicationConnectionState
.
Connected
)
{
ReaderInstance
.
Stop
();
ReaderInstance
.
DisConnect
();
ReaderInstance
=
null
;
btnScanRfid
.
Text
=
"开始扫描"
;
btnScanRfid
.
BackColor
=
Color
.
PapayaWhip
;
btnScanRfid
.
ForeColor
=
Color
.
Chocolate
;
}
else
{
initReader
();
List
<
string
>
readers
=
null
;
#
region
获取读卡器
try
{
readers
=
ReaderInstance
.
GetReaderList
();
if
(
readers
.
Count
<
1
)
{
MessageBox
.
Show
(
"未能连接RFID读写终端,请检查连接线!"
,
"连接读卡器失败"
);
ReaderInstance
=
null
;
return
;
}
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
Message
,
"初始化失败"
);
ReaderInstance
=
null
;
return
;
}
try
{
ReaderInstance
.
Connect
(
readers
[
0
]);
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
Message
,
"连接读卡器失败"
);
ReaderInstance
=
null
;
return
;
}
#
endregion
btnScanRfid
.
Text
=
"停止扫描"
;
btnScanRfid
.
BackColor
=
Color
.
DarkGray
;
btnScanRfid
.
ForeColor
=
Color
.
Black
;
}
}
private
void
dgvSamples_CellContentClick
(
object
sender
,
DataGridViewCellEventArgs
e
)
{
if
(
dgvSamples
.
Columns
[
e
.
ColumnIndex
].
CellType
!=
typeof
(
DataGridViewButtonCell
))
return
;
if
(
_client
==
null
)
{
MessageBox
.
Show
(
"未连接"
);
return
;
}
var
currentRowSample
=
_currentSamples
[
e
.
RowIndex
];
if
(
currentRowSample
==
null
)
return
;
sampleUnpackaging
(
currentRowSample
);
}
}
}
}
}
Src/Kivii.Client.SamplePackages.V4.0.csproj
View file @
a0616726
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
<Deterministic>
true
</Deterministic>
<Deterministic>
true
</Deterministic>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<PlatformTarget>
x86
</PlatformTarget>
<DebugSymbols>
true
</DebugSymbols>
<DebugSymbols>
true
</DebugSymbols>
<DebugType>
full
</DebugType>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<Optimize>
false
</Optimize>
...
@@ -44,6 +44,9 @@
...
@@ -44,6 +44,9 @@
<Reference
Include=
"Kivii.Linq.V4.0, Version=5.6.2023.4200, Culture=neutral, processorArchitecture=MSIL"
>
<Reference
Include=
"Kivii.Linq.V4.0, Version=5.6.2023.4200, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Kivii.Linq.5.6.2023.4200\lib\net40\Kivii.Linq.V4.0.dll
</HintPath>
<HintPath>
..\packages\Kivii.Linq.5.6.2023.4200\lib\net40\Kivii.Linq.V4.0.dll
</HintPath>
</Reference>
</Reference>
<Reference
Include=
"Kivii.Rfid.D500.V4.0"
>
<HintPath>
Content\Kivii.Rfid.D500.V4.0.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Xml.Linq"
/>
<Reference
Include=
"System.Xml.Linq"
/>
...
@@ -93,5 +96,8 @@
...
@@ -93,5 +96,8 @@
</Compile>
</Compile>
<None
Include=
"Resources\批量读卡器文档.zip"
/>
<None
Include=
"Resources\批量读卡器文档.zip"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<EmbeddedResource
Include=
"Content\Kivii.Rfid.D500.V4.0.dll"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
</Project>
</Project>
\ No newline at end of file
Src/Program.cs
View file @
a0616726
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Threading
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
namespace
Kivii.Client.SamplePackages
namespace
Kivii.Client.SamplePackages
{
{
internal
static
class
Program
internal
static
class
Program
{
{
#
region
设置单进程,开机启动
private
static
Mutex
_mutex
=
null
;
private
static
bool
isProgramExisted
()
{
bool
rtns
=
false
;
_mutex
=
new
Mutex
(
true
,
"Kivii.Rfid.D500.V4.0.dll"
,
out
rtns
);
//mutex.Dispose();
return
!
rtns
;
}
#
endregion
/// <summary>
/// <summary>
/// 应用程序的主入口点。
/// 应用程序的主入口点。
/// </summary>
/// </summary>
[
STAThread
]
[
STAThread
]
static
void
Main
()
static
void
Main
()
{
{
if
(
isProgramExisted
())
{
MessageBox
.
Show
(
$"读卡器被占用正在被使用。"
,
"通讯冲突"
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Warning
,
MessageBoxDefaultButton
.
Button1
,
MessageBoxOptions
.
DefaultDesktopOnly
);
Application
.
Exit
();
return
;
}
Application
.
EnableVisualStyles
();
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
Run
(
new
FrmMain
());
Application
.
Run
(
new
FrmMain
());
...
...
Src/Requests/RestfulRequests.cs
View file @
a0616726
...
@@ -27,4 +27,26 @@ namespace Kivii.Samples.Transforms
...
@@ -27,4 +27,26 @@ namespace Kivii.Samples.Transforms
{
{
public
Guid
PackageKvid
{
get
;
set
;
}
public
Guid
PackageKvid
{
get
;
set
;
}
}
}
[
Route
(
Configs
.
RouteSamplePrePackaging
)]
public
class
SamplePrePackaging
:
IReturn
<
RestfulExecutionResponse
<
Sample
>>
{
public
string
Tid
{
get
;
set
;
}
public
Guid
OwnerKvid
{
get
;
set
;
}
//要打包的样品的所属信息
}
[
Route
(
Configs
.
RouteSamplePackaging
)]
public
class
SamplePackaging
:
IReturn
<
RestfulExecutionResponse
<
Sample
>>
{
public
Guid
Kvid
{
get
;
set
;
}
//要流转样品信息
public
Location
Location
{
get
;
set
;
}
//地点位置信息,只需要InternalCode
public
Sample
Package
{
get
;
set
;
}
//指定包裹信息,Package.PackageName可传入包裹的区域信息,例如包裹A0001中的1号袋子
}
[
Route
(
Configs
.
RouteSampleUnPackaging
)]
public
class
SampleUnPackaging
:
IReturn
<
RestfulExecutionResponse
<
Sample
>>
{
public
Guid
Kvid
{
get
;
set
;
}
//要流转样品信息
public
Location
Location
{
get
;
set
;
}
//地点位置信息,只需要InternalCode
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment