#!/usr/bin/perl package wcatp; ###################################################################### +################################ # wcatp.pl + # # + # # This Perl script executes the ATP.pm controller module. + # + # + # # Created April 2007. + # # Programmer: + # # + # # You must pass one of the following as an argument: + # # 1 - All (entire process, note that current business rules dicate on +ly 1 run per day) # # 2 - Preprocess (everything but submission of eligible files) + # # 3 - Upload Override (no submissions, upload to Mainframe only) + # # 4 - Diagnostics Only (Diagnostics distributed via email only) + # # + # # Maintenance/Notes + # # ----------------- + # # 04/26/2007 - Initial Release (Version 1.0). NJB. + # ###################################################################### +################################ $VERSION = '1.0'; use lib '/workerscomp/sharedatp/modules'; use strict; use warnings; #Comment out prior to moving code to Production use ATP; my $runMode = $ARGV[0]; print "wcatp.pl - Run argument is $runMode\n"; my $returnCode; eval { my $objATP = ATP->new('wcatp','/workerscomp/wcatp'); $returnCode = $objATP->runProcess($runMode); }; if ($@) { print "$@\n"; exit 1; } else { if ($returnCode) { print "wcatp.pl - Execution completed successfully.\n"; exit 0; } else { print "wcatp.pl - Execution completed with handled errors, see + logging for details...\n"; exit 1; } } #!/usr/bin/perl package ATP; ###################################################################### +################################ # ATP.pm + # # + # # This Perl module is the main controller of the Automated Transactio +n Processing system. # + # + # # Created April 2007. + # # Programmer: + # # + # # Public Interface + # # ---------------- + # # new - Instantiate the object. You must pass the following paramete +rs as scalars: # # systemName - System name, e.g. wcatp. + # # baseDir - Base directory of installation. + # # + # # runProcess - Runs the process based upon the following parameter pa +ssed as a scalar: # # mode - 1 - All (entire process, note that current busi +ness rules dicate only 1 run # # per day) + # # 2 - Preprocess (everything but submission of el +igible files) # # 3 - Upload Override (no submissions, upload to +Mainframe only) # # 4 - Diagnostics Only (Diagnostics distributed v +ia email only) # # + # # Maintenance/Notes + # # ----------------- + # # 04/26/2007 - Initial Release (Version 1.0). NJB. + # ###################################################################### +################################ $VERSION = '1.0'; use strict; use warnings; #Comment out prior to moving code to Production use FDX; use FTP; use FileToObject; use TLProcessor; use Utils; use Zip; use ATPLogger; use ValidationManager; use TransactionBuilder; ### Public Methods ### ### Method new (constructor) ### sub new { my ($proto,$systemName,$baseDir) = @_; my $class = ref($proto) || $proto; my $self = {}; bless $self, $class; # set instance variables from caller $self->{_systemName} = $systemName || die "ATP.pm - System name no +t passed!"; $self->{_baseDir} = $baseDir || die "ATP.pm - Base directory + not passed!"; $self->{_objFileToObjectInitial} = FileToObject->new('2'); # insta +ntiate FileToObject in noLog mode -- can't log properly until params +from config are loaded # obtain configuration file information my %configArgs = ( file => $self->{_baseDir} . '/config/' . $self-> +{_systemName} . '.cfg', returnObject => '3', delimiter => '3' ); my %config = $self->{_objFileToObjectInitial}->load(%configArgs); # set instance variables from config file $self->{_logMode} = $config{logmod +e}; $self->{_standardOut} = $config{standa +rdout}; $self->{_standardErr} = $config{standa +rderr}; $self->{_historyLog} = $config{histor +ylog}; $self->{_region} = $config{region +}; $self->{_bypassSFTP} = $config{bypass +sftp}; $self->{_sftpServer} = $config{sftpse +rver}; $self->{_sftpUid} = $config{sftpui +d}; $self->{_sftpPwd} = $config{sftppw +d}; $self->{_sftpLocalIn} = $config{sftplo +calin}; $self->{_temp} = $config{temp}; $self->{_sftpRemoteCD} = $config{sftpre +motecd}; $self->{_textFiles} = $config{textfi +les}; $self->{_bypassPGP} = $config{bypass +pgp}; $self->{_pgpServer} = $config{pgpser +ver}; $self->{_pgpUID} = $config{pgpuid +}; $self->{_pgpPWD} = $config{pgppwd +}; $self->{_pgpDirTemp} = $config{pgpdir +temp}; $self->{_pgpRetries} = $config{pgpret +ries}; $self->{_pgpSleepInterval} = $config{pgpsle +epinterval}; $self->{_highLevelNode} = $config{highle +velnode}; $self->{_mfServer} = $config{mfserv +er}; $self->{_mfUID} = $config{mfuid} +; $self->{_mfPWD} = $config{mfpwd} +; $self->{_localTransferred} = $config{localt +ransferred}; $self->{_dirTemp} = $config{dirtem +p}; $self->{_mfRetries} = $config{mfretr +ies}; $self->{_mfSleepInterval} = $config{mfslee +pinterval}; $self->{_localParentDir} = $config{localp +arentdir}; $self->{_remoteRunJCLPDS} = $config{remote +runjclpds}; $self->{_remoteSubmissionFileRecordFormat} = $config{remote +submissionfilerecordformat}; $self->{_remoteSubmissionFileLogicalRecordLength} = $config{remote +submissionfilelogicalrecordlength}; $self->{_serverSMTP} = $config{server +smtp}; $self->{_subjectBiz} = $config{subjec +tbiz}; $self->{_subjectPSupport} = $config{subjec +tpsupport}; $self->{_toBiz} = $config{tobiz} +; $self->{_toPSupport} = $config{topsup +port}; $self->{_ccBiz} = $config{ccbiz} +; $self->{_ccPSupport} = $config{ccpsup +port}; $self->{_fromBiz} = $config{frombi +z}; $self->{_fromPSupport} = $config{fromps +support}; $self->{_tempDir} = $config{tempdi +r}; my %argsLogger = ( logMode => $self->{_logMode}, standardOut => $self->{_standardOut}, standardErr => $self->{_standardErr}, historyLog => $self->{_historyLog} ); $self->{_objLogger} = ATPLogger->new(%argsLogger); # instantiate l +ogger $self->{_objJCL} = JCL->new(); # instantiate JCL $self->{_objFileToObject} = FileToObject->new(); # instantiate fil +e to object # instance variables for jcl data stored in objects $self->{_allSteps} = undef; $self->{_allProjRes} = undef; $self->{_jobCard} = undef; return $self; } ### Method runProcess ### sub runProcess { my ($self,$mode) = @_; ### FIX this GHKHHJGHJKHJKHKHHJKLNKL)()()()()()()()()()()()()()()( +GHHGJHGJBJHMB print STDOUT "argv 0 is $ARGV[0]\n"; if (defined($mode)) { # general setup $self->setup(); if ($mode eq '4') { # run diagnostics only $self->execDiagnostics(); return 1; } else { if (($mode ne '1') && ($mode ne '2') && ($mode ne '3')) { my $message = 'ATP.pm - Mode ' . $mode . 'is invalid!' +; $self->{_objLogger}->error($message); exit 0; } else { # run process $self->processController($mode); return 1; } } } else { die "ATP.pm - Run mode was not passed!"; } } ### Private Methods ### ### Method DESTROY (destructor) ### #sub DESTROY #{ #} ### Method setup ### sub setup { my ($self) = @_; # load JCL and Job Card files in objects $self->loadJCLObjects(); } ### Method loadJCLObjects ### sub loadJCLObjects { my ($self) = @_; my %custJCLArgs = ( file => $self->{_baseDir} . '/config/' . $self- +>{_systemName} . '_jcl.list', returnObject => '2', delimiter => '2' ); my @file = $self->{_objFileToObject}->load(%custJCLArgs); $self->{_allSteps} = \$self->{_objJCL}->genAllSteps(@file); $self->{_allProjRes} = \$self->{_objJCL}->genAllProjRes(@file); my %jobCardArgs = ( file => $self->{_baseDir} . '/config/' . $s +elf->{_systemName} . '_jobcard.list', returnObject => '3', delimiter => '3' ); $self->{_jobCard} = \$self->{_objFileToObject}->load(%jobCardArgs) +; return 1; } ### Method processController ### sub processController { my ($self, $mode) = @_; if (! $self->{_bypassSFTP} =~ /y/i) { # download all files from SecureFTP my %argsSecureFTP = ( site => $self->{_sftpServer}, uid => $self->{_sftpUid}, pwd => $self->{_sftpPwd}, localIn => $self->{_sftpLocalIn}, localTemp => $self->{_sftpLocalTemp}, remoteCD => $self->{_sftpRemoteCD} ); my $objFDX = FDX->new(%argsSecureFTP); $objFDX->receiveAll(1); # dynamically move/unzip files my $objZip = Zip->new(); my %argsZip = ( sourceDir => $self->{_sftpLocalIn}, targetDir => $self->{_textFiles}, errorDir => $self->{_temp} ); $objZip->moveAll(%argsZip); } if (! $self->{_bypassPGP} =~ /y/i) { # download all files from PGP my %argsPGP = ( site => $self->{_pgpServer}, uid => $self->{_pgpUID}, pwd => $self->{_pgpPWD}, localTransferred => undef, dirTemp => $self->{_pgpDirTemp}, retries => $self->{_pgpRetries}, sleepInterval => $self->{_pgpSleepInterval} ); my $objPGP = FTP->new(%argsPGP); my %argsGet = ( remoteCD => 'IN', mode => '1', regex => '/!pgp$/ && /!asc$/i', ); $objPGP->getAll(%argsGet); } # validation manager to call application specific validations or d +o nothing my $objValidationManager = ValidationManager->new(); my %argsValidationManager = { baseDir => $self->{_baseDir} }; $objValidationManager->validate(%argsValidationManager); if ($mode ne '2') { # transaction builder to build transactions my $sourceDir = $self->{_baseDir} . '/textfiles'; my $targetParentDir = $self->{_baseDir} . '/transactions'; my $objTransBuilder = TransactionBuilder->new(); my $bypassSubmission; if ($mode eq '3') { $bypassSubmission = '2'; } else { $bypassSubmission = '1'; } my %argsTransBuilder = ( exceptionFile => $self->{_baseDir} . '/config/' + . $self->{_systemName} . '_exception.list', processedFile => $self->{_baseDir} . '/config/' + . $self->{_systemName} . '_processed.list', jCLfile => $self->{_baseDir} . '/config/' + . $self->{_systemName} . '_jcl.list', jobCardFile => $self->{_baseDir} . '/config/' + . $self->{_systemName} . '_jobcard.list', sourceDir => $sourceDir, targetParentDir => $targetParentDir, bypassSubmission => $bypassSubmission, highLevelNode => $self->{_highLevelNode} ); $objTransBuilder->generateTransactions(%argsTransBuilder); # FTP files in transactions to the mainframe, submitting same +when applicable my %argsFTP = ( site => $self->{_mfServer}, uid => $self->{_mfUID}, pwd => $self->{_mfPWD}, localTransferred => $self->{_localTransferred}, dirTemp => $self->{_dirTemp}, retries => $self->{_mfRetries}, sleepInterval => $self->{_mfSleepInterval} ); my $objFTP = FTP->new(%argsFTP); my %argsSend = ( localParentDir => $self->{_lo +calParentDir}, remoteRunJCLPDS => $self->{_re +moteRunJCLPDS}, remoteSubmissionFileRecordFormat => $self->{_re +moteSubmissionFileRecordFormat}, remoteSubmissionFileLogicalRecordLength => $self->{_re +moteSubmissionFileLogicalRecordLength} ); $objFTP->sendTransactions(%argsSend); } # send emails out and close logging my %email = ( serverSMTP => $self->{_serverSMTP}, subjectBiz => $self->{_subjectBiz}, subjectPSupport => $self->{_subjectPSupport}, toBiz => $self->{_toBiz}, toPSupport => $self->{_toPSupport}, ccBiz => $self->{_ccBiz}, ccPSupport => $self->{_ccPSupport}, fromBiz => $self->{_fromBiz}, fromPSupport => $self->{_fromPSupport}, tempDir => $self->{_tempDir} ); $self->{_objLogger}->sendEmail(%email); } ### Method execDiagnostics ### sub execDiagnostics { my ($self) = @_; $self->{_objLogger}->info("ATP.pm - Diagnostics not yet implemente +d..."); return 1; } 1;
In reply to Re: ARGV array getting shifted
by nbhar
in thread ARGV array getting shifted
by nbhar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |