本文整理汇总了C#中Microsoft.Deployment.WindowsInstaller.Record类的典型用法代码示例。如果您正苦于以下问题:C# Record类的具体用法?C# Record怎么用?C# Record使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Record类属于Microsoft.Deployment.WindowsInstaller命名空间,在下文中一共展示了Record类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileTableRecordAdapted
public void FileTableRecordAdapted()
{
var path = Path.Combine(this.TestContext.DeploymentDirectory, "Example.msi");
using (var db = new Database(path, DatabaseOpenMode.ReadOnly))
{
var query = db.Tables["File"].SqlSelectString;
using (var view = db.OpenView(query))
{
view.Execute();
var columns = ViewManager.GetColumns(view);
// Fetch and test a single record.
using (var record = view.Fetch())
{
Assert.IsNotNull(record, "No record was found.");
var copy = new Record(record, columns);
var adapter = new RecordPropertyAdapter();
var properties = adapter.GetProperties(copy);
Assert.IsNotNull(properties, "The properties were not adapted.");
Assert.AreEqual<int>(8, properties.Count, "The number of columns are incorrect.");
var property = adapter.GetProperty(copy, "FileName");
var type = typeof(string).FullName;
Assert.IsNotNull(property, "The FileName property was not adapted.");
Assert.IsTrue(adapter.IsGettable(property), "The FileName property is not gettable.");
Assert.AreEqual(type, adapter.GetPropertyTypeName(property), true, "The FileName property type is incorrect.");
Assert.AreEqual("product.wxs", RecordPropertyAdapter.GetPropertyValue(property, copy) as string, "The FileName propert value is incorrect.");
property = adapter.GetProperty(copy, "Attributes");
type = typeof(AttributeColumn).FullName;
Assert.IsNotNull(property, "The Attributes property was not adapted.");
Assert.AreEqual(type, adapter.GetPropertyTypeName(property), true, "The Attributes property type is incorrect.");
Assert.AreEqual<short>(512, Convert.ToInt16(RecordPropertyAdapter.GetPropertyValue(property, copy)), "The Attributes propert value is incorrect.");
property = adapter.GetProperty(copy, "Sequence");
type = typeof(int).FullName;
Assert.IsNotNull(property, "The Sequence property was not adapted.");
Assert.AreEqual("System.Int32", adapter.GetPropertyTypeName(property), true, "The Sequence property type is incorrect.");
Assert.AreEqual<int>(1, Convert.ToInt32(RecordPropertyAdapter.GetPropertyValue(property, copy)), "The Sequence propert value is incorrect.");
}
}
}
}
示例2: QueryAllRecords
/// <summary>
/// Query an MSI table for all records
/// </summary>
/// <param name="msi">The path to an MSI</param>
/// <param name="sql">An MSI query</param>
/// <returns>A list of records is returned</returns>
/// <remarks>Uses DTF</remarks>
public static List<DTF.Record> QueryAllRecords(string msi, string query)
{
List<DTF.Record> result = new List<DTF.Record>();
using (DTF.Database database = new DTF.Database(msi, DTF.DatabaseOpenMode.ReadOnly))
{
using (DTF.View view = database.OpenView(query,null))
{
view.Execute();
DTF.Record record = null;
while (null != (record = view.Fetch()))
{
// Copy record created by Fetch to record created manually to remove View reference
DTF.Record copyRecord = new DTF.Record(record.FieldCount);
for (int i = 0; i <= record.FieldCount; i++)
{
copyRecord[i] = record[i];
}
record.Close();
result.Add(copyRecord);
}
}
}
return result;
}
示例3: 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;
}
示例4: GetWebSites
public static ActionResult GetWebSites(Session session)
{
try
{
if (session == null) { throw new ArgumentNullException("session"); }
var comboBoxView = session.Database.OpenView("select * from ComboBox");
int order = 1;
string first = null;
foreach (var site in IisManager.GetIisWebSites())
{
var newComboRecord = new Record("WEBSITEVALUE", order++, site.ID, site.Name);
comboBoxView.Modify(ViewModifyMode.InsertTemporary, newComboRecord);
if (string.IsNullOrWhiteSpace(first))
first = site.ID;
}
if (first != null)
session["WEBSITEVALUE"] = first;
return ActionResult.Success;
}
catch (Exception ex)
{
if (session != null)
session.Log("Custom Action Exception: " + ex);
return ActionResult.Failure;
}
}
示例5: GetWebSites
public static ActionResult GetWebSites(Session session)
{
try
{
if (session == null) { throw new ArgumentNullException("session"); }
View comboBoxView = session.Database.OpenView("select * from ComboBox");
int order = 1;
foreach (IisWebSite site in IisManager.GetIisWebSites())
{
Record newComboRecord = new Record("WEBSITEVALUE", order++, site.ID, site.Name);
comboBoxView.Modify(ViewModifyMode.InsertTemporary, newComboRecord);
}
return ActionResult.Success;
}
catch (Exception ex)
{
if (session != null)
session.Log("Custom Action Exception: " + ex);
return ActionResult.Failure;
}
}
示例6: ProcessMessage
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;
}
}
示例7: GetAppPools
public static ActionResult GetAppPools(Session session)
{
try
{
if (session == null) { throw new ArgumentNullException("session"); }
var comboBoxView = session.Database.OpenView("select * from ComboBox");
int order = 1;
string first = null;
foreach (var appPool in IisManager.GetIisAppPools())
{
var newComboRecord = new Record("APPPOOLVALUE", order++, appPool);
comboBoxView.Modify(ViewModifyMode.InsertTemporary, newComboRecord);
if (string.IsNullOrWhiteSpace(first))
first = appPool;
}
if (first != null)
session["APPPOOLVALUE"] = first;
return ActionResult.Success;
}
catch (Exception e)
{
if (session != null)
session.Log("Custom Action Exception " + e);
}
return ActionResult.Failure;
}
示例8: CreateUnitTest
/// <summary>
/// Creates the appropriate unit test class and returns the base class.
/// </summary>
/// <param name="session">MSI session handle.</param>
/// <param name="record">Record from the LuxCustomAction MSI table.</param>
/// <param name="logger">Logger to record unit test output.</param>
/// <returns>A Lux unit test appropriate for the given record. Returns null on error.</returns>
public LuxUnitTest CreateUnitTest(Session session, Record record, LuxLogger logger)
{
string wixUnitTestId = record["WixUnitTest"] as string;
string customAction = record["CustomAction_"] as string;
string property = record["Property"] as string;
LuxOperator op = (LuxOperator)Convert.ToInt16(record["Operator"] as object);
string value = record["Value"] as string;
string expression = record["Expression"] as string;
string condition = record["Condition"] as string;
string valueSeparator = record["ValueSeparator"] as string;
string nameValueSeparator = record["NameValueSeparator"] as string;
string index = record["Index"] as string;
switch (this.DetermineTestType(expression, property, op, index, valueSeparator, nameValueSeparator))
{
case TestType.Expression:
return new LuxExpressionUnitTest(session, logger, wixUnitTestId, condition, expression);
case TestType.PropertyValue:
return new LuxPropertyValueUnitTest(session, logger, wixUnitTestId, condition, property, op, value);
case TestType.DelimitedList:
return new LuxDelimitedListUnitTest(session, logger, wixUnitTestId, condition, property, op, value, valueSeparator, index);
case TestType.DelimitedKeyValue:
return new LuxDelimitedKeyValueUnitTest(session, logger, wixUnitTestId, condition, property, op, value, nameValueSeparator, index);
default:
logger.Log(Constants.TestNotCreated, wixUnitTestId);
return null;
}
}
示例9: ProcessMessage
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;
}
示例10: GetAppPools
public static ActionResult GetAppPools(Session session)
{
try
{
if (session == null) { throw new ArgumentNullException("session"); }
// Check if running with admin rights and if not, log a message to
// let them know why it's failing.
if (false == HasAdminRights())
{
session.Log("GetAppPools: " +
"ATTEMPTING TO RUN WITHOUT ADMIN RIGHTS");
return ActionResult.Failure;
}
View comboBoxView = session.Database.OpenView("select * from ComboBox");
int order = 1;
session.Log("Trying to retutn the app pool list");
foreach (string appPool in IisManager.GetIisAppPools())
{
Record newComboRecord = new Record("APPPOOLVALUE", order++, appPool);
comboBoxView.Modify(ViewModifyMode.InsertTemporary, newComboRecord);
}
return ActionResult.Success;
}
catch (Exception e)
{
if (session != null)
session.Log("Custom Action Exception " + e);
}
return ActionResult.Failure;
}
示例11: 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);
}
示例12: 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);
}
示例13: PromptToCloseOutlook
public static ActionResult PromptToCloseOutlook(Session session)
{
session.Log("Detecting running instances of Microsoft Outlook...");
if (null != Process.GetProcessesByName("outlook").FirstOrDefault())
{
session.Log("Microsoft Outlook is running.");
var record = new Record
{
FormatString = "Please exit Microsoft Outlook before continuing\n" +
"or click Retry to close it automatically."
};
var result = session.Message(
InstallMessage.Error | (InstallMessage)MessageBoxIcon.Error |
(InstallMessage)MessageBoxButtons.AbortRetryIgnore, record);
if (result == MessageResult.Abort)
{
session.Log("User chose to abort the installer.");
return ActionResult.Failure;
}
if (result == MessageResult.Ignore)
{
session.Log("User chose to ignore.");
record.FormatString = "This application will not be available until you restart Outlook.";
session.Message(
InstallMessage.Error | (InstallMessage)MessageBoxIcon.Exclamation |
(InstallMessage)MessageBoxButtons.OK, record);
return ActionResult.Success;
}
//check to see if it's still running
var outlook = Process.GetProcessesByName("outlook").FirstOrDefault();
if (outlook == null)
{
session.Log("User closed Outlook");
return ActionResult.Success;
}
session.Log("User clicked Retry but Outlook is still running, attempting to kill it.");
try
{
outlook.Kill();
}
catch
{
session.Log("Failed to kill Outlook, raising alert and returning failure.");
record = new Record
{
FormatString = "Outlook is still running. Open the Task Manager, end any open Outlook processes, and try this install again."
};
session.Message(
InstallMessage.Error | (InstallMessage)MessageBoxIcon.Error, record);
return ActionResult.Failure;
}
}
return ActionResult.Success;
}
示例14: CreateComboBoxRecordItem
private static void CreateComboBoxRecordItem(View view, int numRows, string propertyName, string text, string value)
{
Record record = new Record(4);
record.SetString(1, propertyName);
record.SetInteger(2, numRows);
record.SetString(3, value);
record.SetString(4, text);
view.Modify(ViewModifyMode.InsertTemporary, record);
}
示例15: 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();
}