Validate the hzCron settings. The following tests are performed:- 1) The periodicity must be set. 2) If the periodicty is every two weeks, then an era start date must be provided. This is because the DoW (day of week) function could not unambiquously trigger the event. 3) If the periodicty is monthly or less often, there must be a month-rule to define at which point in the month, the trigger applies. Arguments: None
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzCron::Validate | (void) |
Declared in file: hzCron.h
Defined in file : hzCron.cpp
Function Logic:
Function body:
hzEcode hzCron::Validate (void)
{
// Validate the hzCron settings. The following tests are performed:-
//
// 1) The periodicity must be set.
//
// 2) If the periodicty is every two weeks, then an era start date must be provided. This is because the DoW (day of week) function could
// not unambiquously trigger the event.
//
// 3) If the periodicty is monthly or less often, there must be a month-rule to define at which point in the month, the trigger applies.
//
// Arguments: None
//
// Returns: E_NOINIT If the settings have not been set up or set up correctly
// E_OK If the settings pass all the tests
_hzfunc("hzCron::Validate") ;
hzEcode rc = E_OK ; // Return code
switch (m_Period)
{
case HZPERIOD_DAY: // Every day",
case HZPERIOD_MONSAT: // Mon - Sat",
case HZPERIOD_WEEKDAY: // Weekdays only
case HZPERIOD_EMON: // Every Monday
case HZPERIOD_ETUE: // Every Tuesday
case HZPERIOD_EWED: // Every Wednesday
case HZPERIOD_ETHR: // Every Thursday
case HZPERIOD_EFRI: // Every Friday
case HZPERIOD_ESAT: // Every Saturday
case HZPERIOD_ESUN: // Every Sunday
break ;
case HZPERIOD_ALT_MON: // Every other Monday
case HZPERIOD_ALT_TUE: // Every other Tuesday
case HZPERIOD_ALT_WED: // Every other Wednesday
case HZPERIOD_ALT_THR: // Every other Thursday
case HZPERIOD_ALT_FRI: // Every other Friday
case HZPERIOD_ALT_SAT: // Every other Saturday
case HZPERIOD_ALT_SUN: // Every other Sunday
if (!m_Era.IsSet())
{
rc = E_NOINIT ;
m_error = "\tFortnightly invokations must have an era start date otherwise weeks are ambiguous" ;
}
break ;
case HZPERIOD_MONTH: // Monthly
case HZPERIOD_MONTH1: // Bi-Monthly (odd)
case HZPERIOD_MONTH2: // Bi-Monthly (even)
case HZPERIOD_QTR1: // Quarterly (1)
case HZPERIOD_QTR2: // Quarterly (2)
case HZPERIOD_QTR3: // Quarterly (3)
case HZPERIOD_HYEAR1: // Half-Yearly (1)
case HZPERIOD_HYEAR2: // Half-Yearly (2)
case HZPERIOD_HYEAR3: // Half-Yearly (3)
case HZPERIOD_HYEAR4: // Half-Yearly (4)
case HZPERIOD_HYEAR5: // Half-Yearly (5)
case HZPERIOD_HYEAR6: // Half-Yearly (6)
case HZPERIOD_YEAR1: // Yearly (Jan)
case HZPERIOD_YEAR2: // Yearly (Feb)
case HZPERIOD_YEAR3: // Yearly (Mar)
case HZPERIOD_YEAR4: // Yearly (Apr)
case HZPERIOD_YEAR5: // Yearly (May)
case HZPERIOD_YEAR6: // Yearly (Jun)
case HZPERIOD_YEAR7: // Yearly (Jul)
case HZPERIOD_YEAR8: // Yearly (Aug)
case HZPERIOD_YEAR9: // Yearly (Sep)
case HZPERIOD_YEAR10: // Yearly (Oct)
case HZPERIOD_YEAR11: // Yearly (Nov)
case HZPERIOD_YEAR12: // Yearly (Dec)
case HZPERIOD_RANDOM: // Completly Random
if (m_Rule == HZMONTHRULE_INVALID && !m_Era.IsSet())
{
rc = E_NOINIT ;
m_error = "Periods of a month or more must have a valid monthrule" ;
}
break ;
default:
m_error = "Periodicity not set" ;
rc = E_NOINIT ;
}
if (rc == E_OK)
m_bActive = true ;
return rc ;
}