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


C# Session.HandleErrors方法代码示例

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


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

示例1: OnInstall

    public static ActionResult OnInstall(Session session)
    {
        //Note if your custom action requires non-GAC assembly then you need deploy it too.
        //You can do it by setting ManagedAction.RefAssemblies.
        //See "Wix# Samples\DTF (ManagedCA)\Different Scenarios\ExternalAssembly" sample for details.

        //System.Diagnostics.Debugger.Launch();

        session.Log("------------- " + session.Property("INSTALLDIR"));
        session.Log("------------- " + session.Property("CONFIG_FILE"));
        session.Log("------------- " + session.Property("APP_FILE"));

        return session.HandleErrors(() =>
        {
            string configFile = session.Property("INSTALLDIR") + "MyApp.exe.config";

            //alternative ways of extracting 'deferred' properties
            //configFile = session.Property("APP_FILE") + ".config";
            //configFile = session.Property("CONFIG_FILE");

            UpdateAsAppConfig(configFile);

            //alternative implementations for the config manipulations
            UpdateAsXml(configFile);
            UpdateAsText(configFile);
            UpdateWithWixSharp(configFile);

            MessageBox.Show(GetContext());
        });
    }
开发者ID:Eun,项目名称:WixSharp,代码行数:30,代码来源:setup.cs

示例2: UninstallSonarQubeService

        public static ActionResult UninstallSonarQubeService(Session session)
        {
            return session.HandleErrors(() =>
            {
                try
                {
                    SendProgressMessageToBA(session, "Uninstalling SonarQube", 1);

                    StopSonarQubeNTService(session);

                    UninstallSonarQubeNTService(session);
                }
                catch (Exception e)
                {
                    session.Log("[UninstallService] {0}", e.Message);
                }
            });
        }
开发者ID:SonarQubeCommunity,项目名称:sonarqube-windows-installer,代码行数:18,代码来源:Program.cs

示例3: SetupSonarQubeConfiguration

        public static ActionResult SetupSonarQubeConfiguration(Session session)
        {
            return session.HandleErrors(() =>
            {
                SendProgressMessageToBA(session, "Configuring SonarQube", 5);

                // The default temp directory can be only accessed by SYSTEM account. Hence we change
                // the temp directory to the one present in SonarQube installation folder.
                try
                {
                    System.IO.File.AppendAllText(Path.Combine(session.Property("INSTALLDIR"), BootstrapperConstants.SonarQubeProductName, @"conf\wrapper.conf"),

                                                 Environment.NewLine
                                                 + "wrapper.java.additional.2=-Djava.io.tmpdir=../../temp/"
                                                 + Environment.NewLine);
                }
                catch (Exception e)
                {
                    session.Log("[SetupSonarQubeConfiguration] {0}", e.Message);
                }

                try
                {
                    string setupType = session.Property("SETUPTYPE");

                    if (setupType.Equals(SetupType.Express, StringComparison.InvariantCultureIgnoreCase)
                        || setupType.Equals(SetupType.Custom, StringComparison.InvariantCultureIgnoreCase))
                    {
                        // Update SonarQube configuration file
                        session.Log("[SetupSonarQubeConfiguration] Updating sonar.properties for {0} setup.", setupType);
                        SonarConfigurationFileEditor.UpdateSonarPropertiesFileForSql(session);
                    }
                }
                catch (Exception e)
                {
                    session.Log("[SetupSonarQubeConfiguration] {0}", e.Message);
                }
            });
        }
开发者ID:SonarQubeCommunity,项目名称:sonarqube-windows-installer,代码行数:39,代码来源:Program.cs

示例4: SetSqlAuthInEnvironmentPath

        public static ActionResult SetSqlAuthInEnvironmentPath(Session session)
        {
            return session.HandleErrors(() =>
            {
                SendProgressMessageToBA(session, "Configuring SQL authentication dll", 4);

                string setupType = session.Property("SETUPTYPE");

                if (SetupType.Express.Equals(setupType, StringComparison.InvariantCultureIgnoreCase))
                {
                    SetPathToSqlAuthDllForTarget(session, EnvironmentVariableTarget.Machine);
                    SetPathToSqlAuthDllForTarget(session, EnvironmentVariableTarget.User);
                }
            });
        }
开发者ID:SonarQubeCommunity,项目名称:sonarqube-windows-installer,代码行数:15,代码来源:Program.cs

示例5: ExtractSqlExpress

        public static ActionResult ExtractSqlExpress(Session session)
        {
            return session.HandleErrors(() =>
            {
                SendProgressMessageToBA(session, "Extracting Sql Express setup", 2);

                string setupPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), @"SqlExpress.exe");
                string configPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), @"ConfigurationFile.ini");
                string sqlComponentName = "SqlExpress32";

                if (Environment.Is64BitOperatingSystem)
                {
                    sqlComponentName = "SqlExpress64";
                }

                session.SaveBinary(sqlComponentName, setupPath);
                session.SaveBinary("ConfigurationFile", configPath);
            });
        }
开发者ID:SonarQubeCommunity,项目名称:sonarqube-windows-installer,代码行数:19,代码来源:Program.cs

示例6: CleanSonarQubeInstallation

        public static ActionResult CleanSonarQubeInstallation(Session session)
        {
            return session.HandleErrors(() =>
            {
                SendProgressMessageToBA(session, "Cleaning SonarQube", 2);

                string extractPath = session.Property("INSTALLDIR");

                try
                {
                    Directory.Delete(extractPath, true);
                }
                catch (Exception e)
                {
                    session.Log("[CleanSonarQubeInstallation] {0}", e.Message);
                }
            });
        }
开发者ID:SonarQubeCommunity,项目名称:sonarqube-windows-installer,代码行数:18,代码来源:Program.cs

示例7: ChangeUserPrivilegesToLogOnAsService

        public static ActionResult ChangeUserPrivilegesToLogOnAsService(Session session)
        {
            return session.HandleErrors(() =>
            {
                string ntrightsPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), @"ntrights.exe");
                string setupType = session.Property("SETUPTYPE");
                string currentLoggedInUser = session.Property("CURRENTLOGGEDINUSER");

                if (SetupType.Express.Equals(setupType, StringComparison.InvariantCultureIgnoreCase))
                {
                    SendProgressMessageToBA(session, "Granting user log on as service permission", 1);

                    session.SaveBinary("NtRights", ntrightsPath);

                    try
                    {
                        Process ntRightsProcess = new Process();

                        ntRightsProcess.StartInfo.FileName = ntrightsPath;
                        ntRightsProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                        ntRightsProcess.StartInfo.CreateNoWindow = true;
                        ntRightsProcess.StartInfo.UseShellExecute = false;
                        ntRightsProcess.StartInfo.Arguments = "+r SeServiceLogonRight -u \"" + currentLoggedInUser + "\"";

                        ntRightsProcess.Start();

                        ntRightsProcess.WaitForExit(ProcessExitWaitTime);

                        // This needs to be done as this process can wait for standard input in case of failure.
                        // We nicely kill this process ourselves in this case to not stop the setup from progressing.
                        if (!ntRightsProcess.HasExited)
                        {
                            ntRightsProcess.Kill();
                        }

                        if (ntRightsProcess.ExitCode == 0)
                        {
                            // [TODO] Add strings for localization
                            SendMessageBoxMessageToBA(session, string.Format("The account {0} has been granted the Log On As A Service right.",
                                                                    currentLoggedInUser));
                        }
                        else
                        {
                            SendMessageBoxMessageToBA(session, string.Format("The account {0} couldn't be grated the Log On As A Service right.",
                                                                    currentLoggedInUser));
                        }
                    }
                    catch (Exception e)
                    {
                        session.Log("[ChangeUserPrivilegesToLogOnAsService] {0}", e.Message);
                    }
                    finally
                    {
                        // We can safely try to delete this file here as Delete() doesn't throw exception for
                        // file not found.
                        System.IO.File.Delete(ntrightsPath);
                    }
                }
            });
        }
开发者ID:SonarQubeCommunity,项目名称:sonarqube-windows-installer,代码行数:60,代码来源:Program.cs


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