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


C# Request.Warning方法代码示例

本文整理汇总了C#中Request.Warning方法的典型用法代码示例。如果您正苦于以下问题:C# Request.Warning方法的具体用法?C# Request.Warning怎么用?C# Request.Warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Request的用法示例。


在下文中一共展示了Request.Warning方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UninstallPackage

        /// <summary>
        ///     Uninstalls a package
        /// </summary>
        /// <param name="fastPackageReference"></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 UninstallPackage(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}::UninstallPackage' '{1}'", ProviderName, fastPackageReference);

            try {
                Guid guid;
                if (!Guid.TryParse(fastPackageReference, out guid)) {
                    request.Error(ErrorCategory.InvalidArgument, fastPackageReference, Constants.Messages.UnableToResolvePackage, fastPackageReference);
                    return;
                }
                var product = ProductInstallation.GetProducts(fastPackageReference, null, UserContexts.All).FirstOrDefault();
                if (product == null) {
                    request.Error(ErrorCategory.InvalidArgument, fastPackageReference, Constants.Messages.UnableToResolvePackage, fastPackageReference);
                    return;
                }
                var productVersion = product.ProductVersion.ToString();
                var productName = product.ProductName;
                var summary = product["Summary"];

                Installer.SetInternalUI(InstallUIOptions.UacOnly | InstallUIOptions.Silent);
                _progressId = request.StartProgress(0, "Uninstalling MSI '{0}'", productName);
                var handler = CreateProgressHandler(request);

                Installer.SetExternalUI(handler, InstallLogModes.Progress | InstallLogModes.Info);
                Installer.InstallProduct(product.LocalPackage, "REMOVE=ALL REBOOT=REALLYSUPPRESS");
                Installer.SetInternalUI(InstallUIOptions.Default);

                Installer.SetExternalUI(handler, InstallLogModes.None);

                // YieldPackage(product,fastPackageReference, request);
                if (request.YieldSoftwareIdentity(fastPackageReference, productName, productVersion, "multipartnumeric", summary, "", fastPackageReference, "", "") != null) {
                    request.AddMetadata(fastPackageReference, "ProductCode", fastPackageReference);
                }

                request.Warning("Reboot is required to complete uninstallation.");
            } catch (Exception e) {
                e.Dump();
            }
            request.CompleteProgress(_progressId, true);
            _progressId = 0;
        }
开发者ID:vairam-svs,项目名称:oneget,代码行数:55,代码来源:MsiProvider.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");
            }
            // Nice-to-have put a debug message in that tells what's going on.
            request.Debug("Calling '{0}::InstallPackage' '{1}'", ProviderName, fastPackageReference);
            var file = fastPackageReference.CanonicalizePath(false);
            if (!file.FileExists()) {
                request.Error(Microsoft.PackageManagement.Internal.ErrorCategory.OpenError, fastPackageReference, Constants.Messages.UnableToResolvePackage, fastPackageReference);
                return;
            }
            string errorLogFolder = Path.GetTempPath() + Guid.NewGuid();
            DirectoryInfo errorDir = Directory.CreateDirectory(errorLogFolder);
            string errorLogPath = errorLogFolder + "\\msi.log";       
            try {
                var package = new InstallPackage(file, DatabaseOpenMode.ReadOnly);

                Installer.SetInternalUI(InstallUIOptions.UacOnly | InstallUIOptions.Silent);

                // todo 1501: support additional parameters!

                if (request.Sources != null && request.Sources.Any()) {
                    // The 'file' can be from a temp location downloaded by a chained provider. In that case, we can show 
                    // the orignal package source specified in the request.Sources.
                    _progressId = request.StartProgress(0, Resources.Messages.InstallingMSIPackage, request.Sources.FirstOrDefault());

                } else {
                    _progressId = request.StartProgress(0, Resources.Messages.InstallingMSIPackage, file);
                }

                var handler = CreateProgressHandler(request, Resources.Messages.Installing);

                Installer.SetExternalUI(handler, InstallLogModes.Progress | InstallLogModes.Info);
                Installer.EnableLog(InstallLogModes.Error, errorLogPath);
                Installer.InstallProduct(file, "REBOOT=REALLYSUPPRESS");
                Installer.SetInternalUI(InstallUIOptions.Default);

                Installer.SetExternalUI(handler, InstallLogModes.None);

                if (request.Sources != null && request.Sources.Any()) {

                    // The 'file' can be from a temp location downloaded by a chained provider. In that case, we can show 
                    // the orignal package source specified in the request.Sources.
                    YieldPackage(package, request.Sources.FirstOrDefault(), request);
                } else {
                    YieldPackage(package, file, request);
                }

                package.Close();

                if (Installer.RebootRequired) {
                    request.Warning(Resources.Messages.InstallRequireReboot);
                }

                if (errorDir.Exists)
                    errorDir.Delete(true);
            } catch (Exception e) {
                e.Dump();
                request.Error(Microsoft.PackageManagement.Internal.ErrorCategory.InvalidOperation, file, Constants.Messages.PackageFailedInstallErrorLog, file, errorLogPath);
            }

            request.CompleteProgress(_progressId, true);
        }
开发者ID:40a,项目名称:PowerShell,代码行数:74,代码来源:MsiProvider.cs

示例3: 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);
            var file = fastPackageReference.CanonicalizePath(false);
            if (!file.FileExists()) {
                request.Error(ErrorCategory.OpenError, fastPackageReference, Constants.Messages.UnableToResolvePackage, fastPackageReference);
                return;
            }
            try {
                var package = new InstallPackage(file, DatabaseOpenMode.ReadOnly);

                Installer.SetInternalUI(InstallUIOptions.UacOnly | InstallUIOptions.Silent);

                // todo 1501: support additional parameters!

                var handler = CreateProgressHandler(request);
                _progressId = request.StartProgress(0, "Installing MSI '{0}'", file);
                Installer.SetExternalUI(handler, InstallLogModes.Progress | InstallLogModes.Info);
                Installer.InstallProduct(file, "REBOOT=REALLYSUPPRESS");
                Installer.SetInternalUI(InstallUIOptions.Default);

                Installer.SetExternalUI(handler, InstallLogModes.None);

                YieldPackage(package, file, request);
                package.Close();

                if (Installer.RebootRequired) {
                    request.Warning("Reboot is required to complete Installation.");
                }
            } catch (Exception e) {
                e.Dump();
                request.Error(ErrorCategory.InvalidOperation, file, Constants.Messages.UnableToResolvePackage, file);
            }

            request.CompleteProgress(_progressId, true);
        }
开发者ID:vairam-svs,项目名称:oneget,代码行数:50,代码来源:MsiProvider.cs

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