TrinDeleteContracts
From Pickwiki
HomePage>>SourceCode>>BasicSource>>InfoLease
This is an extremely dangerous program! Make sure you are in the right account, on the right machine, and you know what it is doing!
It will take several seconds per contract, so be prepared for an evening or weekend run.
*************************************************************************** * Program: TRIN.DELETE.CONTRACTS * Author : mcgowan * Date : 05/14/2002 * Edited : 15:58:40 May 28 2002 By MCGOWAN * Comment: *************************************************************************** * Date By Desc * ---------- ---- --------------------------------------------------------- OPEN 'LS.MASTER' TO LS.MASTER ELSE ABORT OPEN 'LS.MASTER,LS.BILLING' TO LS.BILLING ELSE ABORT OPEN 'CS.MASTER,CS.APPLICATIONS' TO CS.APPLICATIONS ELSE ABORT OPEN 'CS.MASTER,CS.CONTRACTS' TO CS.CONTRACTS ELSE ABORT OPEN 'TRIN.DELETE.CONTRACT.LOG' TO DELETE.LOG ELSE ABORT PRINT 'This program will *DELETE* all contracts in the save list DEL.CONTRACTS' PRINT 'Are you sure (Y[[/N]])': INPUT YORN IF YORN # 'Y' THEN STOP * Make sure there are no locks present PRINT 'Have all locks been cleared (YES[[/N]])': INPUT YORN IF YORN # 'YES' THEN STOP COMO=\DELETE.CONTRACTS.\:TIME() EXECUTE \COMO ON \:COMO E=\GET.LIST DEL.CONTRACTS\ PRINT E EXECUTE E RTNLIST L1 CTR=0 ; TOT.TM=0 LOOP READNEXT CONTRACT FROM L1 ELSE EXIT T1=TIME() PRINT TIMEDATE():" ":CONTRACT:" deleting ":CTR GOSUB DELETE.CONTRACT PRINT TIMEDATE():" ":CONTRACT:" done" T2=TIME() CTR+=1 TM=T2-T1 TOT.TM+=TM PRINT TM:' seconds to delete, Average: ':TOT.TM[[/CTR]] REPEAT PRINT 'Done' EXECUTE \COMO OFF \:COMO STOP DELETE.CONTRACT: LESSOR=CONTRACT[1,3] SCHEDULE=CONTRACT[5,11] * 1 is for maintenance, 0 for inquiry DATA 1 * Not sure what the next three are for DATA "" DATA "" DATA "" DATA LESSOR DATA SCHEDULE * "D" for delete DATA "D" * "Y", why yes I do want to delete DATA "Y" * If there are active assets there will be another question READV NUM.OF.ASSETS FROM LS.BILLING, CONTRACT, 9 ELSE STOP 'CANNOT READ LS.BILLING:':CONTRACT IF NUM.OF.ASSETS > 0 THEN PRINT "There are active assets" DATA "Y" END * If this is the last contract for this cust, there will be a question READV CCAN FROM LS.MASTER, CONTRACT, 13 ELSE STOP 'CANNOT READ LS.MASTER:':CONTRACT READ APP.REC FROM CS.APPLICATIONS, CCAN ELSE APP.REC='' READ POINTER.REC FROM CS.CONTRACTS, CCAN ELSE STOP 'CANNOT READ CS.POINTERS:':CCAN * The count includes active and disposed, and we need to check for apps CONTRACT.COUNT=DCOUNT(POINTER.REC<1>,@VM)+DCOUNT(POINTER.REC<2>,@VM) IF CONTRACT.COUNT = 1 THEN IF APP.REC<1> = "" THEN PRINT "This is the last contract, there are no apps" DATA "Y" END END * The final cut DATA "" EXECUTE \CMAINT.00\\ RETURN