Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
RC1250-ACPackingStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 16d7267e
由
LN
编写于
2020-09-15 19:16:53 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
与服务器通信修改
1 个父辈
5199794c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
69 行增加
和
26 行删除
source/Common/util/HttpHelper.cs
source/DeviceLibrary/ACPackingStore/AC_BOX_Bean_Shelf.cs
source/Common/util/HttpHelper.cs
查看文件 @
16d7267
...
@@ -26,7 +26,7 @@ namespace OnlineStore.Common
...
@@ -26,7 +26,7 @@ namespace OnlineStore.Common
{
{
while
((
DateTime
.
Now
-
startTime
).
TotalMinutes
<
60
)
while
((
DateTime
.
Now
-
startTime
).
TotalMinutes
<
60
)
{
{
postRes
=
Post
(
url
,
paramData
,
Encoding
.
UTF8
,
out
bool
isTimeOut
);
postRes
=
Post
Json
(
url
,
paramData
,
Encoding
.
UTF8
,
out
bool
isTimeOut
);
ResponseData
data
=
JsonHelper
.
DeserializeJsonToObject
<
ResponseData
>(
postRes
);
ResponseData
data
=
JsonHelper
.
DeserializeJsonToObject
<
ResponseData
>(
postRes
);
if
(
data
!=
null
)
if
(
data
!=
null
)
...
@@ -57,12 +57,8 @@ namespace OnlineStore.Common
...
@@ -57,12 +57,8 @@ namespace OnlineStore.Common
return
postRes
;
return
postRes
;
}
}
public
static
string
Post
(
string
url
,
string
paramData
)
{
public
static
Operation
PostJson
(
string
url
,
Operation
operation
,
bool
simulate
=
false
)
bool
isTimeOut
=
false
;
return
Post
(
url
,
paramData
,
Encoding
.
UTF8
,
out
isTimeOut
);
}
public
static
Operation
Post
(
string
url
,
Operation
operation
,
bool
simulate
=
false
)
{
{
try
try
{
{
...
@@ -92,8 +88,9 @@ namespace OnlineStore.Common
...
@@ -92,8 +88,9 @@ namespace OnlineStore.Common
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
"JsonHelper.SerializeObject(operation) 出错【operation.op="
+
operation
.
op
+
"】"
+
ex
);
LogUtil
.
error
(
"JsonHelper.SerializeObject(operation) 出错【operation.op="
+
operation
.
op
+
"】"
+
ex
);
}
}
string
result
=
Post
(
url
,
json
);
bool
IsTimeOut
=
false
;
string
result
=
PostJson
(
url
,
json
,
Encoding
.
UTF8
,
out
IsTimeOut
);
if
(!
string
.
IsNullOrEmpty
(
result
))
if
(!
string
.
IsNullOrEmpty
(
result
))
{
{
try
try
...
@@ -115,17 +112,14 @@ namespace OnlineStore.Common
...
@@ -115,17 +112,14 @@ namespace OnlineStore.Common
}
}
private
static
int
isLog
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
Server_Log_Open
);
private
static
int
isLog
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
Server_Log_Open
);
public
static
string
LastServerMsg
=
""
;
public
static
string
LastServerMsg
=
""
;
p
ublic
static
string
Post
(
string
url
,
string
paramData
,
Encoding
encoding
,
out
bool
isTimeOut
)
p
rivate
static
string
PostJson
(
string
url
,
string
paramData
,
Encoding
encoding
,
out
bool
isTimeOut
)
{
{
isTimeOut
=
false
;
isTimeOut
=
false
;
if
(
isLog
==
1
)
if
(
isLog
==
1
)
{
{
LogUtil
.
info
(
"给服务器发送数据【"
+
paramData
+
"】 "
);
LogUtil
.
info
(
"给服务器发送数据【"
+
paramData
+
"】 "
);
}
}
if
(
paramData
!=
"null"
&&
paramData
!=
null
)
{
// LogUtil.debug(LOGGER, "HTTP POST to " + url + " \n\t >> " + paramData);
}
string
result
=
""
;
string
result
=
""
;
if
(
url
.
ToLower
().
IndexOf
(
"https"
,
System
.
StringComparison
.
Ordinal
)
>
-
1
)
if
(
url
.
ToLower
().
IndexOf
(
"https"
,
System
.
StringComparison
.
Ordinal
)
>
-
1
)
...
@@ -142,7 +136,6 @@ namespace OnlineStore.Common
...
@@ -142,7 +136,6 @@ namespace OnlineStore.Common
wc
.
Encoding
=
encoding
;
wc
.
Encoding
=
encoding
;
result
=
wc
.
UploadString
(
url
,
"POST"
,
paramData
);
result
=
wc
.
UploadString
(
url
,
"POST"
,
paramData
);
//LogUtil.info(result);
}
}
catch
(
WebException
e
)
catch
(
WebException
e
)
{
{
...
@@ -153,20 +146,70 @@ namespace OnlineStore.Common
...
@@ -153,20 +146,70 @@ namespace OnlineStore.Common
{
{
LogUtil
.
error
(
"POST ERROR:"
+
ex
.
ToString
(),
1
);
LogUtil
.
error
(
"POST ERROR:"
+
ex
.
ToString
(),
1
);
}
}
if
(!
result
.
Contains
(
"null"
)
&&
result
.
Length
!=
0
)
{
//LogUtil.debug(LOGGER,"receive << " + result);
}
if
(
isLog
==
1
)
if
(
isLog
==
1
)
{
{
LogUtil
.
info
(
"收到服务器数据【"
+
result
+
"】"
);
LogUtil
.
info
(
"收到服务器数据【"
+
result
+
"】"
);
}
}
LastServerMsg
=
DateTime
.
Now
.
ToLongTimeString
()
+
" URL:"
+
url
+
"\r\n"
LastServerMsg
=
DateTime
.
Now
.
ToLongTimeString
()
+
" URL:"
+
url
+
"\r\n"
+
"发送:"
+
paramData
+
"\r\n"
+
"发送:"
+
paramData
+
"\r\n"
+
"接收:"
+
result
+
"\r\n"
+
"接收:"
+
result
+
"\r\n"
;
return
result
;
}
;
public
static
string
Post
(
string
url
,
string
paramData
,
int
timeOut
=
5000
)
{
bool
IsTimeOut
=
false
;
return
Post
(
url
,
paramData
,
Encoding
.
UTF8
,
timeOut
,
out
IsTimeOut
);
}
public
static
string
Post
(
string
url
,
string
paramData
,
Encoding
encoding
,
int
timeOut
,
out
bool
IsTimeOut
)
{
if
(
paramData
.
Equals
(
""
))
{
int
index
=
url
.
IndexOf
(
"?"
);
if
(
index
>
0
)
{
paramData
=
url
.
Substring
(
index
+
1
,
url
.
Length
-
index
-
1
);
url
=
url
.
Substring
(
0
,
index
);
}
}
IsTimeOut
=
false
;
if
(
isLog
==
1
)
{
LogUtil
.
info
(
"给服务器发送数据【"
+
url
+
"】【"
+
paramData
+
"】 "
);
}
string
result
=
""
;
if
(
url
.
ToLower
().
IndexOf
(
"https"
,
System
.
StringComparison
.
Ordinal
)
>
-
1
)
{
ServicePointManager
.
ServerCertificateValidationCallback
=
new
RemoteCertificateValidationCallback
((
sender
,
certificate
,
chain
,
errors
)
=>
{
return
true
;
});
}
try
{
var
wc
=
new
MyWebClient
(
timeOut
);
if
(
string
.
IsNullOrEmpty
(
wc
.
Headers
[
"Content-Type"
]))
wc
.
Headers
.
Add
(
"Content-Type"
,
"application/x-www-form-urlencoded;charset=UTF-8"
);
wc
.
Encoding
=
encoding
;
result
=
wc
.
UploadString
(
url
,
"POST"
,
paramData
);
}
catch
(
WebException
ex
)
{
IsTimeOut
=
true
;
LogUtil
.
error
(
"POST ["
+
url
+
"] WebException :"
+
ex
.
ToString
(),
101
);
}
catch
(
Exception
e
)
{
LogUtil
.
error
(
"POST ["
+
url
+
"] ERROR:"
+
e
.
ToString
(),
101
);
}
if
(
isLog
==
1
)
{
LogUtil
.
info
(
"收到服务器数据【"
+
result
+
"】"
);
}
return
result
;
return
result
;
}
}
...
...
source/DeviceLibrary/ACPackingStore/AC_BOX_Bean_Shelf.cs
查看文件 @
16d7267
...
@@ -581,7 +581,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -581,7 +581,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil
.
error
(
Name
+
"没有湿度预警范围,需要从服务器获取,发送OP="
+
lineOperation
.
op
,
DeviceID
+
105
);
LogUtil
.
error
(
Name
+
"没有湿度预警范围,需要从服务器获取,发送OP="
+
lineOperation
.
op
,
DeviceID
+
105
);
}
}
string
server
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
http_server
);
string
server
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
http_server
);
Operation
resultOperation
=
HttpHelper
.
Post
(
StoreManager
.
GetPostApi
(
server
),
lineOperation
,
false
);
Operation
resultOperation
=
HttpHelper
.
Post
Json
(
StoreManager
.
GetPostApi
(
server
),
lineOperation
,
false
);
//发送状态信息到服务器
//发送状态信息到服务器
if
(
resultOperation
==
null
||
(
resultOperation
.
op
<=
0
))
if
(
resultOperation
==
null
||
(
resultOperation
.
op
<=
0
))
...
@@ -732,7 +732,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -732,7 +732,7 @@ namespace OnlineStore.DeviceLibrary
operation
.
op
=
1
;
operation
.
op
=
1
;
operation
.
data
=
new
Dictionary
<
string
,
string
>()
{
{
"code"
,
message
},
{
"boxId"
,
1.
ToString
()
},
{
ParamDefine
.
rfid
,
CurrShelfID
}
};
operation
.
data
=
new
Dictionary
<
string
,
string
>()
{
{
"code"
,
message
},
{
"boxId"
,
1.
ToString
()
},
{
ParamDefine
.
rfid
,
CurrShelfID
}
};
string
server
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
http_server
);
string
server
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
http_server
);
Operation
resultOperation
=
HttpHelper
.
Post
(
StoreManager
.
GetPostApi
(
server
),
operation
,
false
);
Operation
resultOperation
=
HttpHelper
.
Post
Json
(
StoreManager
.
GetPostApi
(
server
),
operation
,
false
);
if
(
resultOperation
==
null
)
if
(
resultOperation
==
null
)
{
{
CodeMsg
=
"二维码【"
+
message
+
"】没有收到服务器反馈"
;
CodeMsg
=
"二维码【"
+
message
+
"】没有收到服务器反馈"
;
...
@@ -876,7 +876,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -876,7 +876,7 @@ namespace OnlineStore.DeviceLibrary
operation
.
op
=
1
;
operation
.
op
=
1
;
operation
.
data
=
new
Dictionary
<
string
,
string
>()
{
{
"code"
,
message
},
{
"boxId"
,
1.
ToString
()
},
{
ParamDefine
.
rfid
,
CurrShelfID
}
};
operation
.
data
=
new
Dictionary
<
string
,
string
>()
{
{
"code"
,
message
},
{
"boxId"
,
1.
ToString
()
},
{
ParamDefine
.
rfid
,
CurrShelfID
}
};
string
server
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
http_server
);
string
server
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
http_server
);
Operation
resultOperation
=
HttpHelper
.
Post
(
StoreManager
.
GetPostApi
(
server
),
operation
,
false
);
Operation
resultOperation
=
HttpHelper
.
Post
Json
(
StoreManager
.
GetPostApi
(
server
),
operation
,
false
);
if
(
resultOperation
==
null
)
if
(
resultOperation
==
null
)
{
{
CodeMsg
=
"二维码【"
+
message
+
"】没有收到服务器反馈"
;
CodeMsg
=
"二维码【"
+
message
+
"】没有收到服务器反馈"
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论