projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Presenter Code - gl_transaction aus invoice wieder entfernt
[kivitendo-erp.git]
/
SL
/
DB
/
BackgroundJob.pm
diff --git
a/SL/DB/BackgroundJob.pm
b/SL/DB/BackgroundJob.pm
index
1a9c869
..
10e319b
100644
(file)
--- a/
SL/DB/BackgroundJob.pm
+++ b/
SL/DB/BackgroundJob.pm
@@
-5,13
+5,15
@@
use strict;
use DateTime::Event::Cron;
use English qw(-no_match_vars);
use DateTime::Event::Cron;
use English qw(-no_match_vars);
-require SL::DB::MetaSetup::BackgroundJob;
-require SL::DB::Manager::BackgroundJob;
+use Rose::DB::Object::Helpers qw(as_tree);
-require SL::DB::BackgroundJobHistory;
+use SL::DB::MetaSetup::BackgroundJob;
+use SL::DB::Manager::BackgroundJob;
use SL::System::Process;
use SL::System::Process;
+__PACKAGE__->meta->initialize;
+
__PACKAGE__->before_save('_before_save_set_next_run_at');
sub _before_save_set_next_run_at {
__PACKAGE__->before_save('_before_save_set_next_run_at');
sub _before_save_set_next_run_at {
@@
-36,6
+38,8
@@
sub run {
my $run_at = DateTime->now_local;
my $history;
my $run_at = DateTime->now_local;
my $history;
+ require SL::DB::BackgroundJobHistory;
+
my $ok = eval {
eval "require $package" or die $@;
my $result = $package->new->run($self);
my $ok = eval {
eval "require $package" or die $@;
my $result = $package->new->run($self);
@@
-43,7
+47,7
@@
sub run {
$history = SL::DB::BackgroundJobHistory
->new(package_name => $self->package_name,
run_at => $run_at,
$history = SL::DB::BackgroundJobHistory
->new(package_name => $self->package_name,
run_at => $run_at,
- status =>
'success'
,
+ status =>
SL::DB::BackgroundJobHistory::SUCCESS()
,
result => $result,
data => $self->data);
$history->save;
result => $result,
data => $self->data);
$history->save;
@@
-56,7
+60,7
@@
sub run {
$history = SL::DB::BackgroundJobHistory
->new(package_name => $self->package_name,
run_at => $run_at,
$history = SL::DB::BackgroundJobHistory
->new(package_name => $self->package_name,
run_at => $run_at,
- status =>
'failure'
,
+ status =>
SL::DB::BackgroundJobHistory::FAILURE()
,
error_col => $error,
data => $self->data);
$history->save;
error_col => $error,
data => $self->data);
$history->save;
@@
-83,6
+87,8
@@
sub set_data {
my $data = YAML::Load($self->data);
$data->{$_} = $data{$_} for keys %data;
$self->data(YAML::Dump($data));
my $data = YAML::Load($self->data);
$data->{$_} = $data{$_} for keys %data;
$self->data(YAML::Dump($data));
+
+ $self;
}
sub validate {
}
sub validate {