Exemple #1
0
        /// <summary>
        /// Decompile the ServiceConfig table.
        /// </summary>
        /// <param name="table">The table to decompile.</param>
        private void DecompileServiceConfigTable(Table table)
        {
            foreach (Row row in table.Rows)
            {
                Util.ServiceConfig serviceConfig = new Util.ServiceConfig();

                serviceConfig.ServiceName = (string)row[0];

                switch ((string)row[3])
                {
                case "none":
                    serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.none;
                    break;

                case "reboot":
                    serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.reboot;
                    break;

                case "restart":
                    serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.restart;
                    break;

                case "runCommand":
                    serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.runCommand;
                    break;

                default:
                    this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[3].Column.Name, row[3]));
                    break;
                }

                switch ((string)row[4])
                {
                case "none":
                    serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.none;
                    break;

                case "reboot":
                    serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.reboot;
                    break;

                case "restart":
                    serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.restart;
                    break;

                case "runCommand":
                    serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.runCommand;
                    break;

                default:
                    this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[4].Column.Name, row[4]));
                    break;
                }

                switch ((string)row[5])
                {
                case "none":
                    serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.none;
                    break;

                case "reboot":
                    serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.reboot;
                    break;

                case "restart":
                    serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.restart;
                    break;

                case "runCommand":
                    serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.runCommand;
                    break;

                default:
                    this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[5].Column.Name, row[5]));
                    break;
                }

                if (null != row[6])
                {
                    serviceConfig.ResetPeriodInDays = (int)row[6];
                }

                if (null != row[7])
                {
                    serviceConfig.RestartServiceDelayInSeconds = (int)row[7];
                }

                if (null != row[8])
                {
                    serviceConfig.ProgramCommandLine = (string)row[8];
                }

                if (null != row[9])
                {
                    serviceConfig.RebootMessage = (string)row[9];
                }

                this.Core.IndexElement(row, serviceConfig);
            }
        }
Exemple #2
0
        /// <summary>
        /// Decompile the ServiceConfig table.
        /// </summary>
        /// <param name="table">The table to decompile.</param>
        private void DecompileServiceConfigTable(Table table)
        {
            foreach (Row row in table.Rows)
            {
                Util.ServiceConfig serviceConfig = new Util.ServiceConfig();

                serviceConfig.ServiceName = (string)row[0];

                switch ((string)row[3])
                {
                    case "none":
                        serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.none;
                        break;
                    case "reboot":
                        serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.reboot;
                        break;
                    case "restart":
                        serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.restart;
                        break;
                    case "runCommand":
                        serviceConfig.FirstFailureActionType = Util.ServiceConfig.FirstFailureActionTypeType.runCommand;
                        break;
                    default:
                        this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[3].Column.Name, row[3]));
                        break;
                }

                switch ((string)row[4])
                {
                    case "none":
                        serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.none;
                        break;
                    case "reboot":
                        serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.reboot;
                        break;
                    case "restart":
                        serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.restart;
                        break;
                    case "runCommand":
                        serviceConfig.SecondFailureActionType = Util.ServiceConfig.SecondFailureActionTypeType.runCommand;
                        break;
                    default:
                        this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[4].Column.Name, row[4]));
                        break;
                }

                switch ((string)row[5])
                {
                    case "none":
                        serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.none;
                        break;
                    case "reboot":
                        serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.reboot;
                        break;
                    case "restart":
                        serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.restart;
                        break;
                    case "runCommand":
                        serviceConfig.ThirdFailureActionType = Util.ServiceConfig.ThirdFailureActionTypeType.runCommand;
                        break;
                    default:
                        this.Core.OnMessage(WixWarnings.IllegalColumnValue(row.SourceLineNumbers, table.Name, row.Fields[5].Column.Name, row[5]));
                        break;
                }

                if (null != row[6])
                {
                    serviceConfig.ResetPeriodInDays = (int)row[6];
                }

                if (null != row[7])
                {
                    serviceConfig.RestartServiceDelayInSeconds = (int)row[7];
                }

                if (null != row[8])
                {
                    serviceConfig.ProgramCommandLine = (string)row[8];
                }

                if (null != row[9])
                {
                    serviceConfig.RebootMessage = (string)row[9];
                }

                this.Core.IndexElement(row, serviceConfig);
            }
        }
Exemple #3
0
        /// <summary>
        /// Finalize the ServiceConfig table.
        /// </summary>
        /// <param name="tables">The collection of all tables.</param>
        /// <remarks>
        /// Since there is no foreign key from the ServiceName column to the
        /// ServiceInstall table, this relationship must be handled late.
        /// </remarks>
        private void FinalizeServiceConfigTable(TableCollection tables)
        {
            Table serviceConfigTable  = tables["ServiceConfig"];
            Table serviceInstallTable = tables["ServiceInstall"];

            Hashtable serviceInstalls = new Hashtable();

            // index the ServiceInstall table because the foreign key used by the ServiceConfig
            // table is actually the ServiceInstall.Name, not the ServiceInstall.ServiceInstall
            // this is unfortunate because the service Name is not guaranteed to be unique, so
            // decompiler must assume there could be multiple matches and add the ServiceConfig to each
            // TODO: the Component column information should be taken into acount to accurately identify
            // the correct column to use
            if (null != serviceInstallTable)
            {
                foreach (Row row in serviceInstallTable.Rows)
                {
                    string             name           = (string)row[1];
                    Wix.ServiceInstall serviceInstall = (Wix.ServiceInstall) this.Core.GetIndexedElement(row);

                    if (!serviceInstalls.Contains(name))
                    {
                        serviceInstalls.Add(name, new ArrayList());
                    }

                    ((ArrayList)serviceInstalls[name]).Add(serviceInstall);
                }
            }

            if (null != serviceConfigTable)
            {
                foreach (Row row in serviceConfigTable.Rows)
                {
                    Util.ServiceConfig serviceConfig = (Util.ServiceConfig) this.Core.GetIndexedElement(row);

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

                        if (null != component)
                        {
                            component.AddChild(serviceConfig);
                        }
                        else
                        {
                            this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, serviceConfigTable.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "Component_", (string)row[1], "Component"));
                        }
                    }
                    else
                    {
                        ArrayList serviceInstallElements = (ArrayList)serviceInstalls[row[0]];

                        if (null != serviceInstallElements)
                        {
                            foreach (Wix.ServiceInstall serviceInstall in serviceInstallElements)
                            {
                                serviceInstall.AddChild(serviceConfig);
                            }
                        }
                        else
                        {
                            this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, serviceConfigTable.Name, row.GetPrimaryKey(DecompilerCore.PrimaryKeyDelimiter), "ServiceName", (string)row[0], "ServiceInstall"));
                        }
                    }
                }
            }
        }