Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
SO853-AutoCountMachine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit df26cf7a
由
刘韬
编写于
2026-01-28 13:31:22 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
客户更新API接口,配合更新
1 个父辈
4825c196
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
58 行增加
和
8 行删除
DeviceLibrary/AutoScan/common/ServerConn.cs
SO853-AutoCountMachine/Program.cs
DeviceLibrary/AutoScan/common/ServerConn.cs
查看文件 @
df26cf7
using
OnlineStore.Common
;
using
OnlineStore.Common
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Net
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
...
@@ -19,14 +21,16 @@ namespace DeviceLibrary
...
@@ -19,14 +21,16 @@ namespace DeviceLibrary
public
static
CountResult
inputCounterDataByXRayMachine
(
string
TwoDBarcode
,
int
qty
)
public
static
CountResult
inputCounterDataByXRayMachine
(
string
TwoDBarcode
,
int
qty
)
{
{
var
wc
=
new
MyWebClient
(
15000
);
var
wc
=
new
MyWebClient
(
15000
);
if
(
string
.
IsNullOrEmpty
(
wc
.
Headers
[
"Content-Type"
]))
//if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
wc
.
Headers
.
Add
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
// wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
wc
.
Headers
[
HttpRequestHeader
.
ContentType
]
=
"application/json; charset=utf-8"
;
wc
.
Encoding
=
Encoding
.
UTF8
;
wc
.
Encoding
=
Encoding
.
UTF8
;
var
data
=
new
Wiston_Request
();
var
data
=
new
Wiston_Request
();
data
.
userId
=
"Q14050052"
;
data
.
userId
=
"Q14050052"
;
data
.
language
=
1
;
data
.
language
=
1
;
data
.
requestTime
=
0
;
data
.
requestTime
=
DateTime
.
UtcNow
.
ToString
(
"yyyy-MM-ddTHH:mm:ss.fffZ"
)
;
data
.
data
.
Add
(
"TwoDBarcode"
,
TwoDBarcode
);
data
.
data
.
Add
(
"TwoDBarcode"
,
TwoDBarcode
);
data
.
data
.
Add
(
"Qty"
,
qty
);
data
.
data
.
Add
(
"Qty"
,
qty
);
data
.
data
.
Add
(
"Counter"
,
ConfigHelper
.
Config
.
Get
(
"upload_Counter"
));
data
.
data
.
Add
(
"Counter"
,
ConfigHelper
.
Config
.
Get
(
"upload_Counter"
));
...
@@ -40,6 +44,23 @@ namespace DeviceLibrary
...
@@ -40,6 +44,23 @@ namespace DeviceLibrary
result
=
wc
.
UploadString
(
ConfigHelper
.
Config
.
Get
(
"inputCounterDataByXRayMachine"
),
"POST"
,
json
);
result
=
wc
.
UploadString
(
ConfigHelper
.
Config
.
Get
(
"inputCounterDataByXRayMachine"
),
"POST"
,
json
);
return
JsonHelper
.
DeserializeJsonToObject
<
CountResult
>(
result
);
return
JsonHelper
.
DeserializeJsonToObject
<
CountResult
>(
result
);
}
}
catch
(
WebException
ex
)
// 先捕获 HTTP 级异常
{
string
respBody
=
null
;
if
(
ex
.
Response
!=
null
)
{
using
(
var
sr
=
new
StreamReader
(
ex
.
Response
.
GetResponseStream
()))
respBody
=
sr
.
ReadToEnd
();
}
LogUtil
.
info
(
$
"inputCounterDataByXRayMachine url:{ConfigHelper.Config.Get("
inputCounterDataByXRayMachine
")} retry:{retry}, "
+
$
"status:{(int?)((HttpWebResponse)ex.Response)?.StatusCode}, "
+
$
"responseBody:{respBody}, "
+
$
"exception:{ex}"
);
retry
++;
if
(
retry
<
3
)
goto
retry
;
return
null
;
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
LogUtil
.
info
(
$
"inputCounterDataByXRayMachine retry:{retry}, {e.ToString()}"
);
LogUtil
.
info
(
$
"inputCounterDataByXRayMachine retry:{retry}, {e.ToString()}"
);
...
@@ -58,14 +79,18 @@ namespace DeviceLibrary
...
@@ -58,14 +79,18 @@ namespace DeviceLibrary
public
static
ReelLocation
DetermineReelStorageLocation
(
string
TwoDBarcode
)
public
static
ReelLocation
DetermineReelStorageLocation
(
string
TwoDBarcode
)
{
{
var
wc
=
new
MyWebClient
(
15000
);
var
wc
=
new
MyWebClient
(
15000
);
if
(
string
.
IsNullOrEmpty
(
wc
.
Headers
[
"Content-Type"
]))
//if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
wc
.
Headers
.
Add
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
// wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
wc
.
Headers
[
HttpRequestHeader
.
ContentType
]
=
"application/json; charset=utf-8"
;
wc
.
Headers
.
Add
(
"Accept"
,
"application/json"
);
wc
.
Encoding
=
Encoding
.
UTF8
;
wc
.
Encoding
=
Encoding
.
UTF8
;
var
data
=
new
Wiston_Request
();
var
data
=
new
Wiston_Request
();
data
.
userId
=
"Q14050052"
;
data
.
userId
=
"Q14050052"
;
data
.
language
=
1
;
data
.
language
=
0
;
data
.
requestTime
=
0
;
data
.
requestTime
=
DateTime
.
UtcNow
.
ToString
(
"yyyy-MM-ddTHH:mm:ss.fffZ"
);
//data.requestTime = 0;
data
.
data
.
Add
(
"str2DBarcode"
,
TwoDBarcode
);
data
.
data
.
Add
(
"str2DBarcode"
,
TwoDBarcode
);
data
.
data
.
Add
(
"labelPrinter"
,
ConfigHelper
.
Config
.
Get
(
"upload_labelPrinter"
));
data
.
data
.
Add
(
"labelPrinter"
,
ConfigHelper
.
Config
.
Get
(
"upload_labelPrinter"
));
...
@@ -79,6 +104,23 @@ namespace DeviceLibrary
...
@@ -79,6 +104,23 @@ namespace DeviceLibrary
result
=
wc
.
UploadString
(
ConfigHelper
.
Config
.
Get
(
"DetermineReelStorageLocation"
),
"POST"
,
json
);
result
=
wc
.
UploadString
(
ConfigHelper
.
Config
.
Get
(
"DetermineReelStorageLocation"
),
"POST"
,
json
);
return
JsonHelper
.
DeserializeJsonToObject
<
ReelLocation
>(
result
);
return
JsonHelper
.
DeserializeJsonToObject
<
ReelLocation
>(
result
);
}
}
catch
(
WebException
ex
)
// 先捕获 HTTP 级异常
{
string
respBody
=
null
;
if
(
ex
.
Response
!=
null
)
{
using
(
var
sr
=
new
StreamReader
(
ex
.
Response
.
GetResponseStream
()))
respBody
=
sr
.
ReadToEnd
();
}
LogUtil
.
info
(
$
"DetermineReelStorageLocation url:{ConfigHelper.Config.Get("
DetermineReelStorageLocation
")} retry:{retry}, "
+
$
"status:{(int?)((HttpWebResponse)ex.Response)?.StatusCode}, "
+
$
"responseBody:{respBody}, "
+
$
"exception:{ex}"
);
retry
++;
if
(
retry
<
3
)
goto
retry
;
return
null
;
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
LogUtil
.
info
(
$
"DetermineReelStorageLocation retry:{retry}, {e.ToString()}"
);
LogUtil
.
info
(
$
"DetermineReelStorageLocation retry:{retry}, {e.ToString()}"
);
...
@@ -99,7 +141,14 @@ namespace DeviceLibrary
...
@@ -99,7 +141,14 @@ namespace DeviceLibrary
{
{
public
string
userId
=
""
;
public
string
userId
=
""
;
public
int
language
=
0
;
public
int
language
=
0
;
public
int
requestTime
=
0
;
public
string
requestTime
=
""
;
public
Dictionary
<
string
,
object
>
data
=
new
Dictionary
<
string
,
object
>();
}
class
Wiston_Request2
{
public
string
userId
=
""
;
public
int
language
=
0
;
public
string
requestTime
=
""
;
public
Dictionary
<
string
,
object
>
data
=
new
Dictionary
<
string
,
object
>();
public
Dictionary
<
string
,
object
>
data
=
new
Dictionary
<
string
,
object
>();
}
}
public
class
CountResult
public
class
CountResult
...
...
SO853-AutoCountMachine/Program.cs
查看文件 @
df26cf7
...
@@ -24,6 +24,7 @@ namespace AutoCountMachine
...
@@ -24,6 +24,7 @@ namespace AutoCountMachine
[
STAThread
]
[
STAThread
]
static
void
Main
()
static
void
Main
()
{
{
var
t
=
DateTime
.
UtcNow
.
ToString
(
"yyyy-MM-ddTHH:mm:ss.fffZ"
);
//OcrProcess.Run();
//OcrProcess.Run();
//ServerConn.inputCounterDataByXRayMachine("20.K0784.008-615313|1KQ-2111|5000|A2061531315212446|PANASONIC", 9);
//ServerConn.inputCounterDataByXRayMachine("20.K0784.008-615313|1KQ-2111|5000|A2061531315212446|PANASONIC", 9);
//return;
//return;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论