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
0142679c
Commit
0142679c
authored
Jun 13, 2023
by
任天宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
36800b3c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
48 deletions
+151
-48
Cp2101_Setup.exe
Src/Content/Cp2101_Setup.exe
+0
-0
FrmMain.Designer.cs
Src/FrmMain.Designer.cs
+19
-4
FrmMain.cs
Src/FrmMain.cs
+85
-44
Kivii.Client.SamplePackages.V4.0.csproj
Src/Kivii.Client.SamplePackages.V4.0.csproj
+1
-0
Reader.cs
Src/Reader.cs
+46
-0
No files found.
Src/Content/Cp2101_Setup.exe
0 → 100644
View file @
0142679c
File added
Src/FrmMain.Designer.cs
View file @
0142679c
...
@@ -73,6 +73,7 @@
...
@@ -73,6 +73,7 @@
this
.
SampleDeadTime
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
SampleDeadTime
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
SampleQuantityUnit
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
SampleQuantityUnit
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
SamplePackageName
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
SamplePackageName
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
btnInstallDriver
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
plLeft
.
SuspendLayout
();
this
.
plLeft
.
SuspendLayout
();
this
.
gbInfo
.
SuspendLayout
();
this
.
gbInfo
.
SuspendLayout
();
this
.
gbLogin
.
SuspendLayout
();
this
.
gbLogin
.
SuspendLayout
();
...
@@ -117,7 +118,7 @@
...
@@ -117,7 +118,7 @@
this
.
lbCurrentPackageNode
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
);
this
.
lbCurrentPackageNode
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
);
this
.
lbCurrentPackageNode
.
Location
=
new
System
.
Drawing
.
Point
(
16
,
180
);
this
.
lbCurrentPackageNode
.
Location
=
new
System
.
Drawing
.
Point
(
16
,
180
);
this
.
lbCurrentPackageNode
.
Name
=
"lbCurrentPackageNode"
;
this
.
lbCurrentPackageNode
.
Name
=
"lbCurrentPackageNode"
;
this
.
lbCurrentPackageNode
.
Size
=
new
System
.
Drawing
.
Size
(
79
,
16
);
this
.
lbCurrentPackageNode
.
Size
=
new
System
.
Drawing
.
Size
(
80
,
16
);
this
.
lbCurrentPackageNode
.
TabIndex
=
7
;
this
.
lbCurrentPackageNode
.
TabIndex
=
7
;
this
.
lbCurrentPackageNode
.
Text
=
"当前袋子:"
;
this
.
lbCurrentPackageNode
.
Text
=
"当前袋子:"
;
//
//
...
@@ -127,7 +128,7 @@
...
@@ -127,7 +128,7 @@
this
.
lbCurrentPackage
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
);
this
.
lbCurrentPackage
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
);
this
.
lbCurrentPackage
.
Location
=
new
System
.
Drawing
.
Point
(
16
,
127
);
this
.
lbCurrentPackage
.
Location
=
new
System
.
Drawing
.
Point
(
16
,
127
);
this
.
lbCurrentPackage
.
Name
=
"lbCurrentPackage"
;
this
.
lbCurrentPackage
.
Name
=
"lbCurrentPackage"
;
this
.
lbCurrentPackage
.
Size
=
new
System
.
Drawing
.
Size
(
79
,
16
);
this
.
lbCurrentPackage
.
Size
=
new
System
.
Drawing
.
Size
(
80
,
16
);
this
.
lbCurrentPackage
.
TabIndex
=
6
;
this
.
lbCurrentPackage
.
TabIndex
=
6
;
this
.
lbCurrentPackage
.
Text
=
"当前箱号:"
;
this
.
lbCurrentPackage
.
Text
=
"当前箱号:"
;
//
//
...
@@ -137,7 +138,7 @@
...
@@ -137,7 +138,7 @@
this
.
lbCurrentLocation
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
);
this
.
lbCurrentLocation
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
);
this
.
lbCurrentLocation
.
Location
=
new
System
.
Drawing
.
Point
(
16
,
74
);
this
.
lbCurrentLocation
.
Location
=
new
System
.
Drawing
.
Point
(
16
,
74
);
this
.
lbCurrentLocation
.
Name
=
"lbCurrentLocation"
;
this
.
lbCurrentLocation
.
Name
=
"lbCurrentLocation"
;
this
.
lbCurrentLocation
.
Size
=
new
System
.
Drawing
.
Size
(
79
,
16
);
this
.
lbCurrentLocation
.
Size
=
new
System
.
Drawing
.
Size
(
80
,
16
);
this
.
lbCurrentLocation
.
TabIndex
=
5
;
this
.
lbCurrentLocation
.
TabIndex
=
5
;
this
.
lbCurrentLocation
.
Text
=
"当前位置:"
;
this
.
lbCurrentLocation
.
Text
=
"当前位置:"
;
//
//
...
@@ -147,7 +148,7 @@
...
@@ -147,7 +148,7 @@
this
.
lbCurrentDepartment
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
);
this
.
lbCurrentDepartment
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
12F
);
this
.
lbCurrentDepartment
.
Location
=
new
System
.
Drawing
.
Point
(
16
,
21
);
this
.
lbCurrentDepartment
.
Location
=
new
System
.
Drawing
.
Point
(
16
,
21
);
this
.
lbCurrentDepartment
.
Name
=
"lbCurrentDepartment"
;
this
.
lbCurrentDepartment
.
Name
=
"lbCurrentDepartment"
;
this
.
lbCurrentDepartment
.
Size
=
new
System
.
Drawing
.
Size
(
79
,
16
);
this
.
lbCurrentDepartment
.
Size
=
new
System
.
Drawing
.
Size
(
80
,
16
);
this
.
lbCurrentDepartment
.
TabIndex
=
4
;
this
.
lbCurrentDepartment
.
TabIndex
=
4
;
this
.
lbCurrentDepartment
.
Text
=
"当前部门:"
;
this
.
lbCurrentDepartment
.
Text
=
"当前部门:"
;
//
//
...
@@ -315,6 +316,7 @@
...
@@ -315,6 +316,7 @@
//
//
// gbTools
// gbTools
//
//
this
.
gbTools
.
Controls
.
Add
(
this
.
btnInstallDriver
);
this
.
gbTools
.
Controls
.
Add
(
this
.
ckbAutoCreatePackage
);
this
.
gbTools
.
Controls
.
Add
(
this
.
ckbAutoCreatePackage
);
this
.
gbTools
.
Controls
.
Add
(
this
.
lbTips
);
this
.
gbTools
.
Controls
.
Add
(
this
.
lbTips
);
this
.
gbTools
.
Controls
.
Add
(
this
.
lbScanSample
);
this
.
gbTools
.
Controls
.
Add
(
this
.
lbScanSample
);
...
@@ -567,6 +569,18 @@
...
@@ -567,6 +569,18 @@
this
.
SamplePackageName
.
ReadOnly
=
true
;
this
.
SamplePackageName
.
ReadOnly
=
true
;
this
.
SamplePackageName
.
Width
=
120
;
this
.
SamplePackageName
.
Width
=
120
;
//
//
// btnInstallDriver
//
this
.
btnInstallDriver
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Bottom
;
this
.
btnInstallDriver
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
99
);
this
.
btnInstallDriver
.
Name
=
"btnInstallDriver"
;
this
.
btnInstallDriver
.
Size
=
new
System
.
Drawing
.
Size
(
780
,
23
);
this
.
btnInstallDriver
.
TabIndex
=
82
;
this
.
btnInstallDriver
.
Text
=
"驱动安装"
;
this
.
btnInstallDriver
.
UseVisualStyleBackColor
=
true
;
this
.
btnInstallDriver
.
Visible
=
false
;
this
.
btnInstallDriver
.
Click
+=
new
System
.
EventHandler
(
this
.
btnInstallDriver_Click
);
//
// FrmMain
// FrmMain
//
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
...
@@ -639,6 +653,7 @@
...
@@ -639,6 +653,7 @@
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
SampleDeadTime
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
SampleDeadTime
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
SampleQuantityUnit
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
SampleQuantityUnit
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
SamplePackageName
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
SamplePackageName
;
private
System
.
Windows
.
Forms
.
Button
btnInstallDriver
;
}
}
}
}
Src/FrmMain.cs
View file @
0142679c
...
@@ -207,19 +207,47 @@ namespace Kivii.Client.SamplePackages
...
@@ -207,19 +207,47 @@ namespace Kivii.Client.SamplePackages
}));
}));
var
request
=
new
SampleQuery2
();
var
request
=
new
SampleQuery2
();
request
.
PackageKvid
=
_currentPackage
.
Kvid
;
request
.
PackageKvid
=
_currentPackage
.
Kvid
;
var
task
=
_client
.
PostAsync
(
request
);
try
task
.
Success
(
resp
=>
{
var
resp
=
_client
.
Post
(
request
);
if
(!
resp
.
Results
.
IsNullOrEmpty
())
{
{
_currentSamples
=
resp
.
Results
.
ToList
();
_currentSamples
=
resp
.
Results
.
ToList
();
this
.
Invoke
(
new
Action
(
delegate
this
.
Invoke
(
new
Action
(
delegate
{
{
dgvSamples
.
DataSource
=
_currentSamples
;
dgvSamples
.
DataSource
=
_currentSamples
;
}));
}));
});
}
task
.
Error
(
err
=>
}
catch
(
Exception
ex
)
{
{
MessageBox
.
Show
(
err
.
Message
,
"查询样品"
);
MessageBox
.
Show
(
ex
.
GetResponseStatus
().
Message
,
"查询样品"
+
ex
.
Message
);
});
}
//task.Success(resp =>
//{
// _currentSamples = resp.Results.ToList();
// this.Invoke(new Action(delegate
// {
// dgvSamples.DataSource = _currentSamples;
// }));
//});
//task.Error(err =>
//{
// MessageBox.Show(err.Message, "查询样品");
//});
//var task = _client.PostAsync(request);
//task.Success(resp =>
//{
// _currentSamples = resp.Results.ToList();
// this.Invoke(new Action(delegate
// {
// dgvSamples.DataSource = _currentSamples;
// }));
//});
//task.Error(err =>
//{
// MessageBox.Show(err.Message, "查询样品");
//});
}
}
private
void
samplePrepackaging
(
string
tid
,
string
epc
=
null
,
string
bizId
=
null
)
private
void
samplePrepackaging
(
string
tid
,
string
epc
=
null
,
string
bizId
=
null
)
...
@@ -366,9 +394,9 @@ namespace Kivii.Client.SamplePackages
...
@@ -366,9 +394,9 @@ namespace Kivii.Client.SamplePackages
var
request
=
new
SampleQuery
();
var
request
=
new
SampleQuery
();
request
.
Name
=
tbSetCurrentPackage
.
Text
;
request
.
Name
=
tbSetCurrentPackage
.
Text
;
request
.
Type
=
SampleType
.
Package
;
request
.
Type
=
SampleType
.
Package
;
var
task
=
_client
.
PostAsync
(
request
);
try
task
.
Success
(
resp
=>
{
{
var
resp
=
_client
.
Post
(
request
);
if
(
resp
.
Results
.
Count
<=
0
)
if
(
resp
.
Results
.
Count
<=
0
)
{
{
if
(!
ckbAutoCreatePackage
.
Checked
)
if
(!
ckbAutoCreatePackage
.
Checked
)
...
@@ -379,15 +407,15 @@ namespace Kivii.Client.SamplePackages
...
@@ -379,15 +407,15 @@ namespace Kivii.Client.SamplePackages
}
}
else
else
{
{
var
requestCreate
=
new
PackageCreate
();
var
requestCreate
=
new
PackageCreate
();
requestCreate
.
Item
=
new
Sample
();
requestCreate
.
Item
=
new
Sample
();
requestCreate
.
Item
.
Name
=
tbSetCurrentPackage
.
Text
;
requestCreate
.
Item
.
Name
=
tbSetCurrentPackage
.
Text
;
requestCreate
.
Item
.
Type
=
SampleType
.
Package
;
requestCreate
.
Item
.
Type
=
SampleType
.
Package
;
requestCreate
.
Item
.
OperateTime
=
DateTime
.
Now
;
requestCreate
.
Item
.
OperateTime
=
DateTime
.
Now
;
var
createTask
=
_client
.
PostAsync
(
requestCreate
);
try
createTask
.
Success
(
res
=>
{
{
if
(
res
.
Results
.
Count
<=
0
)
var
res
=
_client
.
Post
(
requestCreate
);
if
(
res
.
Results
.
Count
<=
0
)
{
{
_currentPackage
=
null
;
_currentPackage
=
null
;
MessageBox
.
Show
(
"创建箱号失败!"
,
"箱号设置"
);
MessageBox
.
Show
(
"创建箱号失败!"
,
"箱号设置"
);
...
@@ -396,41 +424,39 @@ namespace Kivii.Client.SamplePackages
...
@@ -396,41 +424,39 @@ namespace Kivii.Client.SamplePackages
var
createPackage
=
res
.
Results
.
FirstOrDefault
();
var
createPackage
=
res
.
Results
.
FirstOrDefault
();
setCurrentPackage
(
createPackage
);
setCurrentPackage
(
createPackage
);
return
;
return
;
}
);
}
c
reateTask
.
Error
(
ex
=>
c
atch
(
Exception
ex
)
{
{
_currentPackage
=
null
;
_currentPackage
=
null
;
MessageBox
.
Show
(
"创建箱号失败!"
,
"箱号设置
"
);
MessageBox
.
Show
(
ex
.
GetResponseStatus
().
Message
,
"创建箱号失败
"
);
return
;
return
;
});
return
;
}
}
}
var
package
=
resp
.
Results
.
FirstOrDefault
();
//var createTask = _client.PostAsync(requestCreate);
setCurrentPackage
(
package
);
//createTask.Success(res =>
//_currentPackage = new Sample();
//_currentPackage.PopulateWith(package);
//tbSetCurrentPackage.Enabled = _currentPackage == null;
//tbCurrentPackage.Text = _currentPackage.Name + (_currentPackage.PackageName.IsNullOrEmpty() ? "" : $"({_currentPackage.PackageName})");
//btnClearCurrentPackage.Enabled = _currentPackage != null;
//cbSetCurrentPackageNode.Enabled = _currentPackage.Status == (int)PackageStatus.Empty || _currentPackage.Status == (int)PackageStatus.Full;
//btnScanRfid.Enabled = _currentPackage.Status == (int)PackageStatus.Empty || _currentPackage.Status == (int)PackageStatus.Full;
//tbScanSample.Enabled = _currentPackage.Status == (int)PackageStatus.Empty || _currentPackage.Status == (int)PackageStatus.Full;
//tbScanSample.Text = "";
//if (_currentPackage.Status == (int)PackageStatus.Full || _currentPackage.Status == (int)PackageStatus.Inbound)
//{
//{
// querySampleInPackaged();
// if (res.Results.Count <= 0)
//}
// {
//if (_currentPackage.Status == (int)PackageStatus.Inbound)
// _currentPackage = null;
// MessageBox.Show("创建箱号失败!", "箱号设置");
// return;
// }
// var createPackage = res.Results.FirstOrDefault();
// setCurrentPackage(createPackage);
// return;
//});
//createTask.Error(ex =>
//{
//{
// MessageBox.Show("当前箱子已入库,无法继续操作!", "箱号设置");
// _currentPackage = null;
// MessageBox.Show("创建箱号失败!", "箱号设置");
// return;
// return;
//}
//});
//cbSetCurrentPackageNode.SelectedIndex = 0;
//return;
//Thread.Sleep(200);
}
//btnScanRfid_Click(null, null);
}
});
var
package
=
resp
.
Results
.
FirstOrDefault
();
task
.
Error
(
err
=>
setCurrentPackage
(
package
);
}
catch
(
Exception
ex
)
{
{
_currentPackage
=
null
;
_currentPackage
=
null
;
tbSetCurrentPackage
.
Enabled
=
true
;
tbSetCurrentPackage
.
Enabled
=
true
;
...
@@ -442,8 +468,9 @@ namespace Kivii.Client.SamplePackages
...
@@ -442,8 +468,9 @@ namespace Kivii.Client.SamplePackages
tbScanSample
.
Enabled
=
false
;
tbScanSample
.
Enabled
=
false
;
tbScanSample
.
Text
=
""
;
tbScanSample
.
Text
=
""
;
MessageBox
.
Show
(
err
.
Message
,
"箱号设置"
);
MessageBox
.
Show
(
ex
.
GetResponseStatus
().
Message
,
"箱号设置"
);
});
}
//var task = _client.PostAsync(request);
}
}
private
void
reader_ConnectionLost
(
object
sender
,
ConnectionChangedEventArgs
e
)
private
void
reader_ConnectionLost
(
object
sender
,
ConnectionChangedEventArgs
e
)
...
@@ -461,7 +488,7 @@ namespace Kivii.Client.SamplePackages
...
@@ -461,7 +488,7 @@ namespace Kivii.Client.SamplePackages
private
void
reader_Connected
(
object
sender
,
ConnectionChangedEventArgs
e
)
private
void
reader_Connected
(
object
sender
,
ConnectionChangedEventArgs
e
)
{
{
//在这启动定时器
//在这启动定时器
_tmr
=
new
System
.
Timers
.
Timer
(
10
00
);
_tmr
=
new
System
.
Timers
.
Timer
(
8
00
);
_tmr
.
Elapsed
+=
new
System
.
Timers
.
ElapsedEventHandler
(
tmr_Elapsed
);
_tmr
.
Elapsed
+=
new
System
.
Timers
.
ElapsedEventHandler
(
tmr_Elapsed
);
_tmr
.
Start
();
_tmr
.
Start
();
}
}
...
@@ -544,6 +571,14 @@ namespace Kivii.Client.SamplePackages
...
@@ -544,6 +571,14 @@ namespace Kivii.Client.SamplePackages
_client
.
Dispose
();
_client
.
Dispose
();
_client
=
null
;
_client
=
null
;
initUserInfo
();
initUserInfo
();
if
(
ReaderInstance
!=
null
&&
ReaderInstance
.
State
==
ApplicationConnectionState
.
Connected
)
{
ReaderInstance
.
CloseSpecComPort
();
ReaderInstance
=
null
;
btnScanRfid
.
Text
=
"开始扫描"
;
btnScanRfid
.
BackColor
=
Color
.
PapayaWhip
;
btnScanRfid
.
ForeColor
=
Color
.
Chocolate
;
}
});
});
task
.
Error
(
err
=>
task
.
Error
(
err
=>
{
{
...
@@ -654,7 +689,8 @@ namespace Kivii.Client.SamplePackages
...
@@ -654,7 +689,8 @@ namespace Kivii.Client.SamplePackages
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
MessageBox
.
Show
(
ex
.
Message
,
"连接读卡器失败"
);
MessageBox
.
Show
(
"连接读卡器失败,可能是未安装驱动,请先安装驱动"
,
ex
.
Message
);
btnInstallDriver
.
Visible
=
true
;
ReaderInstance
=
null
;
ReaderInstance
=
null
;
return
;
return
;
}
}
...
@@ -705,5 +741,10 @@ namespace Kivii.Client.SamplePackages
...
@@ -705,5 +741,10 @@ namespace Kivii.Client.SamplePackages
samplePrepackaging
(
null
,
null
,
tbScanSample
.
Text
);
samplePrepackaging
(
null
,
null
,
tbScanSample
.
Text
);
}
}
}
}
private
void
btnInstallDriver_Click
(
object
sender
,
EventArgs
e
)
{
Reader
.
InstallDriver
();
}
}
}
}
}
Src/Kivii.Client.SamplePackages.V4.0.csproj
View file @
0142679c
...
@@ -105,6 +105,7 @@
...
@@ -105,6 +105,7 @@
<CopyToOutputDirectory>
PreserveNewest
</CopyToOutputDirectory>
<CopyToOutputDirectory>
PreserveNewest
</CopyToOutputDirectory>
</EmbeddedResource>
</EmbeddedResource>
<EmbeddedResource
Include=
"Content\UHFReader18CSharp.dll"
/>
<EmbeddedResource
Include=
"Content\UHFReader18CSharp.dll"
/>
<EmbeddedResource
Include=
"Content\Cp2101_Setup.exe"
/>
<Content
Include=
"F.ico"
/>
<Content
Include=
"F.ico"
/>
</ItemGroup>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
...
...
Src/Reader.cs
View file @
0142679c
using
ReaderB
;
using
ReaderB
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
...
@@ -13,6 +14,19 @@ namespace Kivii.Client.SamplePackages
...
@@ -13,6 +14,19 @@ namespace Kivii.Client.SamplePackages
public
event
EventHandler
<
ConnectionChangedEventArgs
>
ConnectionLost
;
public
event
EventHandler
<
ConnectionChangedEventArgs
>
ConnectionLost
;
public
ApplicationConnectionState
State
{
get
;
private
set
;
}
public
ApplicationConnectionState
State
{
get
;
private
set
;
}
private
static
string
_temporaryDirectory
=
string
.
Empty
;
public
static
string
TemporaryDirectory
{
get
{
if
(
_temporaryDirectory
!=
string
.
Empty
)
return
_temporaryDirectory
;
_temporaryDirectory
=
Path
.
Combine
(
Path
.
GetTempPath
(),
"Kivii.Com"
);
_temporaryDirectory
=
_temporaryDirectory
.
ToLower
();
//全小写,适应Linux
if
(!
Directory
.
Exists
(
_temporaryDirectory
))
Directory
.
CreateDirectory
(
_temporaryDirectory
);
return
_temporaryDirectory
;
}
}
private
byte
fComAdr
=
0xff
;
//当前操作的ComAdr
private
byte
fComAdr
=
0xff
;
//当前操作的ComAdr
private
byte
fBaud
;
private
byte
fBaud
;
private
double
fdminfre
;
private
double
fdminfre
;
...
@@ -227,6 +241,38 @@ namespace Kivii.Client.SamplePackages
...
@@ -227,6 +241,38 @@ namespace Kivii.Client.SamplePackages
epc
=
ByteArrayToHexString
(
EPC
);
epc
=
ByteArrayToHexString
(
EPC
);
return
true
;
return
true
;
}
}
public
static
void
InstallDriver
()
{
var
savePath
=
Path
.
Combine
(
TemporaryDirectory
,
"Cp2101_Driver"
);
if
(!
Directory
.
Exists
(
savePath
))
Directory
.
CreateDirectory
(
savePath
);
var
assembly
=
typeof
(
Reader
).
Assembly
;
var
fileNames
=
assembly
.
GetManifestResourceNames
();
if
(
fileNames
==
null
||
fileNames
.
Length
==
0
)
return
;
var
localFileName
=
string
.
Empty
;
foreach
(
var
fileName
in
fileNames
)
{
if
(!
fileName
.
ToLower
().
Contains
(
".cp2101_setup.exe"
))
continue
;
localFileName
=
Path
.
Combine
(
savePath
,
"setup.exe"
);
var
stream
=
assembly
.
GetManifestResourceStream
(
fileName
);
using
(
var
fileStream
=
new
FileStream
(
localFileName
,
FileMode
.
Create
))
{
stream
.
CopyTo
(
fileStream
);
}
stream
.
Dispose
();
break
;
}
if
(
string
.
IsNullOrEmpty
(
localFileName
))
return
;
System
.
Diagnostics
.
ProcessStartInfo
startInfo
=
new
System
.
Diagnostics
.
ProcessStartInfo
();
//设置运行文件
startInfo
.
FileName
=
localFileName
;
//设置启动参数
//设置启动动作,确保以管理员身份运行
startInfo
.
Verb
=
"runas"
;
//如果不是管理员,则启动UAC
System
.
Diagnostics
.
Process
.
Start
(
startInfo
);
}
}
}
public
class
ConnectionChangedEventArgs
:
EventArgs
public
class
ConnectionChangedEventArgs
:
EventArgs
...
...
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