Exemple #1
0
        /// <summary>
        /// Harvest a web directory.
        /// </summary>
        /// <param name="webDirectoryEntry">The web directory directory entry.</param>
        /// <param name="webSite">The parent web site.</param>
        private void HarvestWebDirectory(DirectoryEntry webDirectoryEntry, IIs.WebSite webSite)
        {
            foreach (DirectoryEntry childEntry in webDirectoryEntry.Children)
            {
                switch (childEntry.SchemaClassName)
                {
                case "IIsWebDirectory":
                    this.HarvestWebDirectory(childEntry, webSite);
                    break;

                case "IIsWebVirtualDir":
                    this.HarvestWebVirtualDir(childEntry, webSite);
                    break;
                }
            }

            IIs.WebDirProperties webDirProperties = this.HarvestWebDirProperties(webDirectoryEntry);

            if (null != webDirProperties)
            {
                IIs.WebDir webDir = new IIs.WebDir();

                int indexOfRoot = webDirectoryEntry.Path.IndexOf("Root/");
                webDir.Path = webDirectoryEntry.Path.Substring(indexOfRoot + 5);

                webDir.AddChild(webDirProperties);

                webSite.AddChild(webDir);
            }
        }
Exemple #2
0
        /// <summary>
        /// Harvest a WiX document.
        /// </summary>
        /// <param name="argument">The argument for harvesting.</param>
        /// <returns>The harvested Fragment.</returns>
        public override Wix.Fragment[] Harvest(string argument)
        {
            DirectoryHarvester directoryHarvester = new DirectoryHarvester();

            directoryHarvester.Core = this.Core;
            directoryHarvester.KeepEmptyDirectories = true;

            IIsWebSiteHarvester iisWebSiteHarvester = new IIsWebSiteHarvester();

            iisWebSiteHarvester.Core = this.Core;

            IIs.WebSite webSite = iisWebSiteHarvester.HarvestWebSite(argument);

            Wix.Component component = new Wix.Component();
            component.AddChild(new Wix.CreateFolder());
            component.AddChild(webSite);

            this.Core.RootDirectory = webSite.Directory;
            Wix.Directory directory = directoryHarvester.HarvestDirectory(webSite.Directory, true);
            directory.AddChild(component);

            Wix.Fragment fragment = new Wix.Fragment();
            fragment.AddChild(directory);

            return(new Wix.Fragment[] { fragment });
        }
Exemple #3
0
        /// <summary>
        /// Harvest a web virtual directory.
        /// </summary>
        /// <param name="webVirtualDirEntry">The web virtual directory directory entry.</param>
        /// <param name="webSite">The parent web site.</param>
        private void HarvestWebVirtualDir(DirectoryEntry webVirtualDirEntry, IIs.WebSite webSite)
        {
            IIs.WebVirtualDir webVirtualDir = new IIs.WebVirtualDir();

            foreach (string propertyName in webVirtualDirEntry.Properties.PropertyNames)
            {
                PropertyValueCollection property       = webVirtualDirEntry.Properties[propertyName];
                PropertyValueCollection parentProperty = webVirtualDirEntry.Parent.Properties[propertyName];

                if (null == parentProperty.Value || parentProperty.Value.ToString() != property.Value.ToString())
                {
                    switch (propertyName)
                    {
                    case "Path":
                        webVirtualDir.Directory = (string)property.Value;
                        break;
                    }
                }
            }

            int indexOfRoot = webVirtualDirEntry.Path.IndexOf("ROOT/", StringComparison.OrdinalIgnoreCase);

            webVirtualDir.Alias = webVirtualDirEntry.Path.Substring(indexOfRoot + 5);

            IIs.WebDirProperties webDirProps = this.HarvestWebDirProperties(webVirtualDirEntry);
            if (webDirProps != null)
            {
                webVirtualDir.AddChild(webDirProps);
            }

            foreach (DirectoryEntry childEntry in webVirtualDirEntry.Children)
            {
                switch (childEntry.SchemaClassName)
                {
                case "IIsWebDirectory":
                    this.HarvestWebDirectory(childEntry, webSite);
                    break;

                case "IIsWebVirtualDir":
                    this.HarvestWebVirtualDir(childEntry, webSite);
                    break;
                }
            }

            webSite.AddChild(webVirtualDir);
        }
        /// <summary>
        /// Decompile the IIsWebSite table.
        /// </summary>
        /// <param name="table">The table to decompile.</param>
        private void DecompileIIsWebSiteTable(Table table)
        {
            foreach (Row row in table.Rows)
            {
                IIs.WebSite webSite = new IIs.WebSite();

                webSite.Id = (string)row[0];

                if (null != row[2])
                {
                    webSite.Description = (string)row[2];
                }

                if (null != row[3])
                {
                    webSite.ConnectionTimeout = (int)row[3];
                }

                if (null != row[4])
                {
                    webSite.Directory = (string)row[4];
                }

                if (null != row[5])
                {
                    switch ((int)row[5])
                    {
                        case 0:
                            // this is the default
                            break;
                        case 1:
                            webSite.StartOnInstall = IIs.YesNoType.yes;
                            break;
                        case 2:
                            webSite.AutoStart = IIs.YesNoType.yes;
                            break;
                        default:
                            // TODO: warn
                            break;
                    }
                }

                if (null != row[6])
                {
                    int attributes = (int)row[6];

                    if (0x2 == (attributes & 0x2))
                    {
                        webSite.ConfigureIfExists = IIs.YesNoType.no;
                    }
                }

                // the KeyAddress_ column is handled in FinalizeWebAddressTable

                if (null != row[8])
                {
                    webSite.DirProperties = (string)row[8];
                }

                // the Application_ column is handled in FinalizeIIsWebApplicationTable

                if (null != row[10])
                {
                    if (-1 != (int)row[10])
                    {
                        webSite.Sequence = (int)row[10];
                    }
                }

                if (null != row[11])
                {
                    webSite.WebLog = (string)row[11];
                }

                if (null != row[12])
                {
                    webSite.SiteId = (string)row[12];
                }

                if (null != row[1])
                {
                    Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[1]);

                    if (null != component)
                    {
                        component.AddChild(webSite);
                    }
                    else
                    {
                        this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Component_", (string)row[1], "Component"));
                    }
                }
                else
                {
                    this.Core.RootElement.AddChild(webSite);
                }
                this.Core.IndexElement(row, webSite);
            }
        }
Exemple #5
0
        /// <summary>
        /// Harvest a web site.
        /// </summary>
        /// <param name="webSiteEntry">The web site directory entry.</param>
        /// <returns>The harvested web site.</returns>
        private IIs.WebSite HarvestWebSite(DirectoryEntry webSiteEntry)
        {
            IIs.WebSite webSite = new IIs.WebSite();

            foreach (string propertyName in webSiteEntry.Properties.PropertyNames)
            {
                PropertyValueCollection property       = webSiteEntry.Properties[propertyName];
                PropertyValueCollection parentProperty = webSiteEntry.Parent.Properties[propertyName];

                if (null == parentProperty.Value || parentProperty.Value.ToString() != property.Value.ToString())
                {
                    switch (propertyName)
                    {
                    case "SecureBindings":
                        IIs.WebAddress secureWebAddress = this.HarvestBindings(propertyName, property);
                        if (null != secureWebAddress)
                        {
                            webSite.AddChild(secureWebAddress);
                        }
                        break;

                    case "ServerBindings":
                        IIs.WebAddress webAddress = this.HarvestBindings(propertyName, property);
                        if (null != webAddress)
                        {
                            webSite.AddChild(webAddress);
                        }
                        break;

                    case "ServerComment":
                        webSite.Description = (string)property.Value;
                        break;
                    }
                }
            }

            foreach (DirectoryEntry childEntry in webSiteEntry.Children)
            {
                switch (childEntry.SchemaClassName)
                {
                case "IIsFilters":
                    string   loadOrder   = (string)childEntry.Properties["FilterLoadOrder"].Value;
                    string[] filterNames = loadOrder.Split(",".ToCharArray());

                    for (int i = 0; i < filterNames.Length; i++)
                    {
                        using (DirectoryEntry webFilterEntry = new DirectoryEntry(String.Concat(childEntry.Path, '/', filterNames[i])))
                        {
                            IIs.WebFilter webFilter = this.HarvestWebFilter(webFilterEntry);

                            webFilter.LoadOrder = (i + 1).ToString(CultureInfo.InvariantCulture);

                            webSite.AddChild(webFilter);
                        }
                    }
                    break;

                case "IIsWebDirectory":
                    this.HarvestWebDirectory(childEntry, webSite);
                    break;

                case "IIsWebVirtualDir":
                    foreach (string propertyName in childEntry.Properties.PropertyNames)
                    {
                        PropertyValueCollection property = childEntry.Properties[propertyName];

                        switch (propertyName)
                        {
                        case "Path":
                            webSite.Directory = (string)property.Value;
                            break;
                        }
                    }

                    webSite.AddChild(this.HarvestWebDirProperties(childEntry));

                    foreach (DirectoryEntry child2Entry in childEntry.Children)
                    {
                        switch (child2Entry.SchemaClassName)
                        {
                        case "IIsWebDirectory":
                            this.HarvestWebDirectory(child2Entry, webSite);
                            break;

                        case "IIsWebVirtualDir":
                            this.HarvestWebVirtualDir(child2Entry, webSite);
                            break;
                        }
                    }
                    break;
                }
            }

            return(webSite);
        }
        /// <summary>
        /// Harvest a web site.
        /// </summary>
        /// <param name="webSiteEntry">The web site directory entry.</param>
        /// <returns>The harvested web site.</returns>
        private IIs.WebSite HarvestWebSite(DirectoryEntry webSiteEntry)
        {
            IIs.WebSite webSite = new IIs.WebSite();

            foreach (string propertyName in webSiteEntry.Properties.PropertyNames)
            {
                PropertyValueCollection property = webSiteEntry.Properties[propertyName];
                PropertyValueCollection parentProperty = webSiteEntry.Parent.Properties[propertyName];

                if (null == parentProperty.Value || parentProperty.Value.ToString() != property.Value.ToString())
                {
                    switch (propertyName)
                    {
                        case "SecureBindings":
                            IIs.WebAddress secureWebAddress = this.HarvestBindings(propertyName, property);
                            if (null != secureWebAddress)
                            {
                                webSite.AddChild(secureWebAddress);
                            }
                            break;
                        case "ServerBindings":
                            IIs.WebAddress webAddress = this.HarvestBindings(propertyName, property);
                            if (null != webAddress)
                            {
                                webSite.AddChild(webAddress);
                            }
                            break;
                        case "ServerComment":
                            webSite.Description = (string)property.Value;
                            break;
                    }
                }
            }

            foreach (DirectoryEntry childEntry in webSiteEntry.Children)
            {
                switch (childEntry.SchemaClassName)
                {
                    case "IIsFilters":
                        string loadOrder = (string)childEntry.Properties["FilterLoadOrder"].Value;
                        if (loadOrder.Length > 0)
                        {
                            string[] filterNames = loadOrder.Split(",".ToCharArray());

                            for (int i = 0; i < filterNames.Length; i++)
                            {
                                using (DirectoryEntry webFilterEntry = new DirectoryEntry(String.Concat(childEntry.Path, '/', filterNames[i])))
                                {
                                    IIs.WebFilter webFilter = this.HarvestWebFilter(webFilterEntry);

                                    webFilter.LoadOrder = (i + 1).ToString(CultureInfo.InvariantCulture);

                                    webSite.AddChild(webFilter);
                                }
                            }
                        }
                        break;
                    case "IIsWebDirectory":
                        this.HarvestWebDirectory(childEntry, webSite);
                        break;
                    case "IIsWebVirtualDir":
                        foreach (string propertyName in childEntry.Properties.PropertyNames)
                        {
                            PropertyValueCollection property = childEntry.Properties[propertyName];

                            switch (propertyName)
                            {
                                case "Path":
                                    webSite.Directory = (string)property.Value;
                                    break;
                            }
                        }

                        IIs.WebDirProperties webDirProps = this.HarvestWebDirProperties(childEntry);
                        if (null != webDirProps)
                        {
                            webSite.AddChild(webDirProps);
                        }

                        foreach (DirectoryEntry child2Entry in childEntry.Children)
                        {
                            switch (child2Entry.SchemaClassName)
                            {
                                case "IIsWebDirectory":
                                    this.HarvestWebDirectory(child2Entry, webSite);
                                    break;
                                case "IIsWebVirtualDir":
                                    this.HarvestWebVirtualDir(child2Entry, webSite);
                                    break;
                            }
                        }
                        break;
                }
            }

            return webSite;
        }