public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { try { this.progressCounter.ProcessMessage(messageType, messageRecord); this.progressBar.Value = (int)(this.progressBar.Minimum + this.progressCounter.Progress * (this.progressBar.Maximum - this.progressBar.Minimum)); this.progressLabel.Text = "" + (int)Math.Round(100 * this.progressCounter.Progress) + "%"; switch (messageType) { case InstallMessage.Error: case InstallMessage.Warning: case InstallMessage.Info: string message = String.Format("{0}: {1}", messageType, messageRecord); this.LogMessage(message); break; } if (this.canceled) { this.canceled = false; return MessageResult.Cancel; } } catch (Exception ex) { this.LogMessage(ex.ToString()); this.LogMessage(ex.StackTrace); } Application.DoEvents(); return MessageResult.OK; }
public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { try { this.progressCounter.ProcessMessage(messageType, messageRecord); this.progressBar.Value = this.progressBar.Minimum + this.progressCounter.Progress * (this.progressBar.Maximum - this.progressBar.Minimum); this.progressLabel.Content = "" + (int)Math.Round(100 * this.progressCounter.Progress) + "%"; switch (messageType) { case InstallMessage.Error: case InstallMessage.Warning: case InstallMessage.Info: string message = String.Format("{0}: {1}", messageType, messageRecord); this.LogMessage(message); break; } if (this.canceled) { this.canceled = false; return(MessageResult.Cancel); } } catch (Exception ex) { this.LogMessage(ex.ToString()); this.LogMessage(ex.StackTrace); } return(MessageResult.OK); }
public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { if (_controller.IsCanceled) { this.ViewModel.ClosingModel.Installed = ClosingResult.Cancelled; return(MessageResult.Cancel); } var indicator = _progressCounter.ProcessMessage(messageType, messageRecord); _controller.UpdateProgress(indicator); // Have we finished? if (messageType == InstallMessage.InstallEnd) { try { var returnCode = messageRecord.GetInteger(3); this.ViewModel.ClosingModel.Installed = returnCode == 1 ? ClosingResult.Success : ClosingResult.Failed; } catch (Exception) { this.ViewModel.ClosingModel.Installed = ClosingResult.Failed; } } return(MessageResult.OK); }
public void ProcessMessage(InstallMessage messageType, Record messageRecord) { // This MSI progress-handling code was mostly borrowed from burn and translated from C++ to C#. switch (messageType) { case InstallMessage.ActionStart: if (this.enableActionData) { this.enableActionData = false; } break; case InstallMessage.ActionData: if (this.enableActionData) { if (this.moveForward) { this.completed += this.step; } else { this.completed -= this.step; } this.UpdateProgress(); } break; case InstallMessage.Progress: this.ProcessProgressMessage(messageRecord); break; } }
/// <summary> /// Processes information and progress messages sent to the user interface. /// </summary> /// <param name="messageType">Message type.</param> /// <param name="messageRecord">Record that contains message data.</param> /// <param name="buttons">Message box buttons.</param> /// <param name="icon">Message box icon.</param> /// <param name="defaultButton">Message box default button.</param> /// <returns>Result of processing the message.</returns> public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { // Synchronously send the message to the setup wizard window on its thread. return(InUIThread <MessageResult>(() => { return setupWizard.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton); })); }
MessageResult OnUIUpdate(InstallMessage messageType, string message, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { if (cancelled && installing) { installing = false; return(MessageResult.Cancel); } return(MessageResult.OK); }
public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { object result = this._mainWindow.Dispatcher.Invoke( DispatcherPriority.Send, new Func <MessageResult>(() => this._mainWindow.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton))); return((MessageResult)result); }
public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { return((MessageResult)MessageBox.Show( _shell.shellView, messageRecord.ToString(), "[ErrorDlg_Title]".LocalizeWith(_shell.Runtime.Localize), (MessageBoxButtons)(int)buttons, (MessageBoxIcon)(int)icon, (MessageBoxDefaultButton)(int)defaultButton)); }
public static MessageResult ExternalUILogger( InstallMessage messageType, string message, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { Console.WriteLine("{0}: {1}", messageType, message); return MessageResult.None; }
/// <summary> /// Processes information and progress messages sent to the user interface. /// </summary> /// <param name="messageType">Message type.</param> /// <param name="messageRecord">Record that contains message data.</param> /// <param name="buttons">Message box buttons.</param> /// <param name="icon">Message box icon.</param> /// <param name="defaultButton">Message box default button.</param> /// <returns>Result of processing the message.</returns> public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { // Synchronously send the message to the setup wizard window on its thread. object result = this._mainWindow.Dispatcher.Invoke( DispatcherPriority.Send, new Func <MessageResult>(() => this._mainWindow.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton))); return((MessageResult)result); }
public static MessageResult ExternalUILogger( InstallMessage messageType, string message, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { Console.WriteLine("{0}: {1}", messageType, message); return(MessageResult.None); }
/// <summary> /// Processes information and progress messages sent to the user interface. /// </summary> /// <param name="messageType">Message type.</param> /// <param name="messageRecord">Record that contains message data.</param> /// <param name="buttons">Message box buttons.</param> /// <param name="icon">Message box icon.</param> /// <param name="defaultButton">Message box default button.</param> /// <returns>Result of processing the message.</returns> public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { // Synchronously send the message to the setup wizard window on its thread. var result = setupWizard.Dispatcher.Invoke(DispatcherPriority.Send, new Func <MessageResult>(delegate() { return(setupWizard.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton)); })); return((MessageResult)result); }
/// <summary> /// Processes the message. /// </summary> /// <param name="messageType">Type of the message.</param> /// <param name="messageRecord">The message record.</param> /// <param name="buttons">The buttons.</param> /// <param name="icon">The icon.</param> /// <param name="defaultButton">The default button.</param> /// <returns></returns> public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { switch (messageType) { case InstallMessage.InstallStart: case InstallMessage.InstallEnd: { waitPrompt.Visible = false; } break; case InstallMessage.ActionStart: { try { //messageRecord[0] - is reserved for FormatString value string message = null; bool simple = true; if (simple) { for (int i = messageRecord.FieldCount - 1; i > 0; i--) { message = messageRecord[i].ToString(); } } else { message = messageRecord.FormatString; if (message.IsNotEmpty()) { for (int i = 1; i < messageRecord.FieldCount; i++) { message = message.Replace("[" + i + "]", messageRecord[i].ToString()); } } else { message = messageRecord[messageRecord.FieldCount - 1].ToString(); } } if (message.IsNotEmpty()) { currentAction.Text = currentActionLabel.Text + " " + message; } } catch { } } break; } return(MessageResult.OK); }
private int ExternalUIHandler(uint messageType, string message) { TaskLogger.LogEnter(); int result = 1; InstallMessage installMessage = (InstallMessage)(4278190080U & messageType); InstallMessage installMessage2 = installMessage; if (installMessage2 <= InstallMessage.FilesInUse) { if (installMessage2 != InstallMessage.FatalExit) { if (installMessage2 != InstallMessage.Error) { if (installMessage2 == InstallMessage.FilesInUse) { result = 0; } } else if (this.OnMsiError != null) { this.OnMsiError(message); } } } else if (installMessage2 != InstallMessage.OutOfDiskSpace) { if (installMessage2 != InstallMessage.ActionData) { if (installMessage2 == InstallMessage.Progress) { if (this.HandleProgressMessage(this.ParseProgressString(message))) { this.UpdateProgress(); } } } else if (this.HandleActionDataMessage()) { this.UpdateProgress(); } } else { result = 0; } if (this.IsCanceled()) { result = 2; } TaskLogger.LogExit(); return(result); }
/// <summary> /// Handler for external UI messages. /// </summary> /// <param name="messageType">The type of message.</param> /// <param name="messageRecord">The message details.</param> /// <param name="buttons">Buttons to show (unused).</param> /// <param name="icon">The icon to show (unused).</param> /// <param name="defaultButton">The default button (unused).</param> /// <returns>How the message was handled.</returns> public MessageResult UIRecordHandler( InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { #if False Console.WriteLine("Message type {0}: {1}", messageType.ToString(), this.session.FormatRecord(messageRecord)); #endif if (!this.session.IsClosed && 1 <= messageRecord.FieldCount) { switch (messageType) { case InstallMessage.ActionStart: // only try to interpret the messages if they're coming from WixRunImmediateUnitTests string action = messageRecord.GetString(1); this.runningTests = Constants.LuxCustomActionName == action; return(MessageResult.OK); case InstallMessage.User: if (this.runningTests) { string message = messageRecord.ToString(); int id = messageRecord.GetInteger(1); if (Constants.TestIdMinimumSuccess <= id && Constants.TestIdMaximumSuccess >= id) { this.OnMessage(NitVerboses.TestPassed(message)); ++this.passes; } else if (Constants.TestIdMinimumFailure <= id && Constants.TestIdMaximumFailure >= id) { this.OnMessage(NitErrors.TestFailed(message)); ++this.failures; } } return(MessageResult.OK); case InstallMessage.Error: case InstallMessage.FatalExit: this.OnMessage(NitErrors.PackageFailed(this.session.FormatRecord(messageRecord))); return(MessageResult.Error); } } return(MessageResult.OK); }
public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { // skip showing any FilesInUse dialog, which is shown because the Windows service // is running and will be stopped/removed/started if (messageType == InstallMessage.RMFilesInUse || messageType == InstallMessage.FilesInUse) { return(MessageResult.OK); } object result = this._mainWindow.Dispatcher.Invoke( DispatcherPriority.Send, new Func <MessageResult>(() => this._mainWindow.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton))); return((MessageResult)result); }
/// <summary> /// Creates a new <see cref="ActionStartEventArgs"/> instance. /// </summary> /// <param name="message">The install message text.</param> /// <param name="messageType">The type of install message.</param> /// <param name="style"></param> public ActionStartEventArgs(string message, InstallMessage messageType, MessageBox style) : base(message, messageType, style) { // This message provides information about the current action. // The format is "Action [1]: [2]. [3]", where a colon is used to separate Field 1 and Field 2 and a period is used to separate // Field 2 and Field 3. Field [1] contains the time the action was started using the Time property format (24-hour clock). // Field [2] contains the action's name from the sequence table. Field [3] gives the action's description from the ActionText table // or from the MsiProcessMessage function. // // See https://docs.microsoft.com/en-us/windows/win32/msi/parsing-windows-installer-messages Match match = Regex.Match(message, @"Action\s(?<actionTime>\d+:\d+:\d+):\s+(?<actionName>.*)\.\s+(?<actionDescription>.*)"); ActionTime = match.Success ? match.Groups["actionTime"].Value : null; ActionName = match.Success ? match.Groups["actionName"].Value : null; ActionDescription = match.Success ? match.Groups["actionDescription"].Value : null; }
/// <summary> /// Processes the message. /// </summary> /// <param name="messageType">Type of the message.</param> /// <param name="messageRecord">The message record.</param> /// <param name="buttons">The buttons.</param> /// <param name="icon">The icon.</param> /// <param name="defaultButton">The default button.</param> /// <returns></returns> public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { switch (messageType) { case InstallMessage.ActionStart: { try { //messageRecord[0] - is reserved for FormatString value string message = null; bool simple = true; if (simple) { for (int i = messageRecord.FieldCount - 1; i > 0; i--) { message = messageRecord[i].ToString(); } } else { message = messageRecord.FormatString; if (message.IsNotEmpty()) { for (int i = 1; i < messageRecord.FieldCount; i++) { message = message.Replace("[" + i + "]", messageRecord[i].ToString()); } } else { message = messageRecord[messageRecord.FieldCount - 1].ToString(); } } if (message.IsNotEmpty()) currentAction.Text = message; } catch { } } break; } return MessageResult.OK; }
private MessageResult OnMessage(InstallMessage messageType, Deployment.WindowsInstaller.Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { switch (messageType) { case InstallMessage.FatalExit: case InstallMessage.Error: return(this.OnError(messageRecord)); case InstallMessage.Warning: return(this.OnWarning(messageRecord)); case InstallMessage.User: return(this.OnInformation(messageRecord)); default: return(MessageResult.None); } }
public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { try { WixSharp.CommonTasks.UACRevealer.Exit(); progressCounter.ProcessMessage(messageType, messageRecord); progressBar.Value = progressBar.Minimum + progressCounter.Progress * (progressBar.Maximum - progressBar.Minimum); //this.progressLabel.Content = "" + (int)Math.Round(100 * this.progressCounter.Progress) + "%"; var message = string.Format("{0}: {1}", messageType, messageRecord); switch (messageType) { case InstallMessage.Error: case InstallMessage.Warning: LogMessage(message); break; case InstallMessage.Info: #if DEBUG LogMessage(message); #else if (messageRecord.ToString().Contains("INSTALL. Return value 1.")) { this.messagesTextBox.Text = $"winprint {productVersion} successfully installed."; } #endif break; } if (canceled) { canceled = false; return(MessageResult.Cancel); } } catch (Exception ex) { LogMessage(ex.ToString()); LogMessage(ex.StackTrace); } return(MessageResult.OK); }
/// <summary> /// Message handler for callbacks from the installer. /// </summary> /// <param name="pvContext">Pointer to the application context.</param> /// <param name="iMessageType">A combination of a message box style, icon type, one default button and an installation /// message type.</param> /// <param name="message">The message text.</param> /// <returns>-1 if an internal error occurred or 0 if the message was not handled, otherwise a result corresponding /// to the button type in the message can be returned. /// </returns> /// <remarks> /// See https://docs.microsoft.com/en-us/windows/win32/api/msi/nc-msi-installui_handlerw /// </remarks> private DialogResult Handler(IntPtr pvContext, uint iMessageType, [MarshalAs(UnmanagedType.LPWStr)] string message) { // The message type value is composed from multiple different fields and includes // flags for the message type, along with button controls and icons. InstallMessage messageType = (InstallMessage)(iMessageType & 0xff000000); MessageBox messageBoxStyle = (MessageBox)(iMessageType & (uint)(MessageBox.TYPEMASK | MessageBox.ICONMASK | MessageBox.DEFMASK)); return(messageType switch { InstallMessage.ACTIONDATA => OnActionData(new ActionDataEventArgs(message, messageType, messageBoxStyle)), InstallMessage.ACTIONSTART => OnActionStart(new ActionStartEventArgs(message, messageType, messageBoxStyle)), InstallMessage.PROGRESS => OnProgress(new ProgressEventArgs(message, messageType, messageBoxStyle)), // The handler must return 0 and allow Windows Installer to handle the message. The external user // interface handler can monitor for this message, but it should not perform any action that affects the installation. InstallMessage.RESOLVESOURCE => DialogResult.None, _ => DialogResult.IDOK, });
/// <summary> /// Processes the message. /// </summary> /// <param name="messageType">Type of the message.</param> /// <param name="messageRecord">The message record.</param> /// <param name="buttons">The buttons.</param> /// <param name="icon">The icon.</param> /// <param name="defaultButton">The default button.</param> /// <returns></returns> public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { switch (messageType) { case InstallMessage.InstallStart: case InstallMessage.InstallEnd: { showWaitPromptTimer.Stop(); waitPrompt.Visible = false; } break; case InstallMessage.ActionStart: { try { //messageRecord[0] - is reserved for FormatString value string message = null; if (messageRecord.FieldCount >= 3) { message = messageRecord[2].ToString(); } if (message.IsNotEmpty()) { currentAction.Text = "{0} {1}".FormatWith(currentActionLabel.Text, message); } } catch { //Catch all, we don't want the installer to crash in an //attempt to process message. } } break; } return(MessageResult.OK); }
public MessageResult Message(InstallMessage messageType, Record record) { if (record == null) { throw new ArgumentNullException("record"); } int ret = RemotableNativeMethods.MsiProcessMessage((int)this.Handle, (uint)messageType, (int)record.Handle); if (ret < 0) { throw new InstallerException(); } else if (ret == (int)MessageResult.Cancel) { throw new InstallCanceledException(); } return((MessageResult)ret); }
public ProgressEventArgs(string message, InstallMessage messageType, MessageBox style) : base(message, messageType, style) { // Progress messages have up to 4 fields and are formatted as "<field>: <fieldValue>", e.g. // "1: 2 2: 25 3: 0 4: 1". Not all fields may be present and some fields have no meaning // depending on the message subtype (even though they are present). // // See https://docs.microsoft.com/en-us/windows/win32/msi/parsing-windows-installer-messages Match match = Regex.Match(message, @"(?<field>\d):\s+(?<value>\d+)"); List <int> fields = new(); while (match.Success) { fields.Add(Convert.ToInt32(match.Groups["value"].Value)); match = match.NextMatch(); } Fields = fields.ToArray(); }
public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { switch (messageType) { case InstallMessage.ActionStart: { try { var message = messageRecord[messageRecord.FieldCount - 1].ToString(); if (message.IsNotEmpty()) currentAction.Text = message; } catch { } } break; } return MessageResult.OK; }
private object ParseMessage(string Message, InstallMessage MessageType) { switch (MessageType) { case InstallMessage.ActionStart: ActionStartMessage message = new ActionStartMessage(); String[] items = Message.Trim().Split(new char[] { ' ' }); string dateRun = items[1]; string actionName = items[2]; if (dateRun.EndsWith(":")) { dateRun = dateRun.Trim().TrimEnd(new char[] { ':' }); } if (actionName.EndsWith(".")) { actionName = actionName.Trim().TrimEnd(new char[] { '.' }); } StringBuilder messageInfo = new StringBuilder(); if (items.Length > 3) { for (int i = 3; i < items.Length; i++) { messageInfo.Append(items[i] + " "); } } DateTime.TryParse(dateRun, out message.DateRun); message.Name = actionName.Trim(); message.Message = messageInfo.ToString().Trim(); return(message); break; } return(null); }
public static MessageResult ExternalUIRecordLogger( InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { if (messageRecord != null) { if (messageRecord.FormatString.Length == 0 && messageRecord.FieldCount > 0) { messageRecord.FormatString = "1: [1] 2: [2] 3: [3] 4: [4] 5: [5]"; } Console.WriteLine("{0}: {1}", messageType, messageRecord.ToString()); } else { Console.WriteLine("{0}: (null)", messageType); } return(MessageResult.None); }
public static MessageResult ExternalUIRecordLogger( InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { if (messageRecord != null) { if (messageRecord.FormatString.Length == 0 && messageRecord.FieldCount > 0) { messageRecord.FormatString = "1: [1] 2: [2] 3: [3] 4: [4] 5: [5]"; } Console.WriteLine("{0}: {1}", messageType, messageRecord.ToString()); } else { Console.WriteLine("{0}: (null)", messageType); } return MessageResult.None; }
/// <summary> /// Handles a message <see cref="Deployment.WindowsInstaller.Record"/> from Windows Installer. /// </summary> /// <param name="messageType">The <see cref="InstallMessage"/> type of the message.</param> /// <param name="messageRecord">The <see cref="Deployment.WindowsInstaller.Record"/> containing more information.</param> /// <param name="buttons">the <see cref="MessageButtons"/> to display.</param> /// <param name="icon">The <see cref="MessageIcon"/> to display.</param> /// <param name="defaultButton">The <see cref="MessageDefaultButton"/> to display.</param> /// <returns>The <see cref="MessageResult"/> that informs Windows Installer was action to take in response to the message.</returns> protected MessageResult OnMessage(InstallMessage messageType, Deployment.WindowsInstaller.Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { // Log all messages in debug mode. this.WriteMessage(messageType, messageRecord); switch (messageType) { case InstallMessage.Initialize: return(this.OnInitialize(messageRecord)); case InstallMessage.ActionStart: return(this.OnActionStart(messageRecord)); case InstallMessage.ActionData: return(this.OnActionData(messageRecord)); case InstallMessage.Error: case InstallMessage.FatalExit: case InstallMessage.OutOfDiskSpace: return(this.OnError(messageRecord)); case InstallMessage.Warning: return(this.OnWarning(messageRecord)); case InstallMessage.Info: case InstallMessage.User: return(this.OnVerbose(messageRecord)); case InstallMessage.Progress: return(this.OnProgress(messageRecord)); case InstallMessage.CommonData: return(this.OnCommonData(messageRecord)); } return(MessageResult.None); }
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()); }
/// <summary> /// Processes information and progress messages sent to the user interface. /// <para> This method directly mapped to the /// <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI.ProcessMessage" />.</para> /// </summary> /// <param name="messageType">Type of the message.</param> /// <param name="messageRecord">The message record.</param> /// <param name="buttons">The buttons.</param> /// <param name="icon">The icon.</param> /// <param name="defaultButton">The default button.</param> /// <returns></returns> public virtual MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { return MessageResult.OK; }
/// <summary> /// Processes information and progress messages sent to the user interface. /// </summary> /// <param name="messageType">Message type.</param> /// <param name="messageRecord">Record that contains message data.</param> /// <param name="buttons">Message box buttons.</param> /// <param name="icon">Message box icon.</param> /// <param name="defaultButton">Message box default button.</param> /// <returns>Result of processing the message.</returns> public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { // Synchronously send the message to the setup wizard window on its thread. object result = this.setupWizard.Dispatcher.Invoke(DispatcherPriority.Send, new Func<MessageResult>(delegate() { return this.setupWizard.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton); })); return (MessageResult) result; }
// Method to log to session private static void LogInstallMessage(Session session, InstallMessage messageType, string message) { using (Record record = new Record(0)) { // Square brackets and curly braces are evaluated upon logging the message so we escape them here record.FormatString = Regex.Replace(message, @"[\[\]{}]", @"[\$&]"); // session.Log and session.Message both make use of MsiProcessMessage, which cannot be used during a DoAction ControlEvent. // https://msdn.microsoft.com/en-us/library/aa368322(VS.85).aspx // // Fortunately, session.Message returns a code that can be used to determine whether the call actually logged a message. // Setting the value of a property also generates a message in the log file so we use that as a workaround. if (session.Message(messageType, record) == MessageResult.None) session["LOGMESSAGE"] = message; } }
/// <summary> /// Handler for external UI messages. /// </summary> /// <param name="messageType">The type of message.</param> /// <param name="messageRecord">The message details.</param> /// <param name="buttons">Buttons to show (unused).</param> /// <param name="icon">The icon to show (unused).</param> /// <param name="defaultButton">The default button (unused).</param> /// <returns>How the message was handled.</returns> public MessageResult UIRecordHandler( InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { #if False Console.WriteLine("Message type {0}: {1}", messageType.ToString(), this.session.FormatRecord(messageRecord)); #endif if (!this.session.IsClosed && 1 <= messageRecord.FieldCount) { switch (messageType) { case InstallMessage.ActionStart: // only try to interpret the messages if they're coming from WixRunImmediateUnitTests string action = messageRecord.GetString(1); this.runningTests = Constants.LuxCustomActionName == action; return MessageResult.OK; case InstallMessage.User: if (this.runningTests) { string message = messageRecord.ToString(); int id = messageRecord.GetInteger(1); if (Constants.TestIdMinimumSuccess <= id && Constants.TestIdMaximumSuccess >= id) { this.OnMessage(NitVerboses.TestPassed(message)); ++this.passes; } else if (Constants.TestIdMinimumFailure <= id && Constants.TestIdMaximumFailure >= id) { this.OnMessage(NitErrors.TestFailed(message)); ++this.failures; } } return MessageResult.OK; case InstallMessage.Error: case InstallMessage.FatalExit: this.OnMessage(NitErrors.PackageFailed(this.session.FormatRecord(messageRecord))); return MessageResult.Error; } } return MessageResult.OK; }
public static MessageResult ExternalUI(InstallMessage messageType, string message, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { return MessageResult.OK; }
private object ParseMessage(string Message, InstallMessage MessageType) { switch (MessageType) { case InstallMessage.ActionStart: ActionStartMessage message = new ActionStartMessage(); String[] items = Message.Trim().Split(new char[] { ' ' }); string dateRun = items[1]; string actionName = items[2]; if (dateRun.EndsWith(":")) { dateRun = dateRun.Trim().TrimEnd(new char[] { ':' }); } if (actionName.EndsWith(".")) { actionName = actionName.Trim().TrimEnd(new char[] { '.' }); } StringBuilder messageInfo = new StringBuilder(); if (items.Length > 3) { for (int i = 3; i < items.Length; i++) { messageInfo.Append(items[i] + " "); } } DateTime.TryParse(dateRun, out message.DateRun); message.Name = actionName.Trim(); message.Message = messageInfo.ToString().Trim(); return message; break; } return null; }
/// <summary> /// Processes information and progress messages sent to the user interface. /// </summary> /// <param name="messageType">Message type.</param> /// <param name="messageRecord">Record that contains message data.</param> /// <param name="buttons">Message buttons.</param> /// <param name="icon">Message box icon.</param> /// <param name="defaultButton">Message box default button.</param> /// <returns> /// Result of processing the message. /// </returns> /// <remarks> /// <p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/embeddeduihandler.asp">EmbeddedUIHandler</a></p> /// </remarks> public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { return shell.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton); }
/// <summary> /// Creates a new instance of the <see cref="ExecuteMsiMessageEventArgs"/> class. /// </summary> /// <param name="packageId">The identity of the package that yielded this message.</param> /// <param name="messageType">The type of this message.</param> /// <param name="displayParameters">Recommended display flags for this message.</param> /// <param name="message">The message.</param> /// <param name="data">The extended data for the message.</param> /// <param name="recommendation">Recommended result from engine.</param> public ExecuteMsiMessageEventArgs(string packageId, InstallMessage messageType, int displayParameters, string message, string[] data, int recommendation) : base(recommendation) { this.packageId = packageId; this.messageType = messageType; this.displayParameters = displayParameters; this.message = message; this.data = new ReadOnlyCollection<string>(data ?? new string[] { }); }
/// <summary> /// Processes information and progress messages sent to the user interface. /// <para> This method directly mapped to the /// <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI.ProcessMessage" />.</para> /// </summary> /// <param name="messageType">Type of the message.</param> /// <param name="messageRecord">The message record.</param> /// <param name="buttons">The buttons.</param> /// <param name="icon">The icon.</param> /// <param name="defaultButton">The default button.</param> /// <returns></returns> virtual public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { return(MessageResult.OK); }
public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { try { this.progressCounter.ProcessMessage(messageType, messageRecord); InUIThread(() => currentDialog.OnProgress((int)Math.Round(100 * this.progressCounter.Progress))); switch (messageType) { case InstallMessage.Progress: break; case InstallMessage.Error: case InstallMessage.Warning: case InstallMessage.Info: default: { if (messageType == InstallMessage.Error) ErrorDetected = true; if (messageType == InstallMessage.InstallEnd) { try { string lastValue = messageRecord[messageRecord.FieldCount].ToString(); //MSI record is actually 1-based ErrorDetected = (lastValue == "3"); UserInterrupted = (lastValue == "2"); } catch { }//nothing we can do really } this.LogMessage("{0}: {1}", messageType, messageRecord); break; } } if (this.canceled) { return MessageResult.Cancel; } } catch (Exception ex) { this.LogMessage(ex.ToString()); this.LogMessage(ex.StackTrace); } var result = MessageResult.OK; InUIThread(() => { result = currentDialog.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton); }); return result; }
private MessageResult OnMessage(InstallMessage messageType, Deployment.WindowsInstaller.Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { switch (messageType) { case InstallMessage.FatalExit: case InstallMessage.Error: return this.OnError(messageRecord); case InstallMessage.Warning: return this.OnWarning(messageRecord); case InstallMessage.User: return this.OnInformation(messageRecord); default: return MessageResult.None; } }
public ProgressIndicator ProcessMessage(InstallMessage messageType, Record messageRecord) { switch (messageType) { case InstallMessage.ActionStart: if (this._enableActionData) { this._enableActionData = false; } // get the ActionStart message if (messageRecord.FieldCount > 1) { var message = messageRecord.GetString(2); if (!string.IsNullOrEmpty(message)) { this._lastMessage = message; } } return(new ProgressIndicator(this.Progress, this._lastMessage)); case InstallMessage.ActionData: if (this._enableActionData) { if (this._moveForward) { this._completed += this._step; } else { this._completed -= this._step; } } this.UpdateProgress(); if (messageRecord.FieldCount > 0) { // template is prefixed with the action name in double delimited braces var actionData = Regex.Replace(messageRecord.GetString(0), "{{.*}}", string.Empty); if (!string.IsNullOrEmpty(actionData)) { // Get the Actiondata fields and replace each placeholder in the ActionStart template // with the ActionData field value. The try/catch is needed here as the template may contain // a placeholder for an ActionData field value that does not exist. actionData = Regex.Replace(actionData, @"\[(?<num>\d+)\]", m => { var number = int.Parse(m.Groups["num"].Value); try { var value = messageRecord[number]; return(value?.ToString() ?? string.Empty); } catch { return(string.Empty); } }); this._lastMessage = actionData; } } return(new ProgressIndicator(this.Progress, this._lastMessage)); case InstallMessage.Progress: return(this.ProcessProgressMessage(messageRecord)); default: return(new ProgressIndicator(this.Progress, _lastMessage)); } }
private void OnMessage(InstallMessage type, Deployment.WindowsInstaller.Record record = null) { this.OnMessage(type, record, MessageButtons.OKCancel, MessageIcon.None, MessageDefaultButton.Button1); }
/// <summary> /// Processes information and progress messages sent to the user interface. /// <para> This method directly mapped to the /// <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI.ProcessMessage" />.</para> /// </summary> /// <param name="messageType">Type of the message.</param> /// <param name="messageRecord">The message record.</param> /// <param name="buttons">The buttons.</param> /// <param name="icon">The icon.</param> /// <param name="defaultButton">The default button.</param> /// <returns></returns> public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) => model?.ProcessMessage(messageType, messageRecord, CurrentStatus.Text) ?? MessageResult.None;
Result IBootstrapperApplication.OnExecuteMsiMessage(string wzPackageId, InstallMessage mt, int uiFlags, string wzMessage, int cData, string[] rgwzData, int nRecommendation) { ExecuteMsiMessageEventArgs args = new ExecuteMsiMessageEventArgs(wzPackageId, mt, uiFlags, wzMessage, rgwzData, nRecommendation); this.OnExecuteMsiMessage(args); return args.Result; }
/// <summary> /// Processes information and progress messages sent to the user interface. /// <para> This method directly mapped to the /// <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI.ProcessMessage" />.</para> /// </summary> /// <param name="messageType">Type of the message.</param> /// <param name="messageRecord">The message record.</param> /// <param name="buttons">The buttons.</param> /// <param name="icon">The icon.</param> /// <param name="defaultButton">The default button.</param> /// <returns></returns> public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton) { try { UACRevealer.Exit(); this.progressCounter.ProcessMessage(messageType, messageRecord); if (CurrentDialog != null) { InUIThread(() => CurrentDialog.OnProgress((int)Math.Round(100 * this.progressCounter.Progress))); } switch (messageType) { case InstallMessage.Progress: break; case InstallMessage.Error: case InstallMessage.Warning: case InstallMessage.User: case InstallMessage.Info: default: { if (messageType.IsOneOf(InstallMessage.Error, InstallMessage.Warning, InstallMessage.User)) { MessageBox.Show( this.shellView, messageRecord.ToString(), "[ErrorDlg_Title]".LocalizeWith(MsiRuntime.Localize), (MessageBoxButtons)(int)buttons, (MessageBoxIcon)(int)icon, (MessageBoxDefaultButton)(int)defaultButton); } if (messageType == InstallMessage.Info) { if (messageRecord.ToString().Contains("User canceled installation")) //there is no other way { UserInterrupted = true; } } if (messageType == InstallMessage.Error) { ErrorDetected = true; Errors.Add(messageRecord.ToString()); } if (messageType == InstallMessage.InstallEnd) { try { string lastValue = messageRecord[messageRecord.FieldCount].ToString(); //MSI record is actually 1-based ErrorDetected = (lastValue == "3"); UserInterrupted = (lastValue == "2"); } catch { } //nothing we can do really finished = true; } this.LogMessage("{0}: {1}", messageType, messageRecord); break; } } if (this.canceled) { return(MessageResult.Cancel); } } catch (Exception ex) { this.LogMessage(ex.ToString()); this.LogMessage(ex.StackTrace); } var result = MessageResult.OK; InUIThread(() => { if (CurrentDialog != null) { result = CurrentDialog.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton); } }); return(result); }
internal MessageResult Message(InstallMessage messageType, Record record) { if (record == null) { throw new ArgumentNullException("record"); } int ret = RemotableNativeMethods.MsiProcessMessage((int) this.Handle, (uint) messageType, (int) record.Handle); if (ret < 0) { throw new InstallerException(); } else if (ret == (int) MessageResult.Cancel) { throw new InstallCanceledException(); } return (MessageResult) ret; }