Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
tsai
CAP
Commits
e3b62cff
Commit
e3b62cff
authored
Jun 21, 2017
by
yangxiaodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Cron Helper class.
parent
9765e35c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
181 additions
and
0 deletions
+181
-0
Cron.cs
src/Cap.Consistency/Job/Cron.cs
+181
-0
No files found.
src/Cap.Consistency/Job/Cron.cs
0 → 100644
View file @
e3b62cff
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Cap.Consistency.Job
{
public
class
Cron
{
/// <summary>
/// Returns cron expression that fires every minute.
/// </summary>
public
static
string
Minutely
()
{
return
"* * * * *"
;
}
/// <summary>
/// Returns cron expression that fires every hour at the first minute.
/// </summary>
public
static
string
Hourly
()
{
return
Hourly
(
minute
:
0
);
}
/// <summary>
/// Returns cron expression that fires every hour at the specified minute.
/// </summary>
/// <param name="minute">The minute in which the schedule will be activated (0-59).</param>
public
static
string
Hourly
(
int
minute
)
{
return
string
.
Format
(
"{0} * * * *"
,
minute
);
}
/// <summary>
/// Returns cron expression that fires every day at 00:00 UTC.
/// </summary>
public
static
string
Daily
()
{
return
Daily
(
hour
:
0
);
}
/// <summary>
/// Returns cron expression that fires every day at the first minute of
/// the specified hour in UTC.
/// </summary>
/// <param name="hour">The hour in which the schedule will be activated (0-23).</param>
public
static
string
Daily
(
int
hour
)
{
return
Daily
(
hour
,
minute
:
0
);
}
/// <summary>
/// Returns cron expression that fires every day at the specified hour and minute
/// in UTC.
/// </summary>
/// <param name="hour">The hour in which the schedule will be activated (0-23).</param>
/// <param name="minute">The minute in which the schedule will be activated (0-59).</param>
public
static
string
Daily
(
int
hour
,
int
minute
)
{
return
string
.
Format
(
"{0} {1} * * *"
,
minute
,
hour
);
}
/// <summary>
/// Returns cron expression that fires every week at Monday, 00:00 UTC.
/// </summary>
public
static
string
Weekly
()
{
return
Weekly
(
DayOfWeek
.
Monday
);
}
/// <summary>
/// Returns cron expression that fires every week at 00:00 UTC of the specified
/// day of the week.
/// </summary>
/// <param name="dayOfWeek">The day of week in which the schedule will be activated.</param>
public
static
string
Weekly
(
DayOfWeek
dayOfWeek
)
{
return
Weekly
(
dayOfWeek
,
hour
:
0
);
}
/// <summary>
/// Returns cron expression that fires every week at the first minute
/// of the specified day of week and hour in UTC.
/// </summary>
/// <param name="dayOfWeek">The day of week in which the schedule will be activated.</param>
/// <param name="hour">The hour in which the schedule will be activated (0-23).</param>
public
static
string
Weekly
(
DayOfWeek
dayOfWeek
,
int
hour
)
{
return
Weekly
(
dayOfWeek
,
hour
,
minute
:
0
);
}
/// <summary>
/// Returns cron expression that fires every week at the specified day
/// of week, hour and minute in UTC.
/// </summary>
/// <param name="dayOfWeek">The day of week in which the schedule will be activated.</param>
/// <param name="hour">The hour in which the schedule will be activated (0-23).</param>
/// <param name="minute">The minute in which the schedule will be activated (0-59).</param>
public
static
string
Weekly
(
DayOfWeek
dayOfWeek
,
int
hour
,
int
minute
)
{
return
string
.
Format
(
"{0} {1} * * {2}"
,
minute
,
hour
,
(
int
)
dayOfWeek
);
}
/// <summary>
/// Returns cron expression that fires every month at 00:00 UTC of the first
/// day of month.
/// </summary>
public
static
string
Monthly
()
{
return
Monthly
(
day
:
1
);
}
/// <summary>
/// Returns cron expression that fires every month at 00:00 UTC of the specified
/// day of month.
/// </summary>
/// <param name="day">The day of month in which the schedule will be activated (1-31).</param>
public
static
string
Monthly
(
int
day
)
{
return
Monthly
(
day
,
hour
:
0
);
}
/// <summary>
/// Returns cron expression that fires every month at the first minute of the
/// specified day of month and hour in UTC.
/// </summary>
/// <param name="day">The day of month in which the schedule will be activated (1-31).</param>
/// <param name="hour">The hour in which the schedule will be activated (0-23).</param>
public
static
string
Monthly
(
int
day
,
int
hour
)
{
return
Monthly
(
day
,
hour
,
minute
:
0
);
}
/// <summary>
/// Returns cron expression that fires every month at the specified day of month,
/// hour and minute in UTC.
/// </summary>
/// <param name="day">The day of month in which the schedule will be activated (1-31).</param>
/// <param name="hour">The hour in which the schedule will be activated (0-23).</param>
/// <param name="minute">The minute in which the schedule will be activated (0-59).</param>
public
static
string
Monthly
(
int
day
,
int
hour
,
int
minute
)
{
return
string
.
Format
(
"{0} {1} {2} * *"
,
minute
,
hour
,
day
);
}
/// <summary>
/// Returns cron expression that fires every year on Jan, 1st at 00:00 UTC.
/// </summary>
public
static
string
Yearly
()
{
return
Yearly
(
month
:
1
);
}
/// <summary>
/// Returns cron expression that fires every year in the first day at 00:00 UTC
/// of the specified month.
/// </summary>
/// <param name="month">The month in which the schedule will be activated (1-12).</param>
public
static
string
Yearly
(
int
month
)
{
return
Yearly
(
month
,
day
:
1
);
}
/// <summary>
/// Returns cron expression that fires every year at 00:00 UTC of the specified
/// month and day of month.
/// </summary>
/// <param name="month">The month in which the schedule will be activated (1-12).</param>
/// <param name="day">The day of month in which the schedule will be activated (1-31).</param>
public
static
string
Yearly
(
int
month
,
int
day
)
{
return
Yearly
(
month
,
day
,
hour
:
0
);
}
/// <summary>
/// Returns cron expression that fires every year at the first minute of the
/// specified month, day and hour in UTC.
/// </summary>
/// <param name="month">The month in which the schedule will be activated (1-12).</param>
/// <param name="day">The day of month in which the schedule will be activated (1-31).</param>
/// <param name="hour">The hour in which the schedule will be activated (0-23).</param>
public
static
string
Yearly
(
int
month
,
int
day
,
int
hour
)
{
return
Yearly
(
month
,
day
,
hour
,
minute
:
0
);
}
/// <summary>
/// Returns cron expression that fires every year at the specified month, day,
/// hour and minute in UTC.
/// </summary>
/// <param name="month">The month in which the schedule will be activated (1-12).</param>
/// <param name="day">The day of month in which the schedule will be activated (1-31).</param>
/// <param name="hour">The hour in which the schedule will be activated (0-23).</param>
/// <param name="minute">The minute in which the schedule will be activated (0-59).</param>
public
static
string
Yearly
(
int
month
,
int
day
,
int
hour
,
int
minute
)
{
return
string
.
Format
(
"{0} {1} {2} {3} *"
,
minute
,
hour
,
day
,
month
);
}
}
}
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