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


C# WindowsInstaller.Session类代码示例

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


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


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