Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
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
黄奎
mall.oytour.com
Commits
cea5658e
Commit
cea5658e
authored
Jun 05, 2020
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交代码
parent
3f240980
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
5 deletions
+102
-5
TimersHelper.cs
Mall.WindowsService/Helper/TimersHelper.cs
+32
-0
Mall.WindowsService.csproj
Mall.WindowsService/Mall.WindowsService.csproj
+4
-0
Program.cs
Mall.WindowsService/Program.cs
+3
-1
WindowsService.Designer.cs
Mall.WindowsService/WindowsService.Designer.cs
+37
-0
WindowsService.cs
Mall.WindowsService/WindowsService.cs
+26
-4
No files found.
Mall.WindowsService/Helper/TimersHelper.cs
0 → 100644
View file @
cea5658e
using
Mall.Common.Plugin
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Threading
;
namespace
Mall.WindowsService.Helper
{
public
class
TimersHelper
{
private
static
int
inTimer
=
0
;
/// <summary>
/// 收入单子服务开始执行方法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public
void
RevenueFinance
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
{
if
(
Interlocked
.
Exchange
(
ref
inTimer
,
1
)
==
0
)
{
LogHelper
.
Write
(
"ClearOrder=====Start"
);
//Module.OrderModule.ClearOrderModule();
LogHelper
.
Write
(
"ClearOrder=====End"
);
Interlocked
.
Exchange
(
ref
inTimer
,
0
);
}
}
}
}
Mall.WindowsService/Mall.WindowsService.csproj
View file @
cea5658e
...
@@ -9,4 +9,8 @@
...
@@ -9,4 +9,8 @@
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.7.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.7.0" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mall.Common\Mall.Common.csproj" />
</ItemGroup>
</Project>
</Project>
Mall.WindowsService/Program.cs
View file @
cea5658e
using
System
;
using
System
;
using
System.ServiceProcess
;
namespace
Mall.WindowsService
namespace
Mall.WindowsService
{
{
...
@@ -6,7 +7,8 @@ namespace Mall.WindowsService
...
@@ -6,7 +7,8 @@ namespace Mall.WindowsService
{
{
static
void
Main
(
string
[]
args
)
static
void
Main
(
string
[]
args
)
{
{
Console
.
WriteLine
(
"Hello World!"
);
ServiceBase
[]
services
=
new
ServiceBase
[]
{
new
WindowsService
()
};
ServiceBase
.
Run
(
services
);
}
}
}
}
}
}
Mall.WindowsService/WindowsService.Designer.cs
0 → 100644
View file @
cea5658e
namespace
Mall.WindowsService
{
partial
class
WindowsService
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private
System
.
ComponentModel
.
IContainer
components
=
null
;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected
override
void
Dispose
(
bool
disposing
)
{
if
(
disposing
&&
(
components
!=
null
))
{
components
.
Dispose
();
}
base
.
Dispose
(
disposing
);
}
#
region
组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private
void
InitializeComponent
()
{
components
=
new
System
.
ComponentModel
.
Container
();
this
.
ServiceName
=
"WindowsService"
;
}
#
endregion
}
}
Mall.WindowsService/WindowsService.cs
View file @
cea5658e
using
Mall.Common.Plugin
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.ComponentModel
;
...
@@ -6,12 +6,34 @@ using System.Data;
...
@@ -6,12 +6,34 @@ using System.Data;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.ServiceProcess
;
using
System.ServiceProcess
;
using
System.Text
;
using
System.Text
;
using
Mall.WindowsService.Helper
;
namespace
Mall.WindowsService
namespace
Mall.WindowsService
{
{
public
class
WindowsService
:
ServiceBase
partial
class
WindowsService
:
ServiceBase
{
{
System
.
Timers
.
Timer
timer1
;
//计时器
public
WindowsService
()
{
InitializeComponent
();
}
protected
override
void
OnStart
(
string
[]
args
)
{
// TODO: 在此处添加代码以启动服务。
LogHelper
.
Write
(
"主服务开始运行......"
);
TimersHelper
helper
=
new
TimersHelper
();
timer1
=
new
System
.
Timers
.
Timer
();
timer1
.
Interval
=
1000
*
(
60
*
0.3
);
//60分钟
timer1
.
Elapsed
+=
new
System
.
Timers
.
ElapsedEventHandler
(
helper
.
RevenueFinance
);
timer1
.
Enabled
=
true
;
}
protected
override
void
OnStop
()
{
// TODO: 在此处添加代码以执行停止服务所需的关闭操作。
LogHelper
.
Write
(
"主服务停止运行......"
);
this
.
timer1
.
Enabled
=
false
;
}
}
}
}
}
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