本文整理汇总了C#中Microsoft.Deployment.WindowsInstaller.Session.Message方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Message方法的具体用法?C# Session.Message怎么用?C# Session.Message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Deployment.WindowsInstaller.Session
的用法示例。
在下文中一共展示了Session.Message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveClickOnceInstalls
public static ActionResult RemoveClickOnceInstalls(Session Session)
{
string ShortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UnrealGameSync", "UnrealGameSync.appref-ms");
if(!File.Exists(ShortcutPath))
{
Session.Log("Couldn't find {0} - skipping uninstall", ShortcutPath);
return ActionResult.Success;
}
Record Record = new Record(1);
Record.FormatString = "The previous version of UnrealGameSync cannot be removed automatically.\n\nPlease uninstall from the following window.";
MessageResult Result = Session.Message(InstallMessage.User | (InstallMessage)MessageBoxButtons.OKCancel, Record);
if(Result == MessageResult.Cancel)
{
return ActionResult.UserExit;
}
Process NewProcess = Process.Start("rundll32.exe", "dfshim.dll,ShArpMaintain UnrealGameSync.application, Culture=neutral, PublicKeyToken=0000000000000000, processorArchitecture=msil");
NewProcess.WaitForExit();
if(File.Exists(ShortcutPath))
{
Record IgnoreRecord = new Record(1);
IgnoreRecord.FormatString = "UnrealSync is still installed. Install newer version anyway?";
if(Session.Message(InstallMessage.User | (InstallMessage)MessageBoxButtons.YesNo, IgnoreRecord) == MessageResult.No)
{
return ActionResult.UserExit;
}
}
return ActionResult.Success;
}
示例2: Install
public static ActionResult Install(Session session)
{
// fail very early if we can't find MPEI
string mpei = LookupMPEI();
if (mpei == null)
{
Log.Write("WifiRemote: MPEI not available");
return ActionResult.NotExecuted;
}
Log.Write("WifiRemote: Found MPEI at {0}", mpei);
// download version information
session.Message(InstallMessage.ActionStart, new Record("callAddProgressInfo", "Downloading WifiRemote update information...", ""));
Uri downloadUri;
InitializeVersionInformation(session, out downloadUri);
// fail early if we couldn't find the online version
if (onlineVersion == null)
{
Log.Write("WifiRemote: Online version unavailable, aborting installation...");
return ActionResult.Success;
}
// don't do anything if installed version is the newest one
if (installedVersion != null && installedVersion >= onlineVersion)
{
Log.Write("WifiRemote: Installed version is the last one, doing nothing...");
return ActionResult.Success;
}
// setup for installation
string mpeiPackagePath = Path.GetTempFileName();
session.Message(InstallMessage.ActionStart, new Record("callAddProgressInfo", "Downloading WifiRemote installer...", ""));
if (!DownloadWifiRemote(downloadUri, mpeiPackagePath))
{
Log.Write("WifiRemote: Failed to download version from internet, aborting installation...");
return ActionResult.Success;
}
Log.Write("WifiRemote: Got WifiRemote installer in {0}", mpeiPackagePath);
// execute
session.Message(InstallMessage.ActionStart, new Record("callAddProgressInfo", "Installing WifiRemote MediaPortal plugin with MPEI...", ""));
ProcessStartInfo param = new ProcessStartInfo();
param.FileName = mpei;
param.Arguments = mpeiPackagePath + " /S";
Log.Write("WifiRemote: Starting MPEI with arguments {0}", param.Arguments);
Process proc = new Process();
proc.StartInfo = param;
proc.Start();
proc.WaitForExit();
Log.Write("WifiRemote: MPEI finished with exit code {0}", proc.ExitCode);
// cleanup
File.Delete(mpeiPackagePath);
return ActionResult.Success;
}
示例3: CheckApplicationExists
public static ActionResult CheckApplicationExists(Session session) {
var deploymentManifest = new Uri(session["DeploymentManifest"]);
var downloadTask = (Task<GetManifestCompletedEventArgs>)null;
using(var host = new InPlaceHostingManager(deploymentManifest, false)) {
downloadTask = host.DownloadManifestAsync();
downloadTask.Wait();
if(downloadTask.IsCanceled) {
return ActionResult.UserExit;
}
else if(downloadTask.IsFaulted) {
session.Message(InstallMessage.Error, new Record { FormatString = downloadTask.Exception.ToString() });
return ActionResult.Failure;
}
var manifest = downloadTask.Result;
var result = manifest.ApplicationManifest.CheckApplicationExists();
if(result == ActionResult.SkipRemainingActions) {
session.Log("{0} is already installed.", manifest.ProductName);
}
return result;
}
}
示例4: IncrementProgressBar
public static MessageResult IncrementProgressBar(Session session, int progressPercentage)
{
var record = new Record(3);
record[1] = 2; // "ProgressReport" message
record[2] = progressPercentage; // ticks to increment
record[3] = 0; // ignore
return session.Message(InstallMessage.Progress, record);
}
示例5: ResetProgressBar
/*
* helper methods to control the progress bar
* kudos to a fellow developer http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Update-progress-bar-from-deferred-custom-action-tt4994990.html#a4997563
*/
public static MessageResult ResetProgressBar(Session session, int totalStatements)
{
var record = new Record(3);
record[1] = 0; // "Reset" message
record[2] = totalStatements; // total ticks
record[3] = 0; // forward motion
return session.Message(InstallMessage.Progress, record);
}
示例6: StatusMessage
/*
* helper method used to send the actiontext message to the MSI
* kudos to a fellow developer http://community.flexerasoftware.com/archive/index.php?t-181773.html
*/
internal static void StatusMessage(Session session, string status)
{
Record record = new Record(3);
record[1] = "callAddProgressInfo";
record[2] = status;
record[3] = "Incrementing tick [1] of [2]";
session.Message(InstallMessage.ActionStart, record);
Application.DoEvents();
}
示例7: DoAction
public ActionResult DoAction(Session session)
{
Record record = new Record(3);
for (int i = 1; i <= 100; i++)
{
record[1] = "ProgressMessageDemo";
record[2] = string.Format("Выполнение Demo-плагина (выполнено {0}%)", i);
record[3] = "";
session.Message(InstallMessage.ActionStart, record);
Thread.Sleep(20);
}
return ActionResult.Success;
}
示例8: DownloadApplication
public static ActionResult DownloadApplication(Session session) {
var deploymentManifest = new Uri(session["DeploymentManifest"]);
var cancellationTokenSource = new CancellationTokenSource();
var previousProgressPercentage = 0;
var downloadTask = (Task)null;
DisplayActionData(session, "Hello, World!");
ResetProgress(session);
using(var host = new InPlaceHostingManager(deploymentManifest, false)) {
downloadTask = host.DownloadManifestAsync();
downloadTask.Wait();
if(downloadTask.IsCanceled) {
return ActionResult.UserExit;
}
else if(downloadTask.IsFaulted) {
session.Message(InstallMessage.Error, new Record { FormatString = downloadTask.Exception.ToString() });
return ActionResult.Failure;
}
// Requirements
host.AssertApplicationRequirements(true);
// Download
downloadTask = host.DownloadApplicationAsync(progress => {
session.Log("Downloaded {0,10}", (((double)progress.ProgressPercentage) / 100d).ToString("P"));
IncrementProgress(session, progress.ProgressPercentage - previousProgressPercentage);
previousProgressPercentage = progress.ProgressPercentage;
});
downloadTask.Wait();
if(downloadTask.IsCanceled) {
return ActionResult.UserExit;
}
else if(downloadTask.IsFaulted) {
session.Message(InstallMessage.Error, new Record { FormatString = downloadTask.Exception.ToString() });
return ActionResult.Failure;
}
}
return ActionResult.Success;
}
示例9: ResetProgress
/// <summary>
/// Resets the progress bar to zero and sets a new value for total ticks..
/// </summary>
/// <param name="session">Windows Installer Session.</param>
/// <param name="totalTicks">Total number of ticks.</param>
/// <returns>Returns the message handler .</returns>
public static MessageResult ResetProgress(Session session, int totalTicks)
{
var record = new Record(4);
record[1] = "0"; // / Set reset progress bar and set the total number of ticks of the bar
record[2] = totalTicks.ToString(); // Total ticks
//Move progress bar
// 0: Moving forward from left to right . 1: Way back from right to left )
record[3] = "0";
// 0: Execution in progress, the UI calculates and displays the time remaining
// 1: Creating script execution . The UI displays a message while the installer finishes preparing the installation.
record[4] = "0";
return session.Message(InstallMessage.Progress, record);
}
示例10: NumberOfTicksPerActionData
/// <summary>
/// Set the amount to increase the progress bar for each message sent ActionData .
/// </summary>
/// <param name="session"> Windows Installer Session.</param>
/// <param name="ticks"> Number of ticks to be added to the progress bar.</param>
/// <param name="increaseForActionData">
/// Indicates whether the progress bar increases with each message sent by ActionData:
/// <para>False: : Indicates send the current message to the progress report.</para>
/// <para>
/// True: Indicates increase the progress bar in each ActionData in the number of ticks <paramref name="ticks" />
/// .
/// </para>
/// </param>
/// <returns>Returns message handler.</returns>
public static MessageResult NumberOfTicksPerActionData(Session session, int ticks, bool increaseForActionData)
{
var record = new Record(3);
record[1] = "1"; // Provides information related to the progress message sent by the current action
// Ticks ActionData increase in each message sent by the custom action , this value is ignored if field 3 is 0
record[2] = ticks.ToString();
if (increaseForActionData)
{
record[3] = "1";
// Set the progress bar increasing in each ActionData in the number of ticks in field 2 espeficicados
}
else
{
record[3] = "0"; // / Set the current message to send progress report
}
return session.Message(InstallMessage.Progress, record);
}
示例11: PatchFile
public static ActionResult PatchFile(Session session)
{
session.Log("Begin FilePatcher");
string patch_arguments = session["CustomActionData"];
// check the custom action arguments have been set
if ((patch_arguments == null) || (patch_arguments.Length == 0))
{
session.Log("FilePatcher: ERROR : CustomActionData not set");
return ActionResult.Failure;
}
// split the patch arguments string, the count should be a multiple of 3
string[] split_arguments = patch_arguments.Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries);
if((split_arguments.Length == 0) || ((split_arguments.Length % 3) > 0))
{
session.Log("Invalid number of arguments passed to the FilePatcher");
return ActionResult.Failure;
}
// populate the patch list
List<PatchInstance> files_to_patch = new List<PatchInstance>();
for(int i = 0; i < split_arguments.Length; i+=3)
{
PatchInstance patch = new PatchInstance();
patch.FileID = split_arguments[i];
patch.FilePath = split_arguments[i + 1];
patch.OutputPath = split_arguments[i + 2];
files_to_patch.Add(patch);
}
// patch each file in order
foreach(var patch_instance in files_to_patch)
{
// log the properties for debugging if necessary
session.Log("LOG: FILEPATCHERID : " + patch_instance.FileID);
session.Log("LOG: FILEPATCHERSRCFILE : " + patch_instance.FilePath);
session.Log("LOG: FILEPATCHEROUTPATH : " + patch_instance.OutputPath);
// patch the file
ApplyPatch(patch_instance.FileID, patch_instance.FilePath, patch_instance.OutputPath);
// show error messages
if (g_file_patcher.ErrorMessages.Count != 0)
{
Record record = new Record(g_file_patcher.ErrorMessages.Count);
// there should only ever be one error message since it returns immediately after
// but just in case, log and display all in the list
int index = 0;
foreach (var message in g_file_patcher.ErrorMessages)
{
session.Log("FilePatcher: {0}", message);
record.SetString(index, message);
index++;
}
// present an error message to the user
session.Message(InstallMessage.Error | (InstallMessage)(MessageIcon.Error) | (InstallMessage)MessageButtons.OK, record);
return ActionResult.Failure;
}
}
return ActionResult.Success;
}
示例12: SampleCustomAction2
public static ActionResult SampleCustomAction2(Session session)
{
using (Record msgRec = new Record(0))
{
msgRec[0] = "Hello from SampleCA2!";
session.Message(InstallMessage.Info, msgRec);
session.Message(InstallMessage.User, msgRec);
}
return ActionResult.UserExit;
}
示例13: PrereqCheck
public static ActionResult PrereqCheck(Session session)
{
var SecMsg = "You do not have the appropriate permissions to perform this operation. Make sure you are running the application from the local disk and you have local system administrator privileges.";
var NetMsg = "Microsoft .NET {0} is {1}.";
Action<string> ShowMsg = (string Text) =>
{
using(var Rec = new Record(0))
{
Rec.SetString(0, Text);
session.Message(InstallMessage.Error, Rec);
}
};
Action<Session, string, string> FxLog = (Session SesCtx, string Ver, string StrVer) =>
{
if (YesNo.Get(session[Ver]) == YesNo.Yes)
AddLog(SesCtx, string.Format(NetMsg, StrVer, "available"));
else
AddLog(SesCtx, string.Format(NetMsg, StrVer, "not available"));
};
if (!Adapter.CheckSecurity() || !Adapter.IsAdministrator())
{
ShowMsg(SecMsg);
return ActionResult.Failure;
}
string Msg;
var Ctx = Tool.GetSetupVars(session);
var ros = Adapter.CheckOS(Ctx, out Msg);
AddLog(session, Msg);
var riis = Adapter.CheckIIS(Ctx, out Msg);
AddLog(session, Msg);
var raspnet = Adapter.CheckASPNET(Ctx, out Msg);
AddLog(session, Msg);
session[Prop.REQ_OS] = ros == CheckStatuses.Success ? YesNo.Yes : YesNo.No;
session[Prop.REQ_IIS] = riis == CheckStatuses.Success ? YesNo.Yes : YesNo.No; ;
session[Prop.REQ_ASPNET] = raspnet == CheckStatuses.Success ? YesNo.Yes : YesNo.No; ;
FxLog(session, Prop.REQ_NETFRAMEWORK20, "2.0");
FxLog(session, Prop.REQ_NETFRAMEWORK35, "3.5");
FxLog(session, Prop.REQ_NETFRAMEWORK40FULL, "4.0");
return ActionResult.Success;
}
示例14: SampleCA1
public static ActionResult SampleCA1(Session session)
{
using (Record msgRec = new Record(0))
{
msgRec[0] = "Hello from SampleCA1!" +
"\r\nCLR version is v" + Environment.Version;
session.Message(InstallMessage.Info, msgRec);
session.Message(InstallMessage.User, msgRec);
}
session.Log("Testing summary info...");
SummaryInfo summInfo = session.Database.SummaryInfo;
session.Log("MSI PackageCode = {0}", summInfo.RevisionNumber);
session.Log("MSI ModifyDate = {0}", summInfo.LastSaveTime);
string testProp = session["SampleCATest"];
session.Log("Simple property test: [SampleCATest]={0}.", testProp);
session.Log("Testing subdirectory extraction...");
string testFilePath = "testsub\\SampleCAs.cs";
if (!File.Exists(testFilePath))
{
session.Log("Subdirectory extraction failed. File not found: " + testFilePath);
return ActionResult.Failure;
}
else
{
session.Log("Found file extracted in subdirectory.");
}
session.Log("Testing record stream extraction...");
string tempFile = null;
try
{
tempFile = Path.GetTempFileName();
using (View binView = session.Database.OpenView(
"SELECT `Binary`.`Data` FROM `Binary`, `CustomAction` " +
"WHERE `CustomAction`.`Target` = 'SampleCA1' AND " +
"`CustomAction`.`Source` = `Binary`.`Name`"))
{
binView.Execute();
using (Record binRec = binView.Fetch())
{
binRec.GetStream(1, tempFile);
}
}
session.Log("CA binary file size: {0}", new FileInfo(tempFile).Length);
string binFileVersion = Installer.GetFileVersion(tempFile);
session.Log("CA binary file version: {0}", binFileVersion);
}
finally
{
if (tempFile != null && File.Exists(tempFile))
{
File.Delete(tempFile);
}
}
session.Log("Testing record stream reading...");
using (View binView2 = session.Database.OpenView("SELECT `Data` FROM `Binary` WHERE `Name` = 'TestData'"))
{
binView2.Execute();
using (Record binRec2 = binView2.Fetch())
{
Stream stream = binRec2.GetStream("Data");
string testData = new StreamReader(stream, System.Text.Encoding.UTF8).ReadToEnd();
session.Log("Test data: " + testData);
}
}
session.Log("Listing components");
using (View compView = session.Database.OpenView(
"SELECT `Component` FROM `Component`"))
{
compView.Execute();
foreach (Record compRec in compView)
{
using (compRec)
{
session.Log("\t{0}", compRec["Component"]);
}
}
}
session.Log("Testing the ability to access an external MSI database...");
string tempDbFile = Path.GetTempFileName();
using (Database tempDb = new Database(tempDbFile, DatabaseOpenMode.CreateDirect))
{
// Just create an empty database.
}
using (Database tempDb2 = new Database(tempDbFile))
{
// See if we can open and query the database.
IList<string> tables = tempDb2.ExecuteStringQuery("SELECT `Name` FROM `_Tables`");
session.Log("Found " + tables.Count + " tables in the newly created database.");
}
File.Delete(tempDbFile);
return ActionResult.Success;
//.........这里部分代码省略.........
示例15: ResetProgress
private static void ResetProgress(Session session, int value = 100) {
var record = new Record(4);
record[1] = 0; // "Reset" message
record[2] = value - (value * 0.05); // total ticks;
record[3] = 0; // forward motion
record[4] = 0;
session.Message(InstallMessage.Progress, record);
record = new Record(4);
record[1] = 1;
record[2] = 1;
record[3] = 0;
session.Message(InstallMessage.Progress, record);
}