<schedule tz="Server" start="2007-01-01 00:00:00 -1:00" end="2007-01-02 10:15:00 -1:00"> <trigger type="Daily" exact="true" at="10:00:00 -1:00" duration="00:50:00" repetition="00:30:00" /> <trigger type="Daily" exact="true" at="15:00:00 -1:00" /> <modifier type="Network" /> </schedule>
00:00:00
23:59:59
0
com.altiris.inventorysol.hardware.{ADF4D0F0-C336-488E-AD83-6648E2E46578}
duration
<schedule tz="Local" start="" end=""> <trigger type="Daily" exact="true" at="10:00:00" duration="01:00:00" repetition="00:20:00" /> </schedule>
<schedule tz="Local" start="2008-01-01" end=""> <trigger type="Daily" exact="true" at="10:00:00" frequency="2" /> <trigger type="Weekly" exact="true" at="12:00:00" frequency="4" weekdays="1" /> </schedule>
frequency-1
Daily
Weekly
1
Logon
<schedule tz="Local" start="" end=""> <trigger type="Logon" exact="true" /> </schedule>
Startup
<schedule tz="Local" start="" end=""> <trigger type="Startup" exact="true" /> </schedule>
void MyPlugin::OnAfterPolicyStoreUpdate( const AgentSDK::Interfaces::AIpcCallContext &_call_context, const BaseSDK::AString &agentClsid, const bool &bIsFirstRefresh, const AgentSDK::APolicyStatus::Map &policy_status ) { AError err = E_OK; APolicyXmlList policies; // Obtain client policies XML err = APolicyManager::GetPolicyXml(agentClsid, policies); if (IS_FAILURE(err)) { LOG_ERROR(L"Failed to obtain client policies for plug-in %1: %2, %3", agentClsid, err, AGetErrorMsg(err)); return; } // Extract schedule from each of the policies APolicyXmlList::iterator it = policies.begin(); const APolicyXmlList::iterator end = policies.end(); for ( ; end != it; ++it) { // Get policy GUID; it will be used for task id AString policyGuid = (*it)->SelectSingleNode("/Policy/@guid"); // Extract schedule from the policy ASchedule schedule; err = ADeserializeFromXml(schedule, (*it)->SelectSingleNode("/Policy/ClientPolicy/scheduleXml/schedule")); if (IS_FAILURE(err)) { LOG_WARNING(L"Failed to deserialize schedule for policy '%1': %2, %3", policyGuid, err, AGetErrorMsg(err)); continue; } // Create the task to register in Client Scheduler ATask task(L"com.altiris.sample.clientscheduler.myplugin." + policyGuid); task.SetEnabled(true); task.SetHandlerId(L"Altiris.Sample.ClientScheduler.MyPlugin"); task.AddSchedule(schedule); // Register the task; if task already exists, it will be updated err = AClientScheduler::AddTask(task); if (IS_FAILURE(err)) { LOG_WARNING(L"Failed to add or update task '%1': %2, %3", task.GetId(), err, AGetErrorMsg(err)); } } return E_OK; }
AError MyPlugin::OnPluginUninstall(const AgentSDK::Interfaces::AIpcCallContext &_call_context, const BaseSDK::AString &agentClsid) { // Get the list of all registered tasks ATaskList tasks; AError err = AClientScheduler::GetTasks(tasks); if (IS_FAILURE(err)) { LOG_ERROR(L"Failed to obtain the list of tasks to remove: %1, %2", err, AGetErrorMsg(err)); } else { ATaskList::const_iterator it = tasks.begin(); const ATaskList::const_iterator end = tasks.end(); for ( ; end != it; ++it) { // Check if this is our task if (!it->GetId().StartsWith(L"com.altiris.sample.clientscheduler.myplugin.")) continue; // This is our task: remove its registration err = AClientScheduler::RemoveTask(it->GetId()); if (IS_FAILURE(err)) { LOG_WARNING(L"Failed to remove a task '%1': %2, %3", it->GetId(), err, AGetErrorMsg(err)); } } } return E_OK; }
AError MyPlugin::OnClientScheduleTaskTriggered( const AgentSDK::Interfaces::AIpcCallContext &_call_context, const AgentSDK::ClientScheduling::ATriggeredTask &task ) { // First check if this is our task if (!task.GetId().StartsWith(L"com.altiris.sample.clientscheduler.myplugin.")) return E_OK; // Do some real work. // Or, alternatively, spin off/notify a thread to do the work. ... return E_OK; }
OnClientScheduleTaskTriggered
AError MyPlugin::Initialize() { // Subscribe to NTracker notifications long lEvents[] = { NTN_CS_TASK_BECAME_ACTIVE, NTN_CS_TASK_BECAME_INACTIVE }; int iSubscriberID = -1; AError err = NTracker::Subscribe(L"Altiris.Sample.ClientScheduler.MyPlugin", lEvents, COUNT_OF(lEvents), iSubscriberID); if (IS_FAILURE(err)) LOG_ERROR(L"APeriodManager::Init(), failed to subscribe to notifications: %1, %2", err, AGetErrorMsg(err)); return E_OK; } AError MyPlugin::NotifyObject( const AgentSDK::Interfaces::AIpcCallContext &_call_context, const long &lNotification, const long &lParam, const BaseSDK::AString& strParam ) { // Handle NTracker notifications if (NOTIFICATION_NTRACKER == lNotification) { // A schedule is active if (NTN_CS_TASK_BECAME_ACTIVE == lParam) { // Is it our schedule? if (strParam.StartsWith(L"com.altiris.sample.clientscheduler.myplugin.")) { // Do some work here. ... } } // A schedule became inactive else if (NTN_CS_TASK_BECAME_INACTIVE == lParam) { // Is it our schedule? if (strParam.StartsWith(L"com.altiris.sample.clientscheduler.myplugin.")) { // Do some work here. ... } } } return E_OK; }