source: EWD/ewdapps/so/r/ewdu.m@ 1306

Last change on this file since 1306 was 1305, checked in by Sam Habiel, 13 years ago

Support for DIINQUIRE application

File size: 6.0 KB
Line 
1ewdu ; JJIH/SMH - Utilities for EWD to VISTA interaction ; 11/18/11 5:39pm
2 ;
3r(sessid) ; Restore Symbol Table
4 d mergeArrayFromSession^%zewdAPI(.DUZ,"DUZ",sessid)
5 d mergeArrayFromSession^%zewdAPI(.IO,"IO",sessid)
6 s U=$$getSessionValue^%zewdAPI("U",sessid)
7 quit
8 ;
9s(sessid) ; Save to Symbol Table
10 d mergeArrayToSession^%zewdAPI(.DUZ,"DUZ",sessid)
11 d mergeArrayToSession^%zewdAPI(.IO,"IO",sessid)
12 d setSessionValue^%zewdAPI("U","^",sessid)
13 quit
14 ;
15NULL ; Open Null Device
16 s %ZIS="0H",IOP="NULL" d ^%ZIS
17 i POP s $ec=",U1," ; this crashes everything... intended...
18 q
19 ;
20SETUP(sessid) ; Set-up and SSO
21 ; TODO: Set IO("CLNM")
22 i '$data(IO) d NULL ; Open Null Device
23 s IO("IP")=$$getServerValue^%zewdAPI("REMOTE_ADDR",sessid)
24 n return
25 d SETUP^XUSRB(.return) ; Set-up and Try SSO
26 i $g(return(5)),DUZ>0 q $$s(sessid) ; Single Sign-On Successful!
27 e d q "" ; Otherwise, get INTRO text
28 . N RET
29 . D INTRO^XUSRB(.RET)
30 . d mergeArrayToSession^%zewdAPI(.RET,"introtxt",sessid)
31 ; ---
32so(sessid) ; SO from EWD; routes to $$SO
33 ; TODO: Set IO("CLNM")
34 d NULL ; IO set-up
35 s IO("IP")=$$getServerValue^%zewdAPI("REMOTE_ADDR",sessid)
36 d SETUP^XUSRB(); ; This time, just need partition set-up
37 n ac s ac=$$getSessionValue^%zewdAPI("ac",sessid)
38 n vc s vc=$$getSessionValue^%zewdAPI("vc",sessid)
39 n result s result=$$SO(ac,vc)
40 ;
41 ; Change Verify Code Logic Ahead... Damn Complex!
42 i $l(result),result="CVC" d q "" ; User must change Verify Code
43 . S DUZ=$$STATE^XWBSEC("XUS DUZ") ; VISTA kills off DUZ if vc needs changing.
44 . ; That's fine when it can get it back. But we are not a stateful process.
45 . ; By the time the second request is made, XUS DUZ is gone gone gone.
46 . d s(sessid) ; Save symbol table for next page (including DUZ)
47 . d setRedirect^%zewdAPI("cvc",sessid) ; Next page is cvc.
48 . d setSessionValue^%zewdAPI("cvcForced",1,sessid) ; Need to know that the user is toast!
49 ;
50 i $l(result) q result ; General Error Message - User can't log-in
51 ;
52 e d q "" ; Everything Okay
53 . d s(sessid)
54 . i $$isCheckboxOn^%zewdAPI("cvc","cvc",sessid) d setRedirect^%zewdAPI("cvc",sessid)
55 ;
56SO(ac,vc) ; Sign-on to VISTA, AV way
57 ; TODO: Handle the rest of the return values
58 N return
59 D VALIDAV^XUSRB(.return,$$ENCRYP^XUSRB1(ac_";"_vc))
60 i return(0)>0,'return(2) q "" ; Sign on successful!
61 i return(0)=0,return(2) q "CVC" ; Verify Code must be changed NOW!
62 i $l(return(3)) q return(3) ; Error Message returned whole
63 ; Note: division selection not implemented here
64 quit ""
65 ; ---
66sss(id) ; Test
67 d setRedirect^%zewdAPI("index",id,"bb")
68 q ""
69whoami(sessid) ; Who Am I? PrePage Script
70 d r(sessid)
71 n Name s Name=$$GET1^DIQ(200,DUZ,.01) ; User Name
72 d setSessionValue^%zewdAPI("Name",Name,sessid)
73 q ""
74cvc(sessid) ; Change Verify Code
75 ; get stored session values for DUZ, IO, and U
76 d r(sessid) ; Restore the Symbol Table
77 n VC1,VC2,VC3
78 s VC1=$$getPasswordValue^%zewdAPI("vc1",sessid)
79 s VC2=$$getPasswordValue^%zewdAPI("vc2",sessid)
80 s VC3=$$getPasswordValue^%zewdAPI("vc3",sessid)
81 ; Uppercase them -- otherwise CVC will fail.
82 s VC1=$$UP^XLFSTR(VC1)
83 s VC2=$$UP^XLFSTR(VC2)
84 s VC3=$$UP^XLFSTR(VC3)
85 ; Roman Cipher them vista-wise
86 n eVC1,eVC2,eVC3
87 s eVC1=$$ENCRYP^XUSRB1(VC1)
88 s eVC2=$$ENCRYP^XUSRB1(VC2)
89 s eVC3=$$ENCRYP^XUSRB1(VC3)
90 ; Set-up Call
91 n vcString s vcString=eVC1_U_eVC2_U_eVC3
92 n ret
93 d CVC^XUSRB(.ret,vcString)
94 i ret(0)=0 q "" ; Success
95 i ret(0)>0 q ret(1) ; Failure
96 ;;
97 ;;return(0)=0
98 ;;return(1)=0
99 ;;return(2)=1
100 ;;return(3)="VERIFY CODE must be changed before continued use."
101 ;;return(4)=0
102 ;;return(5)=0
103 ;;return(6)=""
104 ;;return(7)="Good evening DOCTOR,TEN"
105 ;;return(8)=" You last signed on today at 22:19"
106listEWDApps(sessid) ; Lists all available EWD Applicaitons, not including ewdMgr. Intended to be an imitation of a menu.
107 n apps ; Will hold our applications
108 do
109 . n ewdpath s ewdpath=^zewd("config","applicationRootPath")
110 . o "lsApps":(shell="/bin/bash":command="ls -1 "_ewdpath:READONLY)::"PIPE"
111 . u "lsApps"
112 . n line
113 . n counter s counter=1
114 . for read line quit:$zeof do
115 . . i line="ewdMgr" quit ; Don't include ewdMgr
116 . . s apps(counter)=line
117 . . s counter=counter+1
118 . c "lsApps"
119 . zwrite:$g(debug) apps
120 . d mergeArrayToSession^%zewdAPI(.apps,"installedapps",sessid)
121 ;
122 ; Old code: uses JSON
123 ; n appsjson s appsjson=$$arrayToJSON^%zewdJSON("apps")
124 ; zwrite:$g(debug) appsjson
125 ; d setSessionValue^%zewdAPI("appsjson",appsjson,sessid)
126 ;
127 q ""
128redir(sessid)
129 n redirapp s redirapp=$$getRequestValue^%zewdAPI("nextapp",sessid)
130 d setRedirect^%zewdAPI("index",sessid,redirapp)
131 q ""
132 ;
133INQ(sessid) ; DIINQUIRE Application Pre-Page Script
134 n outopt ; Output Options checkbox values
135 d getCheckboxValues^%zewdAPI("outopt",.outopt,sessid)
136 n capopts s capopts="" ; Caption Options to get from checkbox values
137 n i s i=""
138 for set i=$order(outopt(i)) q:i="" s capopts=capopts_i
139 S IOP="HFS" D ^%ZIS ; Open HFS Device
140 U IO ; USE HFS Device
141 D CAPTION^DIQ(200,9,capopts) ; Write Out Report
142 D ^%ZISC ; Close Device
143 ;
144 ; This code doesn't work, and my debugger couldn't go through it.
145 ; something is wrong--and I have an old version of GT.M--why is this happening?
146 ; N PATH S PATH=$$PATH^MXMLPRSE(IO("CLOSE"))
147 ; N FILE S FILE=$P(IO("CLOSE"),PATH,2)
148 ; N RESULT S RESULT=$$FTG^%ZISH(PATH,FILE,$NAME(^TMP("EWDU",$J)),3) ; Doesn't work!!!
149 ;
150 ; ------------------> Read the File Back
151 OPEN IO("CLOSE"):(READONLY:rewind) ; Open Again for reading
152 USE IO("CLOSE") ; Use
153 N CNT S CNT=1 ; Counter
154 KILL ^TMP("EWDU",$J) ; Kill TMP Global
155 FOR DO Q:$ZEOF ; Read the file
156 . N % R %
157 . S ^TMP("EWDU",$J,CNT)=%
158 . S CNT=CNT+1
159 C IO("CLOSE"):(delete) ; Close and delete
160 ; <------------------ Close the File
161 ;
162 ; Move to EWD Session
163 d clearSessionArray^%zewdAPI("DIINQUIRE",sessid)
164 d mergeGlobalToSession^%zewdAPI($NAME(^TMP("EWDU",$J)),"DIINQUIRE",sessid)
165 QUIT ""
Note: See TracBrowser for help on using the repository browser.