locals bDoOnce : boolean; sFixScript : string; sUndoScript : string; s1 : string; s2 : string; sDate : string; sTime : string; args : string; path : string; bFixable : boolean; nNoFix : integer; bNoPage : boolean; bPreReg : boolean; nPreReg : integer; nNoPage : integer; sPath : string; nMaxProjId : integer; sErrLog : string; sFixLog : string; sRevName : string; nCount : integer; sStem : string; sVaultName : string; bOK : boolean; errmess : string; projid : integer; cur3 : integer; cur2 : integer; cur : integer begin let sUndoScript = "crdterrsundo.sql@@TEST" let sFixScript = "crdterrs.sql@@TEST" let sErrLog = "crdtnotfixable.csv@@TEST" let sFixLog = "crdtfixable.csv@@TEST" System delete sErrLog EndSystem System delete sFixLog EndSystem System delete sFixScript EndSystem System delete sUndoScript EndSystem openout sErrLog gosub OutputHeader closeout openout sFixLog gosub OutputHeader closeout let projid = 762 -- should be 1 let projid = 1 let nCount = 0 let nNoFix = 0 let nPreReg = 0 let nNoPage = 0 -- Get The Max Project ID SQL execute cur "SELECT MAX(ID) FROM EDMPROJECTS" EndSQL SQL fetch cur nMaxProjId EndSQL SQL break cur --let nMaxProjId = 765 -- ******************* -- Loop Around Projects while projid <= nMaxProjId loop SQL execute cur "SELECT PROJECT, PASSWD FROM EDMPROJECTS WHERE ID=:projid AND STATUS=1" EndSQL SQL fetch cur PROJ_hidname PROJ_hidpass EndSQL SQL break cur if Qerrorno = 0 then let PROJ_login = true -- Log on to a project let PROJ_hidden = true -- Use PROJ_name rather than inquire from the user run SQLlogin.hcl@@EDMutils -- connect to DB if not Qdblogged then -- logged on to RDB account let errmess = @(76187,PROJ_hidname) -- Failed to connect to project ^1. lprint errmess run SQLlogin.hcl@@EDMutils -- connect to DB else gosub Checkdrawings endif endif let projid = projid + 1 if rem(projid ,50) = 0 then mprint "Processed(" projid ")" nl endprint endif endloop openout sErrLog mprint "**************************************************" nl "Revisions with null dates," nCount nl "Number of Errors Not fixable," nNoFix nl "Number of Pre-Registered," nPreReg nl "NUmber of Revision with No Page," nNoPage nl "**************************************************" nl endprint closeout goto EXIT ------------------------------------------------------------------------- label Checkdrawings let bDoOnce = true -- get the drawing class vaults SQL execute cur "SELECT NAME, STEM FROM VAULTS WHERE CLASS='draw'" EndSQL let bOK = (Qerrorno = 0) while bOK loop SQL fetch cur sVaultName QEDMvaultstem EndSQL let bOK = (Qerrorno = 0) if bOK then SQL execute cur2 "SELECT ID, PAGE, NAME FROM :QEDMvaultstem:_PR WHERE created is null" EndSQL SQL fetch cur2 QEDMprid QEDMpgid sRevName EndSQL while Qerrorno = 0 loop let bFixable = false -- **************** if QEDMpgid = 0 then SQL execute cur3 "select ID from :QEDMvaultstem:_PG where latest = :QEDMprid:" EndSQL SQL fetch cur3 QEDMpgid EndSQL SQL break cur3 endif -- **************** EDM get page if Qok then let bNoPage = false else let bNoPage = true let nNoPage = nNoPage + 1 endif EDM get pagerev if Qok then runa getxdata.hcl@@CLASS_draw ( true ) -- Check if pre-registered Function path QEDMprlocation sPath if QEDMprlocation = "" then let bPreReg = true let nPreReg = nPreReg + 1 else let bPreReg = false endif if bNoPage or bPreReg then let nNoFix = nNoFix + 1 else let bFixable = true endif else let nNoFix = nNoFix + 1 endif let nCount = nCount + 1 -- -- Dump out the fixable pages -- let sDate = "" let sTime = "" if bFixable then if QEDMprlocation /= "" then let EDM_File1 = QEDMprlocation run GetPrim.hcl@@EDMutils if EDM_ok1 then let path = "getdate.exe@@TEST" let s1 = EDM_File1 let s2 = "getdate.txt@@TEST" Function path s1 s1 Function path s2 s2 let args = s1 + ' ' + s2 + ' &&&' System runprog path args EndSystem openin s2 if Qok then Get - sDate Get - sTime endif closein endif endif openout sFixLog gosub OutputDetails closeout openout sFixScript if bDoOnce then let bDoOnce = false mprint "CONNECT " PROJ_hidname "/" PROJ_hidpass "@EDMCOR;" nl endprint endif mprint "UPDATE " QEDMvaultstem "_PR SET CREATED='" sDate "'" ",NAME='" QEDMpgname "_" Vr_draw_REVISION "'" ",STATUS=1" " WHERE ID = " QEDMprid ";" nl endprint closeout openout sUndoScript mprint "UPDATE " QEDMvaultstem "_PR SET CREATED=null" ",NAME=null" ",STATUS=0" " WHERE ID = " QEDMprid ";" nl endprint closeout else -- -- These pages are not fixable -- openout sErrLog gosub OutputDetails closeout endif SQL fetch cur2 QEDMprid QEDMpgid sRevName EndSQL endloop SQL break cur2 endif endloop SQL break cur return ------------------------------------------------------------------------- label OutputHeader mprint "Project," "Vault," "Stem," "QEDMpgid," "QEDMpgsecurity," "QEDMpgwriter," "QEDMpgdocument," "QEDMpglatest," "QEDMpgname," "QEDMpgsnap," "QEDMpgkind," "QEDMpgicon," "QEDMpgissue," "QEDMpgdoctype," "Vg_draw_NAME," "Vg_draw_DRG_ACTIV," "QEDMprid," "QEDMprname," "QEDMprdesc," "QEDMprnum," "QEDMprcreated," "QEDMprlocation," "QEDMprlocation," "File Date," "File Time," "QEDMprstatus," "QEDMprattach," "QEDMprxref," "QEDMpricon1," "QEDMpricon2," "QEDMpricon3," "QEDMpricon4," "Vr_draw_REVISION," "Vr_draw_SCALE," "Vr_draw_DOC_SIZE," "Vr_draw_ORIGIN," "Vr_draw_TRANSMITTAL," "Vr_draw_REQUIRED," "Vr_draw_AUTHOR," "Vr_draw_CADNAME," "Vr_draw_STATUS," "Vr_draw_PACKAGE," "Vr_draw_SHEET," "Vr_draw_ARCHIVE," "Vr_draw_TIME," "Vr_draw_ALTERNATIVE," "Vr_draw_PLOTNAME," "Vr_draw_ORIG_CODE," "Vr_draw_REASON7," "Vr_draw_RECEIVED," "Vr_draw_ISSUED," "Vr_draw_INPUTBY," nl endprint return ------------------------------------------------------------------------- label OutputDetails mprint PROJ_hidname "," sVaultName "," QEDMvaultstem "," QEDMpgid "," QEDMpgsecurity "," QEDMpgwriter "," QEDMpgdocument "," QEDMpglatest "," QEDMpgname "," QEDMpgsnap "," QEDMpgkind "," QEDMpgicon "," QEDMpgissue "," QEDMpgdoctype "," Vg_draw_NAME "," Vg_draw_DRG_ACTIV "," QEDMprid "," QEDMprname "," QEDMprdesc "," QEDMprnum "," QEDMprcreated "," QEDMprlocation "," sPath "," sDate "," sTime "," QEDMprstatus "," QEDMprattach "," QEDMprxref "," QEDMpricon1 "," QEDMpricon2 "," QEDMpricon3 "," QEDMpricon4 "," Vr_draw_REVISION "," Vr_draw_SCALE "," Vr_draw_DOC_SIZE "," Vr_draw_ORIGIN "," Vr_draw_TRANSMITTAL "," Vr_draw_REQUIRED "," Vr_draw_AUTHOR "," Vr_draw_CADNAME "," Vr_draw_STATUS "," Vr_draw_PACKAGE "," Vr_draw_SHEET "," Vr_draw_ARCHIVE "," Vr_draw_TIME "," Vr_draw_ALTERNATIVE "," Vr_draw_PLOTNAME "," Vr_draw_ORIG_CODE "," Vr_draw_REASON7 "," Vr_draw_RECEIVED "," Vr_draw_ISSUED "," Vr_draw_INPUTBY nl endprint return ------------------------------------------------------------------------- label EXIT end