Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
李娜
/
SO664-HCSingleStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit ba1e2704
由
LN
编写于
2021-04-20 15:07:52 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
修改离线问题
1 个父辈
684dce68
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
127 行增加
和
56 行删除
source/Common/util/ConfigAppSettings.cs
source/Common/util/HttpHelper.cs
source/DeviceLibrary/acSingleStore/BoxBean.cs
source/DeviceLibrary/lineConnect/LineConnect.cs
source/HCSingleStore/FrmBox.Designer.cs
source/HCSingleStore/FrmBox.cs
source/HCSingleStore/FrmStore.Designer.cs
source/HCSingleStore/FrmStore.cs
source/Common/util/ConfigAppSettings.cs
查看文件 @
ba1e270
...
...
@@ -13,18 +13,7 @@ namespace OnlineStore.Common
public
class
ConfigAppSettings
{
private
static
int
seq
=
1
;
public
static
int
nextSeq
()
{
if
(
seq
.
Equals
(
Int32
.
MaxValue
))
{
LogUtil
.
info
(
"seq当前值:"
+
seq
+
",重置seq=0"
);
seq
=
0
;
}
Interlocked
.
Increment
(
ref
seq
);
return
seq
;
}
public
static
string
GetValue
(
string
keyStr
,
string
storeStr
)
{
string
key
=
keyStr
+
storeStr
;
...
...
source/Common/util/HttpHelper.cs
查看文件 @
ba1e270
...
...
@@ -19,13 +19,17 @@ namespace OnlineStore.Common
{
public
class
HttpHelper
{
public
static
string
LastSend
=
""
;
public
static
string
LastRevice
=
""
;
private
static
int
isLog
=
ConfigAppSettings
.
GetIntValue
(
Setting_Init
.
Server_Log_Open
);
private
static
object
lockObj
=
""
;
//
private static object lockObj = "";
public
static
Operation
PostOP
(
string
url
,
Operation
operation
,
int
lockTime
,
out
bool
isTimeOut
)
{
isTimeOut
=
false
;
if
(
Monitor
.
TryEnter
(
lockObj
,
lockTime
))
{
//
if (Monitor.TryEnter(lockObj, lockTime))
//
{
try
{
string
json
=
JsonHelper
.
SerializeObject
(
operation
);
...
...
@@ -39,16 +43,16 @@ namespace OnlineStore.Common
{
LogUtil
.
error
(
"Post 出错【operation.op="
+
operation
.
op
+
"】:"
+
ex
);
}
finally
{
Monitor
.
Exit
(
lockObj
);
}
}
else
if
(
lockTime
>
10
)
{
string
json
=
JsonHelper
.
SerializeObject
(
operation
);
LogUtil
.
error
(
" PostOP "
+
lockTime
+
" send "
+
json
+
" TryEnter fail "
);
}
//
finally
//
{
//
Monitor.Exit(lockObj);
//
}
//
}
//
else if (lockTime > 10)
//
{
//
string json = JsonHelper.SerializeObject(operation);
//
LogUtil.error(" PostOP " + lockTime + " send " + json + " TryEnter fail ");
//
}
return
null
;
}
private
static
string
PostJson
(
string
url
,
string
paramData
,
Encoding
encoding
,
out
bool
IsTimeOut
)
...
...
@@ -69,12 +73,14 @@ namespace OnlineStore.Common
try
{
var
wc
=
new
MyWebClient
(
3000
);
LastSend
=
DateTime
.
Now
.
ToLongTimeString
()
+
" Send :"
+
paramData
;
var
wc
=
new
MyWebClient
(
3000
);
if
(
string
.
IsNullOrEmpty
(
wc
.
Headers
[
"Content-Type"
]))
wc
.
Headers
.
Add
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
wc
.
Encoding
=
encoding
;
result
=
wc
.
UploadString
(
url
,
"POST"
,
paramData
);
result
=
wc
.
UploadString
(
url
,
"POST"
,
paramData
);
LastRevice
=
DateTime
.
Now
.
ToLongTimeString
()
+
" Revice :"
+
result
;
}
catch
(
WebException
ex
)
{
...
...
source/DeviceLibrary/acSingleStore/BoxBean.cs
查看文件 @
ba1e270
...
...
@@ -1122,7 +1122,17 @@ namespace OnlineStore.DeviceLibrary
isInProcess
=
false
;
}
}
private
int
seq
=
1
;
public
int
nextSeq
()
{
if
(
seq
.
Equals
(
Int32
.
MaxValue
))
{
LogUtil
.
info
(
"seq当前值:"
+
seq
+
",重置seq=0"
);
seq
=
0
;
}
Interlocked
.
Increment
(
ref
seq
);
return
seq
;
}
public
Operation
getLineBoxStatus
()
{
//构建发送给服务器的对象
...
...
@@ -1130,7 +1140,7 @@ namespace OnlineStore.DeviceLibrary
lineOperation
.
msg
=
""
;
lineOperation
.
alarmList
=
new
List
<
AlarmInfo
>();
lineOperation
.
cid
=
CID
;
lineOperation
.
seq
=
ConfigAppSettings
.
nextSeq
();
lineOperation
.
seq
=
nextSeq
();
lineOperation
.
status
=
1
;
if
(
WarnMsg
!=
""
)
{
...
...
@@ -1194,11 +1204,7 @@ namespace OnlineStore.DeviceLibrary
boxStatus
.
status
=
(
int
)
StoreStatus
.
InStoreExecute
;
}
}
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.Temperate_Serveraddress);
//HumitureParam param = HumitureController.LastData;
if
(
humBean
!=
null
)
{
boxStatus
.
humidity
=
humBean
.
LastData
.
Humidity
.
ToString
();
...
...
@@ -1212,7 +1218,7 @@ namespace OnlineStore.DeviceLibrary
}
return
lineOperation
;
}
public
string
LastSend
=
""
;
public
void
SendLineStatus
()
{
DateTime
time
=
DateTime
.
Now
;
...
...
@@ -1226,6 +1232,7 @@ namespace OnlineStore.DeviceLibrary
}
string
server
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
http_server
);
bool
isTimeout
=
false
;
LastSend
=
DateTime
.
Now
.
ToLongTimeString
()
+
" Send: "
+
JsonHelper
.
SerializeObject
(
lineOperation
);
Operation
resultOperation
=
HttpHelper
.
PostOP
(
StoreManager
.
GetPostApi
(
server
),
lineOperation
,
10
,
out
isTimeout
);
//发送状态信息到服务器
...
...
source/DeviceLibrary/lineConnect/LineConnect.cs
查看文件 @
ba1e270
...
...
@@ -11,7 +11,11 @@ using System.Threading.Tasks;
namespace
OnlineStore.DeviceLibrary
{
public
class
LineConnect
{
{
public
string
LastSend
=
""
;
public
string
LastRevice
=
""
;
public
static
char
cmd_spilt
=
';'
;
public
static
string
cmd_heart
=
"heart"
;
private
static
string
cmd_outend
=
"outend"
;
...
...
@@ -68,7 +72,7 @@ namespace OnlineStore.DeviceLibrary
Interlocked
.
Increment
(
ref
seq
);
return
seq
;
}
public
void
SendHeart
(
StoreSendBean
store
)
{
if
(
client
==
null
)
...
...
@@ -76,15 +80,15 @@ namespace OnlineStore.DeviceLibrary
return
;
}
try
{
{
store
.
Cmd
=
cmd_heart
;
string
heartMsg
=
ToParamStr
(
store
);
LastSend
=
DateTime
.
Now
.
ToLongTimeString
()
+
" Send :"
+
heartMsg
;
client
.
send
(
heartMsg
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"["
+
CID
+
"]SendHeart 出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"["
+
CID
+
"]SendHeart 出错:"
+
ex
.
ToString
());
}
}
private
DateTime
LastOutStoreEndTime
=
DateTime
.
Now
;
...
...
@@ -100,6 +104,8 @@ namespace OnlineStore.DeviceLibrary
store
.
Cmd
=
cmd_outend
;
string
msg
=
ToParamStr
(
store
);
LogUtil
.
info
(
"["
+
CID
+
"]OutStoreEnd:"
+
msg
);
LastSend
=
DateTime
.
Now
.
ToLongTimeString
()
+
" Send :"
+
msg
;
client
.
send
(
msg
);
}
catch
(
Exception
ex
)
...
...
@@ -117,7 +123,9 @@ namespace OnlineStore.DeviceLibrary
try
{
message
=
message
.
Replace
(
"\r"
,
""
);
StoreReviceBean
reviceInfo
=
JsonHelper
.
DeserializeJsonToObject
<
StoreReviceBean
>(
message
);
LastRevice
=
DateTime
.
Now
.
ToLongTimeString
()
+
" Revice :"
+
message
;
StoreReviceBean
reviceInfo
=
JsonHelper
.
DeserializeJsonToObject
<
StoreReviceBean
>(
message
);
//string[] msgArray = message.Split(cmd_spilt);
if
(
reviceInfo
==
null
)
{
...
...
source/HCSingleStore/FrmBox.Designer.cs
查看文件 @
ba1e270
...
...
@@ -137,6 +137,10 @@
this
.
tableLayoutPanel1
=
new
System
.
Windows
.
Forms
.
TableLayoutPanel
();
this
.
groupBox5
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
tableLayoutPanel2
=
new
System
.
Windows
.
Forms
.
TableLayoutPanel
();
this
.
lblLRevice
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblLSend
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblRevice
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblSend
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
tabControl1
.
SuspendLayout
();
this
.
tabPage2
.
SuspendLayout
();
this
.
groupBox1
.
SuspendLayout
();
...
...
@@ -262,6 +266,10 @@
//
// tabPage2
//
this
.
tabPage2
.
Controls
.
Add
(
this
.
lblLRevice
);
this
.
tabPage2
.
Controls
.
Add
(
this
.
lblLSend
);
this
.
tabPage2
.
Controls
.
Add
(
this
.
lblRevice
);
this
.
tabPage2
.
Controls
.
Add
(
this
.
lblSend
);
this
.
tabPage2
.
Controls
.
Add
(
this
.
lblMoveStr
);
this
.
tabPage2
.
Controls
.
Add
(
this
.
groupBox1
);
this
.
tabPage2
.
Controls
.
Add
(
this
.
groupBox2
);
...
...
@@ -315,7 +323,7 @@
this
.
groupBox1
.
Controls
.
Add
(
this
.
label43
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
label42
);
this
.
groupBox1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
groupBox1
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
462
);
this
.
groupBox1
.
Location
=
new
System
.
Drawing
.
Point
(
505
,
324
);
this
.
groupBox1
.
Name
=
"groupBox1"
;
this
.
groupBox1
.
Size
=
new
System
.
Drawing
.
Size
(
476
,
136
);
this
.
groupBox1
.
TabIndex
=
217
;
...
...
@@ -495,7 +503,7 @@
this
.
groupBox2
.
Controls
.
Add
(
this
.
button6
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
button3
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
button5
);
this
.
groupBox2
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
3
78
);
this
.
groupBox2
.
Location
=
new
System
.
Drawing
.
Point
(
11
,
3
82
);
this
.
groupBox2
.
Name
=
"groupBox2"
;
this
.
groupBox2
.
Size
=
new
System
.
Drawing
.
Size
(
476
,
78
);
this
.
groupBox2
.
TabIndex
=
276
;
...
...
@@ -1665,6 +1673,50 @@
this
.
tableLayoutPanel2
.
Size
=
new
System
.
Drawing
.
Size
(
218
,
297
);
this
.
tableLayoutPanel2
.
TabIndex
=
103
;
//
// lblLRevice
//
this
.
lblLRevice
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)));
this
.
lblLRevice
.
AutoSize
=
true
;
this
.
lblLRevice
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblLRevice
.
ForeColor
=
System
.
Drawing
.
Color
.
Green
;
this
.
lblLRevice
.
Location
=
new
System
.
Drawing
.
Point
(
13
,
538
);
this
.
lblLRevice
.
Name
=
"lblLRevice"
;
this
.
lblLRevice
.
Size
=
new
System
.
Drawing
.
Size
(
0
,
17
);
this
.
lblLRevice
.
TabIndex
=
281
;
//
// lblLSend
//
this
.
lblLSend
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)));
this
.
lblLSend
.
AutoSize
=
true
;
this
.
lblLSend
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblLSend
.
ForeColor
=
System
.
Drawing
.
Color
.
Green
;
this
.
lblLSend
.
Location
=
new
System
.
Drawing
.
Point
(
13
,
518
);
this
.
lblLSend
.
Name
=
"lblLSend"
;
this
.
lblLSend
.
Size
=
new
System
.
Drawing
.
Size
(
0
,
17
);
this
.
lblLSend
.
TabIndex
=
280
;
//
// lblRevice
//
this
.
lblRevice
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)));
this
.
lblRevice
.
AutoSize
=
true
;
this
.
lblRevice
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblRevice
.
ForeColor
=
System
.
Drawing
.
Color
.
Green
;
this
.
lblRevice
.
Location
=
new
System
.
Drawing
.
Point
(
13
,
579
);
this
.
lblRevice
.
Name
=
"lblRevice"
;
this
.
lblRevice
.
Size
=
new
System
.
Drawing
.
Size
(
0
,
17
);
this
.
lblRevice
.
TabIndex
=
279
;
//
// lblSend
//
this
.
lblSend
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)));
this
.
lblSend
.
AutoSize
=
true
;
this
.
lblSend
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblSend
.
ForeColor
=
System
.
Drawing
.
Color
.
Green
;
this
.
lblSend
.
Location
=
new
System
.
Drawing
.
Point
(
13
,
559
);
this
.
lblSend
.
Name
=
"lblSend"
;
this
.
lblSend
.
Size
=
new
System
.
Drawing
.
Size
(
0
,
17
);
this
.
lblSend
.
TabIndex
=
278
;
//
// FrmBox
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
...
...
@@ -1818,6 +1870,10 @@
private
System
.
Windows
.
Forms
.
PictureBox
picPPoint
;
private
UserFromControl
.
IOTextControl
ioSingle
;
private
System
.
Windows
.
Forms
.
Label
lblSize
;
private
System
.
Windows
.
Forms
.
Label
lblLRevice
;
private
System
.
Windows
.
Forms
.
Label
lblLSend
;
private
System
.
Windows
.
Forms
.
Label
lblRevice
;
private
System
.
Windows
.
Forms
.
Label
lblSend
;
}
}
source/HCSingleStore/FrmBox.cs
查看文件 @
ba1e270
...
...
@@ -179,6 +179,10 @@ namespace OnlineStore.ACSingleStore
{
return
;
}
lblLSend
.
Text
=
boxBean
.
lineConnect
.
LastSend
.
ToString
();
//lblLRevice.Text = boxBean.lineConnect.LastRevice.ToString();
lblSend
.
Text
=
boxBean
.
LastSend
.
ToString
();
//lblRevice.Text = HttpHelper.LastRevice.ToString();
ioSingle
.
IOValue
=
(
int
)
boxBean
.
IOValue
(
IO_Type
.
CheckPos
);
ioSingle
.
ShowData
();
...
...
source/HCSingleStore/FrmStore.Designer.cs
查看文件 @
ba1e270
...
...
@@ -55,9 +55,9 @@
this
.
toolStripMenuItem4
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
开机自动启动
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
toolStripSeparator10
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
toolStripMenuItem5
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
toolStripSeparator15
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
启用蜂鸣器
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
toolStripSeparator15
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
toolStripMenuItem5
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
toolStripSeparator11
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
开启
DEBUG
日志
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
设置
TToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
...
...
@@ -214,7 +214,7 @@
this
.
logBox
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
logBox
.
Location
=
new
System
.
Drawing
.
Point
(
241
,
6
);
this
.
logBox
.
Name
=
"logBox"
;
this
.
logBox
.
Size
=
new
System
.
Drawing
.
Size
(
1085
,
6
13
);
this
.
logBox
.
Size
=
new
System
.
Drawing
.
Size
(
1085
,
6
32
);
this
.
logBox
.
TabIndex
=
106
;
this
.
logBox
.
Text
=
""
;
this
.
logBox
.
VisibleChanged
+=
new
System
.
EventHandler
(
this
.
logBox_VisibleChanged
);
...
...
@@ -343,24 +343,24 @@
this
.
toolStripSeparator10
.
Name
=
"toolStripSeparator10"
;
this
.
toolStripSeparator10
.
Size
=
new
System
.
Drawing
.
Size
(
196
,
6
);
//
//
toolStripMenuItem5
//
启用蜂鸣器ToolStripMenuItem
//
this
.
toolStripMenuItem5
.
Name
=
"toolStripMenuItem5
"
;
this
.
toolStripMenuItem5
.
Size
=
new
System
.
Drawing
.
Size
(
199
,
26
);
this
.
toolStripMenuItem5
.
Text
=
"启用温湿度
"
;
this
.
toolStripMenuItem5
.
Click
+=
new
System
.
EventHandler
(
this
.
toolStripMenuItem5
_Click
);
this
.
启用蜂鸣器
ToolStripMenuItem
.
Name
=
"启用蜂鸣器ToolStripMenuItem
"
;
this
.
启用蜂鸣器
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
199
,
26
);
this
.
启用蜂鸣器
ToolStripMenuItem
.
Text
=
"启用蜂鸣器
"
;
this
.
启用蜂鸣器
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
启用蜂鸣器
ToolStripMenuItem
_Click
);
//
// toolStripSeparator15
//
this
.
toolStripSeparator15
.
Name
=
"toolStripSeparator15"
;
this
.
toolStripSeparator15
.
Size
=
new
System
.
Drawing
.
Size
(
196
,
6
);
//
//
启用蜂鸣器ToolStripMenuItem
//
toolStripMenuItem5
//
this
.
启用蜂鸣器
ToolStripMenuItem
.
Name
=
"启用蜂鸣器ToolStripMenuItem
"
;
this
.
启用蜂鸣器
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
199
,
26
);
this
.
启用蜂鸣器
ToolStripMenuItem
.
Text
=
"启用蜂鸣器
"
;
this
.
启用蜂鸣器
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
启用蜂鸣器
ToolStripMenuItem
_Click
);
this
.
toolStripMenuItem5
.
Name
=
"toolStripMenuItem5
"
;
this
.
toolStripMenuItem5
.
Size
=
new
System
.
Drawing
.
Size
(
199
,
26
);
this
.
toolStripMenuItem5
.
Text
=
"启用温湿度
"
;
this
.
toolStripMenuItem5
.
Click
+=
new
System
.
EventHandler
(
this
.
toolStripMenuItem5
_Click
);
//
// toolStripSeparator11
//
...
...
source/HCSingleStore/FrmStore.cs
查看文件 @
ba1e270
...
...
@@ -401,6 +401,7 @@ namespace OnlineStore.ACSingleStore
{
return
;
}
//lblServerMsg.Text = HttpHelper.LastServerMsg;
ReadIOList
();
string
msg
=
""
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论