|
| 1 | +*--------------------------------------------------------------- |
| 2 | +. |
| 3 | +. Program Name: answer |
| 4 | +. Description: Answer program for 2019 conference |
| 5 | +. |
| 6 | +. Revision History: |
| 7 | +. |
| 8 | +. 21 Jun 19 W Keech |
| 9 | +. Original code |
| 10 | +. |
| 11 | +*--------------------------------------------------------------- |
| 12 | + INCLUDE plbequ.inc |
| 13 | + INCLUDE plbmeth.inc |
| 14 | + |
| 15 | +signonPath DIM %100 |
| 16 | +httpRootPath DIM %100 // For downloads |
| 17 | +httpRootPath1 DIM %100 // For browser access |
| 18 | +urlPath DIM %100 |
| 19 | +signonName DIM %40 |
| 20 | + |
| 21 | +signon PLFORM signon.pwf |
| 22 | + |
| 23 | +userPath INIT "C:\sunbelt\td\" |
| 24 | +userIsiName DIM 260 |
| 25 | +userFileName DIM 260 |
| 26 | +users IFILE |
| 27 | +userName DIM 20 |
| 28 | +userPswd DIM 20 |
| 29 | + |
| 30 | +*................................................................ |
| 31 | +. |
| 32 | +. Code start |
| 33 | +. |
| 34 | + CALL Main |
| 35 | + STOP |
| 36 | + |
| 37 | +*................................................................ |
| 38 | +. |
| 39 | +. FetchJsonStringValue - Fetch string data for String 'label' |
| 40 | +. |
| 41 | +. Only update the result if the label is found |
| 42 | +. |
| 43 | +FetchJsonStringValue LFUNCTION |
| 44 | +pXData XDATA ^ |
| 45 | +xLabel DIM 50 |
| 46 | +dReturn DIM ^ |
| 47 | + ENTRY |
| 48 | +. |
| 49 | +xString DIM 200 |
| 50 | +x200 DIM 200 |
| 51 | +xError DIM 100 |
| 52 | +nvar FORM 2 |
| 53 | +. |
| 54 | +. Find the specified JSON label node |
| 55 | +. |
| 56 | + PACK s$cmdlin, "label='",xLabel,"'" |
| 57 | + pXData.FindNode GIVING nvar: |
| 58 | + USING *FILTER=S$cmdlin: //Locate specified JSON label! |
| 59 | + *POSITION=START_DOCUMENT_NODE //Start at the beginning of the document! |
| 60 | + IF ( nvar == 0 ) |
| 61 | +... |
| 62 | +. Move to the child node of the 'orient' JSON label. |
| 63 | +. |
| 64 | + pXData.MoveToNode GIVING nvar USING *POSITION=MOVE_FIRST_CHILD |
| 65 | +. |
| 66 | + IF ( nvar == 0 ) |
| 67 | +... |
| 68 | +. Fetch the data for the JSON label. |
| 69 | +. |
| 70 | + pXData.GetText GIVING xString |
| 71 | + PACK s$cmdlin, xLabel,"= '",xString,"'" |
| 72 | + ELSE |
| 73 | + MOVE "Error Move Node:", s$cmdlin |
| 74 | + ENDIF |
| 75 | + ELSE |
| 76 | + PACK s$cmdlin, "Error Find Node:",nvar |
| 77 | + ENDIF |
| 78 | + |
| 79 | + TYPE xString |
| 80 | + IF NOT EOS |
| 81 | + MOVE xString, dReturn |
| 82 | + ENDIF |
| 83 | + |
| 84 | + FUNCTIONEND |
| 85 | + |
| 86 | + |
| 87 | +*................................................................ |
| 88 | +. |
| 89 | +. Logon - Get the name and check against a file |
| 90 | +. |
| 91 | +Logon LFUNCTION |
| 92 | + ENTRY |
| 93 | +Name DIM 20 |
| 94 | +Pswd DIM 20 |
| 95 | +nvar FORM 2 |
| 96 | +rootPath DIM 100 |
| 97 | +saveToPath DIM 40 |
| 98 | +runtime RUNTIME |
| 99 | + |
| 100 | + HctlSignon.GetAttr Giving Name Using "uname", "value" |
| 101 | + HctlSignon.GetAttr Giving Pswd Using "psw", "value" |
| 102 | +. |
| 103 | +. Add code to lookup and verify |
| 104 | +. |
| 105 | + READ users,Name;userName,*LL, userPswd, signonName |
| 106 | + IF Over |
| 107 | + ALERT NOTE,"User name not found!", nvar, "PLB Answer" |
| 108 | + RETURN |
| 109 | + ENDIF |
| 110 | + IF (Pswd == userPswd) |
| 111 | +. |
| 112 | +. All ok go to master |
| 113 | +. |
| 114 | + SETPROP signonForm, *Visible=0 |
| 115 | + PACK signonPath, userPath, userName |
| 116 | + SQUEEZE signonPath,signonPath," " |
| 117 | + runtime.GetDir Giving rootPath Using 3 |
| 118 | + runtime.GetDir Giving saveToPath Using 5 |
| 119 | + PACK httpRootPath, rootPath, "\", saveToPath, "td\", userName |
| 120 | + SQUEEZE httpRootPath,httpRootPath," " |
| 121 | + PACK httpRootPath1, rootPath, "\td\", userName |
| 122 | + SQUEEZE httpRootPath1,httpRootPath1," " |
| 123 | + PACK urlPath, "td/",userName, "/" |
| 124 | + SQUEEZE urlPath,urlPath," " |
| 125 | + STOP |
| 126 | + ENDIF |
| 127 | + ALERT NOTE,"Invalid password!", nvar, "PLB Answer" |
| 128 | + FUNCTIONEND |
| 129 | +*................................................................ |
| 130 | +. |
| 131 | +. SignonEvent - Main event handler for the Signon form |
| 132 | +. |
| 133 | +SignonEvent LFUNCTION |
| 134 | + ENTRY |
| 135 | +JsonData DIM 4096 |
| 136 | +JsonEvent XDATA |
| 137 | +BtnId DIM 20 |
| 138 | + |
| 139 | + EVENTINFO 0, Arg1=JsonData |
| 140 | + JsonEvent.LoadJson Using JsonData |
| 141 | + |
| 142 | + CALL FetchJsonStringValue Using JsonEvent,"id",BtnId |
| 143 | + SWITCH BtnId |
| 144 | + CASE "cancel" |
| 145 | + SHUTDOWN |
| 146 | + CASE "logon" |
| 147 | + CALL Logon |
| 148 | + CASE "forgot" |
| 149 | + SHUTDOWN |
| 150 | + ENDSWITCH |
| 151 | + FUNCTIONEND |
| 152 | +*................................................................ |
| 153 | +. |
| 154 | +. Shutdown if not handle files |
| 155 | +. |
| 156 | +Shutdown |
| 157 | + SHUTDOWN |
| 158 | +*................................................................ |
| 159 | +. |
| 160 | +. Make Isam |
| 161 | +. |
| 162 | +MakeIsam LFUNCTION |
| 163 | + ENTRY |
| 164 | +attdFile FILE |
| 165 | +seq FORM "-1" |
| 166 | +name DIM 2 |
| 167 | +fullName DIM 40 |
| 168 | +saveToPath DIM 100 |
| 169 | +rootPath DIM 100 |
| 170 | +httpRootPath DIM 300 |
| 171 | +newPath DIM 300 |
| 172 | +runtime RUNTIME |
| 173 | + |
| 174 | + // Get the http root and add a td direcoty |
| 175 | + runtime.GetDir Giving rootPath Using 3 |
| 176 | + PACK httpRootPath1, rootPath, "\td" |
| 177 | + SQUEEZE httpRootPath1,httpRootPath1," " |
| 178 | + PATH Create Using httpRootPath1 |
| 179 | + |
| 180 | + runtime.GetDir Giving saveToPath Using 5 |
| 181 | + PACK httpRootPath, rootPath, "\", saveToPath, "td" |
| 182 | + SQUEEZE httpRootPath,httpRootPath," " |
| 183 | + PATH Create Using httpRootPath |
| 184 | + |
| 185 | + PATH Create Using userPath |
| 186 | + TRAP Shutdown If IO |
| 187 | + PACK userFileName With userPath, "conf2019users.txt" |
| 188 | + OPEN attdFile, userFileName |
| 189 | + |
| 190 | + PACK userFileName With userPath, "confusers.txt" |
| 191 | + PREP users, userFileName, userIsiName, "20", "80" |
| 192 | + LOOP |
| 193 | + READ attdFile,seq;name,fullName |
| 194 | + BREAK If OVER |
| 195 | + MOVE name To userName |
| 196 | + MOVE "p" To userPswd |
| 197 | + WRITE users,userName;userName,userPswd,fullName |
| 198 | + PACK newPath, userPath, userName, "\" |
| 199 | + SQUEEZE newPath,newPath," " |
| 200 | + PATH Create Using newPath |
| 201 | + PACK newPath, httpRootPath, "\", userName, "\" |
| 202 | + SQUEEZE newPath,newPath," " |
| 203 | + PATH Create Using newPath |
| 204 | + PACK newPath, httpRootPath1, "\", userName, "\" |
| 205 | + SQUEEZE newPath,newPath," " |
| 206 | + PATH Create Using newPath |
| 207 | + REPEAT |
| 208 | + FUNCTIONEND |
| 209 | +*................................................................ |
| 210 | +. |
| 211 | +. Main - Main entry point |
| 212 | +. |
| 213 | +Main LFUNCTION |
| 214 | + ENTRY |
| 215 | +client CLIENT |
| 216 | +isCordova FORM 1 |
| 217 | + |
| 218 | + WINHIDE |
| 219 | + TRAP MakeIsam If IO |
| 220 | + PACK userIsiName With userPath, "confusers.isi" |
| 221 | + OPEN users,userIsiName |
| 222 | + TRAPCLR IO |
| 223 | + FORMLOAD signon |
| 224 | + client.GetState GIVING isCordova USING *STATEMASK=2 |
| 225 | + IF ( isCordova == 1 ) |
| 226 | + SETPROP SignonForm,Webwidth="100%" |
| 227 | + ENDIF |
| 228 | + LOOP |
| 229 | + EVENTWAIT |
| 230 | + REPEAT |
| 231 | + FUNCTIONEND |
0 commit comments