| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolset.Iis |
| 4 | { |
| 5 | #if TODO_CONSIDER_DECOMPILER |
| 6 | using System; |
| 7 | using System.Collections; |
| 8 | using System.Globalization; |
| 9 | using WixToolset.Data; |
| 10 | using WixToolset.Extensibility; |
| 11 | using IIs = WixToolset.Extensions.Serialize.IIs; |
| 12 | using Wix = WixToolset.Data.Serialize; |
| 13 | |
| 14 | /// <summary> |
| 15 | /// The decompiler for the WiX Toolset Internet Information Services Extension. |
| 16 | /// </summary> |
| 17 | public sealed class IIsDecompiler : DecompilerExtension |
| 18 | { |
| 19 | /// <summary> |
| 20 | /// Creates a decompiler for IIs Extension. |
| 21 | /// </summary> |
| 22 | public IIsDecompiler() |
| 23 | { |
| 24 | this.TableDefinitions = IIsExtensionData.GetExtensionTableDefinitions(); |
| 25 | } |
| 26 | |
| 27 | /// <summary> |
| 28 | /// Get the extensions library to be removed. |
| 29 | /// </summary> |
| 30 | /// <param name="tableDefinitions">Table definitions for library.</param> |
| 31 | /// <returns>Library to remove from decompiled output.</returns> |
| 32 | public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) |
| 33 | { |
| 34 | return IIsExtensionData.GetExtensionLibrary(tableDefinitions); |
| 35 | } |
| 36 | |
| 37 | /// <summary> |
| 38 | /// Decompiles an extension table. |
| 39 | /// </summary> |
| 40 | /// <param name="table">The table to decompile.</param> |
| 41 | public override void DecompileTable(Table table) |
| 42 | { |
| 43 | switch (table.Name) |
| 44 | { |
| 45 | case "Certificate": |
| 46 | this.DecompileCertificateTable(table); |
| 47 | break; |
| 48 | case "CertificateHash": |
| 49 | // There is nothing to do for this table, it contains no authored data |
| 50 | // to be decompiled. |
| 51 | break; |
| 52 | case "IIsAppPool": |
| 53 | this.DecompileIIsAppPoolTable(table); |
| 54 | break; |
| 55 | case "IIsFilter": |
| 56 | this.DecompileIIsFilterTable(table); |
| 57 | break; |
| 58 | case "IIsProperty": |
| 59 | this.DecompileIIsPropertyTable(table); |
| 60 | break; |
| 61 | case "IIsHttpHeader": |
| 62 | this.DecompileIIsHttpHeaderTable(table); |
| 63 | break; |
| 64 | case "IIsMimeMap": |
| 65 | this.DecompileIIsMimeMapTable(table); |
| 66 | break; |
| 67 | case "IIsWebAddress": |
| 68 | this.DecompileIIsWebAddressTable(table); |
| 69 | break; |
| 70 | case "IIsWebApplication": |
| 71 | this.DecompileIIsWebApplicationTable(table); |
| 72 | break; |
| 73 | case "IIsWebDirProperties": |
| 74 | this.DecompileIIsWebDirPropertiesTable(table); |
| 75 | break; |
| 76 | case "IIsWebError": |
| 77 | this.DecompileIIsWebErrorTable(table); |
| 78 | break; |
| 79 | case "IIsWebLog": |
| 80 | this.DecompileIIsWebLogTable(table); |
| 81 | break; |
| 82 | case "IIsWebServiceExtension": |
| 83 | this.DecompileIIsWebServiceExtensionTable(table); |
| 84 | break; |
| 85 | case "IIsWebSite": |
| 86 | this.DecompileIIsWebSiteTable(table); |
| 87 | break; |
| 88 | case "IIsWebVirtualDir": |
| 89 | this.DecompileIIsWebVirtualDirTable(table); |
| 90 | break; |
| 91 | case "IIsWebSiteCertificates": |
| 92 | this.DecompileIIsWebSiteCertificatesTable(table); |
| 93 | break; |
| 94 | default: |
| 95 | base.DecompileTable(table); |
| 96 | break; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | /// <summary> |
| 101 | /// Finalize decompilation. |
| 102 | /// </summary> |
| 103 | /// <param name="tables">The collection of all tables.</param> |
| 104 | public override void Finish(TableIndexedCollection tables) |
| 105 | { |
| 106 | this.FinalizeIIsMimeMapTable(tables); |
| 107 | this.FinalizeIIsHttpHeaderTable(tables); |
| 108 | this.FinalizeIIsWebApplicationTable(tables); |
| 109 | this.FinalizeIIsWebErrorTable(tables); |
| 110 | this.FinalizeIIsWebVirtualDirTable(tables); |
| 111 | this.FinalizeIIsWebSiteCertificatesTable(tables); |
| 112 | this.FinalizeWebAddressTable(tables); |
| 113 | } |
| 114 | |
| 115 | /// <summary> |
| 116 | /// Decompile the Certificate table. |
| 117 | /// </summary> |
| 118 | /// <param name="table">The table to decompile.</param> |
| 119 | private void DecompileCertificateTable(Table table) |
| 120 | { |
| 121 | foreach (Row row in table.Rows) |
| 122 | { |
| 123 | IIs.Certificate certificate = new IIs.Certificate(); |
| 124 | |
| 125 | certificate.Id = (string)row[0]; |
| 126 | certificate.Name = (string)row[2]; |
| 127 | |
| 128 | switch ((int)row[3]) |
| 129 | { |
| 130 | case 1: |
| 131 | certificate.StoreLocation = IIs.Certificate.StoreLocationType.currentUser; |
| 132 | break; |
| 133 | case 2: |
| 134 | certificate.StoreLocation = IIs.Certificate.StoreLocationType.localMachine; |
| 135 | break; |
| 136 | default: |
| 137 | // TODO: warn |
| 138 | break; |
| 139 | } |
| 140 | |
| 141 | switch ((string)row[4]) |
| 142 | { |
| 143 | case "CA": |
| 144 | certificate.StoreName = IIs.Certificate.StoreNameType.ca; |
| 145 | break; |
| 146 | case "MY": |
| 147 | certificate.StoreName = IIs.Certificate.StoreNameType.my; |
| 148 | break; |
| 149 | case "REQUEST": |
| 150 | certificate.StoreName = IIs.Certificate.StoreNameType.request; |
| 151 | break; |
| 152 | case "Root": |
| 153 | certificate.StoreName = IIs.Certificate.StoreNameType.root; |
| 154 | break; |
| 155 | case "AddressBook": |
| 156 | certificate.StoreName = IIs.Certificate.StoreNameType.otherPeople; |
| 157 | break; |
| 158 | case "TrustedPeople": |
| 159 | certificate.StoreName = IIs.Certificate.StoreNameType.trustedPeople; |
| 160 | break; |
| 161 | case "TrustedPublisher": |
| 162 | certificate.StoreName = IIs.Certificate.StoreNameType.trustedPublisher; |
| 163 | break; |
| 164 | default: |
| 165 | // TODO: warn |
| 166 | break; |
| 167 | } |
| 168 | |
| 169 | int attribute = (int)row[5]; |
| 170 | |
| 171 | if (0x1 == (attribute & 0x1)) |
| 172 | { |
| 173 | certificate.Request = IIs.YesNoType.yes; |
| 174 | } |
| 175 | |
| 176 | if (0x2 == (attribute & 0x2)) |
| 177 | { |
| 178 | if (null != row[6]) |
| 179 | { |
| 180 | certificate.BinaryKey = (string)row[6]; |
| 181 | } |
| 182 | else |
| 183 | { |
| 184 | // TODO: warn about expected value in row 5 |
| 185 | } |
| 186 | } |
| 187 | else if (null != row[7]) |
| 188 | { |
| 189 | certificate.CertificatePath = (string)row[7]; |
| 190 | } |
| 191 | |
| 192 | if (0x4 == (attribute & 0x4)) |
| 193 | { |
| 194 | certificate.Overwrite = IIs.YesNoType.yes; |
| 195 | } |
| 196 | |
| 197 | if (null != row[8]) |
| 198 | { |
| 199 | certificate.PFXPassword = (string)row[8]; |
| 200 | } |
| 201 | |
| 202 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[1]); |
| 203 | if (null != component) |
| 204 | { |
| 205 | component.AddChild(certificate); |
| 206 | } |
| 207 | else |
| 208 | { |
| 209 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[1], "Component")); |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | /// <summary> |
| 215 | /// Decompile the IIsAppPool table. |
| 216 | /// </summary> |
| 217 | /// <param name="table">The table to decompile.</param> |
| 218 | private void DecompileIIsAppPoolTable(Table table) |
| 219 | { |
| 220 | foreach (Row row in table.Rows) |
| 221 | { |
| 222 | IIs.WebAppPool webAppPool = new IIs.WebAppPool(); |
| 223 | |
| 224 | webAppPool.Id = (string)row[0]; |
| 225 | |
| 226 | webAppPool.Name = (string)row[1]; |
| 227 | |
| 228 | switch ((int)row[3] & 0x1F) |
| 229 | { |
| 230 | case 1: |
| 231 | webAppPool.Identity = IIs.WebAppPool.IdentityType.networkService; |
| 232 | break; |
| 233 | case 2: |
| 234 | webAppPool.Identity = IIs.WebAppPool.IdentityType.localService; |
| 235 | break; |
| 236 | case 4: |
| 237 | webAppPool.Identity = IIs.WebAppPool.IdentityType.localSystem; |
| 238 | break; |
| 239 | case 8: |
| 240 | webAppPool.Identity = IIs.WebAppPool.IdentityType.other; |
| 241 | break; |
| 242 | case 0x10: |
| 243 | webAppPool.Identity = IIs.WebAppPool.IdentityType.applicationPoolIdentity; |
| 244 | break; |
| 245 | default: |
| 246 | // TODO: warn |
| 247 | break; |
| 248 | } |
| 249 | |
| 250 | if (null != row[4]) |
| 251 | { |
| 252 | webAppPool.User = (string)row[4]; |
| 253 | } |
| 254 | |
| 255 | if (null != row[5]) |
| 256 | { |
| 257 | webAppPool.RecycleMinutes = (int)row[5]; |
| 258 | } |
| 259 | |
| 260 | if (null != row[6]) |
| 261 | { |
| 262 | webAppPool.RecycleRequests = (int)row[6]; |
| 263 | } |
| 264 | |
| 265 | if (null != row[7]) |
| 266 | { |
| 267 | string[] recycleTimeValues = ((string)row[7]).Split(','); |
| 268 | |
| 269 | foreach (string recycleTimeValue in recycleTimeValues) |
| 270 | { |
| 271 | IIs.RecycleTime recycleTime = new IIs.RecycleTime(); |
| 272 | |
| 273 | recycleTime.Value = recycleTimeValue; |
| 274 | |
| 275 | webAppPool.AddChild(recycleTime); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | if (null != row[8]) |
| 280 | { |
| 281 | webAppPool.IdleTimeout = (int)row[8]; |
| 282 | } |
| 283 | |
| 284 | if (null != row[9]) |
| 285 | { |
| 286 | webAppPool.QueueLimit = (int)row[9]; |
| 287 | } |
| 288 | |
| 289 | if (null != row[10]) |
| 290 | { |
| 291 | string[] cpuMon = ((string)row[10]).Split(','); |
| 292 | |
| 293 | if (0 < cpuMon.Length && "0" != cpuMon[0]) |
| 294 | { |
| 295 | webAppPool.MaxCpuUsage = Convert.ToInt32(cpuMon[0], CultureInfo.InvariantCulture); |
| 296 | } |
| 297 | |
| 298 | if (1 < cpuMon.Length) |
| 299 | { |
| 300 | webAppPool.RefreshCpu = Convert.ToInt32(cpuMon[1], CultureInfo.InvariantCulture); |
| 301 | } |
| 302 | |
| 303 | if (2 < cpuMon.Length) |
| 304 | { |
| 305 | switch (Convert.ToInt32(cpuMon[2], CultureInfo.InvariantCulture)) |
| 306 | { |
| 307 | case 0: |
| 308 | webAppPool.CpuAction = IIs.WebAppPool.CpuActionType.none; |
| 309 | break; |
| 310 | case 1: |
| 311 | webAppPool.CpuAction = IIs.WebAppPool.CpuActionType.shutdown; |
| 312 | break; |
| 313 | default: |
| 314 | // TODO: warn |
| 315 | break; |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | if (3 < cpuMon.Length) |
| 320 | { |
| 321 | // TODO: warn |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | if (null != row[11]) |
| 326 | { |
| 327 | webAppPool.MaxWorkerProcesses = (int)row[11]; |
| 328 | } |
| 329 | |
| 330 | if (null != row[12]) |
| 331 | { |
| 332 | webAppPool.VirtualMemory = (int)row[12]; |
| 333 | } |
| 334 | |
| 335 | if (null != row[13]) |
| 336 | { |
| 337 | webAppPool.PrivateMemory = (int)row[13]; |
| 338 | } |
| 339 | |
| 340 | if (null != row[14]) |
| 341 | { |
| 342 | webAppPool.ManagedRuntimeVersion = (string)row[14]; |
| 343 | } |
| 344 | |
| 345 | if (null != row[15]) |
| 346 | { |
| 347 | webAppPool.ManagedPipelineMode = (string)row[15]; |
| 348 | } |
| 349 | |
| 350 | if (null != row[2]) |
| 351 | { |
| 352 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[2]); |
| 353 | |
| 354 | if (null != component) |
| 355 | { |
| 356 | component.AddChild(webAppPool); |
| 357 | } |
| 358 | else |
| 359 | { |
| 360 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); |
| 361 | } |
| 362 | } |
| 363 | else |
| 364 | { |
| 365 | this.Core.RootElement.AddChild(webAppPool); |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | /// <summary> |
| 371 | /// Decompile the IIsProperty table. |
| 372 | /// </summary> |
| 373 | /// <param name="table">The table to decompile.</param> |
| 374 | private void DecompileIIsPropertyTable(Table table) |
| 375 | { |
| 376 | foreach (Row row in table.Rows) |
| 377 | { |
| 378 | IIs.WebProperty webProperty = new IIs.WebProperty(); |
| 379 | |
| 380 | switch ((string)row[0]) |
| 381 | { |
| 382 | case "ETagChangeNumber": |
| 383 | webProperty.Id = IIs.WebProperty.IdType.ETagChangeNumber; |
| 384 | break; |
| 385 | case "IIs5IsolationMode": |
| 386 | webProperty.Id = IIs.WebProperty.IdType.IIs5IsolationMode; |
| 387 | break; |
| 388 | case "LogInUTF8": |
| 389 | webProperty.Id = IIs.WebProperty.IdType.LogInUTF8; |
| 390 | break; |
| 391 | case "MaxGlobalBandwidth": |
| 392 | webProperty.Id = IIs.WebProperty.IdType.MaxGlobalBandwidth; |
| 393 | break; |
| 394 | } |
| 395 | |
| 396 | if (0 != (int)row[2]) |
| 397 | { |
| 398 | // TODO: warn about value in unused column |
| 399 | } |
| 400 | |
| 401 | if (null != row[3]) |
| 402 | { |
| 403 | webProperty.Value = (string)row[3]; |
| 404 | } |
| 405 | |
| 406 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[1]); |
| 407 | if (null != component) |
| 408 | { |
| 409 | component.AddChild(webProperty); |
| 410 | } |
| 411 | else |
| 412 | { |
| 413 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[1], "Component")); |
| 414 | } |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | /// <summary> |
| 419 | /// Decompile the IIsHttpHeader table. |
| 420 | /// </summary> |
| 421 | /// <param name="table">The table to decompile.</param> |
| 422 | private void DecompileIIsHttpHeaderTable(Table table) |
| 423 | { |
| 424 | foreach (Row row in table.Rows) |
| 425 | { |
| 426 | IIs.HttpHeader httpHeader = new IIs.HttpHeader(); |
| 427 | |
| 428 | httpHeader.Name = (string)row[3]; |
| 429 | |
| 430 | // the ParentType and Parent columns are handled in FinalizeIIsHttpHeaderTable |
| 431 | |
| 432 | httpHeader.Value = (string)row[4]; |
| 433 | |
| 434 | this.Core.IndexElement(row, httpHeader); |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | /// <summary> |
| 439 | /// Decompile the IIsMimeMap table. |
| 440 | /// </summary> |
| 441 | /// <param name="table">The table to decompile.</param> |
| 442 | private void DecompileIIsMimeMapTable(Table table) |
| 443 | { |
| 444 | foreach (Row row in table.Rows) |
| 445 | { |
| 446 | IIs.MimeMap mimeMap = new IIs.MimeMap(); |
| 447 | |
| 448 | mimeMap.Id = (string)row[0]; |
| 449 | |
| 450 | // the ParentType and ParentValue columns are handled in FinalizeIIsMimeMapTable |
| 451 | |
| 452 | mimeMap.Type = (string)row[3]; |
| 453 | |
| 454 | mimeMap.Extension = (string)row[4]; |
| 455 | |
| 456 | this.Core.IndexElement(row, mimeMap); |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | /// <summary> |
| 461 | /// Decompile the IIsWebAddress table. |
| 462 | /// </summary> |
| 463 | /// <param name="table">The table to decompile.</param> |
| 464 | private void DecompileIIsWebAddressTable(Table table) |
| 465 | { |
| 466 | foreach (Row row in table.Rows) |
| 467 | { |
| 468 | IIs.WebAddress webAddress = new IIs.WebAddress(); |
| 469 | |
| 470 | webAddress.Id = (string)row[0]; |
| 471 | |
| 472 | if (null != row[2]) |
| 473 | { |
| 474 | webAddress.IP = (string)row[2]; |
| 475 | } |
| 476 | |
| 477 | webAddress.Port = (string)row[3]; |
| 478 | |
| 479 | if (null != row[4]) |
| 480 | { |
| 481 | webAddress.Header = (string)row[4]; |
| 482 | } |
| 483 | |
| 484 | if (null != row[5] && 1 == (int)row[5]) |
| 485 | { |
| 486 | webAddress.Secure = IIs.YesNoType.yes; |
| 487 | } |
| 488 | |
| 489 | this.Core.IndexElement(row, webAddress); |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | /// <summary> |
| 494 | /// Decompile the IIsWebApplication table. |
| 495 | /// </summary> |
| 496 | /// <param name="table">The table to decompile.</param> |
| 497 | private void DecompileIIsWebApplicationTable(Table table) |
| 498 | { |
| 499 | foreach (Row row in table.Rows) |
| 500 | { |
| 501 | IIs.WebApplication webApplication = new IIs.WebApplication(); |
| 502 | |
| 503 | webApplication.Id = (string)row[0]; |
| 504 | |
| 505 | webApplication.Name = (string)row[1]; |
| 506 | |
| 507 | // these are not listed incorrectly - the order is low, high, medium |
| 508 | switch ((int)row[2]) |
| 509 | { |
| 510 | case 0: |
| 511 | webApplication.Isolation = IIs.WebApplication.IsolationType.low; |
| 512 | break; |
| 513 | case 1: |
| 514 | webApplication.Isolation = IIs.WebApplication.IsolationType.high; |
| 515 | break; |
| 516 | case 2: |
| 517 | webApplication.Isolation = IIs.WebApplication.IsolationType.medium; |
| 518 | break; |
| 519 | default: |
| 520 | // TODO: warn |
| 521 | break; |
| 522 | } |
| 523 | |
| 524 | if (null != row[3]) |
| 525 | { |
| 526 | switch ((int)row[3]) |
| 527 | { |
| 528 | case 0: |
| 529 | webApplication.AllowSessions = IIs.YesNoDefaultType.no; |
| 530 | break; |
| 531 | case 1: |
| 532 | webApplication.AllowSessions = IIs.YesNoDefaultType.yes; |
| 533 | break; |
| 534 | default: |
| 535 | // TODO: warn |
| 536 | break; |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | if (null != row[4]) |
| 541 | { |
| 542 | webApplication.SessionTimeout = (int)row[4]; |
| 543 | } |
| 544 | |
| 545 | if (null != row[5]) |
| 546 | { |
| 547 | switch ((int)row[5]) |
| 548 | { |
| 549 | case 0: |
| 550 | webApplication.Buffer = IIs.YesNoDefaultType.no; |
| 551 | break; |
| 552 | case 1: |
| 553 | webApplication.Buffer = IIs.YesNoDefaultType.yes; |
| 554 | break; |
| 555 | default: |
| 556 | // TODO: warn |
| 557 | break; |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | if (null != row[6]) |
| 562 | { |
| 563 | switch ((int)row[6]) |
| 564 | { |
| 565 | case 0: |
| 566 | webApplication.ParentPaths = IIs.YesNoDefaultType.no; |
| 567 | break; |
| 568 | case 1: |
| 569 | webApplication.ParentPaths = IIs.YesNoDefaultType.yes; |
| 570 | break; |
| 571 | default: |
| 572 | // TODO: warn |
| 573 | break; |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | if (null != row[7]) |
| 578 | { |
| 579 | switch ((string)row[7]) |
| 580 | { |
| 581 | case "JScript": |
| 582 | webApplication.DefaultScript = IIs.WebApplication.DefaultScriptType.JScript; |
| 583 | break; |
| 584 | case "VBScript": |
| 585 | webApplication.DefaultScript = IIs.WebApplication.DefaultScriptType.VBScript; |
| 586 | break; |
| 587 | default: |
| 588 | // TODO: warn |
| 589 | break; |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | if (null != row[8]) |
| 594 | { |
| 595 | webApplication.ScriptTimeout = (int)row[8]; |
| 596 | } |
| 597 | |
| 598 | if (null != row[9]) |
| 599 | { |
| 600 | switch ((int)row[9]) |
| 601 | { |
| 602 | case 0: |
| 603 | webApplication.ServerDebugging = IIs.YesNoDefaultType.no; |
| 604 | break; |
| 605 | case 1: |
| 606 | webApplication.ServerDebugging = IIs.YesNoDefaultType.yes; |
| 607 | break; |
| 608 | default: |
| 609 | // TODO: warn |
| 610 | break; |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | if (null != row[10]) |
| 615 | { |
| 616 | switch ((int)row[10]) |
| 617 | { |
| 618 | case 0: |
| 619 | webApplication.ClientDebugging = IIs.YesNoDefaultType.no; |
| 620 | break; |
| 621 | case 1: |
| 622 | webApplication.ClientDebugging = IIs.YesNoDefaultType.yes; |
| 623 | break; |
| 624 | default: |
| 625 | // TODO: warn |
| 626 | break; |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | if (null != row[11]) |
| 631 | { |
| 632 | webApplication.WebAppPool = (string)row[11]; |
| 633 | } |
| 634 | |
| 635 | this.Core.IndexElement(row, webApplication); |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | /// <summary> |
| 640 | /// Decompile the IIsWebDirProperties table. |
| 641 | /// </summary> |
| 642 | /// <param name="table">The table to decompile.</param> |
| 643 | private void DecompileIIsWebDirPropertiesTable(Table table) |
| 644 | { |
| 645 | foreach (Row row in table.Rows) |
| 646 | { |
| 647 | IIs.WebDirProperties webDirProperties = new IIs.WebDirProperties(); |
| 648 | |
| 649 | webDirProperties.Id = (string)row[0]; |
| 650 | |
| 651 | if (null != row[1]) |
| 652 | { |
| 653 | int access = (int)row[1]; |
| 654 | |
| 655 | if (0x1 == (access & 0x1)) |
| 656 | { |
| 657 | webDirProperties.Read = IIs.YesNoType.yes; |
| 658 | } |
| 659 | |
| 660 | if (0x2 == (access & 0x2)) |
| 661 | { |
| 662 | webDirProperties.Write = IIs.YesNoType.yes; |
| 663 | } |
| 664 | |
| 665 | if (0x4 == (access & 0x4)) |
| 666 | { |
| 667 | webDirProperties.Execute = IIs.YesNoType.yes; |
| 668 | } |
| 669 | |
| 670 | if (0x200 == (access & 0x200)) |
| 671 | { |
| 672 | webDirProperties.Script = IIs.YesNoType.yes; |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | if (null != row[2]) |
| 677 | { |
| 678 | int authorization = (int)row[2]; |
| 679 | |
| 680 | if (0x1 == (authorization & 0x1)) |
| 681 | { |
| 682 | webDirProperties.AnonymousAccess = IIs.YesNoType.yes; |
| 683 | } |
| 684 | else // set one of the properties to 'no' to force the output value to be '0' if not other attributes are set |
| 685 | { |
| 686 | webDirProperties.AnonymousAccess = IIs.YesNoType.no; |
| 687 | } |
| 688 | |
| 689 | if (0x2 == (authorization & 0x2)) |
| 690 | { |
| 691 | webDirProperties.BasicAuthentication = IIs.YesNoType.yes; |
| 692 | } |
| 693 | |
| 694 | if (0x4 == (authorization & 0x4)) |
| 695 | { |
| 696 | webDirProperties.WindowsAuthentication = IIs.YesNoType.yes; |
| 697 | } |
| 698 | |
| 699 | if (0x10 == (authorization & 0x10)) |
| 700 | { |
| 701 | webDirProperties.DigestAuthentication = IIs.YesNoType.yes; |
| 702 | } |
| 703 | |
| 704 | if (0x40 == (authorization & 0x40)) |
| 705 | { |
| 706 | webDirProperties.PassportAuthentication = IIs.YesNoType.yes; |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | if (null != row[3]) |
| 711 | { |
| 712 | webDirProperties.AnonymousUser = (string)row[3]; |
| 713 | } |
| 714 | |
| 715 | if (null != row[4] && 1 == (int)row[4]) |
| 716 | { |
| 717 | webDirProperties.IIsControlledPassword = IIs.YesNoType.yes; |
| 718 | } |
| 719 | |
| 720 | if (null != row[5]) |
| 721 | { |
| 722 | switch ((int)row[5]) |
| 723 | { |
| 724 | case 0: |
| 725 | webDirProperties.LogVisits = IIs.YesNoType.no; |
| 726 | break; |
| 727 | case 1: |
| 728 | webDirProperties.LogVisits = IIs.YesNoType.yes; |
| 729 | break; |
| 730 | default: |
| 731 | // TODO: warn |
| 732 | break; |
| 733 | } |
| 734 | } |
| 735 | |
| 736 | if (null != row[6]) |
| 737 | { |
| 738 | switch ((int)row[6]) |
| 739 | { |
| 740 | case 0: |
| 741 | webDirProperties.Index = IIs.YesNoType.no; |
| 742 | break; |
| 743 | case 1: |
| 744 | webDirProperties.Index = IIs.YesNoType.yes; |
| 745 | break; |
| 746 | default: |
| 747 | // TODO: warn |
| 748 | break; |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | if (null != row[7]) |
| 753 | { |
| 754 | webDirProperties.DefaultDocuments = (string)row[7]; |
| 755 | } |
| 756 | |
| 757 | if (null != row[8]) |
| 758 | { |
| 759 | switch ((int)row[8]) |
| 760 | { |
| 761 | case 0: |
| 762 | webDirProperties.AspDetailedError = IIs.YesNoType.no; |
| 763 | break; |
| 764 | case 1: |
| 765 | webDirProperties.AspDetailedError = IIs.YesNoType.yes; |
| 766 | break; |
| 767 | default: |
| 768 | // TODO: warn |
| 769 | break; |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | if (null != row[9]) |
| 774 | { |
| 775 | webDirProperties.HttpExpires = (string)row[9]; |
| 776 | } |
| 777 | |
| 778 | if (null != row[10]) |
| 779 | { |
| 780 | // force the value to be a positive number |
| 781 | webDirProperties.CacheControlMaxAge = unchecked((uint)(int)row[10]); |
| 782 | } |
| 783 | |
| 784 | if (null != row[11]) |
| 785 | { |
| 786 | webDirProperties.CacheControlCustom = (string)row[11]; |
| 787 | } |
| 788 | |
| 789 | if (null != row[12]) |
| 790 | { |
| 791 | switch ((int)row[8]) |
| 792 | { |
| 793 | case 0: |
| 794 | webDirProperties.ClearCustomError = IIs.YesNoType.no; |
| 795 | break; |
| 796 | case 1: |
| 797 | webDirProperties.ClearCustomError = IIs.YesNoType.yes; |
| 798 | break; |
| 799 | default: |
| 800 | // TODO: warn |
| 801 | break; |
| 802 | } |
| 803 | } |
| 804 | |
| 805 | if (null != row[13]) |
| 806 | { |
| 807 | int accessSSLFlags = (int)row[13]; |
| 808 | |
| 809 | if (0x8 == (accessSSLFlags & 0x8)) |
| 810 | { |
| 811 | webDirProperties.AccessSSL = IIs.YesNoType.yes; |
| 812 | } |
| 813 | |
| 814 | if (0x20 == (accessSSLFlags & 0x20)) |
| 815 | { |
| 816 | webDirProperties.AccessSSLNegotiateCert = IIs.YesNoType.yes; |
| 817 | } |
| 818 | |
| 819 | if (0x40 == (accessSSLFlags & 0x40)) |
| 820 | { |
| 821 | webDirProperties.AccessSSLRequireCert = IIs.YesNoType.yes; |
| 822 | } |
| 823 | |
| 824 | if (0x80 == (accessSSLFlags & 0x80)) |
| 825 | { |
| 826 | webDirProperties.AccessSSLMapCert = IIs.YesNoType.yes; |
| 827 | } |
| 828 | |
| 829 | if (0x100 == (accessSSLFlags & 0x100)) |
| 830 | { |
| 831 | webDirProperties.AccessSSL128 = IIs.YesNoType.yes; |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | if (null != row[14]) |
| 836 | { |
| 837 | webDirProperties.AuthenticationProviders = (string)row[14]; |
| 838 | } |
| 839 | |
| 840 | this.Core.RootElement.AddChild(webDirProperties); |
| 841 | } |
| 842 | } |
| 843 | |
| 844 | /// <summary> |
| 845 | /// Decompile the IIsWebError table. |
| 846 | /// </summary> |
| 847 | /// <param name="table">The table to decompile.</param> |
| 848 | private void DecompileIIsWebErrorTable(Table table) |
| 849 | { |
| 850 | foreach (Row row in table.Rows) |
| 851 | { |
| 852 | IIs.WebError webError = new IIs.WebError(); |
| 853 | |
| 854 | webError.ErrorCode = (int)row[0]; |
| 855 | |
| 856 | webError.SubCode = (int)row[1]; |
| 857 | |
| 858 | // the ParentType and ParentValue columns are handled in FinalizeIIsWebErrorTable |
| 859 | |
| 860 | if (null != row[4]) |
| 861 | { |
| 862 | webError.File = (string)row[4]; |
| 863 | } |
| 864 | |
| 865 | if (null != row[5]) |
| 866 | { |
| 867 | webError.URL = (string)row[5]; |
| 868 | } |
| 869 | |
| 870 | this.Core.IndexElement(row, webError); |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | /// <summary> |
| 875 | /// Decompile the IIsFilter table. |
| 876 | /// </summary> |
| 877 | /// <param name="table">The table to decompile.</param> |
| 878 | private void DecompileIIsFilterTable(Table table) |
| 879 | { |
| 880 | foreach (Row row in table.Rows) |
| 881 | { |
| 882 | IIs.WebFilter webFilter = new IIs.WebFilter(); |
| 883 | |
| 884 | webFilter.Id = (string)row[0]; |
| 885 | |
| 886 | webFilter.Name = (string)row[1]; |
| 887 | |
| 888 | if (null != row[3]) |
| 889 | { |
| 890 | webFilter.Path = (string)row[3]; |
| 891 | } |
| 892 | |
| 893 | if (null != row[5]) |
| 894 | { |
| 895 | webFilter.Description = (string)row[5]; |
| 896 | } |
| 897 | |
| 898 | webFilter.Flags = (int)row[6]; |
| 899 | |
| 900 | if (null != row[7]) |
| 901 | { |
| 902 | switch ((int)row[7]) |
| 903 | { |
| 904 | case (-1): |
| 905 | webFilter.LoadOrder = "last"; |
| 906 | break; |
| 907 | case 0: |
| 908 | webFilter.LoadOrder = "first"; |
| 909 | break; |
| 910 | default: |
| 911 | webFilter.LoadOrder = Convert.ToString((int)row[7], CultureInfo.InvariantCulture); |
| 912 | break; |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | if (null != row[4]) |
| 917 | { |
| 918 | IIs.WebSite webSite = (IIs.WebSite)this.Core.GetIndexedElement("IIsWebSite", (string)row[4]); |
| 919 | |
| 920 | if (null != webSite) |
| 921 | { |
| 922 | webSite.AddChild(webFilter); |
| 923 | } |
| 924 | else |
| 925 | { |
| 926 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Web_", (string)row[4], "IIsWebSite")); |
| 927 | } |
| 928 | } |
| 929 | else // Component parent |
| 930 | { |
| 931 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[2]); |
| 932 | |
| 933 | if (null != component) |
| 934 | { |
| 935 | component.AddChild(webFilter); |
| 936 | } |
| 937 | else |
| 938 | { |
| 939 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); |
| 940 | } |
| 941 | } |
| 942 | } |
| 943 | } |
| 944 | |
| 945 | /// <summary> |
| 946 | /// Decompile the IIsWebLog table. |
| 947 | /// </summary> |
| 948 | /// <param name="table">The table to decompile.</param> |
| 949 | private void DecompileIIsWebLogTable(Table table) |
| 950 | { |
| 951 | foreach (Row row in table.Rows) |
| 952 | { |
| 953 | IIs.WebLog webLog = new IIs.WebLog(); |
| 954 | |
| 955 | webLog.Id = (string)row[0]; |
| 956 | |
| 957 | switch ((string)row[1]) |
| 958 | { |
| 959 | case "Microsoft IIS Log File Format": |
| 960 | webLog.Type = IIs.WebLog.TypeType.IIS; |
| 961 | break; |
| 962 | case "NCSA Common Log File Format": |
| 963 | webLog.Type = IIs.WebLog.TypeType.NCSA; |
| 964 | break; |
| 965 | case "none": |
| 966 | webLog.Type = IIs.WebLog.TypeType.none; |
| 967 | break; |
| 968 | case "ODBC Logging": |
| 969 | webLog.Type = IIs.WebLog.TypeType.ODBC; |
| 970 | break; |
| 971 | case "W3C Extended Log File Format": |
| 972 | webLog.Type = IIs.WebLog.TypeType.W3C; |
| 973 | break; |
| 974 | default: |
| 975 | // TODO: warn |
| 976 | break; |
| 977 | } |
| 978 | |
| 979 | this.Core.RootElement.AddChild(webLog); |
| 980 | } |
| 981 | } |
| 982 | |
| 983 | /// <summary> |
| 984 | /// Decompile the IIsWebServiceExtension table. |
| 985 | /// </summary> |
| 986 | /// <param name="table">The table to decompile.</param> |
| 987 | private void DecompileIIsWebServiceExtensionTable(Table table) |
| 988 | { |
| 989 | foreach (Row row in table.Rows) |
| 990 | { |
| 991 | IIs.WebServiceExtension webServiceExtension = new IIs.WebServiceExtension(); |
| 992 | |
| 993 | webServiceExtension.Id = (string)row[0]; |
| 994 | |
| 995 | webServiceExtension.File = (string)row[2]; |
| 996 | |
| 997 | if (null != row[3]) |
| 998 | { |
| 999 | webServiceExtension.Description = (string)row[3]; |
| 1000 | } |
| 1001 | |
| 1002 | if (null != row[4]) |
| 1003 | { |
| 1004 | webServiceExtension.Group = (string)row[4]; |
| 1005 | } |
| 1006 | |
| 1007 | int attributes = (int)row[5]; |
| 1008 | |
| 1009 | if (0x1 == (attributes & 0x1)) |
| 1010 | { |
| 1011 | webServiceExtension.Allow = IIs.YesNoType.yes; |
| 1012 | } |
| 1013 | else |
| 1014 | { |
| 1015 | webServiceExtension.Allow = IIs.YesNoType.no; |
| 1016 | } |
| 1017 | |
| 1018 | if (0x2 == (attributes & 0x2)) |
| 1019 | { |
| 1020 | webServiceExtension.UIDeletable = IIs.YesNoType.yes; |
| 1021 | } |
| 1022 | |
| 1023 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[1]); |
| 1024 | if (null != component) |
| 1025 | { |
| 1026 | component.AddChild(webServiceExtension); |
| 1027 | } |
| 1028 | else |
| 1029 | { |
| 1030 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[1], "Component")); |
| 1031 | } |
| 1032 | } |
| 1033 | } |
| 1034 | |
| 1035 | /// <summary> |
| 1036 | /// Decompile the IIsWebSite table. |
| 1037 | /// </summary> |
| 1038 | /// <param name="table">The table to decompile.</param> |
| 1039 | private void DecompileIIsWebSiteTable(Table table) |
| 1040 | { |
| 1041 | foreach (Row row in table.Rows) |
| 1042 | { |
| 1043 | IIs.WebSite webSite = new IIs.WebSite(); |
| 1044 | |
| 1045 | webSite.Id = (string)row[0]; |
| 1046 | |
| 1047 | if (null != row[2]) |
| 1048 | { |
| 1049 | webSite.Description = (string)row[2]; |
| 1050 | } |
| 1051 | |
| 1052 | if (null != row[3]) |
| 1053 | { |
| 1054 | webSite.ConnectionTimeout = (int)row[3]; |
| 1055 | } |
| 1056 | |
| 1057 | if (null != row[4]) |
| 1058 | { |
| 1059 | webSite.Directory = (string)row[4]; |
| 1060 | } |
| 1061 | |
| 1062 | if (null != row[5]) |
| 1063 | { |
| 1064 | switch ((int)row[5]) |
| 1065 | { |
| 1066 | case 0: |
| 1067 | // this is the default |
| 1068 | break; |
| 1069 | case 1: |
| 1070 | webSite.StartOnInstall = IIs.YesNoType.yes; |
| 1071 | break; |
| 1072 | case 2: |
| 1073 | webSite.AutoStart = IIs.YesNoType.yes; |
| 1074 | break; |
| 1075 | default: |
| 1076 | // TODO: warn |
| 1077 | break; |
| 1078 | } |
| 1079 | } |
| 1080 | |
| 1081 | if (null != row[6]) |
| 1082 | { |
| 1083 | int attributes = (int)row[6]; |
| 1084 | |
| 1085 | if (0x2 == (attributes & 0x2)) |
| 1086 | { |
| 1087 | webSite.ConfigureIfExists = IIs.YesNoType.no; |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | // the KeyAddress_ column is handled in FinalizeWebAddressTable |
| 1092 | |
| 1093 | if (null != row[8]) |
| 1094 | { |
| 1095 | webSite.DirProperties = (string)row[8]; |
| 1096 | } |
| 1097 | |
| 1098 | // the Application_ column is handled in FinalizeIIsWebApplicationTable |
| 1099 | |
| 1100 | if (null != row[10]) |
| 1101 | { |
| 1102 | if (-1 != (int)row[10]) |
| 1103 | { |
| 1104 | webSite.Sequence = (int)row[10]; |
| 1105 | } |
| 1106 | } |
| 1107 | |
| 1108 | if (null != row[11]) |
| 1109 | { |
| 1110 | webSite.WebLog = (string)row[11]; |
| 1111 | } |
| 1112 | |
| 1113 | if (null != row[12]) |
| 1114 | { |
| 1115 | webSite.SiteId = (string)row[12]; |
| 1116 | } |
| 1117 | |
| 1118 | if (null != row[1]) |
| 1119 | { |
| 1120 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[1]); |
| 1121 | |
| 1122 | if (null != component) |
| 1123 | { |
| 1124 | component.AddChild(webSite); |
| 1125 | } |
| 1126 | else |
| 1127 | { |
| 1128 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[1], "Component")); |
| 1129 | } |
| 1130 | } |
| 1131 | else |
| 1132 | { |
| 1133 | this.Core.RootElement.AddChild(webSite); |
| 1134 | } |
| 1135 | this.Core.IndexElement(row, webSite); |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | /// <summary> |
| 1140 | /// Decompile the IIsWebVirtualDir table. |
| 1141 | /// </summary> |
| 1142 | /// <param name="table">The table to decompile.</param> |
| 1143 | private void DecompileIIsWebVirtualDirTable(Table table) |
| 1144 | { |
| 1145 | foreach (Row row in table.Rows) |
| 1146 | { |
| 1147 | IIs.WebVirtualDir webVirtualDir = new IIs.WebVirtualDir(); |
| 1148 | |
| 1149 | webVirtualDir.Id = (string)row[0]; |
| 1150 | |
| 1151 | // the Component_ and Web_ columns are handled in FinalizeIIsWebVirtualDirTable |
| 1152 | |
| 1153 | webVirtualDir.Alias = (string)row[3]; |
| 1154 | |
| 1155 | webVirtualDir.Directory = (string)row[4]; |
| 1156 | |
| 1157 | if (null != row[5]) |
| 1158 | { |
| 1159 | webVirtualDir.DirProperties = (string)row[5]; |
| 1160 | } |
| 1161 | |
| 1162 | // the Application_ column is handled in FinalizeIIsWebApplicationTable |
| 1163 | |
| 1164 | this.Core.IndexElement(row, webVirtualDir); |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | /// <summary> |
| 1169 | /// Decompile the IIsWebSiteCertificates table. |
| 1170 | /// </summary> |
| 1171 | /// <param name="table">The table to decompile.</param> |
| 1172 | private void DecompileIIsWebSiteCertificatesTable(Table table) |
| 1173 | { |
| 1174 | foreach (Row row in table.Rows) |
| 1175 | { |
| 1176 | IIs.CertificateRef certificateRef = new IIs.CertificateRef(); |
| 1177 | |
| 1178 | certificateRef.Id = (string)row[1]; |
| 1179 | |
| 1180 | this.Core.IndexElement(row, certificateRef); |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | /// <summary> |
| 1185 | /// Finalize the IIsHttpHeader table. |
| 1186 | /// </summary> |
| 1187 | /// <param name="tables">The collection of all tables.</param> |
| 1188 | /// <remarks> |
| 1189 | /// The IIsHttpHeader table supports multiple parent types so no foreign key |
| 1190 | /// is declared and thus nesting must be done late. |
| 1191 | /// </remarks> |
| 1192 | private void FinalizeIIsHttpHeaderTable(TableIndexedCollection tables) |
| 1193 | { |
| 1194 | Table iisHttpHeaderTable = tables["IIsHttpHeader"]; |
| 1195 | |
| 1196 | if (null != iisHttpHeaderTable) |
| 1197 | { |
| 1198 | foreach (Row row in iisHttpHeaderTable.Rows) |
| 1199 | { |
| 1200 | IIs.HttpHeader httpHeader = (IIs.HttpHeader)this.Core.GetIndexedElement(row); |
| 1201 | |
| 1202 | if (1 == (int)row[1]) |
| 1203 | { |
| 1204 | IIs.WebVirtualDir webVirtualDir = (IIs.WebVirtualDir)this.Core.GetIndexedElement("IIsWebVirtualDir", (string)row[2]); |
| 1205 | if (null != webVirtualDir) |
| 1206 | { |
| 1207 | webVirtualDir.AddChild(httpHeader); |
| 1208 | } |
| 1209 | else |
| 1210 | { |
| 1211 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, iisHttpHeaderTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "ParentValue", (string)row[2], "IIsWebVirtualDir")); |
| 1212 | } |
| 1213 | } |
| 1214 | else if (2 == (int)row[1]) |
| 1215 | { |
| 1216 | IIs.WebSite webSite = (IIs.WebSite)this.Core.GetIndexedElement("IIsWebSite", (string)row[2]); |
| 1217 | if (null != webSite) |
| 1218 | { |
| 1219 | webSite.AddChild(httpHeader); |
| 1220 | } |
| 1221 | else |
| 1222 | { |
| 1223 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, iisHttpHeaderTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "ParentValue", (string)row[2], "IIsWebSite")); |
| 1224 | } |
| 1225 | } |
| 1226 | } |
| 1227 | } |
| 1228 | } |
| 1229 | |
| 1230 | /// <summary> |
| 1231 | /// Finalize the IIsMimeMap table. |
| 1232 | /// </summary> |
| 1233 | /// <param name="tables">The collection of all tables.</param> |
| 1234 | /// <remarks> |
| 1235 | /// The IIsMimeMap table supports multiple parent types so no foreign key |
| 1236 | /// is declared and thus nesting must be done late. |
| 1237 | /// </remarks> |
| 1238 | private void FinalizeIIsMimeMapTable(TableIndexedCollection tables) |
| 1239 | { |
| 1240 | Table iisMimeMapTable = tables["IIsMimeMap"]; |
| 1241 | |
| 1242 | if (null != iisMimeMapTable) |
| 1243 | { |
| 1244 | foreach (Row row in iisMimeMapTable.Rows) |
| 1245 | { |
| 1246 | IIs.MimeMap mimeMap = (IIs.MimeMap)this.Core.GetIndexedElement(row); |
| 1247 | |
| 1248 | if (2 < (int)row[1] || 0 >= (int)row[1]) |
| 1249 | { |
| 1250 | // TODO: warn about unknown parent type |
| 1251 | } |
| 1252 | |
| 1253 | IIs.WebVirtualDir webVirtualDir = (IIs.WebVirtualDir)this.Core.GetIndexedElement("IIsWebVirtualDir", (string)row[2]); |
| 1254 | IIs.WebSite webSite = (IIs.WebSite)this.Core.GetIndexedElement("IIsWebSite", (string)row[2]); |
| 1255 | if (null != webVirtualDir) |
| 1256 | { |
| 1257 | webVirtualDir.AddChild(mimeMap); |
| 1258 | } |
| 1259 | else if (null != webSite) |
| 1260 | { |
| 1261 | webSite.AddChild(mimeMap); |
| 1262 | } |
| 1263 | else |
| 1264 | { |
| 1265 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, iisMimeMapTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "ParentValue", (string)row[2], "IIsWebVirtualDir")); |
| 1266 | } |
| 1267 | } |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | /// <summary> |
| 1272 | /// Finalize the IIsWebApplication table. |
| 1273 | /// </summary> |
| 1274 | /// <param name="tables">The collection of all tables.</param> |
| 1275 | /// <remarks> |
| 1276 | /// Since WebApplication elements may nest under a specific WebSite or |
| 1277 | /// WebVirtualDir (or just the root element), the nesting must be done late. |
| 1278 | /// </remarks> |
| 1279 | private void FinalizeIIsWebApplicationTable(TableIndexedCollection tables) |
| 1280 | { |
| 1281 | Table iisWebApplicationTable = tables["IIsWebApplication"]; |
| 1282 | Table iisWebSiteTable = tables["IIsWebSite"]; |
| 1283 | Table iisWebVirtualDirTable = tables["IIsWebVirtualDir"]; |
| 1284 | |
| 1285 | Hashtable addedWebApplications = new Hashtable(); |
| 1286 | |
| 1287 | if (null != iisWebSiteTable) |
| 1288 | { |
| 1289 | foreach (Row row in iisWebSiteTable.Rows) |
| 1290 | { |
| 1291 | if (null != row[9]) |
| 1292 | { |
| 1293 | IIs.WebSite webSite = (IIs.WebSite)this.Core.GetIndexedElement(row); |
| 1294 | |
| 1295 | IIs.WebApplication webApplication = (IIs.WebApplication)this.Core.GetIndexedElement("IIsWebApplication", (string)row[9]); |
| 1296 | if (null != webApplication) |
| 1297 | { |
| 1298 | webSite.AddChild(webApplication); |
| 1299 | addedWebApplications[webApplication] = null; |
| 1300 | } |
| 1301 | else |
| 1302 | { |
| 1303 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, iisWebSiteTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Application_", (string)row[9], "IIsWebApplication")); |
| 1304 | } |
| 1305 | } |
| 1306 | } |
| 1307 | } |
| 1308 | |
| 1309 | if (null != iisWebVirtualDirTable) |
| 1310 | { |
| 1311 | foreach (Row row in iisWebVirtualDirTable.Rows) |
| 1312 | { |
| 1313 | if (null != row[6]) |
| 1314 | { |
| 1315 | IIs.WebVirtualDir webVirtualDir = (IIs.WebVirtualDir)this.Core.GetIndexedElement(row); |
| 1316 | |
| 1317 | IIs.WebApplication webApplication = (IIs.WebApplication)this.Core.GetIndexedElement("IIsWebApplication", (string)row[6]); |
| 1318 | if (null != webApplication) |
| 1319 | { |
| 1320 | webVirtualDir.AddChild(webApplication); |
| 1321 | addedWebApplications[webApplication] = null; |
| 1322 | } |
| 1323 | else |
| 1324 | { |
| 1325 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, iisWebVirtualDirTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Application_", (string)row[6], "IIsWebApplication")); |
| 1326 | } |
| 1327 | } |
| 1328 | } |
| 1329 | } |
| 1330 | |
| 1331 | if (null != iisWebApplicationTable) |
| 1332 | { |
| 1333 | foreach (Row row in iisWebApplicationTable.Rows) |
| 1334 | { |
| 1335 | IIs.WebApplication webApplication = (IIs.WebApplication)this.Core.GetIndexedElement(row); |
| 1336 | |
| 1337 | if (!addedWebApplications.Contains(webApplication)) |
| 1338 | { |
| 1339 | this.Core.RootElement.AddChild(webApplication); |
| 1340 | } |
| 1341 | } |
| 1342 | } |
| 1343 | } |
| 1344 | |
| 1345 | /// <summary> |
| 1346 | /// Finalize the IIsWebError table. |
| 1347 | /// </summary> |
| 1348 | /// <param name="tables">The collection of all tables.</param> |
| 1349 | /// <remarks> |
| 1350 | /// Since there is no foreign key relationship declared for this table |
| 1351 | /// (because it takes various parent types), it must be nested late. |
| 1352 | /// </remarks> |
| 1353 | private void FinalizeIIsWebErrorTable(TableIndexedCollection tables) |
| 1354 | { |
| 1355 | Table iisWebErrorTable = tables["IIsWebError"]; |
| 1356 | |
| 1357 | if (null != iisWebErrorTable) |
| 1358 | { |
| 1359 | foreach (Row row in iisWebErrorTable.Rows) |
| 1360 | { |
| 1361 | IIs.WebError webError = (IIs.WebError)this.Core.GetIndexedElement(row); |
| 1362 | |
| 1363 | if (1 == (int)row[2]) // WebVirtualDir parent |
| 1364 | { |
| 1365 | IIs.WebVirtualDir webVirtualDir = (IIs.WebVirtualDir)this.Core.GetIndexedElement("IIsWebVirtualDir", (string)row[3]); |
| 1366 | |
| 1367 | if (null != webVirtualDir) |
| 1368 | { |
| 1369 | webVirtualDir.AddChild(webError); |
| 1370 | } |
| 1371 | else |
| 1372 | { |
| 1373 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, iisWebErrorTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "ParentValue", (string)row[3], "IIsWebVirtualDir")); |
| 1374 | } |
| 1375 | } |
| 1376 | else if (2 == (int)row[2]) // WebSite parent |
| 1377 | { |
| 1378 | IIs.WebSite webSite = (IIs.WebSite)this.Core.GetIndexedElement("IIsWebSite", (string)row[3]); |
| 1379 | |
| 1380 | if (null != webSite) |
| 1381 | { |
| 1382 | webSite.AddChild(webError); |
| 1383 | } |
| 1384 | else |
| 1385 | { |
| 1386 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, iisWebErrorTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "ParentValue", (string)row[3], "IIsWebSite")); |
| 1387 | } |
| 1388 | } |
| 1389 | else |
| 1390 | { |
| 1391 | // TODO: warn unknown parent type |
| 1392 | } |
| 1393 | } |
| 1394 | } |
| 1395 | } |
| 1396 | |
| 1397 | /// <summary> |
| 1398 | /// Finalize the IIsWebVirtualDir table. |
| 1399 | /// </summary> |
| 1400 | /// <param name="tables">The collection of all tables.</param> |
| 1401 | /// <remarks> |
| 1402 | /// WebVirtualDir elements nest under either a WebSite or component |
| 1403 | /// depending upon whether the component in the IIsWebVirtualDir row |
| 1404 | /// is the same as the one in the parent IIsWebSite row. |
| 1405 | /// </remarks> |
| 1406 | private void FinalizeIIsWebVirtualDirTable(TableIndexedCollection tables) |
| 1407 | { |
| 1408 | Table iisWebSiteTable = tables["IIsWebSite"]; |
| 1409 | Table iisWebVirtualDirTable = tables["IIsWebVirtualDir"]; |
| 1410 | |
| 1411 | Hashtable iisWebSiteRows = new Hashtable(); |
| 1412 | |
| 1413 | // index the IIsWebSite rows by their primary keys |
| 1414 | if (null != iisWebSiteTable) |
| 1415 | { |
| 1416 | foreach (Row row in iisWebSiteTable.Rows) |
| 1417 | { |
| 1418 | iisWebSiteRows.Add(row[0], row); |
| 1419 | } |
| 1420 | } |
| 1421 | |
| 1422 | if (null != iisWebVirtualDirTable) |
| 1423 | { |
| 1424 | foreach (Row row in iisWebVirtualDirTable.Rows) |
| 1425 | { |
| 1426 | IIs.WebVirtualDir webVirtualDir = (IIs.WebVirtualDir)this.Core.GetIndexedElement(row); |
| 1427 | Row iisWebSiteRow = (Row)iisWebSiteRows[row[2]]; |
| 1428 | |
| 1429 | if (null != iisWebSiteRow) |
| 1430 | { |
| 1431 | if ((string)iisWebSiteRow[1] == (string)row[1]) |
| 1432 | { |
| 1433 | IIs.WebSite webSite = (IIs.WebSite)this.Core.GetIndexedElement(iisWebSiteRow); |
| 1434 | |
| 1435 | webSite.AddChild(webVirtualDir); |
| 1436 | } |
| 1437 | else |
| 1438 | { |
| 1439 | Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[1]); |
| 1440 | |
| 1441 | if (null != component) |
| 1442 | { |
| 1443 | webVirtualDir.WebSite = (string)row[2]; |
| 1444 | component.AddChild(webVirtualDir); |
| 1445 | } |
| 1446 | else |
| 1447 | { |
| 1448 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, iisWebVirtualDirTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[1], "Component")); |
| 1449 | } |
| 1450 | } |
| 1451 | } |
| 1452 | else |
| 1453 | { |
| 1454 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, iisWebVirtualDirTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Web_", (string)row[2], "IIsWebSite")); |
| 1455 | } |
| 1456 | } |
| 1457 | } |
| 1458 | } |
| 1459 | |
| 1460 | /// <summary> |
| 1461 | /// Finalize the IIsWebSiteCertificates table. |
| 1462 | /// </summary> |
| 1463 | /// <param name="tables">The collection of all tables.</param> |
| 1464 | /// <remarks> |
| 1465 | /// This table creates CertificateRef elements which nest under WebSite |
| 1466 | /// elements. |
| 1467 | /// </remarks> |
| 1468 | private void FinalizeIIsWebSiteCertificatesTable(TableIndexedCollection tables) |
| 1469 | { |
| 1470 | Table IIsWebSiteCertificatesTable = tables["IIsWebSiteCertificates"]; |
| 1471 | |
| 1472 | if (null != IIsWebSiteCertificatesTable) |
| 1473 | { |
| 1474 | foreach (Row row in IIsWebSiteCertificatesTable.Rows) |
| 1475 | { |
| 1476 | IIs.CertificateRef certificateRef = (IIs.CertificateRef)this.Core.GetIndexedElement(row); |
| 1477 | IIs.WebSite webSite = (IIs.WebSite)this.Core.GetIndexedElement("IIsWebSite", (string)row[0]); |
| 1478 | |
| 1479 | if (null != webSite) |
| 1480 | { |
| 1481 | webSite.AddChild(certificateRef); |
| 1482 | } |
| 1483 | else |
| 1484 | { |
| 1485 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, IIsWebSiteCertificatesTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Web_", (string)row[0], "IIsWebSite")); |
| 1486 | } |
| 1487 | } |
| 1488 | } |
| 1489 | } |
| 1490 | |
| 1491 | /// <summary> |
| 1492 | /// Finalize the WebAddress table. |
| 1493 | /// </summary> |
| 1494 | /// <param name="tables">The collection of all tables.</param> |
| 1495 | /// <remarks> |
| 1496 | /// There is a circular dependency between the WebAddress and WebSite |
| 1497 | /// tables, so nesting must be handled here. |
| 1498 | /// </remarks> |
| 1499 | private void FinalizeWebAddressTable(TableIndexedCollection tables) |
| 1500 | { |
| 1501 | Table iisWebAddressTable = tables["IIsWebAddress"]; |
| 1502 | Table iisWebSiteTable = tables["IIsWebSite"]; |
| 1503 | |
| 1504 | Hashtable addedWebAddresses = new Hashtable(); |
| 1505 | |
| 1506 | if (null != iisWebSiteTable) |
| 1507 | { |
| 1508 | foreach (Row row in iisWebSiteTable.Rows) |
| 1509 | { |
| 1510 | IIs.WebSite webSite = (IIs.WebSite)this.Core.GetIndexedElement(row); |
| 1511 | |
| 1512 | IIs.WebAddress webAddress = (IIs.WebAddress)this.Core.GetIndexedElement("IIsWebAddress", (string)row[7]); |
| 1513 | if (null != webAddress) |
| 1514 | { |
| 1515 | webSite.AddChild(webAddress); |
| 1516 | addedWebAddresses[webAddress] = null; |
| 1517 | } |
| 1518 | else |
| 1519 | { |
| 1520 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, iisWebSiteTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "KeyAddress_", (string)row[7], "IIsWebAddress")); |
| 1521 | } |
| 1522 | } |
| 1523 | } |
| 1524 | |
| 1525 | if (null != iisWebAddressTable) |
| 1526 | { |
| 1527 | foreach (Row row in iisWebAddressTable.Rows) |
| 1528 | { |
| 1529 | IIs.WebAddress webAddress = (IIs.WebAddress)this.Core.GetIndexedElement(row); |
| 1530 | |
| 1531 | if (!addedWebAddresses.Contains(webAddress)) |
| 1532 | { |
| 1533 | IIs.WebSite webSite = (IIs.WebSite)this.Core.GetIndexedElement("IIsWebSite", (string)row[1]); |
| 1534 | |
| 1535 | if (null != webSite) |
| 1536 | { |
| 1537 | webSite.AddChild(webAddress); |
| 1538 | } |
| 1539 | else |
| 1540 | { |
| 1541 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, iisWebAddressTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Web_", (string)row[1], "IIsWebSite")); |
| 1542 | } |
| 1543 | } |
| 1544 | } |
| 1545 | } |
| 1546 | } |
| 1547 | } |
| 1548 | #endif |
| 1549 | } |