本文整理汇总了C#中Request.Verbose方法的典型用法代码示例。如果您正苦于以下问题:C# Request.Verbose方法的具体用法?C# Request.Verbose怎么用?C# Request.Verbose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request.Verbose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallPackage
/// <summary>
/// Installs a given package.
/// </summary>
/// <param name="fastPackageReference">A provider supplied identifier that specifies an exact package</param>
/// <param name="request">
/// An object passed in from the CORE that contains functions that can be used to interact with
/// the CORE and HOST
/// </param>
public void InstallPackage(string fastPackageReference, Request request) {
if( request == null ) {
throw new ArgumentNullException("request");
}
if( string.IsNullOrWhiteSpace(fastPackageReference) ) {
throw new ArgumentNullException("fastPackageReference");
}
// Nice-to-have put a debug message in that tells what's going on.
request.Debug("Calling '{0}::InstallPackage' '{1}'", ProviderName, fastPackageReference);
string output;
int exitCode = request.ProviderServices.StartProcess(WusaExecutableLocation, fastPackageReference + " /quiet /norestart", true, out output, request);
if (exitCode == 0)
{
request.Verbose("Provider '{0}', Package '{1}': Installation succeeded", ProviderName, fastPackageReference);
}
else
{
request.Verbose("Provider '{0}', Package '{1}': Installation failed with Windows Update error code '{2}'.", ProviderName, fastPackageReference, String.Format(CultureInfo.CurrentCulture, "0x{0:X}", exitCode));
}
}
示例2: InstallPackage
/// <summary>
/// Installs a given package.
/// </summary>
/// <param name="fastPackageReference">A provider supplied identifier that specifies an exact package</param>
/// <param name="request">
/// An object passed in from the CORE that contains functions that can be used to interact with
/// the CORE and HOST
/// </param>
public void InstallPackage(string fastPackageReference, Request request) {
if( request == null ) {
throw new ArgumentNullException("request");
}
if( string.IsNullOrWhiteSpace(fastPackageReference) ) {
throw new ArgumentNullException("fastPackageReference");
}
string errorLogFolder = Path.GetTempPath() + Guid.NewGuid();
DirectoryInfo errorDir = Directory.CreateDirectory(errorLogFolder);
string errorLogPath = errorLogFolder + "\\msuLog.evtx";
// Nice-to-have put a debug message in that tells what's going on.
request.Debug("Calling '{0}::InstallPackage' '{1}'", ProviderName, fastPackageReference);
string output;
string args = "\"" + fastPackageReference + "\"" + " /quiet /norestart /log:" + "\"" + errorLogPath + "\"";
int exitCode = request.ProviderServices.StartProcess(WusaExecutableLocation, args, true, out output, request);
if (exitCode == 0)
{
request.Verbose("Provider '{0}', Package '{1}': Installation succeeded", ProviderName, fastPackageReference);
}
else if (exitCode == 3010) //Exit code: 3010 (0xBC2) ERROR_SUCCESS_REBOOT_REQUIRED
{
request.Warning(Resources.Messages.InstallRequiresReboot);
}
else
{
request.Error(Microsoft.PackageManagement.Internal.ErrorCategory.InvalidOperation, fastPackageReference, Resources.Messages.InstallFailed, fastPackageReference, String.Format(CultureInfo.CurrentCulture, "0x{0:X}", exitCode), errorLogPath);
}
try {
if (exitCode == 0 || exitCode == 3010)
{
if (errorDir.Exists)
errorDir.Delete(true);
}
} catch {
}
}