ARSObject
view release on metacpan or search on metacpan
lib/ARSObject.pm view on Meta::CPAN
my ($i, @a) =(1);
while (@a =caller($i)) {
return(0) if $a[0] =~/^(?:PerlEx::|Apache::Perl|Apache::Registry|Apache::ROOT)/i;
return(1) if $a[3] eq '(eval)';
$i +=1;
}
$^S
}
# error message form ??? use ???
# (err/var, command, operation, function, args)
sub efmt {
efmt1(@_)
}
sub efmt0 {
my ($s, $e, $c, $o, $f, @a) =@_;
cpcon($s
,join(': '
,($c ? $c : ())
,($f ? $f .'(' .join(',', map {$s->dsquot($_)} @a) .')' : ())
lib/ARSObject.pm view on Meta::CPAN
.(ref($a{-recipient}) ? join(', ', (map { !$_ ? () : /<\s*([^<>]+)\s*>/ ? $1 : $_ } @{$a{-recipient}})) : $a{-recipient}) ."' -> " .($s->smtp->message()||'?')));
$s->smtp->data($a{-data})
||return(&{$s->{-die}}("SMTP data '" .$a{-data} ."' -> " .($s->smtp->message()||'?')));
my $r =$s->smtp->dataend()
||return(&{$s->{-die}}("SMTP dataend -> " .($s->smtp->message()||'?')));
$r ||1;
}
sub soon { # Periodical execution of this script
# (minutes ||sub{}, ?log file, ?run command, ?soon command)
# minutes: undef - clear sched, run once || sub{} -> number
# log file: empty || full file name || var file name
# run command: empty || 'command line' || [command line] || sub{}
# soon command: empty || 'command line' || [command line] || []
# empty run command - only soon command will be scheduled
# empty soon command - sleep(minutes*60) will be used
# !defined(minutes) - soon command will be deleted from schedule
# and run command will be executed once
# [soon command,... [arg,...],...] - schedule cleaning hint:
# join(' ',@{[soon,...arg]}) used to clean schedule
# join('', @{[arg,...]}) used in soon command
my ($s, $mm, $lf, $cr, $cs) =@_;
$lf =$s->vfname($lf) if $lf && ($lf !~/[\\\/]/);
my $wl;
if (ref($cs) ? scalar(@$cs) : $cs) {
return(&{$s->{-die}}("MSWin32 required for `at` in soon()\n"))
if $^O ne 'MSWin32';
if (defined($mm) && ($^O eq 'MSWin32') && eval('use Win32::Event; 1')) {
# MSDN: 'CreateEvent', 'Kernel Object Namespaces'
my $q =_sooncl($s, $cs, 1);
my $n =$q;
lib/ARSObject.pm view on Meta::CPAN
print("Error $!\n");
$s->fstore(">>$lf", $s->strtime() ."\t$$\t$!\n")
if $lf;
}
}
$r
}
sub _sooncl { # soon() command line former
my ($s, $cs, $q) =@_;
my $nc;
my $qry =$cs;
if (ref($cs)) {
return(&{$s->{-die}}("MSWin32 required for `at` in soon()\n"))
if $^O ne 'MSWin32';
$cs->[0] =Win32::GetFullPathName($cs->[0])
if ($^O eq 'MSWin32') && ($cs->[0] !~/[\\\/]/);
$cs->[0] = $cs->[0]=~/^(.+?)[^\\\/]+$/ ? $1 .'perl.exe' : $cs->[0]
if $cs->[0] =~/\.dll$/i;
lib/ARSObject.pod view on Meta::CPAN
(C<Utility Objects>)
Connect to L<DBI|DBI> database using C<-dbiconnect>.
=item dbido (dbi do args, , ?-echo=>1) -> dbi do result
(C<Utility Objects>)
Execute L<DBI|DBI> 'do' using C<dbi>.
Use -echo=>1 to output command to STDOUT.
=item dbidsmetasync (-echo => 0 || 1)
(C<Metadata>, C<SQL Data Store Methods>)
Sync SQL Data Store schema with metadata generated by C<arsmetasql>().
Uses C<dbi>(), C<-meta-sql>, C<-sqlschema>.
Calls C<dbido>('CREATE TABLE...') and C<dbido>('ALTER TABLE...').
lib/ARSObject.pod view on Meta::CPAN
(C<Error Processing and Echo>)
Last L<DBI|DBI> error, <dbi>->errstr
=item dbiquery (dbi query args, ?-echo=>1) -> dbi cursor object
(C<Utility Objects>)
Query L<DBI|DBI> database using C<dbi>, 'prepare', 'execute'.
Use -echo=>1 to output command to STDOUT.
=item dscmp (data1, data2) -> cmp
(C<Utility Methods>)
Compare two data structures alike L<cmp|perlop>.
lib/ARSObject.pod view on Meta::CPAN
Parameters:
-form | -from | -schema => schema or form name
-id => entryId
-fields => [internalId | fieldName,...]
-for => {} # steady hash to store each entry fetched
-echo=>1 # output command to STDOUT
=item entryBLOB (-form=>form, -id=>entryId, -field=>fieldId|fieldName) -> data
=item entryBLOB (..., -set=>data) -> id
=item entryBLOB (..., -file=>path, ?-set=>1) -> id
(C<ARS methods>)
Retrieve BLOB field using ARS::ars_GetEntryBLOB()
or update BLOB field using C<entryUpd>().
Parameters:
-form | -schema | -from | -into => schema or form name
-id=>entryId
-echo=>1 # output command to STDOUT
-field=>fieldId | fieldName
-file=>path, -set=>boolean # when using file for BLOB field data
-set=>data # when updating BLOB field from scalar data
=item entryDel (-form=>form, -id=>entryId, ?-echo=>1) -> id
(C<ARS methods>)
Delete record into ARS using ARS::ars_DeleteEntry().
Parameters:
-form | -into | -schema => schema or form name
-id=>entryId
-echo=>1 # output command to STDOUT
=item entryDif ({old field => value,...}, {new field => value,...}, ?exclude empty) -> {values to update} | undef
(C<ARS methods>)
Distinguish the difference between two hashes of field => value.
Returns undef when no difference.
lib/ARSObject.pod view on Meta::CPAN
Insert new record into ARS using ARS::ars_CreateEntry().
Field names are translated to ids using C<-metadn>/C<-meta>.
Field values are translated with C<strIn> when C<-strFields>.
Specially for 'HPD:Help Desk': 'Incident Number' value will be generated if it is 1.
Parameters:
-form | -into | -schema => schema or form name
-echo=>1 # output command to STDOUT
field === internalId | fieldName
=item entryNew (-form=>form, field=>value,...) -> {field=>value,...}
(C<ARS methods>)
Form field => value hash for a new ARS record using values given and default values in C<-meta>.
This may be not needed, C<entryIns> may be sufficient.
lib/ARSObject.pod view on Meta::CPAN
(C<ARS methods>)
Update record into ARS using ARS::ars_SetEntry().
Field names are translated to ids using C<-metadn>/C<-meta>.
Field values are translated with C<strIn> when C<-strFields>.
Parameters:
-form | -into | -schema => schema or form name
-id=>entryId
-echo=>1 # output command to STDOUT
field === internalId | fieldName
=item fdirls (?-opt, path, ? filter sub{}(self, path, $_ =entry)) -> (entry,...)
=item fdirls (..., []) -> [entry,...]
(C<Utility Methods>)
lib/ARSObject.pod view on Meta::CPAN
=item smtpsend (-from || -sender => name, -to || -recipient => [name,...], -data => smtp data || (-subject => string, -text || -html => text)) -> Net::SMTP::dataend
(C<Utility Objects>)
Send L<Net::SMTP|Net/SMTP> e-mail using C<smtp>.
=item soon (minutes number || sub{}, logfile ||'', run command || [command line] || sub{}, soon command || [command line] || [])
=item soon (minutes number || sub{}, logfile ||'', run command || [command line] || sub{})
=item soon (minutes number || sub{}, logfile ||'', '', soon command || [command line])
Execute the script periodically, run command immediately, soon command after delay specified.
Log file name may be full file name, else C<vfname>(file name) will be used.
If run command is empty, soon command will be scheduled.
If soon command is empty, sleep(minutes*60) will be used, otherwise 'at' MSWin32 scheduling command.
If !defined(minutes), soon command will be deleted from schedule and run command will be executed once.
=item sqlname (formName, ?fieldName, ?forceMetaUpd) -> sql name
(C<Metadata>, C<SQL Data Store Methods>)
Get SQL Data Store table or column name converted from ARS form and field name.
Used by C<arsmetasql>().
Uses C<-sqlname>, C<-sqlntbl>, C<-sqlncol>, C<-sqlninc> settings.
( run in 4.949 seconds using v1.01-cache-2.11-cpan-fe3c2283af0 )