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
d75c0559
Commit
d75c0559
authored
Nov 09, 2019
by
guanzhenshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加docker支持
parent
3ef2d18a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
22 deletions
+86
-22
Bailun.DC.DailySemiPurchaseSellStock.csproj
...haseSellStock/Bailun.DC.DailySemiPurchaseSellStock.csproj
+2
-1
Dockerfile
Bailun.DC.DailySemiPurchaseSellStock/Dockerfile
+21
-0
Program.cs
Bailun.DC.DailySemiPurchaseSellStock/Program.cs
+20
-20
Services.cs
Bailun.DC.DailySemiPurchaseSellStock/Services.cs
+36
-1
docker-compose.yml
docker-compose.yml
+7
-0
No files found.
Bailun.DC.DailySemiPurchaseSellStock/Bailun.DC.DailySemiPurchaseSellStock.csproj
View file @
d75c0559
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
...
...
Bailun.DC.DailySemiPurchaseSellStock/Dockerfile
0 → 100644
View file @
d75c0559
FROM
microsoft/dotnet:2.1-runtime AS base
WORKDIR
/app
RUN
/bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
&&
echo
'Asia/Shanghai'
>
/etc/timezone
FROM
microsoft/dotnet:2.1-sdk AS build
WORKDIR
/src
COPY
Bailun.DC.DailySemiPurchaseSellStock/Bailun.DC.DailySemiPurchaseSellStock.csproj Bailun.DC.DailySemiPurchaseSellStock/
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.DailySemiPurchaseSellStock/Bailun.DC.DailySemiPurchaseSellStock.csproj
COPY
. .
WORKDIR
/src/Bailun.DC.DailySemiPurchaseSellStock
RUN
dotnet build Bailun.DC.DailySemiPurchaseSellStock.csproj
-c
Release
-o
/app
FROM
build AS publish
RUN
dotnet publish Bailun.DC.DailySemiPurchaseSellStock.csproj
-c
Release
-o
/app
FROM
base AS final
WORKDIR
/app
COPY
--from=publish /app .
ENTRYPOINT
["dotnet", "Bailun.DC.DailySemiPurchaseSellStock.dll"]
Bailun.DC.DailySemiPurchaseSellStock/Program.cs
View file @
d75c0559
...
...
@@ -7,28 +7,28 @@ namespace Bailun.DC.DailySemiPurchaseSellStock
{
class
Program
{
//static async Task Main(string[] args)
//{
// Console.WriteLine("启动服务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
// var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
// {
// services.AddHostedService<Services>();
// });
// await builder.RunConsoleAsync();
//}
static
void
Main
(
string
[]
args
)
static
async
Task
Main
(
string
[]
args
)
{
var
_services
=
new
Services
();
var
start
=
DateTime
.
Parse
(
"2019-09-01"
);
while
(
start
.
AddDays
(
1
)
<
DateTime
.
Now
)
Console
.
WriteLine
(
"启动服务 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
var
builder
=
new
HostBuilder
().
ConfigureServices
((
hostContext
,
services
)
=>
{
Console
.
WriteLine
(
start
);
_services
.
Init
(
start
);
start
=
start
.
AddDays
(
1
);
}
services
.
AddHostedService
<
Services
>(
);
}
);
await
builder
.
RunConsoleAsync
();
}
//static void Main(string[] args)
//{
// var _services = new Services();
// var start = DateTime.Parse("2019-09-01");
// while (start.AddDays(1) < DateTime.Now)
// {
// Console.WriteLine(start);
// _services.Init(start);
// start = start.AddDays(1);
// }
//}
}
}
Bailun.DC.DailySemiPurchaseSellStock/Services.cs
View file @
d75c0559
using
Bailun.DC.Models
;
using
Dapper
;
using
Microsoft.Extensions.Hosting
;
using
MySql.Data.MySqlClient
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
Bailun.DC.DailySemiPurchaseSellStock
{
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
==
01
)
//每天 5:01分启动
{
Console
.
WriteLine
(
"开始启动 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
var
start
=
DateTime
.
Parse
(
now
.
AddDays
(-
1
).
ToShortDateString
());
Init
(
start
);
Console
.
WriteLine
(
"任务运行完成 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
}
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
ex
.
Message
);
}
}
public
void
Init
(
DateTime
day
,
int
count
=
0
)
{
try
...
...
docker-compose.yml
View file @
d75c0559
...
...
@@ -76,3 +76,10 @@ services:
context
:
.
dockerfile
:
Bailun.DC.MonthSaleProfit/Dockerfile
bailun.dc.dailysemipurchasesellstock
:
image
:
${DOCKER_REGISTRY}bailundcdailysemipurchasesellstock
build
:
context
:
.
dockerfile
:
Bailun.DC.DailySemiPurchaseSellStock/Dockerfile
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