Lines 96-107
Return the job_id of the newly created job.
Link Here
|
96 |
sub enqueue { |
96 |
sub enqueue { |
97 |
my ( $self, $params ) = @_; |
97 |
my ( $self, $params ) = @_; |
98 |
|
98 |
|
99 |
my $job_type = $self->job_type; |
99 |
my $job_type = $self->job_type; |
100 |
my $job_size = $params->{job_size}; |
100 |
my $job_size = $params->{job_size}; |
101 |
my $job_args = $params->{job_args}; |
101 |
my $job_args = $params->{job_args}; |
102 |
my $job_queue = $params->{job_queue} // 'default'; |
102 |
my $job_context = $params->{job_context} // C4::Context->userenv; |
|
|
103 |
my $job_queue = $params->{job_queue} // 'default'; |
103 |
|
104 |
|
104 |
my $borrowernumber = (C4::Context->userenv) ? C4::Context->userenv->{number} : undef; |
105 |
my $borrowernumber = (C4::Context->userenv) ? C4::Context->userenv->{number} : undef; |
|
|
106 |
$job_context->{interface} = C4::Context->interface; |
107 |
my $json_context = encode_json $job_context; |
105 |
my $json_args = encode_json $job_args; |
108 |
my $json_args = encode_json $job_args; |
106 |
|
109 |
|
107 |
$self->set( |
110 |
$self->set( |
Lines 111-116
sub enqueue {
Link Here
|
111 |
queue => $job_queue, |
114 |
queue => $job_queue, |
112 |
size => $job_size, |
115 |
size => $job_size, |
113 |
data => $json_args, |
116 |
data => $json_args, |
|
|
117 |
context => $json_context, |
114 |
enqueued_on => dt_from_string, |
118 |
enqueued_on => dt_from_string, |
115 |
borrowernumber => $borrowernumber, |
119 |
borrowernumber => $borrowernumber, |
116 |
} |
120 |
} |
Lines 162-167
sub process {
Link Here
|
162 |
|
166 |
|
163 |
$args ||= {}; |
167 |
$args ||= {}; |
164 |
|
168 |
|
|
|
169 |
my $context = decode_json($self->context); |
170 |
C4::Context->_new_userenv(-1); |
171 |
C4::Context->interface( $context->{interface} ); |
172 |
C4::Context->set_userenv( |
173 |
$context->{number}, $context->{id}, |
174 |
$context->{cardnumber}, $context->{firstname}, |
175 |
$context->{surname}, $context->{branch}, |
176 |
$context->{branchname}, $context->{flags}, |
177 |
$context->{emailaddress}, undef, |
178 |
$context->{desk_id}, $context->{desk_name}, |
179 |
$context->{register_id}, $context->{register_name} |
180 |
); |
181 |
|
165 |
return $derived_class->process( $args ); |
182 |
return $derived_class->process( $args ); |
166 |
} |
183 |
} |
167 |
|
184 |
|