X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fqueue.pm;h=1f2abe3ae4ef3e2b640ca04ce8c1fd0634f64731;hb=9f64bfef652922b7b546a12290805710acbeed08;hp=5f8bf11f037f8855f00ba1b2f13b167934e24a3c;hpb=c648976f0b7975f2328ebd7ba8c711fad0ca4195;p=freeside.git diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm index 5f8bf11f0..1f2abe3ae 100644 --- a/FS/FS/queue.pm +++ b/FS/FS/queue.pm @@ -3,6 +3,8 @@ package FS::queue; use strict; use vars qw( @ISA @EXPORT_OK $DEBUG $conf $jobnums); use Exporter; +use MIME::Base64; +use Storable qw( nfreeze thaw ); use FS::UID qw(myconnect); use FS::Conf; use FS::Record qw( qsearch qsearchs dbh ); @@ -48,17 +50,40 @@ FS::Record. The following fields are currently supported: =over 4 -=item jobnum - primary key +=item jobnum -=item job - fully-qualified subroutine name +Primary key -=item status - job status +=item job -=item statustext - freeform text status message +Fully-qualified subroutine name -=item _date - UNIX timestamp +=item status -=item svcnum - optional link to service (see L) +Job status (new, locked, or failed) + +=item statustext + +Freeform text status message + +=item _date + +UNIX timestamp + +=item svcnum + +Optional link to service (see L). + +=item custnum + +Optional link to customer (see L). + +=item secure + +Secure flag, 'Y' indicates that when using encryption, the job needs to be +run on a machine with the private key. + +=cut =back @@ -91,7 +116,7 @@ created (see L). #false laziness w/part_export.pm sub insert { - my $self = shift; + my( $self, @args ) = @_; local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; @@ -104,16 +129,26 @@ sub insert { local $FS::UID::AutoCommit = 0; my $dbh = dbh; + my %args = (); + { + no warnings "misc"; + %args = @args; + } + + $self->custnum( $args{'custnum'} ) if $args{'custnum'}; + my $error = $self->SUPER::insert; if ( $error ) { $dbh->rollback if $oldAutoCommit; return $error; } - foreach my $arg ( @_ ) { + foreach my $arg ( @args ) { + my $freeze = ref($arg) ? 'Y' : ''; my $queue_arg = new FS::queue_arg ( { 'jobnum' => $self->jobnum, - 'arg' => $arg, + 'frozen' => $freeze, + 'arg' => $freeze ? encode_base64(nfreeze($arg)) : $arg,# always freeze? } ); $error = $queue_arg->insert; if ( $error ) { @@ -223,11 +258,12 @@ Returns a list of the arguments associated with this job. sub args { my $self = shift; - map $_->arg, qsearch( 'queue_arg', - { 'jobnum' => $self->jobnum }, - '', - 'ORDER BY argnum' - ); + map { $_->frozen ? thaw(decode_base64($_->arg)) : $_->arg } + qsearch( 'queue_arg', + { 'jobnum' => $self->jobnum }, + '', + 'ORDER BY argnum' + ); } =item cust_svc