C# Wix引导程序-更新/安装Visual FoxPro数据库的最佳方法
如前所述,我使用C# Wix引导程序-更新/安装Visual FoxPro数据库的最佳方法,c#,wix,bootstrapper,visual-foxpro,C#,Wix,Bootstrapper,Visual Foxpro,如前所述,我使用引导程序安装两个MSI软件包 在安装过程中,我想安装/更新一个visualfoxpro数据库(由自由表组成) 目前,我通过在bootstrapper应用程序的ApplyComplete-事件期间调用visualfoxpro-exe来实现这一点。要在bootstrapper应用程序和Visual FoxPro exe之间建立通信,我使用MSMQ: private void OnApplyComplete(object sender, ApplyCompleteEventArgs e
引导程序安装两个MSI软件包
在安装过程中,我想安装/更新一个visualfoxpro数据库
(由自由表组成)
目前,我通过在bootstrapper应用程序的ApplyComplete
-事件期间调用visualfoxpro-exe
来实现这一点。要在bootstrapper应用程序
和Visual FoxPro exe
之间建立通信,我使用MSMQ
:
private void OnApplyComplete(object sender, ApplyCompleteEventArgs e)
{
string updateFile = this.installationFolder + "\\updfile.exe";
if (!MessageQueue.Exists(NAMEDPVDATENBANKNACHRICHTENSCHLANGE))
{
this._msmq = MessageQueue.Create(UPDATEMSMQ);
}
else
{
this._msmq = new MessageQueue(UPDATEMSMQ);
}
this._msmq.SetPermissions("Everyone", MessageQueueAccessRights.FullControl);
this._msmq.Purge();
if (System.IO.File.Exists(updateFile))
{
this._dbUpdate = true;
ProcessStartInfo updateProcessInfo = new ProcessStartInfo();
updateProcessInfo.FileName = updateFile;
updateProcessInfo.Arguments = UPDATEMSMQ;
updateProcessInfo.UseShellExecute = true;
updateProcessInfo.WorkingDirectory = this.installationFolder;
updateProcessInfo.CreateNoWindow = true;
Process updateProcess = new Process();
updateProcess.StartInfo = updateProcessInfo;
updateProcess.EnableRaisingEvents = true;
updateProcess.Exited += new EventHandler(this.updateFinished);
updateProcess .Start();
while (this._dbUpdate)
{
Message msg = null;
try
{
nachricht = this._msmq.Receive(new TimeSpan(0, 0, 45));
}
catch (MessageQueueException msgEx)
{
if (nachrichtAusnahme.MessageQueueErrorCode != MessageQueueErrorCode.IOTimeout)
{
this.Engine.Log(LogLevel.Verbose, msgEx);
}
}
if (msg != null)
{
msg.Formatter = new ActiveXMessageFormatter();
this.Engine.Log(LogLevel.Verbose, "VfpUpdate - " + msg.Body.ToString());
}
}
}
this._msmq.Close();
MessageQueue.Delete(UPDATEMSMQ);
}
private void updateFinished(object sender, EventArgs e)
{
this._dbUpdate = false;
this.Engine.Log(LogLevel.Verbose, "Update finished");
}
这样,除非在更新visualfoxpro
数据库的过程中出现错误,否则它就像一个魔咒。应该可以回滚安装过程中所做的更改。对我来说,创建Visual FoxPro文件的备份并在发生错误时恢复这些文件是没有问题的。但是,对于实际的引导程序更改的文件,我应该如何做到这一点呢
使用CustomAction
我可以使用ActionResult.Failure
或ActionResult.Success
。但是使用CustomAction
我面临以下问题:
- 无法访问
应用程序.Current
(用于使用我在引导程序中使用的本地化字符串从自定义资源字典
读取值)
- 发送第一条消息后,MSMQ队列已断开(关闭?!)
- 在
主窗口中显示当前执行的任务李>
对于如何在bootstrapper应用程序中更新visualfoxpro
数据库,欢迎提供任何建议 在安装引导程序的环境中,我不知道这一点。当然,VFP数据库和表或VFP表(免费)只是从文件夹复制/移动的普通文件。您不需要使用exe来以编程方式创建它们
同时,将这些文件作为设置的一部分也不是一个好主意。如果由于版本更改而删除了一些文件,那么安装程序可能会开始抱怨
查看引导程序代码,我怀疑您正在安装文件夹或其子文件夹中创建那些空闲表,这将是一个真正的PITA。因为安装文件夹通常位于“Program Files(x86)”下,这是一个只读位置
您的引导程序代码是C#。您也可以使用C#来创建这些表。一种方法是使用VFPOLEDB和ExecScript()调用