Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DataCenter_Core2.1_20190520
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
DataCenter_Core2.1_20190520
Commits
4a534c72
Commit
4a534c72
authored
Jul 03, 2019
by
guanzhenshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加定时服务
parent
87e6be37
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
7 deletions
+49
-7
Program.cs
SkuWHRedundancyService/Program.cs
+18
-5
Services.cs
SkuWHRedundancyService/Services.cs
+30
-2
SkuWHRedundancyService.csproj
SkuWHRedundancyService/SkuWHRedundancyService.csproj
+1
-0
No files found.
SkuWHRedundancyService/Program.cs
View file @
4a534c72
using
System
;
using
Microsoft.Extensions.Hosting
;
using
System
;
using
System.Threading.Tasks
;
namespace
SkuWHRedundancyService
namespace
SkuWHRedundancyService
{
{
class
Program
class
Program
{
{
static
void
Main
(
string
[]
args
)
static
async
Task
Main
(
string
[]
args
)
{
{
Console
.
WriteLine
(
"统计易仓发货单指标"
);
var
service
=
new
Services
();
var
builder
=
new
HostBuilder
().
ConfigureServices
((
hostContext
,
services
)
=>
service
.
SaveRedundancy
(
DateTime
.
Now
.
AddDays
(-
1
));
{
services
.
AddHostedService
<
Services
>();
});
await
builder
.
RunConsoleAsync
();
}
}
//static void Main(string[] args)
//{
// var service = new Services();
// service.SaveRedundancy(DateTime.Now.AddDays(-1));
//}
}
}
}
}
SkuWHRedundancyService/Services.cs
View file @
4a534c72
...
@@ -5,12 +5,40 @@ using MySql.Data.MySqlClient;
...
@@ -5,12 +5,40 @@ using MySql.Data.MySqlClient;
using
Bailun.DC.Models.Warehouse
;
using
Bailun.DC.Models.Warehouse
;
using
Bailun.DC.Common
;
using
Bailun.DC.Common
;
using
Dapper
;
using
Dapper
;
using
System.Threading.Tasks
;
using
System.Threading
;
using
Microsoft.Extensions.Hosting
;
namespace
SkuWHRedundancyService
namespace
SkuWHRedundancyService
{
{
public
class
Services
public
class
Services
:
BackgroundService
{
{
private
Timer
_timer
;
protected
override
Task
ExecuteAsync
(
CancellationToken
stoppingToken
)
{
_timer
=
new
Timer
(
DoWork
,
null
,
TimeSpan
.
Zero
,
TimeSpan
.
FromMinutes
(
1
));
return
Task
.
CompletedTask
;
}
private
void
DoWork
(
object
state
)
{
try
{
var
now
=
DateTime
.
Now
;
if
(
now
.
Hour
==
5
&&
now
.
Minute
==
1
)
{
SaveRedundancy
(
DateTime
.
Now
.
AddDays
(-
1
));
}
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
ex
.
Message
);
}
}
public
bool
SaveRedundancy
(
DateTime
date
)
public
bool
SaveRedundancy
(
DateTime
date
)
{
{
...
...
SkuWHRedundancyService/SkuWHRedundancyService.csproj
View file @
4a534c72
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
<ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="1.60.6" />
<PackageReference Include="Dapper" Version="1.60.6" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
<PackageReference Include="MySql.Data" Version="8.0.16" />
<PackageReference Include="MySql.Data" Version="8.0.16" />
</ItemGroup>
</ItemGroup>
...
...
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