Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
ACSingleStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 8feba3d1
由
LN
编写于
2020-08-24 15:04:59 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
http修改
1 个父辈
37cce6d8
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
73 行增加
和
59 行删除
source/ACSingleStore/Program.cs
source/Common/util/HttpHelper.cs
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean.cs
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Inventory.cs
source/ACSingleStore/Program.cs
查看文件 @
8feba3d
...
...
@@ -95,7 +95,8 @@ namespace OnlineStore.ACSingleStore
{
log4net
.
GlobalContext
.
Properties
[
"fname"
]
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
Store_CID
);
log4net
.
Config
.
XmlConfigurator
.
Configure
();
// XmlConfigurator.Configure();
System
.
Net
.
ServicePointManager
.
DefaultConnectionLimit
=
512
;
// XmlConfigurator.Configure();
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
Run
(
new
FrmStoreBox
());
...
...
source/Common/util/HttpHelper.cs
查看文件 @
8feba3d
...
...
@@ -20,28 +20,11 @@ namespace OnlineStore.Common
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
public
static
Operation
Post
(
string
url
,
Operation
operation
,
out
bool
isTimeOut
)
public
static
Operation
Post
OP
(
string
url
,
Operation
operation
,
out
bool
isTimeOut
)
{
isTimeOut
=
false
;
try
{
//if (simulate)
//{//模拟服务器返回
// operation.status = 200;
// operation.data.Clear();
// operation.data.Add("posId", "A001");
// string pos = "D100-111#D102-222#D104-333";
// operation.data.Add("pos", pos);
// if (operation.op == 1 || operation.op == 2)
// {//入库或出库
// string json = JsonHelper.SerializeObject(operation);
// LogUtil.error(LOGGER, "模拟HTTP服务器返回出库入库信息:" + json);
// return operation;
// }
//}
//else
//{
{
string
json
=
""
;
try
{
...
...
@@ -52,7 +35,9 @@ namespace OnlineStore.Common
LogUtil
.
error
(
"JsonHelper.SerializeObject(operation) 出错【operation.op="
+
operation
.
op
+
"】"
+
ex
);
}
string
result
=
Post
(
url
,
json
,
Encoding
.
UTF8
,
out
isTimeOut
);
string
result
=
PostJson
(
url
,
json
,
Encoding
.
UTF8
,
out
isTimeOut
);
if
(!
string
.
IsNullOrEmpty
(
result
))
{
try
...
...
@@ -63,8 +48,7 @@ namespace OnlineStore.Common
{
LogUtil
.
error
(
"JsonHelper.DeserializeJsonToObject 出错【result="
+
result
+
"】"
+
ex
);
}
}
//}
}
}
catch
(
Exception
ex
)
{
...
...
@@ -73,17 +57,14 @@ namespace OnlineStore.Common
return
null
;
}
private
static
int
isLog
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
Server_Log_Open
);
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
;
if
(
isLog
==
1
)
{
LOGGER
.
Info
(
"给服务器发送数据【"
+
paramData
+
"】 "
);
}
if
(
paramData
!=
"null"
&&
paramData
!=
null
)
{
// LogUtil.debug(LOGGER, "HTTP POST to " + url + " \n\t >> " + paramData);
}
string
result
=
""
;
if
(
url
.
ToLower
().
IndexOf
(
"https"
,
System
.
StringComparison
.
Ordinal
)
>
-
1
)
...
...
@@ -99,8 +80,7 @@ namespace OnlineStore.Common
wc
.
Headers
.
Add
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
wc
.
Encoding
=
encoding
;
result
=
wc
.
UploadString
(
url
,
"POST"
,
paramData
);
//LogUtil.info(result);
result
=
wc
.
UploadString
(
url
,
"POST"
,
paramData
);
}
catch
(
WebException
ex
)
{
...
...
@@ -110,6 +90,64 @@ namespace OnlineStore.Common
catch
(
Exception
e
)
{
LogUtil
.
error
(
LOGGER
,
"POST ERROR:"
+
e
.
ToString
(),
1
);
}
if
(
isLog
==
1
)
{
LogUtil
.
info
(
"收到服务器数据【"
+
result
+
"】"
);
}
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
);
//LogUtil.info(result);
}
catch
(
WebException
ex
)
{
IsTimeOut
=
true
;
LogUtil
.
error
(
"POST ["
+
url
+
"] WebException :"
+
ex
.
ToString
()
);
}
catch
(
Exception
e
)
{
LogUtil
.
error
(
"POST ["
+
url
+
"] ERROR:"
+
e
.
ToString
()
);
}
if
(!
result
.
Contains
(
"null"
)
&&
result
.
Length
!=
0
)
{
...
...
@@ -122,30 +160,5 @@ namespace OnlineStore.Common
return
result
;
}
//public static string Get(string url)
//{
// return Get(url, Encoding.UTF8);
//}
//public static string Get(string url, Encoding encoding)
//{
// try
// {
// LogUtil.info(LOGGER, "HTTP GET FROM: " + url);
// var wc = new WebClient { Encoding = encoding };
// var readStream = wc.OpenRead(url);
// using (var sr = new StreamReader(readStream, encoding))
// {
// var result = sr.ReadToEnd();
// LogUtil.info(LOGGER, "receive << " + result);
// return result;
// }
// }
// catch (Exception e)
// {
// LogUtil.error(LOGGER, "HTTP GET ERROR:" + e.Message, 2);
// }
// return "";
//}
}
}
\ No newline at end of file
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean.cs
查看文件 @
8feba3d
...
...
@@ -1287,7 +1287,7 @@ namespace OnlineStore.DeviceLibrary
for
(
int
i
=
1
;
i
<=
3
;
i
++)
{
bool
timeOut
=
false
;
Operation
resultOperation
=
HttpHelper
.
Post
(
StoreManager
.
GetPostApi
(
server
),
operation
,
out
timeOut
);
Operation
resultOperation
=
HttpHelper
.
Post
OP
(
StoreManager
.
GetPostApi
(
server
),
operation
,
out
timeOut
);
if
(
timeOut
)
{
LogUtil
.
info
(
LOGGER
,
logName
+
" 第"
+
i
+
"次发送超时 "
);
...
...
@@ -1655,7 +1655,7 @@ namespace OnlineStore.DeviceLibrary
}
string
server
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
http_server
);
bool
isTimeout
=
false
;
Operation
resultOperation
=
HttpHelper
.
Post
(
StoreManager
.
GetPostApi
(
server
),
lineOperation
,
out
isTimeout
);
Operation
resultOperation
=
HttpHelper
.
Post
OP
(
StoreManager
.
GetPostApi
(
server
),
lineOperation
,
out
isTimeout
);
//发送状态信息到服务器
if
(
resultOperation
==
null
||
(
resultOperation
.
op
<=
0
))
...
...
source/DeviceLibrary/acSingleStore/AC_SA_BoxBean_Inventory.cs
查看文件 @
8feba3d
...
...
@@ -68,8 +68,8 @@ namespace OnlineStore.DeviceLibrary
paramMap
.
Add
(
"pos"
,
StoreMove
.
MoveParam
.
PosInfo
.
PosId
);
// 库位
paramMap
.
Add
(
"hasReel"
,
reelIsExist
.
ToString
());
// 是否有料
string
server
=
StoreManager
.
GetAddr
(
StoreManager
.
Addr_posReelCheck
,
paramMap
);
bool
timeOut
=
false
;
string
resultStr
=
HttpHelper
.
Post
(
server
,
""
,
Encoding
.
UTF8
,
out
timeOut
);
//
bool timeOut = false;
string
resultStr
=
HttpHelper
.
Post
(
server
,
""
);
CheckPositionLog
(
"盘点仓位: [CID="
+
CID
+
"] ["
+
StoreMove
.
MoveParam
.
PosInfo
.
PosId
+
"] [IO_Type.reelIsExist="
+
reelIsExist
.
ToString
()
+
"] [resultStr="
+
resultStr
+
"]"
);
reelIsExist
=
false
;
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论