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
4645cddc
Commit
4645cddc
authored
Dec 23, 2021
by
lcx
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix/v20211223'
parents
6799bf4a
d70ef16c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
20 deletions
+31
-20
performance/Performance.Api/Controllers/AllotController.cs
+9
-1
performance/Performance.Api/Controllers/ModExtractController.cs
+22
-19
No files found.
performance/Performance.Api/Controllers/AllotController.cs
View file @
4645cddc
...
...
@@ -297,7 +297,15 @@ public ApiResponse GenerateReport([CustomizeValidator(RuleSet = "Delete"), FromB
if
(
null
==
allot
||
!
states
.
Contains
(
allot
.
States
))
throw
new
PerformanceException
(
"当前绩效暂未生成,无法统计报表数据。"
);
//_publishEndpoint.Publish(allot).Wait();
_backgroundTaskQueue
.
QueueBackgroundWorkItem
(
async
token
=>
{
using
(
var
scope
=
_serviceScopeFactory
.
CreateScope
())
{
var
scopedServices
=
scope
.
ServiceProvider
.
GetRequiredService
<
AllotService
>();
scopedServices
.
GenerateReport
(
allot
);
await
Task
.
Delay
(
TimeSpan
.
FromSeconds
(
5
),
token
);
}
});
return
new
ApiResponse
(
ResponseType
.
OK
,
"统计报表数据任务开始"
);
}
...
...
performance/Performance.Api/Controllers/ModExtractController.cs
View file @
4645cddc
...
...
@@ -20,6 +20,7 @@ public class ModExtractController : Controller
private
readonly
AllotService
_allotService
;
private
readonly
CustomExtractService
_extractService
;
private
readonly
IServiceScopeFactory
_serviceScopeFactory
;
private
readonly
IBackgroundTaskQueue
_backgroundTaskQueue
;
private
readonly
IHubNotificationQueue
_notificationQueue
;
public
ModExtractController
(
...
...
@@ -27,12 +28,14 @@ public class ModExtractController : Controller
AllotService
allotService
,
CustomExtractService
extractService
,
IServiceScopeFactory
serviceScopeFactory
,
IBackgroundTaskQueue
backgroundTaskQueue
,
IHubNotificationQueue
notificationQueue
)
{
_claim
=
claim
;
_allotService
=
allotService
;
_extractService
=
extractService
;
_serviceScopeFactory
=
serviceScopeFactory
;
_backgroundTaskQueue
=
backgroundTaskQueue
;
_notificationQueue
=
notificationQueue
;
}
...
...
@@ -43,27 +46,27 @@ public ApiResponse CustomExtract(int allotId)
if
(!
_extractService
.
CheckConfigScript
(
userId
,
allotId
))
return
new
ApiResponse
(
ResponseType
.
Fail
,
"未配置自定义抽取,请联系绩效管理人员。"
);
//
_backgroundTaskQueue.QueueBackgroundWorkItem(async token =>
//
{
//
using (var scope = _serviceScopeFactory.CreateScope())
//
{
//
var scopedServices = scope.ServiceProvider.GetRequiredService<CustomExtractService>();
//
var scopedAllotService = scope.ServiceProvider.GetRequiredService<AllotService>();
//
var scopedQueue = scope.ServiceProvider.GetRequiredService<IHubNotificationQueue>();
_backgroundTaskQueue
.
QueueBackgroundWorkItem
(
async
token
=>
{
using
(
var
scope
=
_serviceScopeFactory
.
CreateScope
())
{
var
scopedServices
=
scope
.
ServiceProvider
.
GetRequiredService
<
CustomExtractService
>();
var
scopedAllotService
=
scope
.
ServiceProvider
.
GetRequiredService
<
AllotService
>();
var
scopedQueue
=
scope
.
ServiceProvider
.
GetRequiredService
<
IHubNotificationQueue
>();
//
if (scopedServices.ExtractData(userId, allotId, out string resultFilePath))
//
{
//
scopedAllotService.UpdateAllotCustomExtractPath(allotId, resultFilePath);
//
scopedQueue.Send(new Notification(allotId, "CustomDowoload", new CustomDownloadContent("自定义数据提取数据成功,是否立即下载", allotId)));
//
}
//
else
//
{
//
scopedQueue.Send(new Notification(allotId, "Notification", new TextContent("自定义数据提取数据失败", NotificationLevel.ERR)));
//
}
if
(
scopedServices
.
ExtractData
(
userId
,
allotId
,
out
string
resultFilePath
))
{
scopedAllotService
.
UpdateAllotCustomExtractPath
(
allotId
,
resultFilePath
);
scopedQueue
.
Send
(
new
Notification
(
allotId
,
"CustomDowoload"
,
new
CustomDownloadContent
(
"自定义数据提取数据成功,是否立即下载"
,
allotId
)));
}
else
{
scopedQueue
.
Send
(
new
Notification
(
allotId
,
"Notification"
,
new
TextContent
(
"自定义数据提取数据失败"
,
NotificationLevel
.
ERR
)));
}
//
await Task.Delay(TimeSpan.FromSeconds(5), token);
//
}
//
});
await
Task
.
Delay
(
TimeSpan
.
FromSeconds
(
5
),
token
);
}
});
_notificationQueue
.
Send
(
new
Notification
(
allotId
,
"Notification"
,
new
TextContent
(
"自定义数据提取任务开始执行"
)));
...
...
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