当前位置: 首页>>代码示例>>C#>>正文


C# Request.Verbose方法代码示例

本文整理汇总了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));
            }
        }
开发者ID:vairam-svs,项目名称:oneget,代码行数:30,代码来源:MsuProvider.cs

示例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 {
            }
            
        }
开发者ID:40a,项目名称:PowerShell,代码行数:49,代码来源:MsuProvider.cs


注:本文中的Request.Verbose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。