• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# WindowsInstaller.Session类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Session类属于Microsoft.Deployment.WindowsInstaller命名空间,在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetAllLocalMachineCerts

        public static ActionResult GetAllLocalMachineCerts(Session session)
        {
            LogWriter.WriteToLog("Started GetAllLocalMachineCerts method");

            try
            {
                var count = 0;
                foreach (var cert in GetAllLocalMachineCerts())
                {
                    if (string.IsNullOrEmpty(cert))
                        continue;

                    LogWriter.WriteToLog("Found certificate: {0}", cert);

                    WixUtil.AddToComboBox(session, "CERTIFICATENAME", count, cert, cert);

                    count++;
                }

                return ActionResult.Success;
            }
            catch (Exception ex)
            {
                LogWriter.WriteToLog("Error in GetAllLocalMachineCerts method. EXCEPTION: {0}", ex.ToString());
                return ActionResult.Failure;
            }
            finally
            {

                LogWriter.WriteToLog("Finished GetAllLocalMachineCerts method");
            }
        }
开发者ID:antonyn,项目名称:SlpsTest,代码行数:32,代码来源:ServerCertificate.cs


示例2: SetRightAction

        public static ActionResult SetRightAction(Session session)
        {
            try
            {
                string folder = Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "digiCamControl");
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                DirectoryInfo dInfo = new DirectoryInfo(folder);
                DirectorySecurity dSecurity = dInfo.GetAccessControl();
                SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
                dSecurity.AddAccessRule(new FileSystemAccessRule(everyone, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow));
                dInfo.SetAccessControl(dSecurity);
                string cachfolder = Path.Combine(
                                    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "digiCamControl", "Cache");
                if (Directory.Exists(cachfolder))
                {
                    Directory.Delete(cachfolder, true);
                }

            }
            catch (Exception ex)
            {
                session.Log("Set right error " + ex.Message);
            }
            return ActionResult.Success;
        }
开发者ID:Drikus,项目名称:digiCamControl,代码行数:29,代码来源:setup.cs


示例3: UninstallEventSource

        public static ActionResult UninstallEventSource(Session session)
        {
            try
            {
                LogWriter.WriteToLog("Started UninstallEventSource method");

                if (EventLog.SourceExists(_sourceName))
                {
                    LogWriter.WriteToLog("Event source exists, so lets delete it");
                    EventLog.DeleteEventSource(_sourceName);
                }
                else
                {
                    LogWriter.WriteToLog("Event source does not exist");
                }

                return ActionResult.Success;
            }
            catch (Exception ex)
            {
                LogWriter.WriteToLog("Error in UninstallEventSource method. EXCEPTION: {0}", ex.Message);
                return ActionResult.Failure;
            }
            finally
            {
                LogWriter.WriteToLog("Finished UninstallEventSource method");
            }
        }
开发者ID:antonyn,项目名称:SlpsTest,代码行数:28,代码来源:ServerEventSource.cs


示例4: OnScpa

        public static ActionResult OnScpa(Session Ctx)
        {
            PopUpDebugger();
            Func<Hashtable, string, string> GetParam = (s, x) => Utils.GetStringSetupParameter(s, x);
            Ctx.AttachToSetupLog();
            Log.WriteStart("OnScpa");

            try
            {
                var Hash = Ctx.CustomActionData.ToNonGenericDictionary() as Hashtable;
                var Scpa = new WebsitePanel.Setup.Actions.ConfigureStandaloneServerAction();
                Scpa.ServerSetup = new SetupVariables { };
                Scpa.EnterpriseServerSetup = new SetupVariables { };
                Scpa.PortalSetup = new SetupVariables { };
                Scpa.EnterpriseServerSetup.ServerAdminPassword = GetParam(Hash, "ServerAdminPassword");
                Scpa.EnterpriseServerSetup.PeerAdminPassword = Scpa.EnterpriseServerSetup.ServerAdminPassword;
                Scpa.PortalSetup.InstallerFolder = GetParam(Hash, "InstallerFolder");
                Scpa.PortalSetup.ComponentId = WiXSetup.GetComponentID(Scpa.PortalSetup);
                AppConfig.LoadConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = WiXSetup.GetFullConfigPath(Scpa.PortalSetup) });
                Scpa.PortalSetup.EnterpriseServerURL = GetParam(Hash, "EnterpriseServerUrl");
                Scpa.PortalSetup.WebSiteIP = GetParam(Hash, "PortalWebSiteIP");
                Scpa.ServerSetup.WebSiteIP = GetParam(Hash, "ServerWebSiteIP");
                Scpa.ServerSetup.WebSitePort = GetParam(Hash, "ServerWebSitePort");
                Scpa.ServerSetup.ServerPassword = GetParam(Hash, "ServerPassword");
                var Make = Scpa as WebsitePanel.Setup.Actions.IInstallAction;
                Make.Run(null);
            }
            catch (Exception ex)
            {
                Log.WriteError(ex.ToString());
            }
            Log.WriteEnd("OnScpa");
            return ActionResult.Success;
        }
开发者ID:JohnyBuchar,项目名称:Websitepanel,代码行数:34,代码来源:CustomAction.cs


示例5: GetAppPools

        public static ActionResult GetAppPools(Session session)
        {
            try
            {
                if (session == null) { throw new ArgumentNullException("session"); }

                var comboBoxView = session.Database.OpenView("select * from ComboBox");

                int order = 1;
                string first = null;

                foreach (var appPool in IisManager.GetIisAppPools())
                {
                    var newComboRecord = new Record("APPPOOLVALUE", order++, appPool);
                    comboBoxView.Modify(ViewModifyMode.InsertTemporary, newComboRecord);
                    if (string.IsNullOrWhiteSpace(first))
                        first = appPool;
                }

                if (first != null)
                    session["APPPOOLVALUE"] = first;
               
                return ActionResult.Success;
            }
            catch (Exception e)
            {
                if (session != null)
                    session.Log("Custom Action Exception " + e);
            }

            return ActionResult.Failure;
        }
开发者ID:egandro,项目名称:wixmvc6,代码行数:32,代码来源:CustomAction.cs


示例6: WixRunImmediateUnitTests

        public static ActionResult WixRunImmediateUnitTests(Session session)
        {
            LuxUnitTestFactory factory = new LuxUnitTestFactory();
            LuxLogger logger = new LuxLogger(session);
            string sql = String.Concat("SELECT `WixUnitTest`, `CustomAction_`, `Property`, `Operator`, `Value`, `Expression`, `Condition`, `ValueSeparator`, `NameValueSeparator`, `Index` FROM ", Constants.LuxTableName, " WHERE `Mutation` IS NULL");
            string mutation = session[Constants.LuxMutationRunningProperty];
            if (!String.IsNullOrEmpty(mutation))
            {
                sql = String.Concat(sql, " OR `Mutation` = '", mutation, "'");
            }

            using (View view = session.Database.OpenView(sql))
            {
                view.Execute();

                foreach (Record rec in view)
                {
                    using (rec)
                    {
                        LuxUnitTest unitTest = factory.CreateUnitTest(session, rec, logger);
                        if (null != unitTest)
                        {
                            if (unitTest.IsTestConditionMet())
                            {
                                unitTest.RunTest();
                            }
                            unitTest.LogResult();
                        }
                    }
                }
            }

            return ActionResult.UserExit;    
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:34,代码来源:CustomAction.cs


示例7: GetWebSites

        public static ActionResult GetWebSites(Session session)
        {
            try
            {
                if (session == null) { throw new ArgumentNullException("session"); }

                View comboBoxView = session.Database.OpenView("select * from ComboBox");

                int order = 1;

                foreach (IisWebSite site in IisManager.GetIisWebSites())
                {
                    Record newComboRecord = new Record("WEBSITEVALUE", order++, site.ID, site.Name);
                    comboBoxView.Modify(ViewModifyMode.InsertTemporary, newComboRecord);
                }

                return ActionResult.Success;
            }
            catch (Exception ex)
            {
                if (session != null)
                    session.Log("Custom Action Exception: " + ex);

                return ActionResult.Failure;
            }
        }
开发者ID:KonstantinDavidov,项目名称:mytestRep,代码行数:26,代码来源:CustomAction.cs


示例8: UpdateFlagPackagesFileForVS2012

    public static ActionResult UpdateFlagPackagesFileForVS2012(Session session)
    {
      string VSpath = System.IO.Path.Combine(session.CustomActionData["VS2012_PathProp"], @"Extensions\extensions.configurationchanged");
      System.IO.File.WriteAllText(VSpath, string.Empty);

      return ActionResult.Success;
    }
开发者ID:luguandao,项目名称:MySql.Data,代码行数:7,代码来源:CustomAction.cs


示例9: RemoveData

        public static ActionResult RemoveData(Session session)
        {
            Log.Session = session;
            Log.Write("Entered RemoveConfig");

            try
            {
                DataFiles.Remove("Authentication.xml");
                DataFiles.Remove("MediaAccess.xml");
                DataFiles.Remove("Services.xml");
                DataFiles.Remove("Streaming.xml");
                DataFiles.Remove("StreamingProfiles.xml");
                DataFiles.RemoveDirectory("Cache");
                DataFiles.Remove(@"Logs/Service.log");
                DataFiles.Remove(@"Logs/ServiceConfigurator.log");
                DataFiles.RemoveDirectoryIfEmpty("Logs");
                DataFiles.RemoveDirectoryIfEmpty();
            }
            catch (Exception ex)
            {
                Log.Write("RemoveConfig: Exception during uninstallation: {0}", ex.Message);
            }

            return ActionResult.Success;
        }
开发者ID:puenktchen,项目名称:MPExtended,代码行数:25,代码来源:CustomAction.cs


示例10: InstallMsmq

        public static ActionResult InstallMsmq(Session session)
        {
            session.Log("Installing/Starting MSMQ if necessary.");

            try
            {
                CaptureOut(() =>
                    {
                        if (MsmqSetup.StartMsmqIfNecessary(true))
                        {
                            session.Log("MSMQ installed and configured.");
                        }
                        else
                        {
                            session.Log("MSMQ already properly configured.");
                        }
                    }, session);

                return ActionResult.Success;
            }
            catch (Exception)
            {
                return ActionResult.Failure;
            }
        }
开发者ID:remogloor,项目名称:NServiceBus,代码行数:25,代码来源:CustomAction.cs


示例11: InstallPerformanceCounters

        public static ActionResult InstallPerformanceCounters(Session session)
        {
            session.Log("Installing NSB performance counters.");

            try
            {
                CaptureOut(() =>
                    {
                        if (PerformanceCounterSetup.SetupCounters(true))
                        {
                            session.Log("NSB performance counters installed.");
                        }
                        else
                        {
                            session.Log("NSB performance counters already installed.");
                        }
                    }, session);

                return ActionResult.Success;
            }
            catch (Exception)
            {
                return ActionResult.Failure;
            }
        }
开发者ID:remogloor,项目名称:NServiceBus,代码行数:25,代码来源:CustomAction.cs


示例12: SetUserBackupDirectorySystemFolder

        public static ActionResult SetUserBackupDirectorySystemFolder( Session session )
        {
            try {
                var path = session["ANDROIDBACKUPDIR"];
                if ( string.IsNullOrEmpty ( path ) ) {
                    session.Log ( "using default location for Backup path" );
                    path = Path.Combine ( Environment.GetEnvironmentVariable ( "USERPROFILE" ), "Android Backups" );
                }
                session.Log ( "Path: {0}", path );
                var dir = new DirectoryInfo ( path );
                if ( !dir.Exists ) {
                    try {
                        Directory.CreateDirectory ( path );
                    } catch ( Exception e ) {
                        session.Log ( e.ToString ( ) );
                        return ActionResult.Failure;
                    }
                }

                dir.Attributes = System.IO.FileAttributes.System | System.IO.FileAttributes.ReadOnly;

                return ActionResult.Success;
            } catch ( Exception ex ) {
                session.Log ( ex.ToString ( ) );
                return ActionResult.Failure;
            }
        }
开发者ID:camalot,项目名称:droidexplorer,代码行数:27,代码来源:CreateSystemAndroidBackupDirectory.cs


示例13: CopySoundFiles

        public static ActionResult CopySoundFiles(Session session)
        {
            session.Log("Begin CopySoundFiles");

            try
            {
                // Check that files were installed
                if (Directory.Exists(session["INSTALLLOCATION"] + @"\Sounds"))
                {
                    // Get source folder path
                    DirectoryInfo source = new DirectoryInfo(session["INSTALLLOCATION"] + @"\Sounds");

                    // Set destination folder to AGC folder in AppData
                    string destination = appdata + @"\AGC\Sounds";

                    // Create AGC folder in AppData if it doesn't exist yet
                    Directory.CreateDirectory(destination);

                    // Copy sound files to AGC folder in AppData
                    foreach (FileInfo file in source.GetFiles())
                    {
                        file.CopyTo(destination + @"\" + file.Name, true);
                    }
                }
                session.Log("End CopySoundFiles");
                return ActionResult.Success;
            }
            catch (Exception ex)
            {
                session.Log("CopySoundFiles custom action failed with exception. Exception message: " + ex.Message);
                return ActionResult.Failure;
            }
        }
开发者ID:Aishaj,项目名称:AGC.v3,代码行数:33,代码来源:CustomAction.cs


示例14: EnumerateIISWebSitesAndAppPools

        public static ActionResult EnumerateIISWebSitesAndAppPools(Session session)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            session.Log("EnumerateIISWebSitesAndAppPools: Begin");

            // Check if running with admin rights and if not, log a message to let them know why it's failing.
            if (!HasAdminRights())
            {
                session.Log("EnumerateIISWebSitesAndAppPools: ATTEMPTING TO RUN WITHOUT ADMIN RIGHTS");
                return ActionResult.Failure;
            }

            session.Log("EnumerateIISWebSitesAndAppPools: Getting the IIS 7 management object");
            ActionResult result;
            using (var iisManager = new ServerManager())
            {
                result = EnumSitesIntoComboBox(session, iisManager);
                if (result == ActionResult.Success)
                {
                    result = EnumAppPoolsIntoComboBox(session, iisManager);
                }
            }

            session.Log("EnumerateIISWebSitesAndAppPools: End");
            return result;
        }
开发者ID:aivascu,项目名称:WiX.WebAppInstaller,代码行数:30,代码来源:WebAppInstallCustomActions.cs


示例15: RemoveReadOnlyAttributeCA

        public static ActionResult RemoveReadOnlyAttributeCA(Session session)
        {
            // display message to allow attaching the debugger
            // MessageBox.Show("Please attach a debugger to rundll32.exe.", "Attach");

            session.Log("Begin RemoveReadOnlyAttributeCA");

            string desktopDir = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);
            string filePath   = desktopDir + "\\desktop.ini"; // full path of "desktop.ini" system file

            // Create the file if it exists.
            if (!File.Exists(filePath))
            {
                session.Log("File \"desktop.ini\" not found. Exit custom action with success.");
                return ActionResult.Success;
            }

            session.Log("File \"desktop.ini\" found at:" + filePath);

            System.IO.FileAttributes attributes = File.GetAttributes(filePath);

            if ((attributes & System.IO.FileAttributes.ReadOnly) == System.IO.FileAttributes.ReadOnly)
            {
                // Make the file RW
                attributes = RemoveAttribute(attributes, System.IO.FileAttributes.ReadOnly);
                File.SetAttributes(filePath, attributes);
                session.Log(" Read-only attribute removed for file\"desktop.ini\".");
            }

            session.Log("Exit custom action RemoveReadOnlyAttributeCA with success.");
            return ActionResult.Success;
        }
开发者ID:BogdanMitrache,项目名称:custom-actions,代码行数:32,代码来源:CustomAction.cs


示例16: UninstallDynamo07

        public static ActionResult UninstallDynamo07(Session session)
        {
            session.Log("Begin Dynamo uninstall.");

            try
            {
                // Dynamo 0.7.1 AppId
                // 6B5FA6CA-9D69-46CF-B517-1F90C64F7C0B
                string uninstallPath;
                if (!GetUninstallPathFromRegistry(session, out uninstallPath))
                {
                    return ActionResult.NotExecuted;
                }

                if (!string.IsNullOrEmpty(uninstallPath) && File.Exists(uninstallPath))
                {
                    Uninstall(session, uninstallPath);
                }
                else
                {
                    session.Log(string.Format("Dynamo uninstall path: {0}, could not be located.", uninstallPath));
                    return ActionResult.NotExecuted;
                }

                return ActionResult.Success;

            }
            catch (Exception ex)
            {
                session.Log("There was an error uninstalling Dynamo:");
                session.Log(ex.Message);
                return ActionResult.Failure;
            }
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:34,代码来源:CustomAction.cs


示例17: LuxUnitTest

 /// <summary>
 /// Initializes a new instance of the LuxUnitTest class. This constructor can only be called by subclasses.
 /// </summary>
 /// <param name="session">MSI session where the unit test will be running</param>
 /// <param name="logger">Logger to record test output</param>
 /// <param name="wixUnitTestId">Wix unit test id</param>
 /// <param name="condition">MSI condition to determine if test should run</param>
 protected LuxUnitTest(Session session, LuxLogger logger, string wixUnitTestId, string condition)
 {
     this.Session = session;
     this.Logger = logger;
     this.WixUnitTestId = wixUnitTestId;
     this.Condition = condition;
 }
开发者ID:Jeremiahf,项目名称:wix3,代码行数:14,代码来源:LuxUnitTest.cs


示例18: CreateUnitTest

        /// <summary>
        /// Creates the appropriate unit test class and returns the base class.
        /// </summary>
        /// <param name="session">MSI session handle.</param>
        /// <param name="record">Record from the LuxCustomAction MSI table.</param>
        /// <param name="logger">Logger to record unit test output.</param>
        /// <returns>A Lux unit test appropriate for the given record. Returns null on error.</returns>
        public LuxUnitTest CreateUnitTest(Session session, Record record, LuxLogger logger)
        {
            string wixUnitTestId = record["WixUnitTest"] as string;
            string customAction = record["CustomAction_"] as string;
            string property = record["Property"] as string;
            LuxOperator op = (LuxOperator)Convert.ToInt16(record["Operator"] as object);
            string value = record["Value"] as string;
            string expression = record["Expression"] as string;
            string condition = record["Condition"] as string;
            string valueSeparator = record["ValueSeparator"] as string;
            string nameValueSeparator = record["NameValueSeparator"] as string;
            string index = record["Index"] as string;

            switch (this.DetermineTestType(expression, property, op, index, valueSeparator, nameValueSeparator))
            {
                case TestType.Expression:
                    return new LuxExpressionUnitTest(session, logger, wixUnitTestId, condition, expression);
                case TestType.PropertyValue:
                    return new LuxPropertyValueUnitTest(session, logger, wixUnitTestId, condition, property, op, value);
                case TestType.DelimitedList:
                    return new LuxDelimitedListUnitTest(session, logger, wixUnitTestId, condition, property, op, value, valueSeparator, index);
                case TestType.DelimitedKeyValue:
                    return new LuxDelimitedKeyValueUnitTest(session, logger, wixUnitTestId, condition, property, op, value, nameValueSeparator, index);
                default:
                    logger.Log(Constants.TestNotCreated, wixUnitTestId);
                    return null;
            }
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:35,代码来源:LuxUnitTestFactory.cs


示例19: SetupEventLogging

        public static ActionResult SetupEventLogging(Session session)
        {
            try
            {
            #if DEBUG
                System.Windows.Forms.MessageBox.Show("Starting ASCOM UnRegistration");
            #endif
                session.Log("Setting up Optec.EventLogger");
                Trace.WriteLine("Setting up Optec.EventLogger");

                EventLogger.LogMessage("Installer Custom Action setting up EventLogger", TraceLevel.Error);

                Trace.WriteLine("Setting up Optec.EventLogger was successful");
                return ActionResult.Success;
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Setting up Optec.EventLogger failed: " + ex.Message);
            #if DEBUG
                ActionResult.Failure;           // FAIL when debugging only
            #else
                return ActionResult.Success;    // ALWAYS return success so that program can be uninstalled
            #endif
            }
        }
开发者ID:OptecInc,项目名称:TCF-Software--PC-,代码行数:25,代码来源:CustomAction.cs


示例20: CheckConnection

        /// <summary>
        /// CheckConnection method tries to open connection to the SQL server based on the ServerName and the Credentials provided
        /// </summary>
        /// <param name="connection"> ConnectionString to be used to connect to the SQL Server</param>
        /// <param name="session"> It opens the install database that contains installation tables and data</param>
        /// <returns>Status Value of custom action </returns>
        public static bool CheckConnection(SqlConnection connection, Session session)
        {
            try
            {
                if (connection == null)
                {
                    return false;
                }
                //Opens connection to the SQL Server
                connection.Open();

                var canOpen = Convert.ToBoolean(connection.State);

                connection.Close();
                session[StringConstants.Odbc_Error] = "0";
                return canOpen;
            }
            catch (SqlException ex)
            {
                session[StringConstants.Odbc_Error] = ex.Message;

                MessageBox.Show(StringConstants.UnsuccessfulConnection, StringConstants.MessageHeader);
                session[StringConstants.Odbc_Error] = "1";
                return false;
            }
        }
开发者ID:clone278,项目名称:adcms,代码行数:32,代码来源:CustomAction.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Plugins.FileModel类代码示例发布时间:2022-05-26
下一篇:
C# WindowsInstaller.Record类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap