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
32e94794
Commit
32e94794
authored
Dec 18, 2020
by
guanzhenshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加任务支持
parent
8f590d2d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
14 deletions
+77
-14
Bailun.DC.BalanceSheet4K.csproj
Bailun.DC.BalanceSheet4K/Bailun.DC.BalanceSheet4K.csproj
+1
-0
Dockerfile
Bailun.DC.BalanceSheet4K/Dockerfile
+23
-0
Program.cs
Bailun.DC.BalanceSheet4K/Program.cs
+16
-12
Services.cs
Bailun.DC.BalanceSheet4K/Services.cs
+37
-2
No files found.
Bailun.DC.BalanceSheet4K/Bailun.DC.BalanceSheet4K.csproj
View file @
32e94794
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
<PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
...
...
Bailun.DC.BalanceSheet4K/Dockerfile
0 → 100644
View file @
32e94794
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM
mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base
WORKDIR
/app
RUN
/bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
&&
echo
'Asia/Shanghai'
>
/etc/timezone
FROM
mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR
/src
COPY
["Bailun.DC.BalanceSheet4K/Bailun.DC.BalanceSheet4K.csproj", "Bailun.DC.BalanceSheet4K/"]
COPY
["Bailun.DC.Common/Bailun.DC.Common.csproj", "Bailun.DC.Common/"]
COPY
["Bailun.DC.Models/Bailun.DC.Models.csproj", "Bailun.DC.Models/"]
RUN
dotnet restore
"Bailun.DC.BalanceSheet4K/Bailun.DC.BalanceSheet4K.csproj"
COPY
. .
WORKDIR
"/src/Bailun.DC.BalanceSheet4K"
RUN
dotnet build
"Bailun.DC.BalanceSheet4K.csproj"
-c
Release
-o
/app/build
FROM
build AS publish
RUN
dotnet publish
"Bailun.DC.BalanceSheet4K.csproj"
-c
Release
-o
/app/publish
FROM
base AS final
WORKDIR
/app
COPY
--from=publish /app/publish .
ENTRYPOINT
["dotnet", "Bailun.DC.BalanceSheet4K.dll"]
Bailun.DC.BalanceSheet4K/Program.cs
View file @
32e94794
using
System
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Hosting
;
using
System
;
using
System.Threading.Tasks
;
namespace
Bailun.DC.BalanceSheet4K
namespace
Bailun.DC.BalanceSheet4K
{
{
...
@@ -7,20 +10,21 @@ namespace Bailun.DC.BalanceSheet4K
...
@@ -7,20 +10,21 @@ namespace Bailun.DC.BalanceSheet4K
/// </summary>
/// </summary>
class
Program
class
Program
{
{
static
void
Main
(
string
[]
args
)
static
async
Task
Main
(
string
[]
args
)
{
{
//
Console.WriteLine("启动服务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
Console
.
WriteLine
(
"启动服务 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
//
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
var
builder
=
new
HostBuilder
().
ConfigureServices
((
hostContext
,
services
)
=>
//
{
{
//
services.AddHostedService<Services>();
services
.
AddHostedService
<
Services
>();
//
});
});
//
await builder.RunConsoleAsync();
await
builder
.
RunConsoleAsync
();
var
_service
=
new
Services
();
//var _service = new Services();
var
day
=
DateTime
.
Parse
(
"2020-11-01"
);
//var day = DateTime.Parse("2020-11-01");
_service
.
Init
(
day
);
//_service.Init(day);
}
}
}
}
}
}
Bailun.DC.BalanceSheet4K/Services.cs
View file @
32e94794
...
@@ -4,12 +4,47 @@ using System.Text;
...
@@ -4,12 +4,47 @@ using System.Text;
using
MySql.Data.MySqlClient
;
using
MySql.Data.MySqlClient
;
using
Dapper
;
using
Dapper
;
using
Bailun.DC.Models
;
using
Bailun.DC.Models
;
using
System.Threading
;
using
Microsoft.Extensions.Hosting
;
using
System.Threading.Tasks
;
namespace
Bailun.DC.BalanceSheet4K
namespace
Bailun.DC.BalanceSheet4K
{
{
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
.
Day
==
1
&&
now
.
Hour
==
0
&&
now
.
Minute
==
1
)
//每个月的1日0点1分启动
{
Console
.
WriteLine
(
"开始启动 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
var
start
=
DateTime
.
Parse
(
now
.
AddMonths
(-
1
).
ToShortDateString
());
Init
(
start
);
Console
.
WriteLine
(
"任务运行完成 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
}
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
ex
.
Message
);
}
}
/// <summary>
/// <summary>
/// 每月的第一天
/// 每月的第一天
/// </summary>
/// </summary>
...
...
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