Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
EduSpider
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
viitto
EduSpider
Commits
795786fc
Commit
795786fc
authored
Jun 07, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
111
parent
872978a1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
0 deletions
+115
-0
StuCommentType.cs
EduSpider.Model/Extend/StuCommentType.cs
+29
-0
TimedTaskServices.cs
EduSpider.WebApi/Timers/TimedTaskServices.cs
+86
-0
No files found.
EduSpider.Model/Extend/StuCommentType.cs
0 → 100644
View file @
795786fc
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
EduSpider.Model.Extend
{
/// <summary>
/// 老师创建评价类型
/// </summary>
public
class
StuCommentType
{
/// <summary>
/// 评论类型(1-自定义评价,2-模板评价)
/// </summary>
public
int
CommentType
{
get
;
set
;
}
/// <summary>
/// 是否默认(1-默认,其他值-之定义)
/// </summary>
public
int
IsDefault
{
get
;
set
;
}
/// <summary>
/// 评论主表编号(IsDefault=0 取rb_comment表,其他值取rb_course_comment表)
/// </summary>
public
int
CommentId
{
get
;
set
;
}
}
}
EduSpider.WebApi/Timers/TimedTaskServices.cs
0 → 100644
View file @
795786fc
using
EduSpider.IServices
;
using
Microsoft.Extensions.Hosting
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
VTX.FW.Attr
;
namespace
EduSpider.WebApi.Timers
{
/// <summary>
/// 定时任务
/// </summary>
public
class
TimedTaskServices
:
IHostedService
,
IDisposable
{
/// <summary>
/// 课程仓储接口
/// </summary>
[
Autowired
]
public
ICourseService
CourseService
{
get
;
set
;
}
//定义一个定时器
private
Timer
_timer
;
private
static
int
create_Comment
=
0
;
public
Task
StartAsync
(
CancellationToken
cancellationToken
)
{
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"StartAsync"
,
"定时任务被启动"
);
int
Interval
=
0
;
Interval
=
2
;
//Interval = 1;
//绑定定时任务
//设置延迟时间
_timer
=
new
Timer
(
DoWork
,
null
,
TimeSpan
.
Zero
,
TimeSpan
.
FromSeconds
(
60
*
Interval
));
return
Task
.
CompletedTask
;
}
public
Task
StopAsync
(
CancellationToken
cancellationToken
)
{
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"StopAsync"
,
"定时任务被关闭"
);
_timer
?.
Change
(
Timeout
.
Infinite
,
0
);
return
Task
.
CompletedTask
;
}
/// <summary>
/// 定时生成市场部和课程顾问部数据统计
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
private
void
DoWork
(
object
state
)
{
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"DoWork"
,
"定时任务被触发"
);
try
{
if
(
Interlocked
.
Exchange
(
ref
create_Comment
,
1
)
==
0
)
{
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"DoWork"
,
"DealMarketConsultantData========Start"
);
var
today
=
DateTime
.
Now
;
CourseService
.
CreateHomeWorkComment
(
0
);
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"DoWork"
,
"DealMarketConsultantData========End"
);
Interlocked
.
Exchange
(
ref
create_Comment
,
0
);
}
}
catch
(
Exception
ex
)
{
VTX
.
FW
.
Helper
.
LogHelper
.
WriteError
(
"DoWork"
,
"定时任务异常"
,
ex
);
}
}
public
void
Dispose
()
{
VTX
.
FW
.
Helper
.
LogHelper
.
WriteInfo
(
"Dispose"
,
"定时任务被释放闭"
);
_timer
?.
Dispose
();
//iis会回收这个定时任务,这边在回收的时候触发一个请求,来再次唤醒该服务
Thread
.
Sleep
(
5000
);
string
url
=
"https://jjswapi.oytour.com/api/login/Heart"
;
VTX
.
FW
.
Helper
.
HttpHelper
.
HttpGet
(
url
);
}
}
}
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