Example #1
0
        public bool InstallApplication(
            string appId,
            List<WpiUpdatedDeploymentParameter> updatedValues, 
            string languageId,
            EventHandler<InstallStatusEventArgs> installStatusUpdatedHandler,
            EventHandler<EventArgs> installCompleteHandler,
            out string log,
            out string failedMessage
            )
        {

            Product app = GetProduct(appId);
            Installer appInstaller = GetInstaller(languageId, app);
            WpiAppInstallLogger logger = new WpiAppInstallLogger();

            /*
            if (null == _installManager)
            {
                Debugger.Break();
            }
            */

            if (null != installStatusUpdatedHandler)
            {
                _installManager.InstallerStatusUpdated += installStatusUpdatedHandler;
            }
            _installManager.InstallerStatusUpdated += logger.HanlderInstallerStatusUpdated;

            if (null != installCompleteHandler)
            {
                _installManager.InstallCompleted += installCompleteHandler;
            }
            _installManager.InstallCompleted += logger.HandlerInstallCompleted;

            // set updated parameters
            foreach (WpiUpdatedDeploymentParameter parameter in updatedValues)
            {
                if (!string.IsNullOrEmpty(parameter.Value))
                {
                    appInstaller.MSDeployPackage.SetParameters[parameter.Name] = parameter.Value;
                }
            }

            DeploymentWellKnownTag dbTag = (DeploymentWellKnownTag)GetDbTag(updatedValues);

            // remove parameters with alien db tags
            foreach (DeploymentParameterWPI parameter in appInstaller.MSDeployPackage.DeploymentParameters)
            {
                if (IsAlienDbTaggedParameter(dbTag, parameter))
                {
                    appInstaller.MSDeployPackage.RemoveParameters.Add(parameter.Name);
                }
            }

            // skip alien directives
            RemoveUnusedProviders(appInstaller.MSDeployPackage, dbTag);

            _installCompleted = false;

            _installManager.StartApplicationInstallation();
            while (!_installCompleted)
            {
                Thread.Sleep(1000);
            }

            WriteLog("InstallApplication complete");

            //save logs
            SaveLogDirectory();

            _installCompleted = false;

            log = logger.GetLog();
            failedMessage = logger.FailedMessage;
            
            return !logger.IsFailed;
        }
Example #2
0
        public bool InstallApplication(
            string appId,
            List <WpiUpdatedDeploymentParameter> updatedValues,
            string languageId,
            EventHandler <InstallStatusEventArgs> installStatusUpdatedHandler,
            EventHandler <EventArgs> installCompleteHandler,
            out string log,
            out string failedMessage
            )
        {
            Product             app          = GetProduct(appId);
            Installer           appInstaller = GetInstaller(languageId, app);
            WpiAppInstallLogger logger       = new WpiAppInstallLogger();

            /*
             * if (null == _installManager)
             * {
             *  Debugger.Break();
             * }
             */

            if (null != installStatusUpdatedHandler)
            {
                _installManager.InstallerStatusUpdated += installStatusUpdatedHandler;
            }
            _installManager.InstallerStatusUpdated += logger.HanlderInstallerStatusUpdated;

            if (null != installCompleteHandler)
            {
                _installManager.InstallCompleted += installCompleteHandler;
            }
            _installManager.InstallCompleted += logger.HandlerInstallCompleted;

            // set updated parameters
            foreach (WpiUpdatedDeploymentParameter parameter in updatedValues)
            {
                if (!string.IsNullOrEmpty(parameter.Value))
                {
                    appInstaller.MSDeployPackage.SetParameters[parameter.Name] = parameter.Value;
                }
            }

            DeploymentWellKnownTag dbTag = (DeploymentWellKnownTag)GetDbTag(updatedValues);

            // remove parameters with alien db tags
            foreach (DeploymentParameterWPI parameter in appInstaller.MSDeployPackage.DeploymentParameters)
            {
                if (IsAlienDbTaggedParameter(dbTag, parameter))
                {
                    appInstaller.MSDeployPackage.RemoveParameters.Add(parameter.Name);
                }
            }

            // skip alien directives
            RemoveUnusedProviders(appInstaller.MSDeployPackage, dbTag);

            _installCompleted = false;

            _installManager.StartApplicationInstallation();
            while (!_installCompleted)
            {
                Thread.Sleep(1000);
            }

            WriteLog("InstallApplication complete");

            //save logs
            SaveLogDirectory();

            _installCompleted = false;

            log           = logger.GetLog();
            failedMessage = logger.FailedMessage;

            return(!logger.IsFailed);
        }