-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetContent.ashx
729 lines (607 loc) · 33.5 KB
/
GetContent.ashx
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
<%@ WebHandler Language="C#" Class="GetContent" %>
using System;
using System.Web;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
public class GetContent : IHttpHandler {
string sdkRoot = "C:\\Inetpub\\wwwroot\\sdk\\";
private string GetHtml(string file)
{
if (File.Exists(file))
{
StringBuilder retval = new StringBuilder();
using (System.IO.FileStream s = System.IO.File.OpenRead(file))
{
using (System.IO.StreamReader reader = new System.IO.StreamReader(s))
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (retval.Length > 0)
retval.Append("<br/>");
retval.Append(line);
}
return retval.ToString();
}
}
}
return "No information available";
}
private string GetDescription(FileInfo file)
{
if (Regex.Match(file.Name, @"gdal-.*-core\.msi", RegexOptions.IgnoreCase).Success)
return "Generic installer for the GDAL core components";
if (Regex.Match(file.Name, @"gdal-.*-ecw\.msi", RegexOptions.IgnoreCase).Success)
return "Installer for the GDAL ECW plugin (must be installed to the same directory as the GDAL core)";
if (Regex.Match(file.Name, @"gdal-.*-oracle\.msi", RegexOptions.IgnoreCase).Success)
return "Installer for the GDAL Oracle plugin (must be installed to the same directory as the GDAL core)";
if (Regex.Match(file.Name, @"gdal-.*-mrsid\.msi", RegexOptions.IgnoreCase).Success)
return "Installer for the GDAL MrSID plugin (must be installed to the same directory as the GDAL core)";
if (Regex.Match(file.Name, @"GDAL-.*py.*\.(exe|msi)", RegexOptions.IgnoreCase).Success)
return "Installer for the GDAL python bindings (requires to install the GDAL core)";
if (Regex.Match(file.Name, @"MapScript-.*py.*\.(exe|msi)", RegexOptions.IgnoreCase).Success)
return "Installer for the MapScript python bindings (Not yet working)";
return "";
}
private void AppendTableRow(StringBuilder s, string title, string file, string logid)
{
string id = Path.GetFileNameWithoutExtension(file);
s.Append("<tr>");
s.Append("<td class=\"title\"><a href=\"query.html?content=filelist&file=" + file + "\">" + title + "</a></td>");
s.Append("<td>");
if (File.Exists(sdkRoot + "build-output\\" + logid + ".html"))
s.Append("<a href=\"query.html?content=buildlog&id=" + logid + "\">buildlog</a> | <a href=\"query.html?content=msautotest&id=" + logid + "&failures=true\">msautotest</a>");
s.Append("<td>");
if (File.Exists(sdkRoot + "build-output\\status-" + logid + ".html"))
s.Append(File.ReadAllText(sdkRoot + "build-output\\status-" + logid + ".html").Trim());
s.Append("</td>");
if (!logid.EndsWith("sdk"))
{
// adding the revision info
s.Append("<td>");
string rev = "";
string revisionfile = sdkRoot + "downloads\\doc\\" + id + "\\ms_revision.txt";
int rev_number;
if (File.Exists(revisionfile))
{
rev = File.ReadAllText(revisionfile);
int pos = rev.LastIndexOf("revision");
if (pos >= 0)
{
rev = rev.Substring(pos + 9).Split(new char[] { '.', '\n', '\r' })[0];
if (int.TryParse(rev, out rev_number))
rev = "<a href=\"http://trac.osgeo.org/mapserver/changeset/" + rev + "\">r" + rev + "</a>";
}
else if (rev.Length == 40)
{
// github
rev = "<a href=\"https://github.com/mapserver/mapserver/commit/" + rev + "\">" + rev.Substring(0, 10) + "</a>";
}
}
s.Append(rev);
revisionfile = sdkRoot + "downloads\\doc\\" + id + "\\gdal_revision.txt";
if (File.Exists(revisionfile))
{
rev = File.ReadAllText(revisionfile);
int pos = rev.LastIndexOf("revision");
if (pos >= 0)
{
rev = rev.Substring(pos + 9).Split(new char[] { '.', '\n', '\r' })[0];
if (int.TryParse(rev, out rev_number))
rev = ", <a href=\"http://trac.osgeo.org/gdal/changeset/" + rev + "\">r" + rev + "</a>";
}
else if (rev.Length == 40)
{
// github
rev = "<a href=\"https://github.com/gdal/gdal/commit/" + rev + "\">" + rev.Substring(0, 10) + "</a>";
}
}
s.Append(rev);
s.Append("</td>");
}
s.Append("</tr>");
}
private void AppendTableHtml(StringBuilder s, string postfix, string id, string version)
{
AppendTableRow(s, "MSVC2005 (Win32)", "release-1400-" + version + ".zip", "vc8-" + id);
AppendTableRow(s, "MSVC2005 (Win64)", "release-1400-x64-" + version + ".zip", "vc8x64-" + id);
AppendTableRow(s, "MSVC2008 (Win32)", "release-1500-" + version + ".zip", "vc9-" + id);
AppendTableRow(s, "MSVC2008 (Win64)", "release-1500-x64-" + version + ".zip", "vc9x64-" + id);
if (File.Exists(sdkRoot + "\\downloads\\release-1600-" + version + ".zip"))
{
AppendTableRow(s, "MSVC2010 (Win32)", "release-1600-" + version + ".zip", "vc10-" + id);
AppendTableRow(s, "MSVC2010 (Win64)", "release-1600-x64-" + version + ".zip", "vc10x64-" + id);
}
}
private void ProcessBuildStatus(HttpContext context)
{
context.Response.Write("<h1>Current Build Status</h1>");
StringBuilder s = new StringBuilder("<h2><a href=\"development.html\">Development Versions</a></h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "development", "dev", "gdal-mapserver");
s.Append("</table>");
context.Response.Write(s.ToString());
s = new StringBuilder("<h2><a href=\"stable.html\">Stable Branches</a></h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "stable", "stable-1.9-6-0", "gdal-1-9-mapserver-6-0");
s.Append("</table>");
context.Response.Write(s.ToString());
s = new StringBuilder("<h2><a href=\"release.html\">Release Versions</a></h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "release", "released-1.9-6-0", "gdal-1-9-1-mapserver-6-0-3");
s.Append("</table>");
context.Response.Write(s.ToString());
s = new StringBuilder("<h2><a href=\"sdk.html\">Development Kits</a></h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th></tr>");
AppendTableHtml(s, "sdk", "sdk", "dev");
s.Append("</table>");
context.Response.Write(s.ToString());
}
private void ProcessArchive(HttpContext context)
{
context.Response.Write("<h1>Archive versions</h1>");
StringBuilder s = new StringBuilder("<h2>gdal-1-10-1-mapserver-6-4-0</h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "release", "released-1.10-6-4", "gdal-1-10-1-mapserver-6-4-0");
s.Append("</table>");
context.Response.Write(s.ToString());
s = new StringBuilder("<h2>gdal-1-10-0-mapserver-6-2-1</h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "release", "released-1.10-6-2", "gdal-1-10-0-mapserver-6-2-1");
s.Append("</table>");
context.Response.Write(s.ToString());
s = new StringBuilder("<h2>gdal-1-9-2-mapserver-6-2-0</h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "release", "released-1.9-6-2", "gdal-1-9-2-mapserver-6-2-0");
s.Append("</table>");
context.Response.Write(s.ToString());
s = new StringBuilder("<h2>gdal-1-9-1-mapserver-6-0-3/h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "release", "released-1.9-6-0", "gdal-1-9-1-mapserver-6-0-3");
s.Append("</table>");
context.Response.Write(s.ToString());
s = new StringBuilder("<h2>gdal-1-9-0-mapserver-6-0-1</h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "release", "released-1.9-6-0", "gdal-1-9-0-mapserver-6-0-1");
s.Append("</table>");
context.Response.Write(s.ToString());
s = new StringBuilder("<h2>gdal-1-8-1-mapserver-6-0-1</h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "release", "released-1.8-6-0", "gdal-1-8-1-mapserver-6-0-1");
s.Append("</table>");
context.Response.Write(s.ToString());
s = new StringBuilder("<h2>gdal-1-8-0-mapserver-6-0-0</h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "release", "released-1.8-6-0", "gdal-1-8-0-mapserver-6-0-0");
s.Append("</table>");
context.Response.Write(s.ToString());
s = new StringBuilder("<h2>gdal-1-8-0-mapserver-5-6-6</h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "release", "released-1.8-5-6", "gdal-1-8-0-mapserver-5-6-6");
s.Append("</table>");
context.Response.Write(s.ToString());
s = new StringBuilder("<h2>gdal-1-7-3-mapserver-5-6-5</h2>");
s.Append("<table><tr><th>Compiler (Platform)</th><th>Build log</th><th>Build status</th><th>Latest revision</th></tr>");
AppendTableHtml(s, "release", "released-1.7-5-6", "gdal-1-7-3-mapserver-5-6-5");
s.Append("</table>");
context.Response.Write(s.ToString());
}
private void ProcessFilelist(HttpContext context)
{
string fileIn = context.Request["file"];
if (fileIn == null)
{
context.Response.Write("No file have been specified.");
return;
}
string baseUrl = context.Request.Url.Scheme + "://" + context.Request.Url.Authority + context.Request.ApplicationPath.TrimEnd('/') + '/';
StringBuilder contents = new StringBuilder();
string dirName = Path.GetFileNameWithoutExtension(fileIn);
contents.Append("<p>Available downloads (<b>" + dirName + "</b>):</p>");
contents.Append("<table>");
contents.Append("<tr><th>File name</th><th>File date</th><th>Size</th><th>Description</th>");
if (File.Exists(sdkRoot + "downloads\\" + fileIn))
{
FileInfo file = new FileInfo(sdkRoot + "downloads\\" + fileIn);
contents.Append("<tr><td><a href=\"" + baseUrl + "Download.aspx?file=" + file.Name + "\">" + file.Name + "</a></td><td>" + file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToShortTimeString() + "</td><td>" + Math.Round((double)file.Length / 1024).ToString() + " kB</td><td>Compiled binaries in a single .zip package</td></tr>");
}
if (File.Exists(sdkRoot + "downloads\\" + dirName + "-src.zip"))
{
FileInfo file = new FileInfo(sdkRoot + "downloads\\" + dirName + "-src.zip");
contents.Append("<tr><td><a href=\"" + baseUrl + "Download.aspx?file=" + file.Name + "\">" + file.Name + "</a></td><td>" + file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToShortTimeString() + "</td><td>" + Math.Round((double)file.Length / 1024).ToString() + " kB</td><td>GDAL and MapServer sources</td></tr>");
}
if (File.Exists(sdkRoot + "downloads\\" + dirName + "-libs.zip"))
{
FileInfo file = new FileInfo(sdkRoot + "downloads\\" + dirName + "-libs.zip");
contents.Append("<tr><td><a href=\"" + baseUrl + "Download.aspx?file=" + file.Name + "\">" + file.Name + "</a></td><td>" + file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToShortTimeString() + "</td><td>" + Math.Round((double)file.Length / 1024).ToString() + " kB</td><td>Compiled libraries and headers</td></tr>");
}
DirectoryInfo di = new DirectoryInfo(sdkRoot + "downloads\\" + dirName);
if (di.Exists)
{
FileInfo[] files = di.GetFiles();
foreach (FileInfo file in files)
{
contents.Append("<tr><td><a href=\"" + baseUrl + "Download.aspx?file=" + dirName + "/" + file.Name + "\">" + file.Name + "</a></td><td>" + file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToShortTimeString() + "</td><td>" + Math.Round((double)file.Length / 1024).ToString() + " kB</td><td>" + GetDescription(file) + "</td></tr>");
}
}
contents.Append("</table>");
if (di.Exists)
{
contents.Append("<p><span class=\"note\">Note:</span> In order to have the bindings work the location of the core components must be included manually in the PATH environment variable.</p>");
}
context.Response.Write(contents.ToString());
}
private void ProcessPackageinfo(HttpContext context)
{
string file = context.Request.QueryString["file"];
if (file == null)
{
context.Response.Write("No file have been specified.");
return;
}
}
private void ProcessChangeLog(HttpContext context)
{
string[] log = File.ReadAllLines("E:\\builds\\changelog.txt");
for (int i = log.Length - 1; i >= 0; --i)
{
context.Response.Write(log[i].Substring(2));
context.Response.Write("<br/>");
}
}
private void ProcessText(HttpContext context)
{
string file = context.Request.QueryString["file"];
if (file == null)
{
context.Response.Write("No file have been specified.");
return;
}
context.Response.Write(GetHtml(sdkRoot + file).Replace("\t","").Replace("\r","").Replace("\n",""));
}
private void ProcessBuildLog(HttpContext context)
{
string id = context.Request.QueryString["id"];
if (id == null)
return;
string file = sdkRoot + "build-output\\" + id + ".html";
if (File.Exists(file))
{
string[] sections = File.ReadAllText(file).Split(new string[] { "<hr/>" }, StringSplitOptions.None);
for (int i = 1; i <= 30; i++)
{
if (i > sections.Length)
break;
context.Response.Write(sections[sections.Length - i].Replace("\r\n", ""));
context.Response.Write("<hr/>");
}
//using (System.IO.FileStream s = System.IO.File.OpenRead(file))
//{
// using (System.IO.StreamReader reader = new System.IO.StreamReader(s))
// {
// string line;
// while ((line = reader.ReadLine()) != null)
// {
// context.Response.Write(line/*.Replace("http://www.gisinternals.com/sdk/", "query.html?content=text&file=")*/);
// }
// }
//}
}
else
context.Response.Write("The specified file doesn't exists!");
}
public void ProcessMSAutotest(HttpContext context)
{
string id = context.Request.QueryString["id"];
if (id == null)
return;
string failures = context.Request.QueryString["failures"];
string file = sdkRoot + "build-output/" + id + ".html";
if (!File.Exists(file))
{
context.Response.Write("The specified file doesn't exists!");
return;
}
// finding out the latest msautotest output
string[] lines = File.ReadAllLines(file);
string[] tokens;
StringBuilder html = new StringBuilder();
for (int i = lines.Length - 1; i >= 0; --i)
{
if (lines[i].Contains("MapServer autotest started"))
{
tokens = lines[i].Split(new string[] { "<a href=\"", " ", "\">stdout</a>", "\">stderr</a>" }, StringSplitOptions.RemoveEmptyEntries);
string resultfile = tokens[1].Replace("http://www.gisinternals.com/sdk/", sdkRoot);
if (!File.Exists(resultfile))
{
resultfile = tokens[1].Replace("http://vbkto.dyndns.org:1280/sdk/", sdkRoot);
if (!File.Exists(resultfile))
{
context.Response.Write("Unable to find autotest results!");
return;
}
}
// parsing the autotest results
lines = File.ReadAllLines(resultfile);
string autotest_dir = lines[0].Substring(4);
string testdir = "";
string mapfile = "";
string mapfilepath = "";
string results = "";
string requires = "";
List<string> run_params = new List<string>();
List<string> out_files = new List<string>();
int run_count = 0;
string[] renderers = new string[] { "", ".png24", ".png" };
int current_renderer = 0;
html.AppendLine("<h1>Test results for <span class=\"filename\">" + id + "</span></h1>");
html.AppendLine("<p>The raw outputs of the tests are avalilable from these direct links: <a href=\"" + tokens[1] + "\">stdout</a> <a href=\"" + tokens[2] + "\">stderr</a></p>");
if (failures == null)
html.AppendLine("<p>Click <a href=\"MSAutotest.aspx?id=" + id + "&failures=true\">here</a> to show the failures only.</p>");
else
html.AppendLine("<p>Click <a href=\"MSAutotest.aspx?id=" + id + "\">here</a> to show all results.</p>");
for (int j = 1; j < lines.Length; j++)
{
if (lines[j].Contains("cd gdal"))
{
if (testdir != "")
html.AppendLine("</table>");
current_renderer = 0;
html.AppendLine("<h2>gdal test results</h2>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
testdir = autotest_dir + "\\gdal\\";
}
if (lines[j].Contains("cd misc"))
{
if (testdir != "")
html.AppendLine("</table>");
current_renderer = 0;
html.AppendLine("<h2>misc test results</h2>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
testdir = autotest_dir + "\\misc\\";
}
if (lines[j].Contains("cd wxs"))
{
if (testdir != "")
html.AppendLine("</table>");
current_renderer = 0;
html.AppendLine("<h2>wxs test results</h2>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
testdir = autotest_dir + "\\wxs\\";
}
if (lines[j].Contains("cd renderers"))
{
if (testdir != "")
html.AppendLine("</table>");
current_renderer = 1;
html.AppendLine("<h2>renderers test results</h2>");
html.AppendLine("<p>renderer = <span style=\"color:Blue;font-weight:bold\">" + renderers[current_renderer].Substring(1) + "</span></p>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
testdir = autotest_dir + "\\renderers\\";
}
if (lines[j].Contains("cd query"))
{
if (testdir != "")
html.AppendLine("</table>");
current_renderer = 0;
html.AppendLine("<h2>query test results</h2>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
testdir = autotest_dir + "\\query\\";
}
if (lines[j].StartsWith("Test done"))
{
if (testdir != "")
html.AppendLine("</table>");
// collect summary
StringBuilder summary = new StringBuilder("Summary of the test: ");
summary.Append("<span style=\"color:Green;font-weight:bold\">" + lines[j].Substring(10) + "</span>");
if (++j < lines.Length)
summary.Append(" " + lines[j]);
if (++j < lines.Length)
summary.Append(", " + lines[j]);
if (++j < lines.Length)
summary.Append(", " + lines[j]);
if (++j < lines.Length)
summary.Append(", " + lines[j]);
if (++j < lines.Length && lines[j].Contains("Serious Failure!"))
summary.Append(", " + lines[j].Replace("Serious Failure!", "<span style=\"color:Red;font-weight:bold\">Serious Failure!</span>"));
html.AppendLine("<p>" + summary + "</p>");
if (current_renderer > 0)
++current_renderer;
if (current_renderer == renderers.Length)
current_renderer = 0;
else if (current_renderer > 0)
{
html.AppendLine("<p>renderer = <span style=\"color:Blue;font-weight:bold\">" + renderers[current_renderer].Substring(1) + "</span></p>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
}
}
if (lines[j].StartsWith(" test"))
{
string testFile = lines[j].Substring(8);
if (run_params.Count == run_count || testFile != out_files[run_count])
{
// There's something
continue;
}
// read result
if (j < lines.Length - 1)
results = lines[j + 1].Substring(1).Trim().Replace("TEST FAILED", "<span style=\"color:Red;font-weight:bold\">TEST FAILED</span>");
else
results = "";
if (failures != null && !results.Contains("TEST FAILED"))
{
++j;
++run_count;
continue;
}
string expected = testdir + "expected\\" + out_files[run_count];
if (File.Exists(expected))
expected = "<a href=\"ShowFile.aspx?file=" + testdir + "expected\\" + out_files[run_count] + "\">" + out_files[run_count] + "</a>";
else
expected = "";
string result = testdir + "result\\" + out_files[run_count];
if (!results.Contains("results match") && File.Exists(result))
result = "<a href=\"ShowFile.aspx?file=" + testdir + "result\\" + out_files[run_count] + "\">" + out_files[run_count] + "</a>";
else
result = "";
StringBuilder run_param = new StringBuilder(run_params[run_count]);
run_param.Replace("[MAPSERV]", "mapserv.exe");
run_param.Replace("[LEGEND]", "legend.exe");
run_param.Replace("[SCALEBAR]", "scalebar.exe");
run_param.Replace("[SHP2IMG]", "shp2img.exe");
run_param.Replace("[MAPFILE]", mapfile);
run_param.Replace("[RESULT]", out_files[run_count]);
run_param.Replace("[RESULT_DEMIME]", out_files[run_count]);
run_param.Replace("[RESULT_DEVERSION]", out_files[run_count]);
run_param.Replace("[POST]", "\"");
run_param.Replace("[/POST]", "\"");
if (current_renderer > 0)
run_param.Replace("[RENDERER]", "-i " + renderers[current_renderer].Substring(1));
else
run_param.Replace("[RENDERER]", "");
html.AppendLine("<tr><td><a href=\"ShowFile.aspx?file=" + mapfilepath + "\">" + mapfile + "</a></td><td>" + results + "</td><td>" + expected + "</td><td>" + result + "</td><td>" + requires + "</td><td>" + run_param.ToString() + "</td></tr>");
++run_count;
++j; // skip result row
}
if (lines[j].StartsWith(" Processing:"))
{
mapfile = lines[j].Substring(13);
mapfilepath = testdir + mapfile;
requires = "";
if (File.Exists(mapfilepath))
{
string[] maplines = File.ReadAllLines(mapfilepath);
run_params.Clear();
out_files.Clear();
run_count = 0;
foreach (string mapline in maplines)
{
if (mapline.Contains("REQUIRES:"))
requires = mapline.Substring(12).Trim();
else if (mapline.Contains("RUN_PARMS:"))
{
string[] items = mapline.Substring(13).Trim().Split();
if (items.Length >= 2)
{
StringBuilder cmdLine = new StringBuilder(items[1]);
out_files.Add(items[0]);
for (int c = 2; c < items.Length; c++)
{
cmdLine.Append(" " + items[c]);
}
run_params.Add(cmdLine.ToString());
}
else if (items.Length == 1)
{
out_files.Add(items[0]);
run_params.Add("[SHP2IMG] [RENDERER] -m [MAPFILE] -o [RESULT]");
}
}
}
if (run_params.Count == 0)
{
out_files.Add(mapfile.Replace(".map", renderers[current_renderer] + ".png"));
run_params.Add("[SHP2IMG] [RENDERER] -m [MAPFILE] -o [RESULT]");
}
// single test case
if (run_params.Count == 1)
{
// read result
if (j < lines.Length - 1)
results = lines[j + 1].Substring(1).Trim().Replace("TEST FAILED", "<span style=\"color:Red;font-weight:bold\">TEST FAILED</span>");
else
results = "";
if (failures != null && !results.Contains("TEST FAILED"))
{
++j;
continue;
}
string expected = testdir + "expected\\" + out_files[0];
if (File.Exists(expected))
expected = "<a href=\"ShowFile.aspx?file=" + testdir + "expected\\" + out_files[0] + "\">" + out_files[0] + "</a>";
else
expected = "";
string result = testdir + "result\\" + out_files[0];
if (!results.Contains("results match") && File.Exists(result))
result = "<a href=\"ShowFile.aspx?file=" + testdir + "result\\" + out_files[0] + "\">" + out_files[0] + "</a>";
else
result = "";
StringBuilder run_param = new StringBuilder(run_params[0]);
run_param.Replace("[MAPSERV]", "mapserv.exe");
run_param.Replace("[LEGEND]", "legend.exe");
run_param.Replace("[SCALEBAR]", "scalebar.exe");
run_param.Replace("[SHP2IMG]", "shp2img.exe");
run_param.Replace("[MAPFILE]", mapfile);
run_param.Replace("[RESULT]", out_files[0]);
run_param.Replace("[RESULT_DEMIME]", out_files[0]);
run_param.Replace("[RESULT_DEVERSION]", out_files[0]);
run_param.Replace("[POST]", "\"");
run_param.Replace("[/POST]", "\"");
if (current_renderer > 0)
run_param.Replace("[RENDERER]", "-i " + renderers[current_renderer].Substring(1));
else
run_param.Replace("[RENDERER]", "");
html.AppendLine("<tr><td><a href=\"ShowFile.aspx?file=" + mapfilepath + "\">" + mapfile + "</a></td><td>" + results + "</td><td>" + expected + "</td><td>" + result + "</td><td>" + requires + "</td><td>" + run_param.ToString() + "</td></tr>");
++j; // skip result row
}
}
}
}
if (testdir != "")
html.AppendLine("</table>");
break;
}
}
}
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
context.Response.Write(context.Request["callback"]);
context.Response.Write("({'html': '");
switch (context.Request["content"])
{
case "filelist":
ProcessFilelist(context);
break;
case "packageinfo":
ProcessPackageinfo(context);
break;
case "changelog":
ProcessChangeLog(context);
break;
case "buildlog":
ProcessBuildLog(context);
break;
case "status":
ProcessBuildStatus(context);
break;
case "archive":
ProcessArchive(context);
break;
case "text":
ProcessText(context);
break;
case "msautotest":
ProcessMSAutotest(context);
break;
default:
context.Response.Write("Content not available at server.");
break;
}
context.Response.Write("'})");
}
public bool IsReusable {
get {
return false;
}
}
}