ACRFXPT ;IHS/OIRM/DSD/AEF - CREATE EXPORT FILE [ 10/27/2004 4:18 PM ]
;;2.1;ADMIN RESOURCE MGT SYSTEM;**13**;NOV 05, 2001
;
;This routine finds and exports the UNIX DHR data file to CORE
;
EN ;EP -- MAIN ENTRY POINT
;
;N ACRDATA,ACRHN,ACRPW,ACRUN,FILE,OUT,Y
;D LIST ;ACR*2.1*13.06 IM14144
;D SEL(.OUT,.Y) ;ACR*2.1*13.06 IM14144
;I $G(OUT) D Q ;ACR*2.1*13.06 IM14144
;. D JCMD^ACRFUTL("rm /usr/spool/afsdata/acr.files") ;ACR*2.1*13.06 IM14144
N ACRDATA,ACRHN,ACRPW,ACRUN,FILE,OUT,Y,ACRDIR ;ACR*2.1*13.06 IM14144
S ACRDIR=$$ARMSDIR^ACRFSYS(1) ;ACR*2.1*13.06 IM14144
D LIST(ACRDIR) ;ACR*2.1*13.06 IM14144
D SEL(.OUT,.Y,ACRDIR) ;ACR*2.1*13.06 IM14144
I $G(OUT) D DEL^ACRFZISH(ACRDIR,"acr.files") Q ;ACR*2.1*13.06 IM14144
S ACRFN=Y
S ACRDATA=$G(^ACRSYS(1,403))
S ACRUN=$P(ACRDATA,U) ;CORE LOGIN NAME
S ACRPW=$P(ACRDATA,U,2) ;CORE PASSWORD
S ACRHN=$P(ACRDATA,U,3) ;CORE HOST NAME
D EXPORT(ACRDIR,ACRFN,ACRUN,ACRPW,ACRHN) ;ACR*2.1*13.06 IM14144
K ^TMP("ACR",$J)
G EN
Q
EXPORT(ACRDIR,ACRFN,ACRUN,ACRPW,ACRHN) ;- EXPORT FILE TO CORE ;ACR*2.1*13.06 IM14144
;
; INPUT:
; ACRDIR = DIRECTORY PATH
; ACRFN = UNIX FILENAME
; ACRUN = CORE LOGIN NAME
; ACRPW = CORE PASSWORD
; ACRHN = CORE HOSTNAME
;
W !
;D TCMD^ACRFUTL("/usr/spool/afsdata/acrdhrsend "_ACRFN_" "_ACRUN_" "_ACRPW_" "_ACRHN) ;ACR*2.1*13.06 IM14144
D TCMD^ACRFUTL(ACRDIR_"acrdhrsend "_ACRFN_" "_ACRUN_" "_ACRPW_" "_ACRHN) ;ACR*2.1*13.06 IM14144
H 2
D PAUSE^ACRFWARN
Q
SEL(OUT,Y,ACRDIR) ; ;ACR*2.1*13.06 IM14144
;----- SELECT FILE TO EXPORT
;
N DIR,X
W !
S DIR(0)="F^3:30"
S DIR("A")="Select FILE for export"
S DIR("?")="Enter file name to export, or '??' for a list of files"
S DIR("??")="^D LIST^ACRFXPT(ACRDIR)" ;ACR*2.1*13.06 IM14144
F D Q:$G(OUT) Q:$G(Y)]""
. D ^DIR
. I $D(DTOUT)!($D(DUOUT)) S OUT=1 Q
. I '$D(^TMP("ACR",$J,"FILES",Y)) D K Y
. . W !,?5,"No such file "_Y
Q
;LIST ;----- LIST UNIX DHR FILES FOR EXPORT ;ACR*2.1*13.06 IM14144
;
;N OUT ;ACR*2.1*13.06 IM14144
;D ^XBKVAR ;ACR*2.1*13.06 IM14144
;S OUT=0 ;ACR*2.1*13.06 IM14144
;D BLD,READ(.OUT) ;ACR*2.1*13.06 IM14144
;Q:$G(OUT) ;ACR*2.1*13.06 IM14144
;S OUT=0 ;ACR*2.1*13.06 IM14144
;D SHOW ;ACR*2.1*13.06 IM14144
;Q ;ACR*2.1*13.06 IM14144
LIST(ACRDIR) ;----- LIST UNIX DHR FILES FOR EXPORT ;ACR*2.1*13.06 IM14144
;
N OUT
D ^XBKVAR
S OUT=0
D BLD(ACRDIR) ;ACR*2.1*13.06 IM14144
D READ(.OUT,ACRDIR) ;ACR*2.1*13.06 IM14144
Q:$G(OUT)
S OUT=0
D SHOW
Q
;
;BLD ;----- BUILD UNIX FILE acr.files ;ACR*2.1*13.06 IM14144
;
;D JCMD^ACRFUTL("ls -l /usr/spool/afsdata/afsdh* > /usr/spool/afsdata/acr.files") ;ACR*2.1*13.06 IM14144
;D JCMD^ACRFUTL("ls -l /usr/spool/afsdata/bar* >> /usr/spool/afsdata/acr.files") ;TO ALLOW SELECTION OF AR FILES TO SEND TO CORE ;ACR*2.1*13.06 IM14144
BLD(ACRDIR) ;----- BUILD UNIX FILE acr.files ;ACR*2.1*13.06 IM14144
D JCMD^ACRFUTL("ls -l "_ACRDIR_"afsdh* > "_ACRDIR_"acr.files") ;ACR*2.1*13.06 IM14144
D JCMD^ACRFUTL("ls -l "_ACRDIR_"bar* >> "_ACRDIR_"acr.files") ;SELECT AR FILES TO SEND TO CORE ;ACR*2.1*13.06 IM14144
Q
READ(OUT,ARCDIR) ; ;ACR*2.1*13.06 IM14144
;----- READ CONTENTS OF UNIX FILE acr.files INTO ^TMP GLOBALS
;
N FILE,I,QUIT,X,Y
K ^TMP("ACR",$J)
;D OPEN^%ZISH("FILE","/usr/spool/afsdata/","acr.files","R") ;ACR*2.1*13.06 IM14144
;I POP W !,"UNABLE TO OPEN acr.files" S OUT=1 Q ;ACR*2.1*13.06 IM14144
;U IO ;ACR*2.1*13.06 IM14144
D HFS^ACRFZISH(ACRDIR,"acr.files","R",.%DEV) ;ACR*2.1*13.06 IM14144
I $G(%DEV)']"" S OUT=1 Q
U %DEV
F I=1:1 D Q:$G(QUIT)
. R X:DTIME I $$STATUS^%ZISH S QUIT=1 Q
. S ^TMP("ACR",$J,"DATA",I,0)=X
D CLOSE^%ZISH("FILE")
S I=0
F S I=$O(^TMP("ACR",$J,"DATA",I)) Q:'I D
. S X=^TMP("ACR",$J,"DATA",I,0)
. S ^TMP("ACR",$J,"FILES",$P($E(X,55,999),"/",5),0)=$TR($E(X,28,40)," ","")_U_$E(X,42,53)_U_$P($E(X,55,999),"/",5)
Q
SHOW ;----- SHOW A LIST OF UNIX DHR FILES
;
N DATA,DIR,FILE,OUT,PAGE
D HOME^%ZIS
W @IOF
S OUT=0
I '$D(^TMP("ACR",$J,"FILES")) W !,"No files to export" Q
S FILE=""
F S FILE=$O(^TMP("ACR",$J,"FILES",FILE)) Q:FILE']"" D Q:$G(OUT)
. I $Y>(IOSL-5) D HDR(.OUT) Q:$G(OUT)
. S DATA=^TMP("ACR",$J,"FILES",FILE,0)
. W !,$J($P(DATA,U),15)
. W ?18,$P(DATA,U,2)
. W ?32,$P(DATA,U,3)
Q
HDR(OUT) ;----- WRITE HEADER
;
N DIR
I $E(IOST)="C",$G(PAGE) S DIR(0)="E" D ^DIR K DIR I 'Y S OUT=1 Q
S PAGE=$G(PAGE)+1
W @IOF
W !,"FILES PENDING EXPORT:"
Q
ACRFXPT ;IHS/OIRM/DSD/AEF - CREATE EXPORT FILE [ 10/27/2004 4:18 PM ]
+1 ;;2.1;ADMIN RESOURCE MGT SYSTEM;**13**;NOV 05, 2001
+2 ;
+3 ;This routine finds and exports the UNIX DHR data file to CORE
+4 ;
EN ;EP -- MAIN ENTRY POINT
+1 ;
+2 ;N ACRDATA,ACRHN,ACRPW,ACRUN,FILE,OUT,Y
+3 ;D LIST ;ACR*2.1*13.06 IM14144
+4 ;D SEL(.OUT,.Y) ;ACR*2.1*13.06 IM14144
+5 ;I $G(OUT) D Q ;ACR*2.1*13.06 IM14144
+6 ;. D JCMD^ACRFUTL("rm /usr/spool/afsdata/acr.files") ;ACR*2.1*13.06 IM14144
+7 ;ACR*2.1*13.06 IM14144
NEW ACRDATA,ACRHN,ACRPW,ACRUN,FILE,OUT,Y,ACRDIR
+8 ;ACR*2.1*13.06 IM14144
SET ACRDIR=$$ARMSDIR^ACRFSYS(1)
+9 ;ACR*2.1*13.06 IM14144
DO LIST(ACRDIR)
+10 ;ACR*2.1*13.06 IM14144
DO SEL(.OUT,.Y,ACRDIR)
+11 ;ACR*2.1*13.06 IM14144
IF $GET(OUT)
DO DEL^ACRFZISH(ACRDIR,"acr.files")
QUIT
+12 SET ACRFN=Y
+13 SET ACRDATA=$GET(^ACRSYS(1,403))
+14 ;CORE LOGIN NAME
SET ACRUN=$PIECE(ACRDATA,U)
+15 ;CORE PASSWORD
SET ACRPW=$PIECE(ACRDATA,U,2)
+16 ;CORE HOST NAME
SET ACRHN=$PIECE(ACRDATA,U,3)
+17 ;ACR*2.1*13.06 IM14144
DO EXPORT(ACRDIR,ACRFN,ACRUN,ACRPW,ACRHN)
+18 KILL ^TMP("ACR",$JOB)
+19 GOTO EN
+20 QUIT
EXPORT(ACRDIR,ACRFN,ACRUN,ACRPW,ACRHN) ;- EXPORT FILE TO CORE ;ACR*2.1*13.06 IM14144
+1 ;
+2 ; INPUT:
+3 ; ACRDIR = DIRECTORY PATH
+4 ; ACRFN = UNIX FILENAME
+5 ; ACRUN = CORE LOGIN NAME
+6 ; ACRPW = CORE PASSWORD
+7 ; ACRHN = CORE HOSTNAME
+8 ;
+9 WRITE !
+10 ;D TCMD^ACRFUTL("/usr/spool/afsdata/acrdhrsend "_ACRFN_" "_ACRUN_" "_ACRPW_" "_ACRHN) ;ACR*2.1*13.06 IM14144
+11 ;ACR*2.1*13.06 IM14144
DO TCMD^ACRFUTL(ACRDIR_"acrdhrsend "_ACRFN_" "_ACRUN_" "_ACRPW_" "_ACRHN)
+12 HANG 2
+13 DO PAUSE^ACRFWARN
+14 QUIT
SEL(OUT,Y,ACRDIR) ; ;ACR*2.1*13.06 IM14144
+1 ;----- SELECT FILE TO EXPORT
+2 ;
+3 NEW DIR,X
+4 WRITE !
+5 SET DIR(0)="F^3:30"
+6 SET DIR("A")="Select FILE for export"
+7 SET DIR("?")="Enter file name to export, or '??' for a list of files"
+8 ;ACR*2.1*13.06 IM14144
SET DIR("??")="^D LIST^ACRFXPT(ACRDIR)"
+9 FOR
Begin DoDot:1
+10 DO ^DIR
+11 IF $DATA(DTOUT)!($DATA(DUOUT))
SET OUT=1
QUIT
+12 IF '$DATA(^TMP("ACR",$JOB,"FILES",Y))
Begin DoDot:2
+13 WRITE !,?5,"No such file "_Y
End DoDot:2
KILL Y
End DoDot:1
IF $GET(OUT)
QUIT
IF $GET(Y)]""
QUIT
+14 QUIT
+15 ;LIST ;----- LIST UNIX DHR FILES FOR EXPORT ;ACR*2.1*13.06 IM14144
+16 ;
+17 ;N OUT ;ACR*2.1*13.06 IM14144
+18 ;D ^XBKVAR ;ACR*2.1*13.06 IM14144
+19 ;S OUT=0 ;ACR*2.1*13.06 IM14144
+20 ;D BLD,READ(.OUT) ;ACR*2.1*13.06 IM14144
+21 ;Q:$G(OUT) ;ACR*2.1*13.06 IM14144
+22 ;S OUT=0 ;ACR*2.1*13.06 IM14144
+23 ;D SHOW ;ACR*2.1*13.06 IM14144
+24 ;Q ;ACR*2.1*13.06 IM14144
LIST(ACRDIR) ;----- LIST UNIX DHR FILES FOR EXPORT ;ACR*2.1*13.06 IM14144
+1 ;
+2 NEW OUT
+3 DO ^XBKVAR
+4 SET OUT=0
+5 ;ACR*2.1*13.06 IM14144
DO BLD(ACRDIR)
+6 ;ACR*2.1*13.06 IM14144
DO READ(.OUT,ACRDIR)
+7 IF $GET(OUT)
QUIT
+8 SET OUT=0
+9 DO SHOW
+10 QUIT
+11 ;
+12 ;BLD ;----- BUILD UNIX FILE acr.files ;ACR*2.1*13.06 IM14144
+13 ;
+14 ;D JCMD^ACRFUTL("ls -l /usr/spool/afsdata/afsdh* > /usr/spool/afsdata/acr.files") ;ACR*2.1*13.06 IM14144
+15 ;D JCMD^ACRFUTL("ls -l /usr/spool/afsdata/bar* >> /usr/spool/afsdata/acr.files") ;TO ALLOW SELECTION OF AR FILES TO SEND TO CORE ;ACR*2.1*13.06 IM14144
BLD(ACRDIR) ;----- BUILD UNIX FILE acr.files ;ACR*2.1*13.06 IM14144
+1 ;ACR*2.1*13.06 IM14144
DO JCMD^ACRFUTL("ls -l "_ACRDIR_"afsdh* > "_ACRDIR_"acr.files")
+2 ;SELECT AR FILES TO SEND TO CORE ;ACR*2.1*13.06 IM14144
DO JCMD^ACRFUTL("ls -l "_ACRDIR_"bar* >> "_ACRDIR_"acr.files")
+3 QUIT
READ(OUT,ARCDIR) ; ;ACR*2.1*13.06 IM14144
+1 ;----- READ CONTENTS OF UNIX FILE acr.files INTO ^TMP GLOBALS
+2 ;
+3 NEW FILE,I,QUIT,X,Y
+4 KILL ^TMP("ACR",$JOB)
+5 ;D OPEN^%ZISH("FILE","/usr/spool/afsdata/","acr.files","R") ;ACR*2.1*13.06 IM14144
+6 ;I POP W !,"UNABLE TO OPEN acr.files" S OUT=1 Q ;ACR*2.1*13.06 IM14144
+7 ;U IO ;ACR*2.1*13.06 IM14144
+8 ;ACR*2.1*13.06 IM14144
DO HFS^ACRFZISH(ACRDIR,"acr.files","R",.%DEV)
+9 IF $GET(%DEV)']""
SET OUT=1
QUIT
+10 USE %DEV
+11 FOR I=1:1
Begin DoDot:1
+12 READ X:DTIME
IF $$STATUS^%ZISH
SET QUIT=1
QUIT
+13 SET ^TMP("ACR",$JOB,"DATA",I,0)=X
End DoDot:1
IF $GET(QUIT)
QUIT
+14 DO CLOSE^%ZISH("FILE")
+15 SET I=0
+16 FOR
SET I=$ORDER(^TMP("ACR",$JOB,"DATA",I))
IF 'I
QUIT
Begin DoDot:1
+17 SET X=^TMP("ACR",$JOB,"DATA",I,0)
+18 SET ^TMP("ACR",$JOB,"FILES",$PIECE($EXTRACT(X,55,999),"/",5),0)=$TRANSLATE($EXTRACT(X,28,40)," ","")_U_$EXTRACT(X,42,53)_U_$PIECE($EXTRACT(X,55,999),"/",5)
End DoDot:1
+19 QUIT
SHOW ;----- SHOW A LIST OF UNIX DHR FILES
+1 ;
+2 NEW DATA,DIR,FILE,OUT,PAGE
+3 DO HOME^%ZIS
+4 WRITE @IOF
+5 SET OUT=0
+6 IF '$DATA(^TMP("ACR",$JOB,"FILES"))
WRITE !,"No files to export"
QUIT
+7 SET FILE=""
+8 FOR
SET FILE=$ORDER(^TMP("ACR",$JOB,"FILES",FILE))
IF FILE']""
QUIT
Begin DoDot:1
+9 IF $Y>(IOSL-5)
DO HDR(.OUT)
IF $GET(OUT)
QUIT
+10 SET DATA=^TMP("ACR",$JOB,"FILES",FILE,0)
+11 WRITE !,$JUSTIFY($PIECE(DATA,U),15)
+12 WRITE ?18,$PIECE(DATA,U,2)
+13 WRITE ?32,$PIECE(DATA,U,3)
End DoDot:1
IF $GET(OUT)
QUIT
+14 QUIT
HDR(OUT) ;----- WRITE HEADER
+1 ;
+2 NEW DIR
+3 IF $EXTRACT(IOST)="C"
IF $GET(PAGE)
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF 'Y
SET OUT=1
QUIT
+4 SET PAGE=$GET(PAGE)+1
+5 WRITE @IOF
+6 WRITE !,"FILES PENDING EXPORT:"
+7 QUIT