本文整理汇总了C#中Microsoft.Deployment.WindowsInstaller.Session.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Get方法的具体用法?C# Session.Get怎么用?C# Session.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Deployment.WindowsInstaller.Session
的用法示例。
在下文中一共展示了Session.Get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckServiceControlUrl
public static ActionResult CheckServiceControlUrl(Session session)
{
Log(session, "Begin custom action CheckServiceControlUrl");
var url = session.Get("INST_URI");
session.Set("VALID_CONTROL_URL", UrlIsValid(url,session) ? "TRUE" : "FALSE");
Log(session, "End custom action CheckServiceControlUrl");
return ActionResult.Success;
}
示例2: ReadForwardAuditMessagesFromConfig
public static ActionResult ReadForwardAuditMessagesFromConfig(Session session)
{
try
{
if (session.CustomActionData.Keys.Count != 1)
{
Log(session, "ReadForwardAuditMessagesFromConfig custom action requires a single property name to be passed in the CustomActionData. The result will passed to that property");
return ActionResult.Failure;
}
var outputProperty = session.CustomActionData.Keys.First();
const string ServiceControlRegKey = @"SOFTWARE\ParticularSoftware\ServiceControl";
var targetPath = session.Get("APPDIR");
var configPath = Path.Combine(targetPath, @"ServiceControl.exe.config");
var entryValue = "null";
// Try to get value from existing config
if (File.Exists(configPath))
{
var configDoc = XDocument.Load(configPath);
var entry = configDoc.XPathSelectElement(@"/configuration/appSettings/add[@key='ServiceControl/ForwardAuditMessages']");
entryValue = (entry != null) ? entry.Attribute("value").Value : "null";
}
// Fallback to getting value from registry.
if (!String.IsNullOrWhiteSpace(entryValue))
{
var key = Registry.LocalMachine.OpenSubKey(ServiceControlRegKey, RegistryKeyPermissionCheck.Default);
if (key != null)
{
entryValue = (string) key.GetValue("ForwardAuditMessages", "null");
}
}
entryValue = entryValue.ToLower();
switch (entryValue)
{
case "true" :
case "false" :
session.Set(outputProperty, entryValue);
break;
default:
session.Set(outputProperty,"null");
break;
}
return ActionResult.Success;
}
catch (Exception ex)
{
Log(session, "ReadForwardAuditMessagesFromConfig failed - {0}", ex);
return ActionResult.Failure;
}
}
示例3: ContactServiceControl
public static ActionResult ContactServiceControl(Session session)
{
Log(session, "Begin custom action ContactServiceControl");
// getting URL from property
var url = session.Get("INST_URI");
var connectionSuccessful = false;
try
{
if (url == null)
{
return ActionResult.Success;
}
var request = WebRequest.Create(url);
request.Timeout = 2000;
using (var response = request.GetResponse() as HttpWebResponse)
{
if (response == null)
{
throw new Exception("No response");
}
if (response.StatusCode != HttpStatusCode.OK)
{
throw new Exception(response.StatusDescription);
}
var version = response.Headers["X-Particular-Version"];
if (!string.IsNullOrEmpty(version))
{
session.Set("REPORTED_VERSION", version.Split(' ').First());
}
}
connectionSuccessful = true;
}
catch (Exception ex)
{
Log(session, ex.ToString());
}
session.Set("CONTACT_SERVICECONTROL", connectionSuccessful ? "TRUE" : "FALSE");
Log(session, "End custom action ContactServiceControl");
return ActionResult.Success;
}
示例4: CheckPulsePort
public static ActionResult CheckPulsePort(Session session)
{
try
{
Log(session, "Start custom action CheckPulsePort");
var port = session.Get("INST_PORT_PULSE");
UInt16 portNumber;
if (UInt16.TryParse(port, out portNumber))
{
// Port number 49152 and above should no be used http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
if (portNumber < 49152)
{
session.Set("VALID_PORT", "TRUE");
return ActionResult.Success;
}
}
session.Set("VALID_PORT", "FALSE");
return ActionResult.Success;
}
finally
{
Log(session, "End custom action CheckPulsePort");
}
}
示例5: SetUrlAcl
public static ActionResult SetUrlAcl(Session session)
{
Log(session, "Start custom action SetUrlAcl");
var port = session.Get("INST_PORT_PULSE");
var aclUrl = string.Format("http://+:{0}/", port);
RunNetsh(string.Format("http del urlacl url={0}", aclUrl));
// sddl=D:(A;;GX;;;WD) maps to the same as setting user=Everyone
// user=everyone fails if the OS language is not English, localised lookup of NTAccount fails as MSI is set to English US
var addUrlAclCommand = string.Format("http add urlacl url={0} sddl=D:(A;;GX;;;WD)", aclUrl);
var exitCode = RunNetsh(addUrlAclCommand);
if (exitCode != 0)
{
Log(session, string.Format("Error: 'netsh.exe {0}' returned {1}", addUrlAclCommand, exitCode));
Log(session, "End custom action SetUrlAcl");
return ActionResult.Failure;
}
Log(session, string.Format("Success :Executed: 'netsh.exe {0}'", addUrlAclCommand));
Log(session, "End custom action SetUrlAcl");
return ActionResult.Success;
}
示例6: ReadServiceControlUrlFromConfigJS
public static ActionResult ReadServiceControlUrlFromConfigJS(Session session)
{
try
{
Log(session, "Start custom action ReadServiceControlUrlFromConfigJS");
var targetPath = session.Get("APPDIR");
var configJsPath = Path.Combine(targetPath, @"app\config.js");
var uri = @"http://localhost:33333/api/";
if (File.Exists(configJsPath))
{
var pattern = new Regex(@"service_control_url:\s*'(?<sc_uri>.*)'", RegexOptions.IgnoreCase);
var matches = pattern.Match(File.ReadAllText(configJsPath));
if (matches.Success)
{
uri = matches.Groups["sc_uri"].Value;
Log(session, string.Format(@"Extracted {0} from existing config.js", uri));
}
else
{
Log(session, "No URI found - using default");
}
}
else
{
Log(session, string.Format("File not found {0}", configJsPath));
}
session.Set("INST_URI", uri);
return ActionResult.Success;
}
finally
{
Log(session, "End custom action ReadServiceControlUrlFromConfigJS");
}
}
示例7: ValidateForwardAuditMessages
public static ActionResult ValidateForwardAuditMessages(Session session)
{
var forwardAuditMessages = session.Get("FORWARDAUDITMESSAGES");
switch (forwardAuditMessages)
{
case "true":
case "false":
return ActionResult.Success;
}
Log(session, "A required settings has not been provided. ForwardAuditMessages must be explicitly set to true or false when installing via unattended mode. e.g. 'Particular.ServiceControl.exe /quiet ForwardAuditMessages=false'");
return ActionResult.Failure;
}