Exemple #1
0
        /// <summary>
        /// Called when a new action starts.
        /// </summary>
        /// <param name="record">The <see cref="Deployment.WindowsInstaller.Record"/> containing additional information.</param>
        /// <returns>The result code indicating how Windows Installer should proceed.</returns>
        protected MessageResult OnActionStart(Deployment.WindowsInstaller.Record record)
        {
            if (this.progress.IsValid)
            {
                var current = this.progress.Current;

                if (current.EnableActionData)
                {
                    current.EnableActionData = false;
                }

                if (current.GeneratingScript)
                {
                    this.progress.CurrentAction = Resources.Action_GeneratingScript;
                }
                else if (null != record && 2 < record.FieldCount)
                {
                    var action = record.GetString(1);
                    Debug.Assert(!string.IsNullOrEmpty(action), "Action should not be null at this point");

                    this.progress.CurrentAction         = record.GetString(2);
                    this.progress.CurrentActionTemplate = record.GetString(3);

                    // Use current culture resources if ActionText is missing or doesn't match the current culture.
                    var culture = this.progress.CurrentCulture ?? CultureInfo.InvariantCulture;
                    if (string.IsNullOrEmpty(this.progress.CurrentAction) || !culture.Equals(CultureInfo.CurrentCulture))
                    {
                        this.progress.CurrentAction = ActionText.GetActionText(action) ?? string.Empty;
                    }

                    if (string.IsNullOrEmpty(this.progress.CurrentActionTemplate) || !culture.Equals(CultureInfo.CurrentCulture))
                    {
                        this.progress.CurrentActionTemplate = ActionText.GetActionData(action);
                    }
                }
            }

            return(MessageResult.OK);
        }
Exemple #2
0
        private static ErrorCategory GetErrorCategory(Deployment.WindowsInstaller.Record record, out string resource)
        {
            resource = null;

            if (1 < record.FieldCount)
            {
                int code = record.GetInteger(1);
                if (1000 <= code && code < 25000)
                {
                    // Specifically handle common errors.
                    switch (code)
                    {
                    case 1301:
                    case 1304:
                        resource = record.GetString(2);
                        return(ErrorCategory.WriteError);

                    case 1303:
                    case 1306:
                    case 1718:
                        resource = record.GetString(2);
                        return(ErrorCategory.PermissionDenied);

                    case 1305:
                        resource = record.GetString(2);
                        return(ErrorCategory.ReadError);

                    case 1308:
                    case 1334:
                        resource = record.GetString(2);
                        return(ErrorCategory.ResourceUnavailable);

                    case 1706:
                        resource = record.GetString(2);
                        return(ErrorCategory.ResourceUnavailable);

                    case 1715:
                    case 1716:
                    case 1717:
                        resource = record.GetString(2);
                        return(ErrorCategory.NotSpecified);

                    case 1935:
                    case 1937:
                        resource = record.GetString(6);
                        return(ErrorCategory.InvalidData);
                    }
                }
            }

            return(ErrorCategory.NotSpecified);
        }
Exemple #3
0
        /// <summary>
        /// Provides information about the install session.
        /// </summary>
        /// <param name="record">The <see cref="Deployment.WindowsInstaller.Record"/> containing common details.</param>
        /// <returns>The result code indicating how Windows Installer should proceed.</returns>
        protected MessageResult OnCommonData(Deployment.WindowsInstaller.Record record)
        {
            // Get the current session language and Windows Installer-generated caption.
            if (1 < record.FieldCount)
            {
                var subtype = record.GetInteger(1);
                if (0 == subtype)
                {
                    var langId = record.GetInteger(2);
                    if (0 != langId)
                    {
                        this.progress.CurrentCulture = CultureInfo.GetCultureInfo(langId);
                    }
                }
                else if (1 == subtype)
                {
                    this.progress.CurrentName = record.GetString(2);
                }
            }

            return(MessageResult.OK);
        }
Exemple #4
0
        private void WriteMessage(InstallMessage type, Deployment.WindowsInstaller.Record record)
        {
            var sb = new StringBuilder();

            sb.AppendFormat(CultureInfo.InvariantCulture, "{0} ({0:d})", type);

            if (null != record)
            {
                sb.Append(": ");

                // Show field 0 (format string) as well.
                for (int i = 0; i <= record.FieldCount; ++i)
                {
                    if (0 != i)
                    {
                        sb.Append(", ");
                    }

                    sb.AppendFormat(CultureInfo.InvariantCulture, "{0}: {1}", i, record.GetString(i));
                }
            }

            this.WriteDebug(sb.ToString());
        }