forked from microsoft/nav-arm-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Default.aspx
623 lines (576 loc) · 21.2 KB
/
Default.aspx
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
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Page Language="c#" debug="true" %>
<script runat="server">
private string getHostname()
{
return System.IO.File.ReadAllText(Server.MapPath(".")+@"\hostname.txt").ToLowerInvariant().Trim();
}
private string getContainerName()
{
return System.IO.File.ReadAllText(Server.MapPath(".")+@"\containerName.txt").ToLowerInvariant().Trim();
}
private string getClickOnceUrl()
{
return System.IO.File.ReadAllText(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\clickonce.txt");
}
private string GetIPAddress()
{
return System.Web.HttpContext.Current.Request.UserHostAddress;
}
private string getProduct()
{
if (System.IO.File.Exists(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\title.txt")) {
return System.IO.File.ReadAllText(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\title.txt");
}
return System.IO.File.ReadAllText(Server.MapPath(".")+@"\title.txt");
}
private string createQrImg(string link, string title, int width = 100, int height = 100)
{
var encodedlink = System.Net.WebUtility.UrlEncode(link);
return string.Format("<img src=\"https://chart.googleapis.com/chart?cht=qr&chs=100x100&chl={0}&chld=L|0\" title=\"{1}\" width=\"{2}\" height=\"{3}\" />", encodedlink, title, width, height);
}
private string getLandingPageUrl()
{
if (isTraefikUsed())
return getHostname() + ":8180";
else
return getHostname();
}
private string getConfigureAppUrl()
{
var url = "";
if (isTraefikUsed())
url = "ms-dynamicsnav://"+getHostname()+"/"+getContainerName();
else
url = "ms-dynamicsnav://"+getHostname()+"/nav";
if (isMultitenant())
{
url += "?tenant=default";
}
return url;
}
private string createQrForLandingPage()
{
return createQrImg("http://"+getLandingPageUrl(), getProduct());
}
private string getCountry()
{
if (System.IO.File.Exists(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\country.txt"))
{
var ct = System.IO.File.ReadAllText(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\country.txt").ToUpperInvariant().Trim();
if (string.IsNullOrEmpty(ct)) {
return "W1";
}
if (ct.StartsWith("FIN")) {
return ct.Substring(3);
}
return ct;
}
return "W1";
}
private string getBuildNumber()
{
var ct = "";
if (System.IO.File.Exists(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\country.txt"))
{
ct = System.IO.File.ReadAllText(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\country.txt").Trim();
}
var cu = "";
if (System.IO.File.Exists(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\cu.txt"))
{
cu = System.IO.File.ReadAllText(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\cu.txt").Trim();
}
if (System.IO.File.Exists(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\version.txt"))
{
var version = System.IO.File.ReadAllText(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\version.txt").Trim();
if (cu != "") {
version += " ("+cu+", "+ct+")";
} else {
version += " ("+ct+")";
}
return version;
}
return "";
}
private XmlDocument customSettings = null;
private bool GetCustomSettings()
{
if ((this.customSettings == null) && (System.IO.File.Exists(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\CustomSettings.config")))
{
customSettings = new XmlDocument();
customSettings.Load(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\CustomSettings.config");
}
return this.customSettings != null;
}
private bool isMultitenant()
{
if (GetCustomSettings())
{
return customSettings.SelectSingleNode("//appSettings/add[@key='Multitenant']").Attributes["value"].Value.ToLowerInvariant().Equals("true");
}
return false;
}
private string getTenant()
{
if (isMultitenant())
{
return "default";
}
return "";
}
private string getWebBaseUrl()
{
if (GetCustomSettings())
{
var url = customSettings.SelectSingleNode("//appSettings/add[@key='PublicWebBaseUrl']").Attributes["value"].Value.ToLowerInvariant();
if (isMultitenant())
{
url += "?tenant=default";
}
return url;
}
return "";
}
private string getODataBaseUrl()
{
if (GetCustomSettings())
{
var url = customSettings.SelectSingleNode("//appSettings/add[@key='PublicODataBaseUrl']").Attributes["value"].Value.ToLowerInvariant().TrimEnd('/')+"/";
if (isMultitenant())
{
url += "?tenant=default";
}
return url;
}
return "";
}
private string getSoapBaseUrl()
{
if (GetCustomSettings())
{
var url = customSettings.SelectSingleNode("//appSettings/add[@key='PublicSOAPBaseUrl']").Attributes["value"].Value.ToLowerInvariant().TrimEnd('/')+"/services";
if (isMultitenant())
{
url += "?tenant=default";
}
return url;
}
return "";
}
private bool isApisEnabled()
{
if (GetCustomSettings())
{
var node = customSettings.SelectSingleNode("//appSettings/add[@key='ApiServicesEnabled']");
if (node == null) {
return false;
}
return node.Attributes["value"].Value.ToLowerInvariant().Equals("true");
}
return false;
}
private string getApisBaseUrl()
{
if (GetCustomSettings())
{
var url = customSettings.SelectSingleNode("//appSettings/add[@key='PublicODataBaseUrl']").Attributes["value"].Value.ToLowerInvariant().Replace("/odata","/api");
if (isMultitenant())
{
url += "?tenant=default";
}
return url;
}
return "";
}
private string getApisSampleUrl()
{
System.Version version = System.Version.Parse("1.0.0.0");
if (System.IO.File.Exists(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\version.txt"))
{
version = System.Version.Parse(System.IO.File.ReadAllText(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\version.txt").Trim());
}
var query = "/microsoft/automation/beta/companies";
if (version.Major >= 14) {
query = "/v1.0/companies";
}
var url = getApisBaseUrl();
var idx = url.IndexOf('?');
if (idx < 0) {
idx = url.Length;
}
return url.Insert(idx, query);
}
private bool isHttps()
{
return getWebBaseUrl().StartsWith("https://");
}
private string getCompanyName()
{
if (GetCustomSettings())
{
return customSettings.SelectSingleNode("//appSettings/add[@key='ServicesDefaultCompany']").Attributes["value"].Value;
}
return "";
}
private string getServerInstance()
{
if (isTraefikUsed())
{
return getContainerName()+"dev";
}
if (GetCustomSettings())
{
return customSettings.SelectSingleNode("//appSettings/add[@key='ServerInstance']").Attributes["value"].Value;
}
return "";
}
private string getAzureSQL()
{
if (GetCustomSettings())
{
var DatabaseServer = customSettings.SelectSingleNode("//appSettings/add[@key='DatabaseServer']").Attributes["value"].Value;
var DatabaseInstance = customSettings.SelectSingleNode("//appSettings/add[@key='DatabaseInstance']").Attributes["value"].Value;
var DatabaseName = customSettings.SelectSingleNode("//appSettings/add[@key='DatabaseName']").Attributes["value"].Value;
if (!string.IsNullOrEmpty(DatabaseInstance))
DatabaseInstance = "\\"+DatabaseInstance;
return "SQL Server<br />"+DatabaseServer+DatabaseInstance+"<br />"+DatabaseName;
}
return "";
}
private bool isTraefikUsed()
{
return System.IO.File.Exists(@"c:\programdata\bccontainerhelper\traefikforbc\traefik.txt");
}
</script>
<html>
<head>
<title><%=getProduct() %></title>
<style type="text/css">
h1 {
font-size: 2em;
font-weight: 400;
color: #000;
margin: 0px;
}
h2 {
font-size: 1.2em;
margin-top: 2em;
}
.h2sub {
font-weight: 100;
}
h3 {
font-size: 1.2em;
margin: 0px;
line-height: 32pt;
}
h4 {
font-size: 1em;
margin: 0px;
line-height: 24pt;
}
h6 {
font-size: 10pt;
position: relative;
left: 10px;
top: 120px;
margin: 0px;
}
h5 {
font-size: 10pt;
}
body {
font-family: "Segoe UI","Lucida Grande",Verdana,Arial,Helvetica,sans-serif;
font-size: 12px;
color: #5f5f5f;
margin-left: 20px;
}
table {
table-layout: fixed;
width: 100%;
}
td {
vertical-align: top;
}
a {
text-decoration: none;
text-underline:none
}
#tenants {
border-collapse:collapse;
}
#tenants td {
text-align: center;
border: 1px solid #808080;
vertical-align: middle;
margin: 2px 2px 2px 2px;
}
#tenants tr.alt td {
background-color: #e0e0e0;
}
#tenants tr.head td {
background-color: #c0c0c0;
}
#tenants td.tenant {
text-align: left;
}
</style>
<script language="javascript">
function show(selected) {
document.getElementById("texttd").style.backgroundColor = "#cccccc";
for(i=1; i<=5; i++) {
var textele = document.getElementById("text"+i);
var linkele = document.getElementById("link"+i);
var tdele = document.getElementById("td"+i);
if (i == selected) {
textele.style.display = "block";
tdele.style.backgroundColor = "#cccccc";
} else {
textele.style.display = "none";
tdele.style.backgroundColor = "#ffffff";
}
}
}
function timeRefresh(timeoutPeriod)
{
if (window.location.protocol == "https:") {
window.location.href = "http://<%=getLandingPageUrl() %>"
}
else {
setTimeout("refresh();",timeoutPeriod);
}
}
function refresh()
{
if (window.location.href.indexOf('?norefresh') == -1)
{
location.reload(true);
}
}
</script>
</head>
<body onload="JavaScript:timeRefresh(30000);">
<table>
<colgroup>
<col span="1" style="width: 14%;">
<col span="1" style="width: 70%;">
<col span="1" style="width: 1%;">
<col span="1" style="width: 15%;">
</colgroup>
<tr><td colspan="2">
<table>
<tr>
<td rowspan="2" width="110"><% =createQrForLandingPage() %></td>
<td style="vertical-align:bottom"> <img src="Microsoft.png" width="108" height="23"></td>
</tr><tr>
<td style="vertical-align:top"><h1><%=getProduct() %></h1><%=getBuildNumber() %></td>
</tr>
</table>
</td>
<td></td>
<td style="vertical-align:middle; color:#c0c0c0; white-space: nowrap"><p><%=getAzureSQL() %></p></td>
</tr>
<tr><td colspan="4"><img src="line.png" width="100%" height="14"></td></tr>
<%
if (GetCustomSettings() && File.Exists(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\Certificate.cer") && ! isTraefikUsed()) {
%>
<tr><td colspan="4"><h3>Download Self Signed Certificate</h3></td></tr>
<tr>
<td colspan="2">The <%=getProduct() %> is secured with a self-signed certificate. In order to connect to the environment, you must trust this certificate. Select operating system and browser to view the process for downloading and trusting the certificate:</td>
<td></td>
<td rowspan="2" style="white-space: nowrap"><a href="http://<%=getLandingPageUrl() %>:8080/Certificate.cer" target="_blank">Download Certificate</a></td>
</tr>
<tr>
<td colspan="2">
<table border="0" cellspacing="0" cellpadding="5"><tr>
<td style="width: 225px; white-space: nowrap" id="td1" style="background-color: #ffffff"><a id="link1" href="javascript:show(1);">Windows (Edge/IE/Chrome)</a></td>
<td style="width: 225px; white-space: nowrap" id="td2" style="background-color: #ffffff"><a id="link2" href="javascript:show(2);">Windows (Firefox)</a></td>
<td style="width: 225px; white-space: nowrap" id="td3" style="background-color: #ffffff"><a id="link3" href="javascript:show(3);">Windows Phone</a></td>
<td style="width: 225px; white-space: nowrap" id="td4" style="background-color: #ffffff"><a id="link4" href="javascript:show(4);">iOS (Safari)</a></td>
<td style="width: 225px; white-space: nowrap" id="td5" style="background-color: #ffffff"><a id="link5" href="javascript:show(5);">Android</a></td>
</tr>
<tr>
<td colspan="5" id="texttd" style="background-color: #ffffff">
<div id="text1" style="display: none"><p>Download and open the certificate file. Click <i>Install Certificate</i>, choose <i>Local Machine</i>, and then place the certificate in the <i>Trusted Root Certification Authorities</i> category.</p></div>
<div id="text2" style="display: none"><p>Open Options, Advanced, View Certificates, Servers and then choose <i>Add Exception</i>. Enter <i>https://<% =getHostname() %>/NAV</i>, choose <i>Get Certificate</i>, and then choose <i>Confirm Security Exception</i>.</p></div>
<div id="text3" style="display: none"><p>Choose the <i>download certificate</i> link. Install the certificate by following the certificate installation process.</p></div>
<div id="text4" style="display: none"><p>Choose the <i>download certificate</i> link. Install the certificate by following the certificate installation process.</p></div>
<div id="text5" style="display: none"><p>Choose the <i>download certificate</i> link. Launch the downloaded certificate, and then choose OK to install the certificate.</p></div>
</td>
</tr>
</table>
</td>
<td colspan="2"></td>
</tr>
<%
}
var rdps = System.IO.Directory.GetFiles(Server.MapPath("."), "*.rdp");
if (rdps.Length > 0) {
%>
<tr><td colspan="4"><h3>Remote Desktop Access</h3></td></tr>
<%
for(int i=0; i<rdps.Length; i++) {
%>
<tr>
<td colspan="2">
<%
if (i == 0) {
if (rdps.Length > 1) {
%>
The <%=getProduct() %> contains multiple servers. You can connect to the individual servers by following these links.
<%
} else {
%>
You can connect to the server in the <%=getProduct() %> by following this link.
<%
}
}
%>
If connections to RDP fails, you might need to add an incoming rule to the networksecurity group allowing port 3389 for IP address <%=GetIPAddress() %>.
</td>
<td></td>
<td style="white-space: nowrap"><a href="http://<%=getLandingPageUrl() %>/<% =System.IO.Path.GetFileName(rdps[i]) %>"><% =System.IO.Path.GetFileNameWithoutExtension(rdps[i]) %></a></td>
</tr>
<%
}
}
if (System.IO.File.Exists(@"c:\demo\status.txt")) {
var status = System.IO.File.ReadAllText(@"c:\demo\status.txt");
if (status.Contains("Desktop setup complete!")) {
%>
<tr><td colspan="4"><h3>Installation complete</h3></td></tr>
<%
} else {
%>
<tr><td colspan="4"><h3>Installation NOT complete</h3></td></tr>
<%
}
%>
<tr>
<td colspan="2">
You can view the installation status by following this link.
</td>
<td></td>
<td style="white-space: nowrap"><a href="http://<%=getLandingPageUrl() %>/status.aspx">View Installation Status</a></td>
</tr>
<%
}
if (GetCustomSettings()) {
%>
<tr><td colspan="4"><h3>Access the <%=getProduct() %></h3></td></tr>
<tr>
<td colspan="2">Choose these links to access the <%=getProduct() %> using the Web Client.</td>
<td></td>
<td><a href="<% =getWebBaseUrl() %>" target="_blank">Web Client</a></td>
</tr>
<%
if (File.Exists(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName()+@"\clickonce.txt")) {
%>
<tr>
<td colspan="2">The <%=getProduct() %> supports running the Microsoft Dynamics NAV Windows client over the internet. Choose this link to install the Microsoft Dynamics NAV Windows client using ClickOnce.</td>
<td></td>
<td style="white-space: nowrap"><a href="<%=getClickOnceUrl() %>" target="_blank">Install Windows Client</a></td>
</tr>
<%
}
if (isHttps()) {
%>
<tr>
<td colspan="2">If you have installed the Microsoft Dynamics NAV Universal App on your phone, tablet or desktop computer and want to configure the app to connect to this <%=getProduct() %>, choose this link.</td>
<td></td>
<td style="white-space: nowrap"><a href="<% =getConfigureAppUrl() %>">Configure App</a></td>
</tr>
<%
}
%>
<tr><td colspan="4"><h3>Access the <%=getProduct() %> using Web Services</h3></td></tr>
<tr>
<td colspan="2">The <%=getProduct() %> exposes functionality as SOAP web services. Choose this link to view the web services.</td>
<td></td>
<td style="white-space: nowrap"><a href="<% =getSoapBaseUrl() %>" target="_blank">View SOAP Web Services</a></td>
</tr>
<tr>
<td colspan="2">The <%=getProduct() %> exposes data as restful OData web services. Choose this link to view the web services</td>
<td></td>
<td style="white-space: nowrap"><a href="<% =getODataBaseUrl() %>" target="_blank">View OData Web Services</a></td>
</tr>
<%
if (isApisEnabled()) {
%>
<tr>
<td colspan="2">The <%=getProduct() %> exposes the API endpoint. APIs are exposed using <API Base Url>/<Publisher>/<Group>/<Version>/<Entity>. Choose this link to get the base URL for the APIs.</td>
<td></td>
<td style="white-space: nowrap"><a href="javascript:alert('<% =getApisBaseUrl() %>/')" target="_blank">View API base URL</a></td>
</tr><tr>
<td colspan="3">Example: <a href="<% =getApisSampleUrl() %>" target="_blank"><% =getApisSampleUrl() %></a></td>
<td></td>
</tr>
<%
}
var vsix = System.IO.Directory.GetFiles(@"c:\programdata\bccontainerhelper\extensions\"+getContainerName(), "*.vsix");
if (vsix.Length == 1) {
var vsixURL = "";
if (isTraefikUsed())
vsixURL = "https://" + getHostname() + "/" + getContainerName() + "dl/" + System.IO.Path.GetFileName(vsix[0]);
else
vsixURL = "http://" + getLandingPageUrl() + ":8080/" + System.IO.Path.GetFileName(vsix[0]);
%>
<tr><td colspan="4"><h3>Access the <%=getProduct() %> using Visual Studio Code</h3></td></tr>
<tr>
<td colspan="2">Download the AL Language Customization for Visual Studio Code (.vsix)</td>
<td></td>
<td style="white-space: nowrap"><a href="<%=vsixURL %>"><% =System.IO.Path.GetFileNameWithoutExtension(vsix[0]) %></a></td>
</tr>
<tr><td colspan="4">launch.json settings:</td></tr>
<tr><td colspan="4" style="font-family: Courier, Monaco, monospace"> "server": "https://<%=getHostname() %>",<br>
"serverInstance": "<%=getServerInstance() %>",<br>
"tenant": "<%=getTenant() %>",<br>
"authentication": "UserPassword",
<% if (isTraefikUsed()) { %>
<br> "port": 443,
<% } %>
</td></tr>
<%
}
}
if (System.IO.Directory.Exists(@"C:\ProgramData\bcContainerHelper\traefikforbc")) {
%>
<tr><td colspan="4"><h3>Traefik containers</h3></td></tr>
<tr><td colspan="4">This VM is setup with Traefik and below are the containers setup for access through Traefik.</td></tr>
<tr>
<table>
<tr><td><b>Name</b></td><td><b>WebClient</b></td><td><b>Soap</b></td><td><b>Rest</b></td><td><b>Developer Endpoint</b></td><td><b>VSIX</b></td></tr>
<%
var directories = System.IO.Directory.GetDirectories(@"C:\ProgramData\bcContainerHelper\Extensions", "*");
foreach(var directory in directories) {
if (System.IO.Directory.Exists(directory+@"\my")) {
var name = System.IO.Path.GetFileName(directory);
var hostname = "https://"+getHostname();
var webclient = "/"+name;
var soap = webclient+"soap";
var rest = webclient+"rest";
var developer = webclient+"dev";
var vsixFile = System.IO.Directory.GetFiles(@"c:\programdata\bccontainerhelper\extensions\"+name, "*.vsix");
var vsix = "";
if (vsixFile.Length == 1) {
vsix = webclient+"dl/"+System.IO.Path.GetFileName(vsixFile[0]);
}
%>
<tr><td><%=name %></td><td nowrap><a href="<%=hostname+webclient %>" target="_blank"><%=webclient %></a></td><td nowrap><a href="<%=hostname+soap %>" target="_blank"><%=soap %></a></td><td nowrap><a href="<%=hostname+rest %>" target="_blank"><%=rest %></a></td><td nowrap><a href="<%=hostname+developer %>" target="_blank"><%=developer %></a></td><td nowrap><a href="<%=hostname+vsix %>" target="_blank"><%=vsix %></a></td></tr>
<%
}
}
%>
</table>
</tr>
<%
}
%>
<tr><td colspan="4"> </td></tr>
</table>
</body>
</html>