Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
980923c5
Commit
980923c5
authored
Dec 30, 2021
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自定义提取日志推送
parent
fae509c7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
performance/Performance.Api/Controllers/ModExtractController.cs
+2
-2
performance/Performance.Services/CustomExtractService.cs
+11
-1
No files found.
performance/Performance.Api/Controllers/ModExtractController.cs
View file @
980923c5
...
...
@@ -61,13 +61,13 @@ public ApiResponse CustomExtract(int allotId)
}
else
{
scopedQueue
.
Send
(
new
Notification
(
allotId
,
"
Notification
"
,
new
TextContent
(
"自定义数据提取数据失败"
,
NotificationLevel
.
ERR
)));
scopedQueue
.
Send
(
new
Notification
(
allotId
,
"
ReceiveMessage
"
,
new
TextContent
(
"自定义数据提取数据失败"
,
NotificationLevel
.
ERR
)));
}
await
Task
.
Delay
(
TimeSpan
.
FromSeconds
(
5
),
token
);
}
});
_notificationQueue
.
Send
(
new
Notification
(
allotId
,
"
Notification
"
,
new
TextContent
(
"自定义数据提取任务开始执行"
)));
_notificationQueue
.
Send
(
new
Notification
(
allotId
,
"
ReceiveMessage
"
,
new
TextContent
(
"自定义数据提取任务开始执行"
)));
return
new
ApiResponse
(
ResponseType
.
OK
);
...
...
performance/Performance.Services/CustomExtractService.cs
View file @
980923c5
...
...
@@ -8,6 +8,7 @@
using
Performance.Infrastructure
;
using
Performance.Repository
;
using
Performance.Services.ExtractExcelService
;
using
Performance.Services.Queues
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
...
...
@@ -26,6 +27,7 @@ public class CustomExtractService : IAutoInjection
private
readonly
PerforPerdeptdicRepository
_perforPerdeptdicRepository
;
private
readonly
PerforHospitalconfigRepository
_perforHospitalconfigRepository
;
private
readonly
PerforCustscriptRepository
_perforcustscriptRepository
;
private
readonly
IHubNotificationQueue
_notificationQueue
;
public
CustomExtractService
(
ILogger
<
CustomExtractService
>
logger
,
...
...
@@ -35,7 +37,8 @@ public class CustomExtractService : IAutoInjection
PerforPerallotRepository
perallotRepository
,
PerforPerdeptdicRepository
perforPerdeptdicRepository
,
PerforHospitalconfigRepository
perforHospitalconfigRepository
,
PerforCustscriptRepository
perforcustscriptRepository
)
PerforCustscriptRepository
perforcustscriptRepository
,
IHubNotificationQueue
notificationQueue
)
{
_logger
=
logger
;
_options
=
options
;
...
...
@@ -45,6 +48,7 @@ public class CustomExtractService : IAutoInjection
_perforPerdeptdicRepository
=
perforPerdeptdicRepository
;
_perforHospitalconfigRepository
=
perforHospitalconfigRepository
;
_perforcustscriptRepository
=
perforcustscriptRepository
;
_notificationQueue
=
notificationQueue
;
}
public
bool
CheckConfigScript
(
int
userId
,
int
allotId
)
...
...
@@ -136,6 +140,7 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
var
conf
=
configs
.
FirstOrDefault
(
w
=>
w
.
Id
==
item
.
ConfigId
);
if
(
conf
!=
null
)
{
_notificationQueue
.
Send
(
new
Notification
(
allot
.
ID
,
"ReceiveMessage"
,
new
TextContent
(
$"正在提取“
{
item
.
Name
}
”的数据"
)));
var
execsql
=
item
.
Script
;
var
dynamics
=
QueryData
(
conf
,
execsql
,
parameters
);
...
...
@@ -150,8 +155,12 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
var
sheet
=
workbook
.
CreateSheet
(
item
.
Name
);
// 没数据跳过
if
(
dynamics
==
null
||
dynamics
.
Count
()
==
0
)
{
_notificationQueue
.
Send
(
new
Notification
(
allot
.
ID
,
"ReceiveMessage"
,
new
TextContent
(
$"“
{
item
.
Name
}
”提取的数据为空"
)));
continue
;
}
_notificationQueue
.
Send
(
new
Notification
(
allot
.
ID
,
"ReceiveMessage"
,
new
TextContent
(
$"正在写入“
{
item
.
Name
}
”的数据"
)));
var
headers
=
((
IDictionary
<
string
,
object
>)
dynamics
.
ElementAt
(
0
)).
Keys
;
for
(
int
col
=
0
;
col
<
headers
.
Count
;
col
++)
{
...
...
@@ -219,6 +228,7 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
}
row
++;
}
_notificationQueue
.
Send
(
new
Notification
(
allot
.
ID
,
"ReceiveMessage"
,
new
TextContent
(
$"“
{
item
.
Name
}
”的数据写入完成"
)));
}
catch
(
Exception
ex
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment