XUTMTP ;SEA/RDS - TaskMan: ToolKit, Print, Part 1 ;04/18/2006 16:19
;;8.0;KERNEL;**20,86,169,242,381**;Jul 10, 1995;Build 2
;
EN(XUTSK,XUINX,FLAG) ;Print one task
I $D(XUTMUCI)_$D(ZTNAME)_$D(ZTFLAG)'="111" D ENV^XUTMUTL
TASK ;Lookup Task File Data
N %,%D,%H,%M,%Y,%ZTT,X,Y,ZT,ZT1,ZT2,ZT3,ZTC,ZTD,ZTF,ZTI,ZTO
S FLAG=+$G(FLAG),ZTC=0
L +^%ZTSK(XUTSK):2 I '$T W !,"Task: ",XUTSK," entry locked." Q
;Get current data
S XUTSK(0)=$G(^%ZTSK(XUTSK,0)),XUTSK(.03)=$G(^(.03)),XUTSK(.1)=$G(^(.1)),XUTSK(.2)=$G(^(.2)),XUTSK(.11)=$G(^(.11)),XUTSK(.26)=$G(^(.26))
I '$D(^%ZTSK(XUTSK)) D I 'XUTSK L -^%ZTSK(XUTSK) K XUTMT Q
. S X=$G(^%ZTSCH("TASK",XUTSK))
. I X="" W !,XUTSK,": No information available." S XUTSK=0 Q
. S XUTSK(0)=$P(X,U,1,2)_"^^"_$P(X,U,7,8)_U_$P(X,U,5)_"^^"_$P(X,U,3,4)_U_$P(X,U,9),XUTSK(.1)="5^"_$P(X,U,12),XUTSK(.2)=$P(X,U,6),XUTSK("TASK")=X
. S XUTSK(.03)="Task in running list, full information missing."
. Q
;
SCHED ;Lookup Task In Schedule File
S ZT1=0 F ZT=0:0 S ZT1=$O(^%ZTSCH(ZT1)) Q:'ZT1 I $D(^%ZTSCH(ZT1,XUTSK))#2 S XUTSK("A",ZT1,XUTSK)="",ZT2=^(XUTSK) I ZT2]"" S $P(XUTSK(.2),U)=ZT2
I XUTSK(.26)="" S ZT1="" F S ZT1=$O(^%ZTSCH("IO",ZT1)),ZT2="" Q:ZT1="" F S ZT2=$O(^%ZTSCH("IO",ZT1,ZT2)) Q:ZT2="" S:$D(^(ZT2,XUTSK))#2 XUTSK("IO",ZT1,ZT2,XUTSK)=""
S ZT1="" F S ZT1=$O(^%ZTSCH("JOB",ZT1)) Q:ZT1="" S:$D(^(ZT1,XUTSK))#2 XUTSK("JOB",ZT1,XUTSK)=""
S ZT1="" F S ZT1=$O(^%ZTSCH("LINK",ZT1)),ZT2="" Q:ZT1="" F S ZT2=$O(^%ZTSCH("LINK",ZT1,ZT2)) Q:ZT2="" S:$D(^(ZT2,XUTSK))#2 XUTSK("LINK",ZT1,ZT2,XUTSK)=""
S:$D(^%ZTSCH("TASK",XUTSK))#2 XUTSK("TASK")=^(XUTSK) S:$D(^%ZTSCH("TASK",XUTSK,1)) XUTSK("TASK1")=^(1)
L -^%ZTSK(XUTSK)
;
SCREEN ;Apply Screen, If Supplied
I $D(XUTMT("S"))#2 X XUTMT("S") E K XUTMT Q
;
S ZT1=$G(^%ZTSK(XUTSK,.3,"XQSCH")) I ZT1 D ;Is it a scheduled task
. S ZT2=+$G(^DIC(19.2,ZT1,1.1)) Q:'ZT2
. S ZT2=$P($G(^VA(200,ZT2,0),"Unk"),"^") D ADD("Run under user: "_ZT2)
. Q
STATUS ;Determine Status According To Lookup Data
S XUTSK("CS")="",XUTSK("UPDATE")=$$TIME($P(XUTSK(.1),U,2))
I $D(XUTSK("A")) S ZT1="" F ZT=0:0 S ZT1=$O(XUTSK("A",ZT1)) Q:ZT1="" D ADD("Scheduled for "_$$TIME(ZT1),1)
I XUTSK(.26)]"" D ADD("Waiting for hunt group"_$S(XUTSK(.26)[",":"s ",1:" ")_XUTSK(.26),"A")
I XUTSK(.26)="",$D(XUTSK("IO")) S ZT1="" F ZT=0:0 S ZT1=$O(XUTSK("IO",ZT1)) Q:ZT1="" D ADD("Waiting for device "_ZT1,"A"),IOQ:FLAG
I $D(XUTSK("JOB")) D ADD("Waiting for a partition.",3),JL:FLAG
I $D(XUTSK("LINK")) S ZT1="" F ZT=0:0 S ZT1=$O(XUTSK("LINK",ZT1)) Q:ZT1="" D ADD("Waiting for the link to "_ZT1_" to be restored.","G"),LL:FLAG
I $D(XUTSK("TASK")) D ADD("Started running "_XUTSK("UPDATE")_".",5)
I $E(XUTSK(.1),1)]"",$E(XUTSK(.1),1)'=XUTSK("CS") D STATUS^XUTMTP0 S ZTC=ZTC+1
;
PRINT ;Go To XUTMTP1 To Print Task And Quit
G ^XUTMTP1
;
TIME(%ZTT) ;Convert $H Time To A Readable Time
Q:%ZTT="" "??"
N %,%XT,%XD,%H,Y I %ZTT>99999 S %XD=(%ZTT\86400),%XT=%ZTT#86400
E S %XD=+%ZTT,%XT=$P(%ZTT,",",2)
S %H=$H,%=%XD-%H I %*%<2 S Y=$S(%<0:"Yesterday",'%:"Today",%>0:"Tomorrow",1:"")
I %*%>1 S Y=$$HTE^XLFDT(%XD_","_%XT,"5D") ;D 7^%DTC S Y=$E(X,4,5)_"/"_$E(X,6,7)_"/"_$E(X,2,3)
S Y=Y_" at "_(%XT\3600)_":"_$E(%XT#3600\60+100,2,3)
Q Y
;
ADD(MSG,FLG) ;Add msg to list
S XUTSK(.15,ZTC)=MSG,ZTC=ZTC+1 S:$D(FLG) XUTSK("CS")=FLG
Q
A ;STATUS--determine position of late task in Schedule List
N ZTP
Q
;
IOQ ;STATUS--determine position in Device Waiting List
N ZTP
S ZTP=0,ZT2="" F ZT=0:0 S ZT2=$O(^%ZTSCH("IO",ZT1,ZT2)),ZT3="" Q:ZT2="" F ZT=0:0 S ZT3=$O(^%ZTSCH("IO",ZT1,ZT2,ZT3)) Q:ZT3="" S ZTP=ZTP+1 I ZT3=ZTSK G I1
I1 D ADD(" "_(ZTP-1)_" task"_$S(ZTP=2:"",1:"s")_" ahead of this one.")
Q
;
JL ;STATUS--determine position in Job List
N ZTP
S ZTP=0,ZT1=""
F S ZT1=$O(^%ZTSCH("JOB",ZT1)),ZT2="" Q:ZT1="" F S ZT2=$O(^%ZTSCH("JOB",ZT1,ZT2)) Q:ZT2="" S ZTP=ZTP+1 I ZT2=ZTSK G J1
J1 D ADD(" "_(ZTP-1)_" task"_$S(ZTP=2:"",1:"s")_" ahead of this one.")
Q
;
LL ;STATUS--determine position in Link Waiting List
N ZTP
S ZTP=0,ZT2=""
F S ZT2=$O(^%ZTSCH("LINK",ZT1,ZT2)),ZT3="" Q:ZT2="" F S ZT3=$O(^%ZTSCH("LINK",ZT1,ZT2,ZT3)) Q:ZT3="" S ZTP=ZTP+1 I ZT3=ZTSK G L1
L1 D ADD(" "_(ZTP-1)_" task"_$S(ZTP=2:"",1:"s")_" ahead of this one.")
Q
;
TASKUSER(TSK) ;Return the user name for a task
N S1,S2,S3
S S1=$G(^%ZTSK(+TSK,0)) I '$L(S1) Q "Unknown"
S S1=+$P(S1,U,3)
S S2=$G(^VA(200,S1,0)) I '$L(S2) Q "Unknown"
S S3=$$ACTIVE^XUSER(S1)
Q $S(S3:$P(S2,U),1:$E($P(S2,U),1,25)_" (T)")
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HXUTMTP 4559 printed Dec 13, 2024@02:13:51 Page 2
XUTMTP ;SEA/RDS - TaskMan: ToolKit, Print, Part 1 ;04/18/2006 16:19
+1 ;;8.0;KERNEL;**20,86,169,242,381**;Jul 10, 1995;Build 2
+2 ;
EN(XUTSK,XUINX,FLAG) ;Print one task
+1 IF $DATA(XUTMUCI)_$DATA(ZTNAME)_$DATA(ZTFLAG)'="111"
DO ENV^XUTMUTL
TASK ;Lookup Task File Data
+1 NEW %,%D,%H,%M,%Y,%ZTT,X,Y,ZT,ZT1,ZT2,ZT3,ZTC,ZTD,ZTF,ZTI,ZTO
+2 SET FLAG=+$GET(FLAG)
SET ZTC=0
+3 LOCK +^%ZTSK(XUTSK):2
IF '$TEST
WRITE !,"Task: ",XUTSK," entry locked."
QUIT
+4 ;Get current data
+5 SET XUTSK(0)=$GET(^%ZTSK(XUTSK,0))
SET XUTSK(.03)=$GET(^(.03))
SET XUTSK(.1)=$GET(^(.1))
SET XUTSK(.2)=$GET(^(.2))
SET XUTSK(.11)=$GET(^(.11))
SET XUTSK(.26)=$GET(^(.26))
+6 IF '$DATA(^%ZTSK(XUTSK))
Begin DoDot:1
+7 SET X=$GET(^%ZTSCH("TASK",XUTSK))
+8 IF X=""
WRITE !,XUTSK,": No information available."
SET XUTSK=0
QUIT
+9 SET XUTSK(0)=$PIECE(X,U,1,2)_"^^"_$PIECE(X,U,7,8)_U_$PIECE(X,U,5)_"^^"_$PIECE(X,U,3,4)_U_$PIECE(X,U,9)
SET XUTSK(.1)="5^"_$PIECE(X,U,12)
SET XUTSK(.2)=$PIECE(X,U,6)
SET XUTSK("TASK")=X
+10 SET XUTSK(.03)="Task in running list, full information missing."
+11 QUIT
End DoDot:1
IF 'XUTSK
LOCK -^%ZTSK(XUTSK)
KILL XUTMT
QUIT
+12 ;
SCHED ;Lookup Task In Schedule File
+1 SET ZT1=0
FOR ZT=0:0
SET ZT1=$ORDER(^%ZTSCH(ZT1))
if 'ZT1
QUIT
IF $DATA(^%ZTSCH(ZT1,XUTSK))#2
SET XUTSK("A",ZT1,XUTSK)=""
SET ZT2=^(XUTSK)
IF ZT2]""
SET $PIECE(XUTSK(.2),U)=ZT2
+2 IF XUTSK(.26)=""
SET ZT1=""
FOR
SET ZT1=$ORDER(^%ZTSCH("IO",ZT1))
SET ZT2=""
if ZT1=""
QUIT
FOR
SET ZT2=$ORDER(^%ZTSCH("IO",ZT1,ZT2))
if ZT2=""
QUIT
if $DATA(^(ZT2,XUTSK))#2
SET XUTSK("IO",ZT1,ZT2,XUTSK)=""
+3 SET ZT1=""
FOR
SET ZT1=$ORDER(^%ZTSCH("JOB",ZT1))
if ZT1=""
QUIT
if $DATA(^(ZT1,XUTSK))#2
SET XUTSK("JOB",ZT1,XUTSK)=""
+4 SET ZT1=""
FOR
SET ZT1=$ORDER(^%ZTSCH("LINK",ZT1))
SET ZT2=""
if ZT1=""
QUIT
FOR
SET ZT2=$ORDER(^%ZTSCH("LINK",ZT1,ZT2))
if ZT2=""
QUIT
if $DATA(^(ZT2,XUTSK))#2
SET XUTSK("LINK",ZT1,ZT2,XUTSK)=""
+5 if $DATA(^%ZTSCH("TASK",XUTSK))#2
SET XUTSK("TASK")=^(XUTSK)
if $DATA(^%ZTSCH("TASK",XUTSK,1))
SET XUTSK("TASK1")=^(1)
+6 LOCK -^%ZTSK(XUTSK)
+7 ;
SCREEN ;Apply Screen, If Supplied
+1 IF $DATA(XUTMT("S"))#2
XECUTE XUTMT("S")
IF '$TEST
KILL XUTMT
QUIT
+2 ;
+3 ;Is it a scheduled task
SET ZT1=$GET(^%ZTSK(XUTSK,.3,"XQSCH"))
IF ZT1
Begin DoDot:1
+4 SET ZT2=+$GET(^DIC(19.2,ZT1,1.1))
if 'ZT2
QUIT
+5 SET ZT2=$PIECE($GET(^VA(200,ZT2,0),"Unk"),"^")
DO ADD("Run under user: "_ZT2)
+6 QUIT
End DoDot:1
STATUS ;Determine Status According To Lookup Data
+1 SET XUTSK("CS")=""
SET XUTSK("UPDATE")=$$TIME($PIECE(XUTSK(.1),U,2))
+2 IF $DATA(XUTSK("A"))
SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(XUTSK("A",ZT1))
if ZT1=""
QUIT
DO ADD("Scheduled for "_$$TIME(ZT1),1)
+3 IF XUTSK(.26)]""
DO ADD("Waiting for hunt group"_$SELECT(XUTSK(.26)[",":"s ",1:" ")_XUTSK(.26),"A")
+4 IF XUTSK(.26)=""
IF $DATA(XUTSK("IO"))
SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(XUTSK("IO",ZT1))
if ZT1=""
QUIT
DO ADD("Waiting for device "_ZT1,"A")
if FLAG
DO IOQ
+5 IF $DATA(XUTSK("JOB"))
DO ADD("Waiting for a partition.",3)
if FLAG
DO JL
+6 IF $DATA(XUTSK("LINK"))
SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(XUTSK("LINK",ZT1))
if ZT1=""
QUIT
DO ADD("Waiting for the link to "_ZT1_" to be restored.","G")
if FLAG
DO LL
+7 IF $DATA(XUTSK("TASK"))
DO ADD("Started running "_XUTSK("UPDATE")_".",5)
+8 IF $EXTRACT(XUTSK(.1),1)]""
IF $EXTRACT(XUTSK(.1),1)'=XUTSK("CS")
DO STATUS^XUTMTP0
SET ZTC=ZTC+1
+9 ;
PRINT ;Go To XUTMTP1 To Print Task And Quit
+1 GOTO ^XUTMTP1
+2 ;
TIME(%ZTT) ;Convert $H Time To A Readable Time
+1 if %ZTT=""
QUIT "??"
+2 NEW %,%XT,%XD,%H,Y
IF %ZTT>99999
SET %XD=(%ZTT\86400)
SET %XT=%ZTT#86400
+3 IF '$TEST
SET %XD=+%ZTT
SET %XT=$PIECE(%ZTT,",",2)
+4 SET %H=$HOROLOG
SET %=%XD-%H
IF %*%<2
SET Y=$SELECT(%<0:"Yesterday",'%:"Today",%>0:"Tomorrow",1:"")
+5 ;D 7^%DTC S Y=$E(X,4,5)_"/"_$E(X,6,7)_"/"_$E(X,2,3)
IF %*%>1
SET Y=$$HTE^XLFDT(%XD_","_%XT,"5D")
+6 SET Y=Y_" at "_(%XT\3600)_":"_$EXTRACT(%XT#3600\60+100,2,3)
+7 QUIT Y
+8 ;
ADD(MSG,FLG) ;Add msg to list
+1 SET XUTSK(.15,ZTC)=MSG
SET ZTC=ZTC+1
if $DATA(FLG)
SET XUTSK("CS")=FLG
+2 QUIT
A ;STATUS--determine position of late task in Schedule List
+1 NEW ZTP
+2 QUIT
+3 ;
IOQ ;STATUS--determine position in Device Waiting List
+1 NEW ZTP
+2 SET ZTP=0
SET ZT2=""
FOR ZT=0:0
SET ZT2=$ORDER(^%ZTSCH("IO",ZT1,ZT2))
SET ZT3=""
if ZT2=""
QUIT
FOR ZT=0:0
SET ZT3=$ORDER(^%ZTSCH("IO",ZT1,ZT2,ZT3))
if ZT3=""
QUIT
SET ZTP=ZTP+1
IF ZT3=ZTSK
GOTO I1
I1 DO ADD(" "_(ZTP-1)_" task"_$SELECT(ZTP=2:"",1:"s")_" ahead of this one.")
+1 QUIT
+2 ;
JL ;STATUS--determine position in Job List
+1 NEW ZTP
+2 SET ZTP=0
SET ZT1=""
+3 FOR
SET ZT1=$ORDER(^%ZTSCH("JOB",ZT1))
SET ZT2=""
if ZT1=""
QUIT
FOR
SET ZT2=$ORDER(^%ZTSCH("JOB",ZT1,ZT2))
if ZT2=""
QUIT
SET ZTP=ZTP+1
IF ZT2=ZTSK
GOTO J1
J1 DO ADD(" "_(ZTP-1)_" task"_$SELECT(ZTP=2:"",1:"s")_" ahead of this one.")
+1 QUIT
+2 ;
LL ;STATUS--determine position in Link Waiting List
+1 NEW ZTP
+2 SET ZTP=0
SET ZT2=""
+3 FOR
SET ZT2=$ORDER(^%ZTSCH("LINK",ZT1,ZT2))
SET ZT3=""
if ZT2=""
QUIT
FOR
SET ZT3=$ORDER(^%ZTSCH("LINK",ZT1,ZT2,ZT3))
if ZT3=""
QUIT
SET ZTP=ZTP+1
IF ZT3=ZTSK
GOTO L1
L1 DO ADD(" "_(ZTP-1)_" task"_$SELECT(ZTP=2:"",1:"s")_" ahead of this one.")
+1 QUIT
+2 ;
TASKUSER(TSK) ;Return the user name for a task
+1 NEW S1,S2,S3
+2 SET S1=$GET(^%ZTSK(+TSK,0))
IF '$LENGTH(S1)
QUIT "Unknown"
+3 SET S1=+$PIECE(S1,U,3)
+4 SET S2=$GET(^VA(200,S1,0))
IF '$LENGTH(S2)
QUIT "Unknown"
+5 SET S3=$$ACTIVE^XUSER(S1)
+6 QUIT $SELECT(S3:$PIECE(S2,U),1:$EXTRACT($PIECE(S2,U),1,25)_" (T)")