110 lines
2.8 KiB
Perl
110 lines
2.8 KiB
Perl
# --
|
|
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
|
|
# --
|
|
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
|
# the enclosed file COPYING for license information (GPL). If you
|
|
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
|
|
# --
|
|
|
|
package Kernel::System::Daemon::DaemonModules::SchedulerTaskWorker::CalendarAppointment;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use parent qw(Kernel::System::Daemon::DaemonModules::BaseTaskWorker);
|
|
|
|
our @ObjectDependencies = (
|
|
'Kernel::System::Log',
|
|
'Kernel::System::Calendar::Appointment',
|
|
);
|
|
|
|
=head1 NAME
|
|
|
|
Kernel::System::Daemon::DaemonModules::SchedulerTaskWorker::CalendarAppointment - Scheduler daemon task handler module for CalendarAppointment
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
This task handler executes calendar appointment jobs.
|
|
|
|
=head1 PUBLIC INTERFACE
|
|
|
|
=head2 new()
|
|
|
|
use Kernel::System::ObjectManager;
|
|
local $Kernel::OM = Kernel::System::ObjectManager->new();
|
|
my $TaskHandlerObject = $Kernel::OM-Get('Kernel::System::Daemon::DaemonModules::SchedulerTaskWorker::CalendarAppointment');
|
|
|
|
=cut
|
|
|
|
sub new {
|
|
my ( $Type, %Param ) = @_;
|
|
|
|
my $Self = {};
|
|
bless( $Self, $Type );
|
|
|
|
$Self->{Debug} = $Param{Debug};
|
|
$Self->{WorkerName} = 'Worker: CalendarAppointment';
|
|
|
|
return $Self;
|
|
}
|
|
|
|
=head2 Run()
|
|
|
|
performs the selected task.
|
|
|
|
my $Result = $TaskHandlerObject->Run(
|
|
TaskID => 123,
|
|
TaskName => 'some name', # optional
|
|
Data => { # appointment id as got from Kernel::System::Calendar::Appointment::AppointmentGet()
|
|
NotifyTime => '2016-08-02 03:59:00',
|
|
},
|
|
);
|
|
|
|
Returns:
|
|
|
|
$Result = 1; # or fail in case of an error
|
|
|
|
=cut
|
|
|
|
sub Run {
|
|
my ( $Self, %Param ) = @_;
|
|
|
|
# check task params
|
|
my $CheckResult = $Self->_CheckTaskParams(
|
|
%Param,
|
|
NeededDataAttributes => ['NotifyTime'],
|
|
);
|
|
|
|
# stop execution if an error in params is detected
|
|
return if !$CheckResult;
|
|
|
|
if ( $Self->{Debug} ) {
|
|
print " $Self->{WorkerName} executes task: $Param{TaskName}\n";
|
|
}
|
|
|
|
# trigger the appointment notification
|
|
my $Success
|
|
= $Kernel::OM->Get('Kernel::System::Calendar::Appointment')->AppointmentNotification( %{ $Param{Data} } );
|
|
|
|
if ( !$Success ) {
|
|
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
|
Priority => 'error',
|
|
Message => "Could not trigger appointment notification for AppointmentID $Param{Data}->{AppointmentID}!",
|
|
);
|
|
}
|
|
|
|
return $Success;
|
|
}
|
|
|
|
1;
|
|
|
|
=head1 TERMS AND CONDITIONS
|
|
|
|
This software is part of the OTRS project (L<https://otrs.org/>).
|
|
|
|
This software comes with ABSOLUTELY NO WARRANTY. For details, see
|
|
the enclosed file COPYING for license information (GPL). If you
|
|
did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
|
|
|
|
=cut
|