Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
data-center-auto
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bltdc
data-center-auto
Commits
5aee2158
Commit
5aee2158
authored
Jul 10, 2019
by
lizefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改缺货改零推送方式
parent
55c81992
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
16 deletions
+18
-16
ShortagePushBackgroundService.cs
ShortagePush/ShortagePushBackgroundService.cs
+18
-16
No files found.
ShortagePush/ShortagePushBackgroundService.cs
View file @
5aee2158
...
@@ -10,29 +10,31 @@ namespace ShortagePush
...
@@ -10,29 +10,31 @@ namespace ShortagePush
{
{
public
class
ShortagePushBackgroundService
:
BackgroundService
public
class
ShortagePushBackgroundService
:
BackgroundService
{
{
private
Timer
_timer
;
protected
override
Task
ExecuteAsync
(
CancellationToken
stoppingToken
)
protected
override
Task
ExecuteAsync
(
CancellationToken
stoppingToken
)
{
{
_timer
=
new
Timer
(
DoWork
,
null
,
TimeSpan
.
Zero
,
TimeSpan
.
FromMinutes
(
5
));
Task
.
Factory
.
StartNew
(()
=>
{
while
(
true
)
{
System
.
Console
.
WriteLine
(
$"开始推送改零数据,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
new
ReportServices
().
ShortagePush
();
System
.
Console
.
WriteLine
(
$"结束推送改零数据,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
System
.
Console
.
WriteLine
(
$"开始推送回货数据,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
new
ReportServices
().
ReturnGoodsPush
();
System
.
Console
.
WriteLine
(
$"结束推送回货数据,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
Thread
.
Sleep
(
5
*
60
*
1000
);
}
});
return
Task
.
CompletedTask
;
return
Task
.
CompletedTask
;
}
private
void
DoWork
(
object
state
)
{
try
{
Console
.
WriteLine
(
$"开始推送缺货数据任务,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
new
ReportServices
().
ShortagePush
();
new
ReportServices
().
ReturnGoodsPush
();
Console
.
WriteLine
(
$"结束推送缺货数据任务,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
ex
.
Message
);
}
}
}
public
override
void
Dispose
()
public
override
void
Dispose
()
{
{
base
.
Dispose
();
base
.
Dispose
();
...
...
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