當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。