-
Notifications
You must be signed in to change notification settings - Fork 1
/
loadVesselData.asp
313 lines (285 loc) · 9.32 KB
/
loadVesselData.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<%
response.expires=-1
'convert the text strings into numbers
UT = int(request.querystring("ut") * 1)
pastUT = -1
'this used to do something but I can't figure out what the hell it was. Maybe not needed anymore
'if request.querystring("pastUT") <> "NaN" then pastUT = int(request.querystring("pastUT") * 1)
'header information that was passed in
output = request.querystring("db") & "Typ3" & request.querystring("type")
'have to open the catalog regardless
db = "..\..\database\dbCatalog.mdb"
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & server.mappath(db) &";" & _
"Persist Security Info=False"
conn.Open(sConnection)
'create and open the tables
set rsCrafts = Server.CreateObject("ADODB.recordset")
'begin loading
rsCrafts.open "select * from Crafts where DB='" & request.querystring("db") & "'", conn, 1, 1
for each field in rsCrafts.fields
output = output & replace(field.name, " ", "") & "~" & field.value & "`"
next
output = left(output, len(output)-1)
output = output & "*"
'get additional data from the individual database
db = "..\..\database\db" & request.querystring("db") & ".mdb"
Dim conn2
Set conn2 = Server.CreateObject("ADODB.Connection")
sConnection2 = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & server.mappath(db) &";" & _
"Persist Security Info=False"
conn2.Open(sConnection2)
'create the tables
set rsCraftData = Server.CreateObject("ADODB.recordset")
set rsResources = Server.CreateObject("ADODB.recordset")
set rsCrew = Server.CreateObject("ADODB.recordset")
set rsComms = Server.CreateObject("ADODB.recordset")
set rsPorts = Server.CreateObject("ADODB.recordset")
set rslaunchTimes = Server.CreateObject("ADODB.recordset")
set rsOrbit = Server.CreateObject("ADODB.recordset")
set rsAscentData = Server.CreateObject("ADODB.recordset")
'query the data
rsCraftData.open "select * from [craft data]", conn2, 2
rsResources.open "select * from [craft resources]", conn2, 2
rsCrew.open "select * from [crew manifest]", conn2, 2
rsComms.open "select * from [craft comms]", conn2, 2
rsPorts.open "select * from [craft ports]", conn2, 2
rsOrbit.open "select * from [flight data]", conn2, 2
rslaunchTimes.open "select * from [launch times]", conn2, 2
rsAscentData.open "select * from [ascent data]", conn2, 2
'let the tracker know if ascent data exists
if not rsAscentData.eof then
output = output & rsAscentData.fields.item("UT") & "~"
rsAscentData.MoveLast
output = output & rsAscentData.fields.item("UT")
output = output & "*"
else
output = output & "false*"
end if
'select the craft data closest to this UT
moveCount = 1
rsCraftData.MoveLast
do until rsCraftData.fields.item("UT") <= UT
rsCraftData.MovePrevious
if rsCraftData.bof then exit do
Loop
actualUT = rsCraftData.fields.item("UT")
'if we have a past UT to jump to, keep searching back
'take into account this record might suffice for the new UT
if pastUT >= 0 then
if pastUT < rsCraftData.fields.item("UT") then
do
moveCount = moveCount + 1
rsCraftData.MovePrevious
if rsCraftData.bof then exit do
Loop until rsCraftData.fields.item("UT") <= pastUT
end if
end if
'output the record in name/value pairs for each field if a record exists for this time period
if not rsCraftData.bof then
for each field in rsCraftData.fields
output = output & replace(field.name, " ", "") & "~" & field.value & "`"
next
'if we jumped to another UT, check to see if it is the same record as the current UT. If not, we are looking at a past record
'if it is a past record, reassign the pastUT time so all other records are pulled from the same time as this past vessel data update
'this check is mainly for someone who tries to access a past record from memory or a general time period
if pastUT >= 0 then
if rsCraftData.fields.item("UT") < actualUT then
output = output & "PastEvent~true^"
bPastEvent = true
pastUT = rsCraftData.fields.item("UT")
else
output = output & "PastEvent~false^"
end if
else
output = output & "PastEvent~false^"
end if
else
output = output & "null^"
end if
'reset the pointer back to any future record
if not rsCraftData.eof then rsCraftData.Move moveCount
'select the resources data closest to this UT
moveCount = 1
if not rsResources.eof then
rsResources.MoveLast
do until rsResources.fields.item("UT") <= UT
rsResources.MovePrevious
if rsResources.bof then exit do
Loop
end if
if not rsResources.bof and pastUT >= 0 then
if pastUT < rsResources.fields.item("UT") then
do
moveCount = moveCount + 1
rsResources.MovePrevious
if rsResources.bof then exit do
Loop until rsResources.fields.item("UT") <= pastUT
end if
end if
if not rsResources.bof then
NotNull = false
for each field in rsResources.fields
output = output & replace(field.name, " ", "") & "~" & field.value & "`"
if field.name <> "UT" and field.value <> "" then NotNull = true
next
output = output & "NotNull~" & NotNull & "^"
else
output = output & "null^"
end if
if not rsResources.eof then rsResources.Move moveCount
'select the crew data closest to this UT
moveCount = 1
if not rsCrew.eof then
rsCrew.MoveLast
do until rsCrew.fields.item("UT") <= UT
rsCrew.MovePrevious
if rsCrew.bof then exit do
Loop
end if
if not rsCrew.bof and pastUT >= 0 then
if pastUT < rsCrew.fields.item("UT") then
do
moveCount = moveCount + 1
rsCrew.MovePrevious
if rsCrew.bof then exit do
Loop until rsCrew.fields.item("UT") <= pastUT
end if
end if
if not rsCrew.bof then
for each field in rsCrew.fields
output = output & replace(field.name, " ", "") & "~" & field.value & "`"
next
output = left(output, len(output)-1)
output = output & "^"
else
output = output & "null^"
end if
if not rsCrew.eof then rsCrew.Move moveCount
'select the comms data closest to this UT
moveCount = 1
if not rsComms.eof then
rsComms.MoveLast
do until rsComms.fields.item("UT") <= UT
rsComms.MovePrevious
if rsComms.bof then exit do
Loop
end if
if not rsComms.bof and pastUT >= 0 then
if pastUT < rsComms.fields.item("UT") then
do
moveCount = moveCount + 1
rsComms.MovePrevious
if rsComms.bof then exit do
Loop until rsComms.fields.item("UT") <= pastUT
end if
end if
if not rsComms.bof then
NotNull = false
for each field in rsComms.fields
output = output & replace(field.name, " ", "") & "~" & field.value & "`"
if (field.name <> "UT" or field.name <> "Connection") and field.value <> "" then NotNull = true
next
output = output & "NotNull~" & NotNull & "^"
else
output = output & "null^"
end if
if not rsComms.eof then rsComms.Move moveCount
'select the orbital data closest to this UT
moveCount = 1
if not rsOrbit.eof then
rsOrbit.MoveLast
do until rsOrbit.fields.item("UT") <= UT
rsOrbit.MovePrevious
if rsOrbit.bof then exit do
Loop
end if
if not rsOrbit.bof and pastUT >= 0 then
if pastUT < rsOrbit.fields.item("UT") then
do
moveCount = moveCount + 1
rsOrbit.MovePrevious
if rsOrbit.bof then exit do
Loop until rsOrbit.fields.item("UT") <= pastUT
end if
end if
if not rsOrbit.bof then
for each field in rsOrbit.fields
output = output & replace(field.name, " ", "") & "~" & field.value & "`"
next
output = left(output, len(output)-1)
output = output & "^"
else
output = output & "null^"
end if
if not rsOrbit.eof then rsOrbit.Move moveCount
'select the ports data closest to this UT
moveCount = 1
if not rsPorts.eof then
rsPorts.MoveLast
do until rsPorts.fields.item("UT") <= UT
rsPorts.MovePrevious
if rsPorts.bof then exit do
Loop
end if
if not rsPorts.bof and pastUT >= 0 then
if pastUT < rsPorts.fields.item("UT") then
do
moveCount = moveCount + 1
rsPorts.MovePrevious
if rsPorts.bof then exit do
Loop until rsPorts.fields.item("UT") <= pastUT
end if
end if
if not rsPorts.bof then
for each field in rsPorts.fields
output = output & replace(field.name, " ", "") & "~" & field.value & "`"
next
output = left(output, len(output)-1)
output = output & "*"
else
output = output & "null*"
end if
if not rsPorts.eof then rsPorts.Move moveCount
'now output all the events for the history paging
rsCraftData.MoveFirst
do until rsCraftData.eof
output = output & rsCraftData.fields.item("UT") & "~" & rsCraftData.fields.item("CraftDescTitle") & "|"
rsCraftData.MoveNext
loop
output = left(output, len(output)-1)
output = output & "*"
'and all the events for the launch time history
if not rslaunchTimes.eof then
rslaunchTimes.MoveFirst
do until rslaunchTimes.eof
output = output & rslaunchTimes.fields.item("UT") & "~" & rslaunchTimes.fields.item("LaunchTime") & "|"
rslaunchTimes.MoveNext
loop
output = left(output, len(output)-1)
output = output & "*"
else
output = output & "null*"
end if
'aaaand now the orbital changes history so we can calculate orbit count
if not rsOrbit.bof then rsOrbit.moveFirst
if not rsOrbit.eof then
do until rsOrbit.eof
output = output & rsOrbit.fields.item("UT") & "~" & rsOrbit.fields.item("Orbital Period") & "|"
rsOrbit.movenext
Loop
output = left(output, len(output)-1)
output = output & "*"
else
output = output & "null*"
end if
conn2.Close
Set conn2 = nothing
'post the final results and cleanup
response.write(left(output, len(output)-1))
conn.Close
Set conn = nothing
%>