/// <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;
            }
        }
Beispiel #2
0
        public static ActionResult InstallCert(Session session)
        {
            var cert = RSA.GetCACertificate();
            if (cert != null) return ActionResult.Success;

            var tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            Configuration.ServerAddress = Configuration.ServerAddress.Replace("https://", "http://");
            var keyPath = string.Format("{0}ca.cert.der", tempDirectory);
            var downloaded = Communication.DownloadFile("/management/other/ca.cert.der", keyPath);
            if (!downloaded)
            {
                DisplayMSIError(session, "Failed to download CA certificate");
                return ActionResult.Failure;
            }

            try
            {
                cert = new X509Certificate2(keyPath);
                var store = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
                store.Open(OpenFlags.ReadWrite);
                store.Add(cert);

                store.Close();
                return ActionResult.Success;
            }
            catch (Exception ex)
            {
                DisplayMSIError(session, "Unable to install CA certificate: " + ex.Message);
                return ActionResult.Failure;
            }
        }
Beispiel #3
0
        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;
            }
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        public static string[] ToSetupArguments(this Microsoft.Deployment.WindowsInstaller.Session session)
        {
            if (session == null)
            {
                return new string[] { }
            }
            ;
            if (CachedSetupArguments != null)
            {
                return(CachedSetupArguments);
            }
            lock (_lock)
            {
                if (CachedSetupArguments != null)
                {
                    return(CachedSetupArguments);
                }

                var allProperties = InstallationModelArgumentParser.AllArguments;
                var arguments     = new List <string>();
                foreach (var p in allProperties)
                {
                    string v;
                    if (session.TryGetValue(p, out v))
                    {
                        arguments.Add($"{p}={v}");
                    }
                }
                CachedSetupArguments = arguments.ToArray();
            }

            return(CachedSetupArguments);
        }
Beispiel #6
0
        /// <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;
            }
        }
Beispiel #7
0
        /// <summary>
        /// Send an action start message. This only works with deferred custom actions
        /// </summary>
        public static MessageResult SendActionStart(this Microsoft.Deployment.WindowsInstaller.Session session, int totalTicks, string actionName, string message, string actionDataTemplate = null)
        {
            // http://www.indigorose.com/webhelp/msifact/Program_Reference/LuaScript/Actions/MSI.ProcessMessage.htm
            // [1] action name (must match the name in the MSI Tables),
            // [2] description,
            // [3] template for InstallMessage.ActionData messages e.g. [1], [2],
            //     etc. relate to the index of values sent in a proceeding ActionData
            using (var record = new Record(actionName, message, actionDataTemplate ?? message))
            {
                session.Message(InstallMessage.ActionStart, record);
            }

            // http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Update-progress-bar-from-deferred-custom-action-td4994990.html
            // reset the progress bar.
            // [1] 0 = Reset progress bar,
            // [2] N = Total ticks in bar,
            // [3] 0 = Forward progress,
            // [4] 0 = Execution in progress i.e. Time remaining
            using (var record = new Record(0, totalTicks, 0, 0))
            {
                session.Message(InstallMessage.Progress, record);
            }

            // tell the installer to use Explicit Progress messages
            using (var record = new Record(1, 1, 0))
            {
                return(session.Message(InstallMessage.Progress, record));
            }
        }
Beispiel #8
0
        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;
        }
Beispiel #9
0
        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");
            }
        }
Beispiel #10
0
        public static ActionResult SaveSettings(Session session)
        {
            try
            {
                var config = GetSettings();
                if (GetValue("LIGHT", config).Equals("1"))
                    return ActionResult.Success;

                GenericSetup.SaveSettings(
                    GetValue("HTTPS", config),
                    GetValue("USETRAY", config),
                    GetValue("WEBADDRESS", config),
                    GetValue("WEBROOT", config),
                    "FOG",
                    GetValue("ROOTLOG", config),
                    GetValue("ProductVersion", config),
                     GetValue("INSTALLDIR", config));

                return ActionResult.Success;
            }
            catch (Exception ex)
            {
                DisplayMSIError(session, "Unable to create settings file: " + ex.Message);
            }

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

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

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

                int order = 1;
                session.Log("Trying to retutn the app pool list");
                foreach (string appPool in IisManager.GetIisAppPools())
                {
                    Record newComboRecord = new Record("APPPOOLVALUE", order++, appPool);
                    comboBoxView.Modify(ViewModifyMode.InsertTemporary, newComboRecord);
                }

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

            return ActionResult.Failure;
        }
Beispiel #12
0
        public static ActionResult GetWebSites(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 site in IisManager.GetIisWebSites())
                {
                    var newComboRecord = new Record("WEBSITEVALUE", order++, site.ID, site.Name);
                    comboBoxView.Modify(ViewModifyMode.InsertTemporary, newComboRecord);
                    if (string.IsNullOrWhiteSpace(first))
                        first = site.ID;
                }

                if (first != null)
                    session["WEBSITEVALUE"] = first;

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

                return ActionResult.Failure;
            }
        }
Beispiel #13
0
 /// <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;
 }
        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
            }
        }
Beispiel #15
0
        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;
            }
        }
Beispiel #16
0
        public static ActionResult InstallWifiRemote(Session session)
        {
            Log.Session = session;
            Log.Write("WifiRemote: Entered InstallWifiRemote");

            try
            {
                if (WifiRemote.Install(session))
                {
                    Log.Write("WifiRemote: Installed successfully");
                    return ActionResult.Success;
                }
                else
                {
                    Log.Write("WifiRemote: Failed to install");
                }
            }
            catch (Exception ex)
            {
                Log.Write("WifiRemote: Exception during installation: {0}", ex.Message);
            }

            Log.Write("WifiRemote: Leave InstallWifiRemote");
            return ActionResult.Failure;
        }
Beispiel #17
0
        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;
            }
        }
        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;
            }
        }
        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;
        }
Beispiel #20
0
        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");
            }
        }
Beispiel #21
0
        public static ActionResult CheckApplicationExists(Session session) {
            var deploymentManifest = new Uri(session["DeploymentManifest"]);
            var downloadTask = (Task<GetManifestCompletedEventArgs>)null;

            using(var host = new InPlaceHostingManager(deploymentManifest, false)) {
                downloadTask = host.DownloadManifestAsync();

                downloadTask.Wait();

                if(downloadTask.IsCanceled) {
                    return ActionResult.UserExit;
                }
                else if(downloadTask.IsFaulted) {
                    session.Message(InstallMessage.Error, new Record { FormatString = downloadTask.Exception.ToString() });
                    return ActionResult.Failure;
                }

                var manifest = downloadTask.Result;

                var result = manifest.ApplicationManifest.CheckApplicationExists();

                if(result == ActionResult.SkipRemainingActions) {
                    session.Log("{0} is already installed.", manifest.ProductName);
                }

                return result;
            }
        }
        public static ActionResult CACommit(Session session)
        {
            string tempfilePath = "";
            string customActionData = SafeToString(session.CustomActionData);

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

            try
            {
                if ((customActionData.Contains("TEMPFILESDIRECTORY")) && (session.CustomActionData["TEMPFILESDIRECTORY"] != null))
                {
                    tempfilePath = SafeToString(session.CustomActionData["TEMPFILESDIRECTORY"]);
                    if (Directory.Exists(tempfilePath))
                    {
                        Directory.Delete(tempfilePath, true);
                    }
                }
            }
            catch (Exception ex)
            {
                session.Log(string.Format("An error occurred during install. {0}", ex.Message));
                MessageBox.Show(string.Format("An error occurred during install. {0}", ex.Message));
                throw;
            }

            return ActionResult.Success;
        }
Beispiel #23
0
        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;
            }
        }
        public static CaParameters ExtractFromSession(Session session)
        {
            const string createHkcuCommandKey = "CREATE_HKCU_OPEN_FULL";
            const string createGuidKey = "ACTIVESETUP_GUID";
            const string productNameKey = "PRODUCTNAME";
            const string companyNameKey = "COMPANYNAME";
            const string versionKey = "VERSION";
            const string removeHkcuCommand = "REMOVE_HKCU_OPEN_FULL";

            string productName = ExtractAndCheck(session, productNameKey);
            string version = ExtractAndCheck(session, versionKey);

            string createCommand = ExtractAndCheck(session, createHkcuCommandKey);
            string createActiveSetupGuid = ExtractAndCheck(session, createGuidKey);

            string removeCommand = ExtractAndCheck(session, removeHkcuCommand);
            string companyName = ExtractAndCheck(session, companyNameKey);

            var caParams = new CaParameters()
                {
                    ActiveSetupGuid = createActiveSetupGuid,
                    CreateCommand = createCommand,
                    ProductName = productName,
                    Version = version,
                    RemoveCommand = removeCommand,
                    CompanyName = companyName
                };

            return caParams;
        }
Beispiel #25
0
    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;
    }
        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;
        }
Beispiel #27
0
        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;
        }
        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;    
        }
Beispiel #29
0
        public static ActionResult InstallEventSource(Session session)
        {
            try
            {

                LogWriter.WriteToLog("Started InstallEventSource method");

                if (!EventLog.SourceExists(_sourceName))
                {
                    LogWriter.WriteToLog("Event source does not exist so lets create it");

                    EventLog.CreateEventSource(
                        _sourceName,
                        _applcation);
                }
                else
                {
                    LogWriter.WriteToLog("Event source already exists");
                }

                return ActionResult.Success;
            }
            catch (Exception ex)
            {
                LogWriter.WriteToLog("Error in InstallEventSource method. EXCEPTION: {0}", ex.Message);
                return ActionResult.Failure;
            }
            finally
            {
                LogWriter.WriteToLog("Finished InstallEventSource method");
            }
        }
        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;
            }
        }
Beispiel #31
0
		public static ActionResult CloseApplications(Session session)
		{
			session.Log("Begin Kill terminate processes");
			Process[] processes = Process.GetProcesses();
			foreach (var process in processes)
			{
				try
				{
					if ((process.ProcessName == "FiresecService")
						|| (process.ProcessName == "FSAgentServer")
						|| (process.ProcessName == "FireMonitor")
						|| (process.ProcessName == "FireAdministrator")
						|| (process.ProcessName == "Revisor")
						|| (process.ProcessName == "FiresecOPCServer")
						|| (process.ProcessName == "FS_SER~1")
						|| (process.ProcessName == "fs_server")
						|| (process.ProcessName == "FiresecNTService")
						|| (process.ProcessName == "scktsrvr"))
					{
						process.Kill();
					}
				}
				catch(Exception e)
				{
					//MessageBox.Show(e.ToString());
				}
			}
			return ActionResult.Success;
		}
        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;
        }
Beispiel #33
0
 public static void Set(this Microsoft.Deployment.WindowsInstaller.Session session, string property, string value)
 {
     if (session.IsActive())
     {
         session[property] = value;
     }
     else
     {
         session.CustomActionData[property] = value;
     }
 }
Beispiel #34
0
 public static bool IsActive(this Microsoft.Deployment.WindowsInstaller.Session session)
 {
     try
     {
         var components = session.Components;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #35
0
        public static string[] GetFilesFromMSI(string msiPath)
        {
            List <string> properties = new List <string>();

            using (WindowsInstaller.Session session = WindowsInstaller.Installer.OpenPackage(msiPath, true))
            {
                properties.Add(session.GetProductProperty("ProductVersion"));
                properties.Add(session.GetProductProperty("ProductCode"));
                properties.Add(session.GetProductProperty("UpgradeCode"));
            }
            return(properties.ToArray());
        }
Beispiel #36
0
 public static ActionResult Handle(this Microsoft.Deployment.WindowsInstaller.Session session, Func <bool> action)
 {
     try
     {
         var executed = action();
         return(executed ? ActionResult.Success : ActionResult.NotExecuted);
     }
     catch (Exception e)
     {
         session.Log(e.ToString());
         e.ToEventLog("ElasticsearchMsiInstaller");
         return(ActionResult.Failure);
     }
 }
Beispiel #37
0
        /// <summary>
        /// Send a progress message. This only works with deferred custom actions
        /// </summary>
        public static MessageResult SendProgress(this Microsoft.Deployment.WindowsInstaller.Session session, int tickIncrement, params object[] actionDataTemplateParameters)
        {
            if (actionDataTemplateParameters.Any())
            {
                // [N] = These are values for the placeholders in the ActionStart template that precedes the ActionData.
                using (var record = new Record(actionDataTemplateParameters))
                {
                    session.Message(InstallMessage.ActionData, record);
                }
            }

            // [1] 2 = Increment the progress bar,
            // [2] N = Number of ticks to move the progress bar,
            // [3] 0 = Unused (but exists in sample)
            using (var record = new Record(2, tickIncrement, 0))
            {
                return(session.Message(InstallMessage.Progress, record));
            }
        }
Beispiel #38
0
 public static bool TryGetValue(this Microsoft.Deployment.WindowsInstaller.Session session, string property, out string value)
 {
     value = null;
     try
     {
         if (session.IsActive())
         {
             value = session[property];
         }
         else
         {
             value = session.CustomActionData.ContainsKey(property)
                                         ? session.CustomActionData[property]
                                         : string.Empty;
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #39
0
 public static ISession ToISession(this Microsoft.Deployment.WindowsInstaller.Session session) => new SessionWrapper(session);
 public SessionWrapper(Microsoft.Deployment.WindowsInstaller.Session session)
 {
     this._session = session;
 }