source: WorldVistAEHR/trunk/r/MAILMAN-XM/XMKPR.m@ 1226

Last change on this file since 1226 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 7.0 KB
Line 
1XMKPR ;ISC-SF/GMB-Post, remote ;10/09/2002 09:40
2 ;;8.0;MailMan;**5,6**;Jun 28, 2002
3 ; Replaces ^XMBPOST and the first part of ^XMS1 (ISC-WASH/THM/RWF/CAP)
4 ; Schedule a task to deliver remote
5REMOTE(XMZ,XMINST) ; For addresses containing "@"
6 N XMSITE,XMREC,XMPOLL
7 S XMREC=^DIC(4.2,XMINST,0)
8 S XMSITE=$P(XMREC,U)
9 D PUTMSG^XMXMSGS2(.5,XMINST+1000,XMSITE,XMZ)
10 Q:$P(XMREC,U,2)'["S" ; S means to start task immediately
11 D:'$$TSKEXIST(XMINST) QUEUE(XMINST,XMSITE)
12 Q
13TSKEXIST(XMINST,XMTSK) ;Is Task scheduled ? (0=no,ZTSK^$H=pending,ZTSK=running)
14 ; Note: ZTSK does not exist when 'playing a script', or for an incoming
15 ; transmission.
16 S:'$G(XMTSK) XMTSK=$$GETTSK(XMINST)
17 Q:'XMTSK 0
18 I $D(ZTQUEUED),$G(ZTSK)=XMTSK Q ZTSK
19 N ZTSK
20 S ZTSK=XMTSK
21 D STAT^%ZTLOAD
22 Q:ZTSK(1)=0 0 ; "Undefined"
23 I ZTSK(1)=1 D Q ZTSK_U_ZTSK("D") ; "Active: Pending"
24 . D ISQED^%ZTLOAD ; ZTSK("D")=$H when scheduled
25 I ZTSK(1)=2 Q ZTSK ; "Active: Running"
26 ;I ZTSK(1)=2 N %1 D L -^DIC(4.2,+$G(XMINST),"XMNETSEND") Q %1
27 ;. ; "Active: Running" - This check isn't reliable,
28 ;. ; because the lock is not set for incoming, only for outgoing.
29 ;. L +^DIC(4.2,+$G(XMINST),"XMNETSEND"):2 ; Is it really running?
30 ;. I $T D KILLTSK(XMINST,ZTSK) S %1=0 Q ; Nope
31 ;. S %1=ZTSK ; Yep
32 Q:ZTSK(1)=3 0 ; "Inactive: Finished"
33 I ZTSK(1)=4 D KILLTSK(XMINST,ZTSK) Q 0 ; "Inactive: Available"
34 I ZTSK(1)=5 D KILLTSK(XMINST,ZTSK) Q 0 ; "Interrupted"
35 Q
36GETTSK(XMINST) ;
37 L +^XMBS(4.2999,XMINST,3):0 L -^XMBS(4.2999,XMINST,3) ; ensure latest
38 Q $P($G(^XMBS(4.2999,XMINST,3)),U,7)
39KILLTSK(XMINST,ZTSK) ;
40 D KILL^%ZTLOAD
41 S $P(^XMBS(4.2999,XMINST,3),U,7)=""
42 S $P(^XMBS(4.2999,XMINST,4),U,2)=$$NOW^XLFDT
43 Q
44QUEUE(XMINST,XMSITE,XMB,ZTDTH,ZTSK) ;
45 ; Was ENQ^XMS1 used by ^XMC2,^XMS5,^XMS5B ***
46 ; in:
47 ; XMINST domain IEN in domain file
48 ; XMSITE domain name
49 ; XMB (optional) script choice (default: highest priority script)
50 ; ZTDTH (optional) task start time (default: now)
51 ; out:
52 ; ZTSK task number
53 N I,XMIENS,XMFDA,ZTIO,ZTDESC,ZTRTN
54 I '$D(^XMBS(4.2999,XMINST,0)) D STAT^XMTDR(XMINST)
55 L +^XMBS(4.2999,XMINST):1
56 I '$G(XMB("SCR IEN")) D Q:'XMB("SCR IEN")
57 . D XMTCHECK(XMINST,.XMB)
58 . D SCRIPT^XMKPR1(XMINST,XMSITE,.XMB)
59 S ZTIO=$P(XMB("SCR REC"),U,5)
60 S ZTDESC=$$EZBLD^DIALOG(42000,XMSITE) ; MailMan: To |1|
61 S:'$G(ZTDTH) ZTDTH=$H
62 F I="XMINST","XMPOLL" S ZTSAVE(I)=""
63 S ZTRTN="TASK^XMTDR"
64 D ^%ZTLOAD
65 S ^XMBS(4.2999,XMINST,3)="" ; current xmit stats
66 S $P(^XMBS(4.2999,XMINST,3),U,7)=ZTSK
67 S XMIENS=XMINST_","
68 I 'XMB("TRIES"),'XMB("ITERATIONS") D
69 . S XMFDA(4.2999,XMIENS,41)="@" ; xmit start date/time
70 . S XMFDA(4.2999,XMIENS,42)="@" ; xmit finish date/time
71 . S XMFDA(4.2999,XMIENS,45)="@" ; xmit latest try date/time
72 . K ^XMBS(4.2999,XMINST,6) ; xmit audit multiple
73 S XMFDA(4.2999,XMIENS,25)=ZTSK ; task number
74 S XMFDA(4.2999,XMIENS,43)=XMB("SCR IEN") ; ien of script to be used
75 S XMFDA(4.2999,XMIENS,44)=XMB("TRIES") ; xmit tries
76 S XMFDA(4.2999,XMIENS,46)=XMB("ITERATIONS") ; xmit iterations
77 S XMFDA(4.2999,XMIENS,47)=XMB("FIRST SCRIPT") ; ien of first script
78 S XMFDA(4.2999,XMIENS,48)=XMB("IP TRIED") ; IP addresses tried
79 S XMFDA(4.2999,XMIENS,51)=XMB("SCR REC") ; script record
80 D FILE^DIE("","XMFDA")
81 L -^XMBS(4.2999,XMINST)
82 Q
83XMTCHECK(XMINST,XMB) ;
84 N XMTREC
85 L +^XMBS(4.2999,XMINST,4):0 L -^XMBS(4.2999,XMINST,4) ; ensure latest
86 S XMTREC=$G(^XMBS(4.2999,XMINST,4))
87 Q:'$P(XMTREC,U,1)!$P(XMTREC,U,2)
88 ; Start time, but no finish time.
89 ; Previous transmission attempt was aborted. Pick up where we left off.
90 S XMB("SCR IEN")=$P(XMTREC,U,3)
91 S XMB("TRIES")=$P(XMTREC,U,4)
92 S XMB("LAST TRY")=$P(XMTREC,U,5)
93 S XMB("ITERATIONS")=$P(XMTREC,U,6)
94 S XMB("FIRST SCRIPT")=$P(XMTREC,U,7)
95 S XMB("IP TRIED")=$P(XMTREC,U,8)
96 S XMB("SCR REC")=$G(^XMBS(4.2999,XMINST,5))
97 Q
98REQUEUE(XMINST,XMSITE,XMB) ;
99 N XMFDA,XMIENS,ZTDTH,ZTIO,ZTDESC,ZTRTN
100 S XMFDA(4.29992,XMB("AUDIT IENS"),2)=$E($G(ER("MSG"),$$EZBLD^DIALOG(42192)),1,200) ;Unknown Error
101 D FILE^DIE("","XMFDA")
102 I XMB("TRIES")+1=$P(XMB("SCR REC"),U,3) D POSTFAIL(XMINST,XMSITE,.XMB)
103 D SCRIPT^XMKPR1(XMINST,XMSITE,.XMB) Q:'XMB("SCR IEN")
104 S XMIENS=XMINST_","
105 S XMFDA(4.2999,XMIENS,43)=XMB("SCR IEN") ; ien of script to be used
106 S XMFDA(4.2999,XMIENS,44)=XMB("TRIES") ; xmit tries
107 S XMFDA(4.2999,XMIENS,46)=XMB("ITERATIONS") ; xmit iterations
108 S XMFDA(4.2999,XMIENS,48)=XMB("IP TRIED") ; IP addresses tried
109 S XMFDA(4.2999,XMIENS,51)=XMB("SCR REC") ; script record
110 D FILE^DIE("","XMFDA")
111 ; XMB("TRIES") starts off at 0 with every script.
112 ; Each time the script is retried, XMB("TRIES") is bumped up by 1.
113 ; XMB("ITERATIONS") starts off at 0. After a cycle of scripts is tried,
114 ; XMB("ITERATIONS") is bumped up by 1 when the cycle is started again.
115 ; We start every new cycle after one hour.
116 ; We start every new try after one minute
117 I XMB("TRIES") D
118 . S ZTDTH=$$HADD^XLFDT($H,"","",1) ; New try, add 1 minute
119 E I XMB("ITERATIONS"),XMB("SCR IEN")=XMB("FIRST SCRIPT") D
120 . S ZTDTH=$$HADD^XLFDT($H,"",1) ; New iteration, add 1 hour
121 E S ZTDTH=$H ; First try, new script within same iteration
122 S ZTIO=$P(XMB("SCR REC"),U,5)
123 S ZTDESC=$$EZBLD^DIALOG(42000.1,XMSITE) ;MailMan: To |1| (requeue)
124 ; ("_XMB("ITERATIONS")_","_XMB("SCR IEN")_","_XMB("TRIES")_")"
125 S ZTRTN="TASK^XMTDR"
126 S ZTREQ=ZTDTH_U_ZTIO_U_ZTDESC_U_ZTRTN
127 D DOTRAN^XMC1(42000.2,XMSITE) ;|1| Requeued
128 Q
129POSTFAIL(XMINST,XMSITE,XMB) ; Postmaster message on queue failure
130 N XMPARM,XMINSTR,XMI,XMJ,XMTRIES,XMFIRST
131 K ^TMP("XM",$J)
132 S XMINSTR("FROM")="POSTMASTER",XMINSTR("ADDR FLAGS")="R"
133 S XMTRIES=$P(XMB("SCR REC"),U,3)
134 S XMPARM(1)=XMSITE,XMPARM(2)=XMTRIES
135 S XMJ=0
136 S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=""
137 S XMFIRST=$P($G(^XMBS(4.2999,XMINST,6,0)),U,3)-XMTRIES
138 S:XMFIRST<0 XMFIRST=0
139 S XMI=XMFIRST ; Get tries audit from ^XMBS(4.2999, "XMIT AUDIT" multiple
140 F S XMI=$O(^XMBS(4.2999,XMINST,6,XMI)) Q:'XMI S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=^(XMI,0)
141 S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=""
142 S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=$$EZBLD^DIALOG(42190) ;A transcript of the last delivery attempt follows:
143 S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=""
144 S XMI=0
145 F S XMI=$O(^TMP("XMC",XMC("AUDIT"),XMI)) Q:'XMI S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=^(XMI,0)
146 I XMFIRST'=0 D
147 . N XMMAX ; Maximum number of old audit records
148 . S XMMAX=100
149 . S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)="**********************************************"
150 . S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=""
151 . I XMFIRST'>XMMAX D
152 . . S XMI=0
153 . . S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=$$EZBLD^DIALOG(42191) ;The following errors occurred in previous attempts:
154 . E D
155 . . S XMI=XMFIRST-XMMAX
156 . . S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=$$EZBLD^DIALOG(42191.1,$$FMTE^XLFDT($P(^XMBS(4.2999,XMINST,6,1,0),U,1),5)) ;The errors started on |1|.
157 . . S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=""
158 . . S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=$$EZBLD^DIALOG(42191.2,XMMAX) ;The following errors occurred in the previous |1| attempts:
159 . ; Get tries audit from ^XMBS(4.2999, "XMIT AUDIT" multiple
160 . S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=""
161 . F S XMI=$O(^XMBS(4.2999,XMINST,6,XMI)) Q:XMI>XMFIRST S XMJ=XMJ+1,^TMP("XM",$J,XMJ,0)=^(XMI,0)
162 D TASKBULL^XMXBULL(.5,"XM SEND ERR TRANSMISSION",.XMPARM,"^TMP(""XM"",$J)",.5,.XMINSTR)
163 K ^TMP("XM",$J)
164 Q
Note: See TracBrowser for help on using the repository browser.