XPDIR ;SFISC/RSD - Install Restart ; 09/29/2005
;;8.0;KERNEL;**30,58,393**;Jul 10, 1995;Build 12
EN ;restart install
N DIR,DIRUT,POP,XPD,XPDA,XPDD,XPDIJ,XPDDIQ,XPDNM,XPDNOQUE,XPDPKG,XPDST,XPDSET,XPDT,XPDQUIT,XPDQUES,Y,ZTSK,%
S %="I $P(^(0),U,9)#3,$D(^XPD(9.7,""ASP"",Y,1,Y)),$D(^XTMP(""XPDI"",Y))",XPDST=$$LOOK^XPDI1(%)
Q:'XPDST!$D(XPDQUIT)
S ZTSK=$P(^XPD(9.7,XPDST,0),U,6) D:ZTSK
.;check if task exist or is queued
.D ISQED^%ZTLOAD
.;task is queued to run
.Q:ZTSK(0)
.;task doesn't exist, k ZTSK so it can be re-scheduled
.I ZTSK(0)="" K ZTSK Q
.D STAT^%ZTLOAD
.;task is not define
.I 'ZTSK(1) K ZTSK Q
.;task is queued to run
.Q:ZTSK(1)=1
.;task is running, set quit flag
.I ZTSK(1)=2 S XPDQUIT=1 W !,"Install is currently running, cannot re-install!" Q
.;task finished or was interrupted, kill it so it can be rescheduled
.D KILL^%ZTLOAD K ZTSK Q
;abort if there is nothing to install or they '^'
G:'$O(XPDT(0))!$D(XPDQUIT) ABORT
;clean out old task, so they can reinstall
I '$D(ZTSK) D
.N XPD
.S XPD(9.7,XPDST_",",5)="" D FILE^DIE("","XPD")
I $G(ZTSK) W !!,"This install is already queued as task #",ZTSK,!,"Please use the Taskman Menu if you want to reschedule." G ABORT
;kill XPDT array so that while in XPDI and ABORT is called, nothing is deleted
S XPDIJ=0,XPDA=XPDST,XPDNM=$P(^XPD(9.7,XPDA,0),U) K XPDT
;restore environment check variables
I $D(^XTMP("XPDI",XPDA,"ENVVAR")) D
.S:$D(^XTMP("XPDI",XPDA,"ENVVAR","XPDNOQUE")) XPDNOQUE=^("XPDNOQUE")
.I $D(^XTMP("XPDI",XPDA,"ENVVAR","XPDDIQ")) M XPDDIQ=^("XPDDIQ")
G DEV^XPDI
;
ABORT W !!,"**RESTART ABORTED**",!
L -XPD(9.7,XPDST)
Q
XPDIR ;SFISC/RSD - Install Restart ; 09/29/2005
+1 ;;8.0;KERNEL;**30,58,393**;Jul 10, 1995;Build 12
EN ;restart install
+1 NEW DIR,DIRUT,POP,XPD,XPDA,XPDD,XPDIJ,XPDDIQ,XPDNM,XPDNOQUE,XPDPKG,XPDST,XPDSET,XPDT,XPDQUIT,XPDQUES,Y,ZTSK,%
+2 SET %="I $P(^(0),U,9)#3,$D(^XPD(9.7,""ASP"",Y,1,Y)),$D(^XTMP(""XPDI"",Y))"
SET XPDST=$$LOOK^XPDI1(%)
+3 IF 'XPDST!$DATA(XPDQUIT)
QUIT
+4 SET ZTSK=$PIECE(^XPD(9.7,XPDST,0),U,6)
IF ZTSK
Begin DoDot:1
+5 ;check if task exist or is queued
+6 DO ISQED^%ZTLOAD
+7 ;task is queued to run
+8 IF ZTSK(0)
QUIT
+9 ;task doesn't exist, k ZTSK so it can be re-scheduled
+10 IF ZTSK(0)=""
KILL ZTSK
QUIT
+11 DO STAT^%ZTLOAD
+12 ;task is not define
+13 IF 'ZTSK(1)
KILL ZTSK
QUIT
+14 ;task is queued to run
+15 IF ZTSK(1)=1
QUIT
+16 ;task is running, set quit flag
+17 IF ZTSK(1)=2
SET XPDQUIT=1
WRITE !,"Install is currently running, cannot re-install!"
QUIT
+18 ;task finished or was interrupted, kill it so it can be rescheduled
+19 DO KILL^%ZTLOAD
KILL ZTSK
QUIT
End DoDot:1
+20 ;abort if there is nothing to install or they '^'
+21 IF '$ORDER(XPDT(0))!$DATA(XPDQUIT)
GOTO ABORT
+22 ;clean out old task, so they can reinstall
+23 IF '$DATA(ZTSK)
Begin DoDot:1
+24 NEW XPD
+25 SET XPD(9.7,XPDST_",",5)=""
DO FILE^DIE("","XPD")
End DoDot:1
+26 IF $GET(ZTSK)
WRITE !!,"This install is already queued as task #",ZTSK,!,"Please use the Taskman Menu if you want to reschedule."
GOTO ABORT
+27 ;kill XPDT array so that while in XPDI and ABORT is called, nothing is deleted
+28 SET XPDIJ=0
SET XPDA=XPDST
SET XPDNM=$PIECE(^XPD(9.7,XPDA,0),U)
KILL XPDT
+29 ;restore environment check variables
+30 IF $DATA(^XTMP("XPDI",XPDA,"ENVVAR"))
Begin DoDot:1
+31 IF $DATA(^XTMP("XPDI",XPDA,"ENVVAR","XPDNOQUE"))
SET XPDNOQUE=^("XPDNOQUE")
+32 IF $DATA(^XTMP("XPDI",XPDA,"ENVVAR","XPDDIQ"))
MERGE XPDDIQ=^("XPDDIQ")
End DoDot:1
+33 GOTO DEV^XPDI
+34 ;
ABORT WRITE !!,"**RESTART ABORTED**",!
+1 LOCK -XPD(9.7,XPDST)
+2 QUIT