cancel
Showing results for 
Search instead for 
Did you mean: 

Notifications if time window is open

former_member206885
Participant
0 Kudos
45

Hi All,

I have created a time window "Notification_weekdays" which is enabled from 'Monday 12 am' to 'Sat 12am'.


I have created below trigger to send email notifications.

{
   String strLogFileName = "";

    if((jcsPostRunningContext.getNewStatus().equals(JobStatus.Error)     ||
        jcsPostRunningContext.getNewStatus().equals(JobStatus.Unknown)   ||
        jcsPostRunningContext.getNewStatus().equals(JobStatus.Killed)) 
       )
    {
          
      {

         String email = "abc@ghi.com";
         String subject = "Redwood job abend";
         String strText = "Job id=" + jcsJob.getJobId().intValue() + ", Job name=" + jcsJob.getJobDefinition().getName() + ", Job Description=" + jcsJob.getDescription() + " , has abended";
         JobDefinition jd = jcsSession.getJobDefinitionByName("System_Mail_Send");

     {
          Job subJob = jd.prepare();
          subJob.getJobParameterByName("To").setInValueString(email);
          subJob.getJobParameterByName("Subject").setInValueString(subject);
          subJob.getJobParameterByName("Text").setInValueString(strText);
          }
     }

   }
}


We need to trigger email notifications only if the time window "Notification_weekdays" is open.

Can you please help with the code for time window logic in the above trigger.

Regards,

Tinku

Accepted Solutions (0)

Answers (1)

Answers (1)

gmblom
Active Contributor
0 Kudos

Hello,

You can just check the time window whether it is open or not:

TimeWindow tw = jcsSession.getTimeWindowByName("Notification_weekdays");

if (tw.isOpen(new DateTimeZone(), null))

{

  // etc

}

Regards Gerben

former_member206885
Participant
0 Kudos

Thank you Gerben. I will test it.

Regards,

Tinku

former_member206885
Participant
0 Kudos

Thank you Gerben. It is working.

Can you also please help me with the code how to send notifications basing on the priority as we need to send emails for only high priority jobs .

Thanks,

Tinku

gmblom
Active Contributor
0 Kudos

Hello,

long jobPriority = 0;

if (jcsJob.getPriority() != null)

{

  jobPriority = jcsJob.getPriority().longValue();

}

if (jobPriority > 40)

{

  // alert

}

Regards Gerben

former_member206885
Participant
0 Kudos

Thank you Gerben