Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
JunmpPoliceStation
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
zxw
JunmpPoliceStation
Commits
765538cf
Commit
765538cf
authored
Mar 15, 2023
by
zxw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复文件编码为utf8
parent
6bed92a5
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
50 行增加
和
50 行删除
+50
-50
MsgPushService.cs
JmpMsgService/MsgPushService.cs
+31
-31
Program.cs
JunmpPoliceStation/Program.cs
+1
-1
Startup.cs
JunmpPoliceStation/Startup.cs
+18
-18
没有找到文件。
JmpMsgService/MsgPushService.cs
View file @
765538cf
...
@@ -54,9 +54,9 @@ namespace JmpMsgService
...
@@ -54,9 +54,9 @@ namespace JmpMsgService
{
{
onRefresh
+=
SendRefresh
;
onRefresh
+=
SendRefresh
;
onReciveMsg
+=
OnMessageReceived
;
onReciveMsg
+=
OnMessageReceived
;
//
启动Ws服务
//
启动Ws服务
wsServer
=
new
WebSocketServer
(
"ws://0.0.0.0:8090"
);
wsServer
=
new
WebSocketServer
(
"ws://0.0.0.0:8090"
);
Console
.
WriteLine
(
"
消息服务 启动成功
"
);
Console
.
WriteLine
(
"
消息服务 启动成功"
);
wsServer
.
Start
(
socket
=>
wsServer
.
Start
(
socket
=>
{
{
socket
.
OnOpen
=
()
=>
socket
.
OnOpen
=
()
=>
...
@@ -80,13 +80,13 @@ namespace JmpMsgService
...
@@ -80,13 +80,13 @@ namespace JmpMsgService
CheckDelete
();
CheckDelete
();
await
Task
.
Delay
(
int
.
Parse
(
checkTime
)
*
60
*
1000
);
//
单位:分钟
await
Task
.
Delay
(
int
.
Parse
(
checkTime
)
*
60
*
1000
);
//
单位:分钟
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
_logger
.
LogError
(
"
消息服务
ExecuteAsync:"
+
ex
.
ToString
());
_logger
.
LogError
(
"
消息服务 E
xecuteAsync:"
+
ex
.
ToString
());
}
}
}
}
public
override
Task
StopAsync
(
CancellationToken
cancellationToken
)
public
override
Task
StopAsync
(
CancellationToken
cancellationToken
)
...
@@ -98,7 +98,7 @@ namespace JmpMsgService
...
@@ -98,7 +98,7 @@ namespace JmpMsgService
}
}
private
void
CheckMessage
()
private
void
CheckMessage
()
{
{
//
启动轮询
//
启动轮询
DateTime
CheckTime
=
DateTime
.
Now
.
Date
;
DateTime
CheckTime
=
DateTime
.
Now
.
Date
;
checkTime
=
Configuration
.
GetConnectionString
(
"CheckTime"
);
checkTime
=
Configuration
.
GetConnectionString
(
"CheckTime"
);
...
@@ -125,7 +125,7 @@ namespace JmpMsgService
...
@@ -125,7 +125,7 @@ namespace JmpMsgService
};
};
Expression
<
Func
<
VScrapView
,
bool
>>
expression
=
p
=>
p
.
WarrantyTime
!=
null
;
Expression
<
Func
<
VScrapView
,
bool
>>
expression
=
p
=>
p
.
WarrantyTime
!=
null
;
//var userInfo1 = _unitOfWork.CommonJpUserRepository.GetList(p=>p.Id!=null);
//var userInfo1 = _unitOfWork.CommonJpUserRepository.GetList(p=>p.Id!=null);
var
scrapList
=
_unitOfWork
.
ScrapViewRepository
.
GetList
(
expression
,
p
=>
p
.
WarrantyTime
,
false
,
parameScrap
);
//
超期数据
var
scrapList
=
_unitOfWork
.
ScrapViewRepository
.
GetList
(
expression
,
p
=>
p
.
WarrantyTime
,
false
,
parameScrap
);
//
超期数据
var
orgList
=
scrapList
.
ToList
().
GroupBy
(
p
=>
p
.
OrgId
);
var
orgList
=
scrapList
.
ToList
().
GroupBy
(
p
=>
p
.
OrgId
);
List
<
string
>
orgs
=
new
List
<
string
>();
List
<
string
>
orgs
=
new
List
<
string
>();
foreach
(
var
item
in
orgList
)
foreach
(
var
item
in
orgList
)
...
@@ -136,7 +136,7 @@ namespace JmpMsgService
...
@@ -136,7 +136,7 @@ namespace JmpMsgService
var
userInfo
=
_unitOfWork
.
CommonJpUserRepository
.
GetList
(
userExpression
,
null
,
false
,
parame
).
ToList
();
var
userInfo
=
_unitOfWork
.
CommonJpUserRepository
.
GetList
(
userExpression
,
null
,
false
,
parame
).
ToList
();
var
borrowList
=
_unitOfWork
.
BorrowReturnApplyRepository
.
GetList
(
p
=>
p
.
ExpectedReturnTime
!=
null
&&
p
.
CommonJpBorrowReturns
.
FirstOrDefault
().
CurrentState
.
Equals
(
1
)
&&
p
.
ExpectedReturnTime
<=
DateTime
.
Now
.
Date
,
null
,
false
,
parameBorrow
).
ToList
();
var
borrowList
=
_unitOfWork
.
BorrowReturnApplyRepository
.
GetList
(
p
=>
p
.
ExpectedReturnTime
!=
null
&&
p
.
CommonJpBorrowReturns
.
FirstOrDefault
().
CurrentState
.
Equals
(
1
)
&&
p
.
ExpectedReturnTime
<=
DateTime
.
Now
.
Date
,
null
,
false
,
parameBorrow
).
ToList
();
var
historyMessage
=
_unitOfWork
.
MessageRepository
.
GetList
(
p
=>
(
p
.
MessageType
.
Equals
(
"rebackWaring"
)
||
p
.
MessageType
.
Equals
(
"scrapWaring"
))
&&
!
string
.
IsNullOrEmpty
(
p
.
OrderId
)).
ToList
();
var
historyMessage
=
_unitOfWork
.
MessageRepository
.
GetList
(
p
=>
(
p
.
MessageType
.
Equals
(
"rebackWaring"
)
||
p
.
MessageType
.
Equals
(
"scrapWaring"
))
&&
!
string
.
IsNullOrEmpty
(
p
.
OrderId
)).
ToList
();
var
borrowTranList
=
_unitOfWork
.
TransferApplyRepository
.
GetList
(
p
=>
p
.
ExpectedReturnTime
!=
null
&&
p
.
CommonJpTransfers
.
FirstOrDefault
().
CurrentState
.
Equals
(
1
)
&&
p
.
ExpectedReturnTime
>
DateTime
.
Now
.
Date
,
null
,
false
,
parameTr
).
ToList
();
//
跨库借用单
var
borrowTranList
=
_unitOfWork
.
TransferApplyRepository
.
GetList
(
p
=>
p
.
ExpectedReturnTime
!=
null
&&
p
.
CommonJpTransfers
.
FirstOrDefault
().
CurrentState
.
Equals
(
1
)
&&
p
.
ExpectedReturnTime
>
DateTime
.
Now
.
Date
,
null
,
false
,
parameTr
).
ToList
();
//
跨库借用单
var
borrowCurrentList
=
_unitOfWork
.
EquipmentInventoryRepository
.
GetList
(
p
=>
p
.
CurrentState
.
Equals
(
14
)&&
p
.
InventoryState
!=
"loss"
,
null
,
false
,
parameInventory
).
ToList
();
var
borrowCurrentList
=
_unitOfWork
.
EquipmentInventoryRepository
.
GetList
(
p
=>
p
.
CurrentState
.
Equals
(
14
)&&
p
.
InventoryState
!=
"loss"
,
null
,
false
,
parameInventory
).
ToList
();
List
<
CommonJpMessage
>
messges
=
new
List
<
CommonJpMessage
>();
List
<
CommonJpMessage
>
messges
=
new
List
<
CommonJpMessage
>();
foreach
(
var
item
in
borrowTranList
)
foreach
(
var
item
in
borrowTranList
)
...
@@ -153,7 +153,7 @@ namespace JmpMsgService
...
@@ -153,7 +153,7 @@ namespace JmpMsgService
message
.
MessageInfo
=
item
.
Order
;
message
.
MessageInfo
=
item
.
Order
;
message
.
SendTime
=
DateTime
.
Now
;
message
.
SendTime
=
DateTime
.
Now
;
message
.
PcNumber
=
Guid
.
NewGuid
().
ToString
();
message
.
PcNumber
=
Guid
.
NewGuid
().
ToString
();
message
.
OrderType
=
"
跨仓库归还提醒
"
;
message
.
OrderType
=
"
跨仓库归还提醒"
;
message
.
OrderId
=
item
.
Order
;
message
.
OrderId
=
item
.
Order
;
messges
.
Add
(
message
);
messges
.
Add
(
message
);
onRefresh
?.
Invoke
(
message
.
SendName
);
onRefresh
?.
Invoke
(
message
.
SendName
);
...
@@ -183,7 +183,7 @@ namespace JmpMsgService
...
@@ -183,7 +183,7 @@ namespace JmpMsgService
message
.
MessageInfo
=
borrowState
.
Id
;
message
.
MessageInfo
=
borrowState
.
Id
;
message
.
SendTime
=
DateTime
.
Now
;
message
.
SendTime
=
DateTime
.
Now
;
message
.
PcNumber
=
Guid
.
NewGuid
().
ToString
();
message
.
PcNumber
=
Guid
.
NewGuid
().
ToString
();
message
.
OrderType
=
"
本仓库归还提醒
"
;
message
.
OrderType
=
"
本仓库归还提醒"
;
message
.
OrderId
=
borrowState
.
EquipmentCodeNavigation
?.
Name
+
"-"
+
borrowState
.
EquipmentSizecodeNavigation
?.
SizeName
;
message
.
OrderId
=
borrowState
.
EquipmentCodeNavigation
?.
Name
+
"-"
+
borrowState
.
EquipmentSizecodeNavigation
?.
SizeName
;
messges
.
Add
(
message
);
messges
.
Add
(
message
);
onRefresh
?.
Invoke
(
message
.
SendName
);
onRefresh
?.
Invoke
(
message
.
SendName
);
...
@@ -192,11 +192,11 @@ namespace JmpMsgService
...
@@ -192,11 +192,11 @@ namespace JmpMsgService
}
}
}
}
foreach
(
var
item
in
scrapList
)
//
添加报废消息到消息数据表
foreach
(
var
item
in
scrapList
)
//
添加报废消息到消息数据表
{
{
string
id
=
item
.
Id
;
string
id
=
item
.
Id
;
string
orgId
=
item
.
OrgId
;
string
orgId
=
item
.
OrgId
;
var
sendUser
=
userInfo
.
Where
(
p
=>
p
.
OrganizationId
.
Equals
(
item
.
OrgId
));
//
当前存的管理员
var
sendUser
=
userInfo
.
Where
(
p
=>
p
.
OrganizationId
.
Equals
(
item
.
OrgId
));
//
当前存的管理员
string
pcNum
=
Guid
.
NewGuid
().
ToString
();
string
pcNum
=
Guid
.
NewGuid
().
ToString
();
if
(
item
.
WarrantyTime
.
Value
.
AddMonths
(-
1
)
<=
DateTime
.
Now
)
if
(
item
.
WarrantyTime
.
Value
.
AddMonths
(-
1
)
<=
DateTime
.
Now
)
{
{
...
@@ -212,7 +212,7 @@ namespace JmpMsgService
...
@@ -212,7 +212,7 @@ namespace JmpMsgService
message
.
MessageInfo
=
item
.
Id
;
message
.
MessageInfo
=
item
.
Id
;
message
.
SendTime
=
DateTime
.
Now
;
message
.
SendTime
=
DateTime
.
Now
;
message
.
PcNumber
=
pcNum
;
message
.
PcNumber
=
pcNum
;
message
.
OrderType
=
"
报废提醒
"
;
message
.
OrderType
=
"
报废提醒"
;
message
.
OrderId
=
item
.
EquName
+
"-"
+
item
.
SizeName
;
message
.
OrderId
=
item
.
EquName
+
"-"
+
item
.
SizeName
;
messges
.
Add
(
message
);
messges
.
Add
(
message
);
onRefresh
?.
Invoke
(
message
.
SendName
);
onRefresh
?.
Invoke
(
message
.
SendName
);
...
@@ -222,7 +222,7 @@ namespace JmpMsgService
...
@@ -222,7 +222,7 @@ namespace JmpMsgService
}
}
}
}
foreach
(
var
item
in
borrowList
)
//
添加归还消息到消息数据表
foreach
(
var
item
in
borrowList
)
//
添加归还消息到消息数据表
{
{
...
@@ -236,7 +236,7 @@ namespace JmpMsgService
...
@@ -236,7 +236,7 @@ namespace JmpMsgService
message
.
MessageInfo
=
item
.
OrderCode
;
message
.
MessageInfo
=
item
.
OrderCode
;
message
.
SendTime
=
DateTime
.
Now
;
message
.
SendTime
=
DateTime
.
Now
;
message
.
PcNumber
=
Guid
.
NewGuid
().
ToString
();
message
.
PcNumber
=
Guid
.
NewGuid
().
ToString
();
message
.
OrderType
=
"
归还提醒
"
;
message
.
OrderType
=
"
归还提醒"
;
message
.
OrderId
=
item
.
OrderCode
;
message
.
OrderId
=
item
.
OrderCode
;
messges
.
Add
(
message
);
messges
.
Add
(
message
);
onRefresh
?.
Invoke
(
message
.
SendName
);
onRefresh
?.
Invoke
(
message
.
SendName
);
...
@@ -247,7 +247,7 @@ namespace JmpMsgService
...
@@ -247,7 +247,7 @@ namespace JmpMsgService
bool
result
=
_unitOfWork
.
MessageRepository
.
Insert
(
messges
,
true
);
bool
result
=
_unitOfWork
.
MessageRepository
.
Insert
(
messges
,
true
);
//_logger.LogDebug("Worker running at: {time},Result:{result}", DateTimeOffset.Now, result);
//_logger.LogDebug("Worker running at: {time},Result:{result}", DateTimeOffset.Now, result);
Task
.
Delay
(
int
.
Parse
(
checkTime
)
*
60
*
1000
);
//
单位:分钟
Task
.
Delay
(
int
.
Parse
(
checkTime
)
*
60
*
1000
);
//
单位:分钟
}
}
...
@@ -256,8 +256,8 @@ namespace JmpMsgService
...
@@ -256,8 +256,8 @@ namespace JmpMsgService
try
try
{
{
clearConfig
=
new
CfgNotice
();
clearConfig
=
new
CfgNotice
();
//
启动后读取一次数据库的配置信息
//
启动后读取一次数据库的配置信息
var
cfg
=
_unitOfWork
.
CommonJpLogCfgRepository
.
Get
(
p
=>
p
.
Id
!=
null
);
//
全局配置信息
var
cfg
=
_unitOfWork
.
CommonJpLogCfgRepository
.
Get
(
p
=>
p
.
Id
!=
null
);
//
全局配置信息
clearConfig
.
id
=
cfg
.
Id
;
clearConfig
.
id
=
cfg
.
Id
;
clearConfig
.
updateCicle
=
cfg
.
UpdateCicle
;
clearConfig
.
updateCicle
=
cfg
.
UpdateCicle
;
clearConfig
.
lastTime
=
DateTime
.
Now
;
clearConfig
.
lastTime
=
DateTime
.
Now
;
...
@@ -267,12 +267,12 @@ namespace JmpMsgService
...
@@ -267,12 +267,12 @@ namespace JmpMsgService
ClearCache
();
ClearCache
();
clearConfig
.
lastTime
=
DateTime
.
Now
;
clearConfig
.
lastTime
=
DateTime
.
Now
;
Task
.
Delay
(
int
.
Parse
(
checkTime
)
*
60
*
1000
);
//
单位:分钟
Task
.
Delay
(
int
.
Parse
(
checkTime
)
*
60
*
1000
);
//
单位:分钟
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
_logger
.
LogError
(
"
消息服务
WaitData:"
+
ex
.
ToString
());
_logger
.
LogError
(
"
消息服务 W
aitData:"
+
ex
.
ToString
());
}
}
}
}
private
void
RefreshCfg
(
string
json
)
private
void
RefreshCfg
(
string
json
)
...
@@ -306,7 +306,7 @@ namespace JmpMsgService
...
@@ -306,7 +306,7 @@ namespace JmpMsgService
if
(
client_info
.
IsAvailable
)
if
(
client_info
.
IsAvailable
)
{
{
client_info
.
Send
(
"refresh"
);
client_info
.
Send
(
"refresh"
);
Console
.
WriteLine
(
$"
发送至
:
{
s
.
Key
}
"
);
Console
.
WriteLine
(
$"
发送至:
{
s
.
Key
}
"
);
}
}
}
}
});
});
...
@@ -343,16 +343,16 @@ namespace JmpMsgService
...
@@ -343,16 +343,16 @@ namespace JmpMsgService
DirectoryInfo
cabPic
=
new
DirectoryInfo
(
_cabinetPath
);
DirectoryInfo
cabPic
=
new
DirectoryInfo
(
_cabinetPath
);
DirectoryInfo
logFile
=
new
DirectoryInfo
(
_logPath
);
DirectoryInfo
logFile
=
new
DirectoryInfo
(
_logPath
);
//
遍历文件夹
//
遍历文件夹
if
(
Directory
.
Exists
(
channelPic
.
ToString
()))
if
(
Directory
.
Exists
(
channelPic
.
ToString
()))
{
{
foreach
(
DirectoryInfo
NextFolder
in
channelPic
.
GetDirectories
())
//
遍历通道
foreach
(
DirectoryInfo
NextFolder
in
channelPic
.
GetDirectories
())
//
遍历通道
{
{
DirectoryInfo
NewTheFolder
=
new
DirectoryInfo
(
NextFolder
.
FullName
);
DirectoryInfo
NewTheFolder
=
new
DirectoryInfo
(
NextFolder
.
FullName
);
foreach
(
DirectoryInfo
NextNewFolder
in
NewTheFolder
.
GetDirectories
())
//
遍历仓库
foreach
(
DirectoryInfo
NextNewFolder
in
NewTheFolder
.
GetDirectories
())
//
遍历仓库
{
{
DirectoryInfo
NewDataFolder
=
new
DirectoryInfo
(
NextNewFolder
.
FullName
);
DirectoryInfo
NewDataFolder
=
new
DirectoryInfo
(
NextNewFolder
.
FullName
);
foreach
(
DirectoryInfo
item
in
NewDataFolder
.
GetDirectories
())
//
遍历仓库下的日期文件夹
foreach
(
DirectoryInfo
item
in
NewDataFolder
.
GetDirectories
())
//
遍历仓库下的日期文件夹
{
{
if
(
item
.
CreationTime
.
AddDays
(
clearConfig
.
updateCicle
)
<
DateTime
.
Now
.
Date
)
if
(
item
.
CreationTime
.
AddDays
(
clearConfig
.
updateCicle
)
<
DateTime
.
Now
.
Date
)
{
{
...
@@ -371,10 +371,10 @@ namespace JmpMsgService
...
@@ -371,10 +371,10 @@ namespace JmpMsgService
}
}
if
(
Directory
.
Exists
(
cabPic
.
ToString
()))
if
(
Directory
.
Exists
(
cabPic
.
ToString
()))
{
{
foreach
(
DirectoryInfo
NextFolder
in
cabPic
.
GetDirectories
())
//
遍历单警柜日志文件夹
foreach
(
DirectoryInfo
NextFolder
in
cabPic
.
GetDirectories
())
//
遍历单警柜日志文件夹
{
{
DirectoryInfo
NewTheFolder
=
new
DirectoryInfo
(
NextFolder
.
FullName
);
DirectoryInfo
NewTheFolder
=
new
DirectoryInfo
(
NextFolder
.
FullName
);
foreach
(
DirectoryInfo
NextNewFolder
in
NewTheFolder
.
GetDirectories
())
//
遍历主柜
foreach
(
DirectoryInfo
NextNewFolder
in
NewTheFolder
.
GetDirectories
())
//
遍历主柜
{
{
...
@@ -390,10 +390,10 @@ namespace JmpMsgService
...
@@ -390,10 +390,10 @@ namespace JmpMsgService
}
}
if
(
Directory
.
Exists
(
logFile
.
ToString
()))
if
(
Directory
.
Exists
(
logFile
.
ToString
()))
{
{
foreach
(
DirectoryInfo
NextFolder
in
logFile
.
GetDirectories
())
//
遍历日志文件夹
foreach
(
DirectoryInfo
NextFolder
in
logFile
.
GetDirectories
())
//
遍历日志文件夹
{
{
DirectoryInfo
NewTheFolder
=
new
DirectoryInfo
(
NextFolder
.
FullName
);
DirectoryInfo
NewTheFolder
=
new
DirectoryInfo
(
NextFolder
.
FullName
);
foreach
(
FileInfo
item
in
NewTheFolder
.
GetFiles
())
//
遍历日志文件夹下的其他文件夹
foreach
(
FileInfo
item
in
NewTheFolder
.
GetFiles
())
//
遍历日志文件夹下的其他文件夹
{
{
if
(
item
.
CreationTime
.
AddDays
(
clearConfig
.
updateCicle
)
<
DateTime
.
Now
.
Date
)
if
(
item
.
CreationTime
.
AddDays
(
clearConfig
.
updateCicle
)
<
DateTime
.
Now
.
Date
)
{
{
...
@@ -409,19 +409,19 @@ namespace JmpMsgService
...
@@ -409,19 +409,19 @@ namespace JmpMsgService
try
try
{
{
var
cmdInfo
=
JsonConvert
.
DeserializeObject
<
CmdInfo
>(
msg
);
var
cmdInfo
=
JsonConvert
.
DeserializeObject
<
CmdInfo
>(
msg
);
if
(
cmdInfo
==
null
)
{
_logger
.
LogInformation
(
"
无效的JSON字符串
"
);
}
if
(
cmdInfo
==
null
)
{
_logger
.
LogInformation
(
"
无效的JSON字符串"
)
;
}
else
else
{
{
switch
(
cmdInfo
.
cmdType
)
switch
(
cmdInfo
.
cmdType
)
{
{
case
CmdType
.
刷新消息
:
case
CmdType
.
刷新消息
:
if
(!
dict_client_role
.
ContainsKey
(
client
)&&!
client
.
Contains
(
"127.0.0.1"
))
if
(!
dict_client_role
.
ContainsKey
(
client
)&&!
client
.
Contains
(
"127.0.0.1"
))
{
{
dict_client_role
.
Add
(
client
,
cmdInfo
.
cmdPara
);
dict_client_role
.
Add
(
client
,
cmdInfo
.
cmdPara
);
}
}
onRefresh
?.
Invoke
(
cmdInfo
.
cmdPara
);
onRefresh
?.
Invoke
(
cmdInfo
.
cmdPara
);
break
;
break
;
case
CmdType
.
缓存删除
:
case
CmdType
.
缓存删除
:
RefreshCfg
(
cmdInfo
.
cmdPara
);
RefreshCfg
(
cmdInfo
.
cmdPara
);
break
;
break
;
default
:
break
;
default
:
break
;
...
...
JunmpPoliceStation/Program.cs
View file @
765538cf
...
@@ -24,7 +24,7 @@ namespace JunmpPoliceStation
...
@@ -24,7 +24,7 @@ namespace JunmpPoliceStation
var
process
=
Process
.
GetProcessesByName
(
"JunmpPoliceStation"
);
var
process
=
Process
.
GetProcessesByName
(
"JunmpPoliceStation"
);
if
(
process
.
Length
>
1
)
if
(
process
.
Length
>
1
)
{
{
Console
.
WriteLine
(
$"[
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm"
)}
] -
已有另一个进程正在运行中
..."
);
Console
.
WriteLine
(
$"[
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm"
)}
] -
已有另一个进程正在运行中..."
);
Console
.
ReadKey
();
Console
.
ReadKey
();
}
}
else
else
...
...
JunmpPoliceStation/Startup.cs
View file @
765538cf
...
@@ -63,13 +63,13 @@ namespace JunmpPoliceStation
...
@@ -63,13 +63,13 @@ namespace JunmpPoliceStation
GlobalContext
.
UseNoticeService
(
new
Uri
(
msg_uri
));
GlobalContext
.
UseNoticeService
(
new
Uri
(
msg_uri
));
if
(
GlobalContext
.
ServerNum
<=
0
||
GlobalContext
.
ServerNum
>
15
)
if
(
GlobalContext
.
ServerNum
<=
0
||
GlobalContext
.
ServerNum
>
15
)
{
{
throw
new
Exception
(
"
服务器编号不正确,应是1-15之间的数字,请检查JSON配置ServerNum字段。
"
);
throw
new
Exception
(
"
服务器编号不正确,应是1-15之间的数字,请检查JSON配置ServerNum字段。"
);
}
}
else
else
{
{
services
.
AddSession
();
services
.
AddSession
();
services
.
AddTransient
(
typeof
(
UnitOfWork
));
//
注入工作单元
services
.
AddTransient
(
typeof
(
UnitOfWork
));
//
注入工作单元
//
配置跨域处理,允许所有来源
//
配置跨域处理,允许所有来源
services
.
AddCors
(
options
=>
services
.
AddCors
(
options
=>
{
{
options
.
AddPolicy
(
"cors"
,
options
.
AddPolicy
(
"cors"
,
...
@@ -101,19 +101,19 @@ namespace JunmpPoliceStation
...
@@ -101,19 +101,19 @@ namespace JunmpPoliceStation
services
.
AddMvc
().
SetCompatibilityVersion
(
CompatibilityVersion
.
Version_3_0
);
services
.
AddMvc
().
SetCompatibilityVersion
(
CompatibilityVersion
.
Version_3_0
);
services
.
AddMvc
().
AddWebApiConventions
();
services
.
AddMvc
().
AddWebApiConventions
();
services
.
AddMvc
().
AddControllersAsServices
();
services
.
AddMvc
().
AddControllersAsServices
();
//
配置
Swagger
//
配置S
wagger
//
注册Swagger生成器,定义一个Swagger 文档
//
注册Swagger生成器,定义一个Swagger 文档
services
.
AddSwaggerGen
(
c
=>
services
.
AddSwaggerGen
(
c
=>
{
{
c
.
DocumentFilter
<
SwaggerIgnoreFilter
>();
c
.
DocumentFilter
<
SwaggerIgnoreFilter
>();
c
.
SwaggerDoc
(
"v1"
,
new
OpenApiInfo
c
.
SwaggerDoc
(
"v1"
,
new
OpenApiInfo
{
{
Version
=
"v1"
,
Version
=
"v1"
,
Title
=
"
警用仓库管理平台接口
"
,
Title
=
"
警用仓库管理平台接口"
,
Description
=
"
仓库
API"
Description
=
"
仓库A
PI"
});
});
//
为 Swagger 设置xml文档注释路径
//
为 Swagger 设置xml文档注释路径
var
xmlFile
=
$"
{
Assembly
.
GetExecutingAssembly
().
GetName
().
Name
}
.xml"
;
var
xmlFile
=
$"
{
Assembly
.
GetExecutingAssembly
().
GetName
().
Name
}
.xml"
;
var
xmlPath
=
Path
.
Combine
(
AppContext
.
BaseDirectory
,
xmlFile
);
var
xmlPath
=
Path
.
Combine
(
AppContext
.
BaseDirectory
,
xmlFile
);
c
.
IncludeXmlComments
(
xmlPath
);
c
.
IncludeXmlComments
(
xmlPath
);
...
@@ -130,7 +130,7 @@ namespace JunmpPoliceStation
...
@@ -130,7 +130,7 @@ namespace JunmpPoliceStation
.
AddNacosConfig
(
Configuration
)
.
AddNacosConfig
(
Configuration
)
.
AddNacosAspNetCore
(
Configuration
);
.
AddNacosAspNetCore
(
Configuration
);
//
启动
MQTT
//
启动M
QTT
//var mqtt = new MQTTServer(connection);
//var mqtt = new MQTTServer(connection);
//mqtt.StartMqttServer(Configuration);
//mqtt.StartMqttServer(Configuration);
//services.AddSingleton(mqtt);
//services.AddSingleton(mqtt);
...
@@ -145,9 +145,9 @@ namespace JunmpPoliceStation
...
@@ -145,9 +145,9 @@ namespace JunmpPoliceStation
services
.
AddSingleton
<
MQTTServer
>();
services
.
AddSingleton
<
MQTTServer
>();
services
.
AddHangfire
(
configuration
=>
configuration
services
.
AddHangfire
(
configuration
=>
configuration
.
UseMemoryStorage
());
//
使用内存
.
UseMemoryStorage
());
//
使用内存
services
.
AddHangfireServer
();
//
添加hangfire服务
services
.
AddHangfireServer
();
//
添加hangfire服务
services
.
AddScoped
<
CronJob
>();
//
注册执行类
services
.
AddScoped
<
CronJob
>();
//
注册执行类
services
.
Configure
<
ForwardedHeadersOptions
>(
options
=>
services
.
Configure
<
ForwardedHeadersOptions
>(
options
=>
{
{
...
@@ -181,9 +181,9 @@ namespace JunmpPoliceStation
...
@@ -181,9 +181,9 @@ namespace JunmpPoliceStation
app
.
UseSession
();
app
.
UseSession
();
//
启用中间件服务生成Swagger作为JSON终结点
//
启用中间件服务生成Swagger作为JSON终结点
app
.
UseSwagger
();
app
.
UseSwagger
();
//
启用中间件服务对swagger-ui,指定Swagger JSON终结点
//
启用中间件服务对swagger-ui,指定Swagger JSON终结点
app
.
UseSwaggerUI
(
c
=>
app
.
UseSwaggerUI
(
c
=>
{
{
c
.
SwaggerEndpoint
(
"/swagger/v1/swagger.json"
,
"My API V1"
);
c
.
SwaggerEndpoint
(
"/swagger/v1/swagger.json"
,
"My API V1"
);
...
@@ -195,8 +195,8 @@ namespace JunmpPoliceStation
...
@@ -195,8 +195,8 @@ namespace JunmpPoliceStation
//app.UseAuthorization();
//app.UseAuthorization();
app
.
UseRouting
();
app
.
UseRouting
();
//
允许所有跨域,cors是在ConfigureServices方法中配置的跨域策略名称
//
允许所有跨域,cors是在ConfigureServices方法中配置的跨域策略名称
//
注意:UseCors必须放在UseRouting和UseEndpoints之间
//
注意:UseCors必须放在UseRouting和UseEndpoints之间
app
.
UseCors
(
"cors"
);
app
.
UseCors
(
"cors"
);
app
.
UseAuthentication
();
app
.
UseAuthentication
();
app
.
UseEndpoints
(
endpoints
=>
app
.
UseEndpoints
(
endpoints
=>
...
@@ -223,7 +223,7 @@ namespace JunmpPoliceStation
...
@@ -223,7 +223,7 @@ namespace JunmpPoliceStation
// template: "{controller=Home}/{action=Index}/{id?}");
// template: "{controller=Home}/{action=Index}/{id?}");
//});
//});
//
注册nacos服务
//
注册nacos服务
//_namingClient.RegisterInstanceAsync(new RegisterInstanceRequest()
//_namingClient.RegisterInstanceAsync(new RegisterInstanceRequest()
//{
//{
// ServiceName = "JunmpPoliceStation12",
// ServiceName = "JunmpPoliceStation12",
...
@@ -245,7 +245,7 @@ namespace JunmpPoliceStation
...
@@ -245,7 +245,7 @@ namespace JunmpPoliceStation
public
class
Setting
public
class
Setting
{
{
/// <summary>
/// <summary>
///
数据库连接字符串
///
数据库连接字符串
/// </summary>
/// </summary>
public
string
MySqlConnection
{
get
;
set
;
}
public
string
MySqlConnection
{
get
;
set
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论