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
0b924a27
Commit
0b924a27
authored
Oct 31, 2019
by
guanzhenshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成每月销售利润报表的统计服务
parent
56fbc946
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
18 deletions
+81
-18
Bailun.DC.MonthSaleProfit.csproj
Bailun.DC.MonthSaleProfit/Bailun.DC.MonthSaleProfit.csproj
+2
-1
Dockerfile
Bailun.DC.MonthSaleProfit/Dockerfile
+21
-0
Program.cs
Bailun.DC.MonthSaleProfit/Program.cs
+19
-16
Services.cs
Bailun.DC.MonthSaleProfit/Services.cs
+32
-1
docker-compose.yml
docker-compose.yml
+7
-0
No files found.
Bailun.DC.MonthSaleProfit/Bailun.DC.MonthSaleProfit.csproj
View file @
0b924a27
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
...
...
Bailun.DC.MonthSaleProfit/Dockerfile
0 → 100644
View file @
0b924a27
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.MonthSaleProfit/Bailun.DC.MonthSaleProfit.csproj Bailun.DC.MonthSaleProfit/
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.MonthSaleProfit/Bailun.DC.MonthSaleProfit.csproj
COPY
. .
WORKDIR
/src/Bailun.DC.MonthSaleProfit
RUN
dotnet build Bailun.DC.MonthSaleProfit.csproj
-c
Release
-o
/app
FROM
build AS publish
RUN
dotnet publish Bailun.DC.MonthSaleProfit.csproj
-c
Release
-o
/app
FROM
base AS final
WORKDIR
/app
COPY
--from=publish /app .
ENTRYPOINT
["dotnet", "Bailun.DC.MonthSaleProfit.dll"]
Bailun.DC.MonthSaleProfit/Program.cs
View file @
0b924a27
using
System
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Hosting
;
using
System
;
using
System.Threading.Tasks
;
namespace
Bailun.DC.MonthSaleProfit
namespace
Bailun.DC.MonthSaleProfit
{
{
class
Program
class
Program
{
{
//static async Task Main(string[] args)
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
)
{
{
var
_services
=
new
Services
();
Console
.
WriteLine
(
"启动服务 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
var
builder
=
new
HostBuilder
().
ConfigureServices
((
hostContext
,
services
)
=>
{
services
.
AddHostedService
<
Services
>();
});
var
start
=
DateTime
.
Parse
(
"2019-09-01"
);
await
builder
.
RunConsoleAsync
();
_services
.
Init
(
start
);
}
}
//static void Main(string[] args)
//{
// var _services = new Services();
// var start = DateTime.Parse("2019-09-01");
// _services.Init(start);
//}
}
}
}
}
Bailun.DC.MonthSaleProfit/Services.cs
View file @
0b924a27
...
@@ -5,14 +5,45 @@ using MySql.Data.MySqlClient;
...
@@ -5,14 +5,45 @@ using MySql.Data.MySqlClient;
using
Dapper
;
using
Dapper
;
using
Bailun.DC.Models
;
using
Bailun.DC.Models
;
using
Bailun.DC.Common
;
using
Bailun.DC.Common
;
using
System.Threading
;
using
Microsoft.Extensions.Hosting
;
using
System.Threading.Tasks
;
namespace
Bailun.DC.MonthSaleProfit
namespace
Bailun.DC.MonthSaleProfit
{
{
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>
/// 每月1日统计
/// 每月1日统计
...
...
docker-compose.yml
View file @
0b924a27
...
@@ -69,3 +69,10 @@ services:
...
@@ -69,3 +69,10 @@ services:
context
:
.
context
:
.
dockerfile
:
Bailun.DC.DailyPurchaseSellStock/Dockerfile
dockerfile
:
Bailun.DC.DailyPurchaseSellStock/Dockerfile
bailun.dc.monthsaleprofit
:
image
:
${DOCKER_REGISTRY}bailundcmonthsaleprofit
build
:
context
:
.
dockerfile
:
Bailun.DC.MonthSaleProfit/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