Esempio n. 1
0
        /// <summary>
        /// Calls Install_Init on the archive's setup.dll if it exists, otherwise does nothing
        /// </summary>
        /// <returns><b>true</b> if setup.dll doesn't exist, Install_Init returned CONTINUE or the current platform OS is not Windows CE, otherwise <b>false</b>.</returns>
        /// <remarks>Returning false from this method will abort the installation process</remarks>
        public virtual bool OnRunInstallerDllInit()
        {
            if (Environment.OSVersion.Platform != PlatformID.WinCE)
            {
                return(true);
            }

            // clean up from any previous install
            string dest = "\\Windows\\oncfinstaller.dll";
            //TODO:VER CON MAS TIEMPO
            // if (SI.File.Exists(dest)) SI.File.Delete(dest);

            // see if there is an installer DLL in the archive
            FileInfo fi = GetFileByExtensionIndex(999);

            if (fi == null)
            {
                return(true);
            }

            // copy the installer to a known location so we can call it
            // this is required because the CF won't let us dynamically declare a P/Invoke or get a managed function pointer from a handle
            string src = System.IO.Path.Combine(m_tempFolder, fi.Name);

            SI.File.Copy(src, dest);

            InstallResult state = NativeMethods.Install_Init(IntPtr.Zero, 1, 0, this.InstallDirectory);

            return(state == InstallResult.Continue);
        }
Esempio n. 2
0
        private static RvSofOperation InstallOperation(RvSofOperation windowsOperation)
        {
            InstallSupportedData data = windowsOperation.InstallSupportedDataList[0];
            //string uri = data.Uris; //TODO: This must be corrected for agent updater to work..
            string filepath = Path.Combine(AgentUpdateDirectory, _fileName);

            try
            {
                InstallResult installResult = ExeInstall(filepath, data.CliOptions);

                if (!installResult.Success)
                {
                    var results = new RVsofResult();
                    results.Success = false.ToString();
                    results.AppId   = data.Id;
                    results.Error   = String.Format("Failed while installing RV Agent update: {0}. {1}. Exit code: {2}.",
                                                    filepath, installResult.ExitCodeMessage, installResult.ExitCode);
                    windowsOperation.AddResult(results);
                    return(windowsOperation);
                }

                return(null);
            }
            catch (Exception e)
            {
                Logger.Log("Could not install RV Agent Update: ", LogLevel.Error);
                Logger.LogException(e);

                var result = new RVsofResult();
                result.AppId = data.Id;
                result.Error = String.Format("Failed to update RV Agent:  {0}.", e.Message);
                windowsOperation.AddResult(result);
                return(windowsOperation);
            }
        }
Esempio n. 3
0
        public string DebugInfo(InstallResult result)
        {
            var           debug = new Debug();
            List <string> infos = new List <string>();

            foreach (var kv in result.Touched)
            {
                infos.Add(string.Format("({0}) {1}", kv.Status, kv.Program.Node.Name.ToString(env.Parameters)));
            }
            debug.Info = infos;

            List <string> errors = new List <string>();

            foreach (var f in result.Flags)
            {
                errors.Add(
                    string.Format("{0} ({1}, {2}): {3}",
                                  f.Item1.Node.Name.ToString(env.Parameters),
                                  f.Item2.Span.StartLine,
                                  f.Item2.Span.StartCol,
                                  f.Item2.Message));
            }
            debug.Error = errors;

            string json = JsonConvert.SerializeObject(debug, Formatting.Indented);

            return(json);
        }
Esempio n. 4
0
        public async Task CanInstall_Directory()
        {
            MockInstallerFactory factory = new MockInstallerFactory();
            MockManagedTemplatePackageProvider provider = new MockManagedTemplatePackageProvider();
            string installPath = _environmentSettingsHelper.CreateTemporaryFolder();
            IEngineEnvironmentSettings engineEnvironmentSettings = _environmentSettingsHelper.CreateEnvironment(virtualize: true);

            FolderInstaller folderInstaller = new FolderInstaller(engineEnvironmentSettings, factory);

            InstallRequest request = new InstallRequest(installPath);

            Assert.True(await folderInstaller.CanInstallAsync(request, CancellationToken.None).ConfigureAwait(false));

            InstallResult result = await folderInstaller.InstallAsync(request, provider, CancellationToken.None).ConfigureAwait(false);

            Assert.True(result.Success);
            Assert.Equal(request, result.InstallRequest);
            Assert.Equal(InstallerErrorCode.Success, result.Error);
            result.ErrorMessage.Should().BeNullOrEmpty();

            var source = (FolderManagedTemplatePackage)result.TemplatePackage;

            source.MountPointUri.Should().Be(installPath);
            source.Version.Should().BeNullOrEmpty();
            source.DisplayName.Should().Be(installPath);
            source.Identifier.Should().Be(installPath);
            source.Installer.Should().Be(folderInstaller);
            source.Provider.Should().Be(provider);
        }
Esempio n. 5
0
        private async Task <InstallResult> InstallAsync(List <TemplatePackageData> packages, InstallRequest installRequest, IInstaller installer, CancellationToken cancellationToken)
        {
            _ = installRequest ?? throw new ArgumentNullException(nameof(installRequest));
            _ = installer ?? throw new ArgumentNullException(nameof(installer));

            (InstallerErrorCode result, string message) = await EnsureInstallPrerequisites(
                packages,
                installRequest.PackageIdentifier,
                installRequest.Version,
                installer,
                cancellationToken,
                forceUpdate : installRequest.Force).ConfigureAwait(false);

            if (result != InstallerErrorCode.Success)
            {
                return(InstallResult.CreateFailure(installRequest, result, message));
            }

            InstallResult installResult = await installer.InstallAsync(installRequest, this, cancellationToken).ConfigureAwait(false);

            if (!installResult.Success)
            {
                return(installResult);
            }
            if (installResult.TemplatePackage is null)
            {
                throw new InvalidOperationException($"{nameof(installResult.TemplatePackage)} cannot be null when {nameof(installResult.Success)} is 'true'");
            }

            lock (packages)
            {
                packages.Add(((ISerializableInstaller)installer).Serialize(installResult.TemplatePackage));
            }
            return(installResult);
        }
Esempio n. 6
0
        public async Task CanUninstall_Success()
        {
            MockInstallerFactory factory = new MockInstallerFactory();
            MockManagedTemplatePackageProvider provider = new MockManagedTemplatePackageProvider();
            string installPath = _environmentSettingsHelper.CreateTemporaryFolder();
            IEngineEnvironmentSettings engineEnvironmentSettings = _environmentSettingsHelper.CreateEnvironment(virtualize: true);

            FolderInstaller folderInstaller = new FolderInstaller(engineEnvironmentSettings, factory);

            InstallRequest request = new InstallRequest(installPath);

            InstallResult result = await folderInstaller.InstallAsync(request, provider, CancellationToken.None).ConfigureAwait(false);

            Assert.True(result.Success);
            Assert.Equal(request, result.InstallRequest);
            Assert.Equal(InstallerErrorCode.Success, result.Error);
            result.ErrorMessage.Should().BeNullOrEmpty();

            var source = (FolderManagedTemplatePackage)result.TemplatePackage;

            source.Should().NotBeNull();
            source.MountPointUri.Should().Be(installPath);
            Directory.Exists(installPath);

            UninstallResult uninstallResult = await folderInstaller.UninstallAsync(source, provider, CancellationToken.None).ConfigureAwait(false);

            Assert.True(uninstallResult.Success);
            Assert.Equal(source, uninstallResult.TemplatePackage);
            Assert.Equal(InstallerErrorCode.Success, result.Error);
            result.ErrorMessage.Should().BeNullOrEmpty();

            //directory is not removed
            Directory.Exists(installPath);
        }
        private void ShowInstallError(InstallResult installResult)
        {
            string msg = string.Format(
                "Failed to install {0}.\n\n{1}",
                tDebugLaunchOptions.AppId,
                ResourcesInstallMessage.ResourceManager.GetString(installResult.ToString()));

            VsPackage.ShowMessage(MessageDialogType.Error, null, msg);
        }
Esempio n. 8
0
        public async Task <IReadOnlyList <InstallResult> > InstallAsync(IEnumerable <InstallRequest> installRequests, CancellationToken cancellationToken)
        {
            _ = installRequests ?? throw new ArgumentNullException(nameof(installRequests));
            if (!installRequests.Any())
            {
                return(new List <InstallResult>());
            }

            //validate that install requests are different - install requests should have unique identifier for given installer
            HashSet <InstallRequest> uniqueInstallRequests = new HashSet <InstallRequest>(new InstallRequestEqualityComparer());

            foreach (InstallRequest installRequest in installRequests)
            {
                if (uniqueInstallRequests.Add(installRequest))
                {
                    continue;
                }
                throw new ArgumentException($"{nameof(installRequests)} has duplicate install requests", nameof(installRequest));
            }

            using var disposable = await _globalSettings.LockAsync(cancellationToken).ConfigureAwait(false);

            var packages = new List <TemplatePackageData>(await _globalSettings.GetInstalledTemplatePackagesAsync(cancellationToken).ConfigureAwait(false));
            var results  = await Task.WhenAll(installRequests.Select(async installRequest =>
            {
                var installersThatCanInstall = new List <IInstaller>();
                foreach (var install in _installersByName.Values)
                {
                    if (await install.CanInstallAsync(installRequest, cancellationToken).ConfigureAwait(false))
                    {
                        installersThatCanInstall.Add(install);
                    }
                }
                if (installersThatCanInstall.Count == 0)
                {
                    return(InstallResult.CreateFailure(
                               installRequest,
                               InstallerErrorCode.UnsupportedRequest,
                               string.Format(LocalizableStrings.GlobalSettingsTemplatePackageProvider_InstallResult_Error_PackageCannotBeInstalled, installRequest.PackageIdentifier)));
                }
                if (installersThatCanInstall.Count > 1)
                {
                    return(InstallResult.CreateFailure(
                               installRequest,
                               InstallerErrorCode.UnsupportedRequest,
                               string.Format(LocalizableStrings.GlobalSettingsTemplatePackageProvider_InstallResult_Error_MultipleInstallersCanBeUsed, installRequest.PackageIdentifier)));
                }

                IInstaller installer = installersThatCanInstall[0];
                return(await InstallAsync(packages, installRequest, installer, cancellationToken).ConfigureAwait(false));
            })).ConfigureAwait(false);

            await _globalSettings.SetInstalledTemplatePackagesAsync(packages, cancellationToken).ConfigureAwait(false);

            return(results);
        }
Esempio n. 9
0
        public Loader(Env env, AST <Program> p, InstallResult iresult, CancellationToken cancel)
        {
            Contract.Requires(env != null);
            Contract.Requires(p != null);

            this.cancel  = cancel;
            this.env     = env;
            this.iresult = iresult;
            initial      = p;
        }
Esempio n. 10
0
 /// <summary>
 /// Updates a package from the pipeline or from the local system.
 /// </summary>
 protected override void ProcessRecord()
 {
     base.ProcessRecord();
     this.GetPackageAndExecute(CompositeSearchBehavior.LocalCatalogs, (package, version) =>
     {
         InstallOptions options = this.GetInstallOptions(version);
         InstallResult result   = this.UpgradePackage(package, options);
         this.WriteObject(result);
     });
 }
Esempio n. 11
0
        private bool InstallTpk(EmulatorPlatformType platformType)
        {
            string packagePath = (platformType == EmulatorPlatformType.TV)
                ? ToolsPathInfo.XamlPreviewerTVPath
                : ToolsPathInfo.XamlPreviewerMobilePath;

            string        lastErrorMessage;
            InstallResult installResult = Launcher.Create().InstallTizenPackage(_selectedDevice, packagePath, null,
                                                                                VsPackage.dialogFactory, false, out lastErrorMessage);

            return(String.IsNullOrEmpty(lastErrorMessage));
        }
Esempio n. 12
0
        /// <summary>
        /// アラーム情報を作成しQueueStorageへ登録する
        /// </summary>
        /// <param name="installResult">適用結果</param>
        /// <param name="messageId">メッセージID</param>
        /// <param name="alarmDef">アラーム定義</param>
        /// <returns>成功した場合true、失敗した場合falseを返す</returns>
        public bool CreateAndEnqueueAlarmInfo(InstallResult installResult, string messageId, IEnumerable <DtAlarmDefInstallResultMonitor> alarmDef)
        {
            bool result = true;

            _logger.EnterJson("{0}", new { installResult, messageId, alarmDef });

            int index      = 1;
            int alarmCount = alarmDef.Count();

            foreach (var alarm in alarmDef)
            {
                string message = null;
                try
                {
                    string alarmDescription = alarm.AlarmDescription;
                    if (!string.IsNullOrEmpty(alarmDescription))
                    {
                        alarmDescription = string.Format(alarmDescription, installResult.UpdateStart, installResult.UpdateEnd, installResult.ErrorCode, installResult.ErrorDescription);
                    }

                    // Sq1.1.3: アラームキューを生成する
                    var alarmInfo = new AlarmInfo
                    {
                        SourceEquipmentUid = installResult.SourceEquipmentUid,
                        TypeCode           = installResult.TypeCode,
                        ErrorCode          = installResult.ErrorCode,
                        AlarmLevel         = alarm.AlarmLevel,
                        AlarmTitle         = alarm.AlarmTitle,
                        AlarmDescription   = alarmDescription,
                        AlarmDatetime      = _timeProvider.UtcNow.ToString(Utility.Const.AlarmQueueDateTimeFormat),
                        EventDatetime      = installResult.EventDt,
                        AlarmDefId         = $"{_settings.SystemName}_{_settings.SubSystemName}_{alarm.Sid.ToString()}",
                        MessageId          = alarmCount <= 1 ? messageId : $"{messageId}_{index}"
                    };
                    index++;

                    message = JsonConvert.SerializeObject(alarmInfo);

                    // Sq1.1.4: キューを登録する
                    _queueRepository.SendMessageToAlarmQueue(message);
                }
                catch (Exception e)
                {
                    // アラーム生成エラー or アラームキューにアラーム情報を送信できない(基本設計書 5.1.2.4 エラー処理)
                    _logger.Error(e, string.IsNullOrEmpty(message) ? nameof(Resources.UT_INM_INM_005) : nameof(Resources.UT_INM_INM_006), new object[] { messageId });
                    result = false;
                }
            }

            _logger.Leave();
            return(result);
        }
 protected void PrintReturnCode(InstallResult result, IComponent package, ComponentAction executeAction)
 {
     if (result.IsFailure())
     {
         var installResultDetails = GetInstallResultDetails(result, package, executeAction.ToString().ToLowerInvariant());
         LogFailure(package, executeAction, installResultDetails);
     }
     else
     {
         var text = "Result: " + result;
         Logger.Trace("Package executed successfully. {0}", text);
     }
 }
Esempio n. 14
0
        private static InstallResult ExeInstall(string exePath, string cliOptions)
        {
            var processInfo = new ProcessStartInfo();

            processInfo.FileName               = exePath;
            processInfo.Arguments              = cliOptions;
            processInfo.UseShellExecute        = false;
            processInfo.CreateNoWindow         = true;
            processInfo.RedirectStandardOutput = true;

            InstallResult installResult = RunProcess(processInfo);

            return(installResult);
        }
Esempio n. 15
0
        public Task <InstallResult> InstallAsync(InstallRequest installRequest, IManagedTemplatePackageProvider provider, CancellationToken cancellationToken)
        {
            _ = installRequest ?? throw new ArgumentNullException(nameof(installRequest));
            _ = provider ?? throw new ArgumentNullException(nameof(provider));

            if (Directory.Exists(installRequest.PackageIdentifier))
            {
                return(Task.FromResult(InstallResult.CreateSuccess(installRequest, new FolderManagedTemplatePackage(_settings, this, provider, installRequest.PackageIdentifier))));
            }
            else
            {
                return(Task.FromResult(InstallResult.CreateFailure(installRequest, InstallerErrorCode.PackageNotFound, $"The folder {installRequest.PackageIdentifier} doesn't exist")));
            }
        }
Esempio n. 16
0
        private static InstallResult RunProcess(ProcessStartInfo processInfo)
        {
            var result = new InstallResult();

            // The following WindowsUninstaller.WindowsExitCode used below might be Windows specific.
            // Third party apps might not use same code. Good luck!
            try
            {
                using (Process process = Process.Start(processInfo))
                {
                    process.WaitForExit();

                    result.ExitCode        = process.ExitCode;
                    result.ExitCodeMessage = new Win32Exception(process.ExitCode).Message;

                    switch (result.ExitCode)
                    {
                    case (int)WindowsUninstaller.WindowsExitCode.Restart:
                    case (int)WindowsUninstaller.WindowsExitCode.Reboot:
                        result.Restart = true;
                        result.Success = true;
                        break;

                    case (int)WindowsUninstaller.WindowsExitCode.Sucessful:
                        result.Success = true;
                        break;

                    default:
                        result.Success = false;
                        break;
                    }

                    StreamReader output = process.StandardOutput;
                    result.Output = output.ReadToEnd();
                }
            }
            catch (Exception e)
            {
                Logger.Log("Could not run {0}.", LogLevel.Error, processInfo.FileName);
                Logger.LogException(e);

                result.ExitCode        = -1;
                result.ExitCodeMessage = String.Format("Error trying to run {0}.", processInfo.FileName);
                result.Output          = String.Empty;
            }

            return(result);
        }
        private bool InstallTizenPackage(SDBDeviceInfo device, TizenDebugLaunchOptions tDebugLaunchOptions)
        {
            SDBLauncher.Create(VsPackage.outputPaneTizen).TerminateApplication(device, tDebugLaunchOptions.AppId);

            InstallResult installResult = Launcher.Create().InstallTizenPackage(device, tDebugLaunchOptions.TpkPath,
                                                                                null, VsPackage.dialogFactory, false, out lastErrorMessage);

            bool isInstallSucceeded = (installResult == InstallResult.OK);

            if (!isInstallSucceeded)
            {
                OutputDebugLaunchMessage(lastErrorMessage);
                ShowInstallError(installResult);
                TizenPackageTracer.CleanTpiFiles();
            }

            return(isInstallSucceeded);
        }
        protected string GetInstallResultDetails(InstallResult installResult, IComponent?component, string action)
        {
            var stringBuilder = new StringBuilder();

            if (stringBuilder.Length > 0)
            {
                stringBuilder.Append(", ");
            }
            stringBuilder.Append("Result: ");
            stringBuilder.Append(installResult);
            if (component != null)
            {
                var failureSignature = component.GetFailureSignature(action, installResult.ToString());
                stringBuilder.Append(", Signature: ");
                stringBuilder.Append(failureSignature);
            }
            return(stringBuilder.ToString());
        }
Esempio n. 19
0
        /// <summary>
        /// Executes Install_Exit in the archive's setup.dll if it exists, otherwise does nothing
        /// </summary>
        /// <returns><b>true</b> if setup.dll doesn't exist or if Install_Exit returned CONTINUE, otherwise <b>false</b>.</returns>
        /// <remarks>Returning false from this method will abort the installation process</remarks>
        public virtual bool OnRunInstallerDllExit()
        {
            if (Environment.OSVersion.Platform != PlatformID.WinCE)
            {
                return(true);
            }

            string dest = "\\Windows\\oncfinstaller.dll";

            if (!SI.File.Exists(dest))
            {
                return(true);
            }

            // TODO: get the success/fail counts
            InstallResult state = NativeMethods.Install_Exit(IntPtr.Zero, this.InstallDirectory, 0, m_failedFiles, 0, m_failedRegVals, 0);

            return(state == InstallResult.Continue);
        }
Esempio n. 20
0
        public Task <InstallResult> InstallAsync(InstallRequest installRequest, IManagedTemplatePackageProvider provider, CancellationToken cancellationToken)
        {
            _ = installRequest ?? throw new ArgumentNullException(nameof(installRequest));
            _ = provider ?? throw new ArgumentNullException(nameof(provider));

            if (_settings.Host.FileSystem.DirectoryExists(installRequest.PackageIdentifier))
            {
                //on installation we update last modification date to trigger package rebuild.
                //on folder package update the date may not change.
                return(Task.FromResult(InstallResult.CreateSuccess(installRequest, new FolderManagedTemplatePackage(_settings, this, provider, installRequest.PackageIdentifier, DateTime.UtcNow))));
            }
            else
            {
                return(Task.FromResult(InstallResult.CreateFailure(
                                           installRequest,
                                           InstallerErrorCode.PackageNotFound,
                                           string.Format(LocalizableStrings.FolderInstaller_InstallResult_Error_FolderDoesNotExist, installRequest.PackageIdentifier))));
            }
        }
Esempio n. 21
0
        public async Task CannotInstall_NotExist()
        {
            MockInstallerFactory factory = new MockInstallerFactory();
            MockManagedTemplatePackageProvider provider = new MockManagedTemplatePackageProvider();
            IEngineEnvironmentSettings         engineEnvironmentSettings = _environmentSettingsHelper.CreateEnvironment(virtualize: true);

            FolderInstaller folderInstaller = new FolderInstaller(engineEnvironmentSettings, factory);

            InstallRequest request = new InstallRequest("not found");

            Assert.False(await folderInstaller.CanInstallAsync(request, CancellationToken.None).ConfigureAwait(false));

            InstallResult result = await folderInstaller.InstallAsync(request, provider, CancellationToken.None).ConfigureAwait(false);

            Assert.False(result.Success);
            Assert.Equal(request, result.InstallRequest);
            Assert.Equal(InstallerErrorCode.PackageNotFound, result.Error);
            result.ErrorMessage.Should().NotBeNullOrEmpty();
            result.TemplatePackage.Should().BeNull();
        }
        public CompletionViewModel(Operation operation, InstallResult result)
        {
            if (result.IsSucceeded)
            {
                switch (operation)
                {
                    case Operation.Install:
                    case Operation.Upgrade:
                        this.Header = Resources.InstallCompleted;
                        this.Message = Resources.InstallCompleted_Message;
                        this.Button = Resources.Launch;
                        break;

                    case Operation.Uninstall:
                        this.Header = Resources.UninstallCompleted;
                        this.Message = Resources.UninstallCompleted_Message;
                        this.Button = Resources.Close;
                        break;
                }
            }
            else
            {
                switch (operation)
                {
                    case Operation.Install:
                    case Operation.Upgrade:
                        this.Header = Resources.InstallFailed;
                        this.Message = Resources.InstallFailed_Message;
                        this.Button = Resources.Close;
                        break;

                    case Operation.Uninstall:
                        this.Header = Resources.UninstallFailed;
                        this.Message = Resources.UninstallFailed_Message;
                        this.Button = Resources.Close;
                        break;
                }
            }
        }
Esempio n. 23
0
        public CompletionViewModel(Operation operation, InstallResult result)
        {
            if (result.IsSucceeded)
            {
                switch (operation)
                {
                case Operation.Install:
                case Operation.Upgrade:
                    this.Header  = Resources.InstallCompleted;
                    this.Message = Resources.InstallCompleted_Message;
                    this.Button  = Resources.Launch;
                    break;

                case Operation.Uninstall:
                    this.Header  = Resources.UninstallCompleted;
                    this.Message = Resources.UninstallCompleted_Message;
                    this.Button  = Resources.Close;
                    break;
                }
            }
            else
            {
                switch (operation)
                {
                case Operation.Install:
                case Operation.Upgrade:
                    this.Header  = Resources.InstallFailed;
                    this.Message = Resources.InstallFailed_Message;
                    this.Button  = Resources.Close;
                    break;

                case Operation.Uninstall:
                    this.Header  = Resources.UninstallFailed;
                    this.Message = Resources.UninstallFailed_Message;
                    this.Button  = Resources.Close;
                    break;
                }
            }
        }
Esempio n. 24
0
        public InstallResult InstallTizenPackage(SDBDeviceInfo device, string tpkPath,
                                                 IVsOutputWindowPane outputPane,
                                                 IVsThreadedWaitDialogFactory dlgFactory,
                                                 bool forceInstall,
                                                 out string lastErrorMessage)
        {
            this.outputPane = outputPane;
            this.outputPane?.Activate();

            if (!TargetHasTizenDotNET(device, out lastErrorMessage))
            {
                return(InstallResult.INSTALL_NOT_TRIED);
            }

            if (!NeedToInstall(device, tpkPath, forceInstall))
            {
                lastErrorMessage = string.Format("  Skip install ({0})", tpkPath);
                return(InstallResult.OK);
            }

            dlgFactory?.CreateInstance(out this.waitDialog);//waitDialog can be null and dialog can not be displayed by VS without some reasons.
            this.waitDialog?.StartWaitDialog(
                "Install Tizen Application",
                "Please wait while the new application is being installed...",
                "Preparing...",
                null,
                "Tizen application install in progress...",
                0, false, true);

            int userCancel;

            var           appUninstallCmd = new SDBAppCmd(device, SDBProtocol.uninstall, VsProjectHelper.GetInstance.GetPackageId(tpkPath));
            InstallResult result          = DoInstallTizenPackage(device, tpkPath, out lastErrorMessage);

            this.waitDialog?.EndWaitDialog(out userCancel);

            return(result);
        }
Esempio n. 25
0
        /// <summary>
        /// アラーム定義を取得する
        /// </summary>
        /// <param name="installResult">適用結果</param>
        /// <param name="messageId">メッセージID</param>
        /// <param name="models">DBから取得したパラメータ</param>
        /// <returns>成功した場合true、失敗した場合falseを返す</returns>
        public bool ReadAlarmDefinition(InstallResult installResult, string messageId, out IEnumerable <DtAlarmDefInstallResultMonitor> models)
        {
            models = null;

            try
            {
                _logger.EnterJson("{0}", new { installResult, messageId });

                // Sq1.1.1: インストール監視アラーム定義を取得
                models = _dtAlarmDefInstallResultMonitorRepository.ReadDtAlarmDefInstallResultMonitor(installResult);

                return(true);
            }
            catch (RmsException e)
            {
                // DBにアクセスできない(基本設計書 5.1.2.4 エラー処理)
                _logger.Error(e, nameof(Resources.UT_INM_INM_003), new object[] { messageId });
                return(false);
            }
            finally
            {
                _logger.LeaveJson("{0}", new { models });
            }
        }
 public static bool IsSuccess(this InstallResult result)
 {
     return(result == InstallResult.Success || result == InstallResult.SuccessRestartRequired);
 }
 public static bool IsFailure(this InstallResult result)
 {
     return(result == InstallResult.Failure || result == InstallResult.FailureException);
 }
Esempio n. 28
0
        public async Task <InstallResult> InstallAsync(InstallRequest installRequest, IManagedTemplatePackageProvider provider, CancellationToken cancellationToken)
        {
            _ = installRequest ?? throw new ArgumentNullException(nameof(installRequest));
            _ = provider ?? throw new ArgumentNullException(nameof(provider));

            if (!await CanInstallAsync(installRequest, cancellationToken).ConfigureAwait(false))
            {
                return(InstallResult.CreateFailure(
                           installRequest,
                           InstallerErrorCode.UnsupportedRequest,
                           string.Format(LocalizableStrings.NuGetInstaller_InstallResut_Error_PackageNotSupported, installRequest.DisplayName, Factory.Name)));
            }

            try
            {
                bool             isLocalPackage = IsLocalPackage(installRequest);
                NuGetPackageInfo nuGetPackageInfo;
                if (isLocalPackage)
                {
                    nuGetPackageInfo = InstallLocalPackage(installRequest);
                }
                else
                {
                    string[] additionalNuGetSources = Array.Empty <string>();
                    if (installRequest.Details != null && installRequest.Details.TryGetValue(InstallerConstants.NuGetSourcesKey, out string nugetSources))
                    {
                        additionalNuGetSources = nugetSources.Split(InstallerConstants.NuGetSourcesSeparator);
                    }

                    nuGetPackageInfo = await _packageDownloader.DownloadPackageAsync(
                        _installPath,
                        installRequest.PackageIdentifier,
                        installRequest.Version,
                        additionalNuGetSources,
                        force : installRequest.Force,
                        cancellationToken)
                                       .ConfigureAwait(false);
                }

                NuGetManagedTemplatePackage package = new NuGetManagedTemplatePackage(
                    _environmentSettings,
                    installer: this,
                    provider,
                    nuGetPackageInfo.FullPath,
                    nuGetPackageInfo.PackageIdentifier)
                {
                    Author         = nuGetPackageInfo.Author,
                    NuGetSource    = nuGetPackageInfo.NuGetSource,
                    Version        = nuGetPackageInfo.PackageVersion.ToString(),
                    IsLocalPackage = isLocalPackage
                };

                return(InstallResult.CreateSuccess(installRequest, package));
            }
            catch (DownloadException e)
            {
                string?packageLocation = e.SourcesList == null
                    ? e.PackageLocation
                    : string.Join(", ", e.SourcesList);

                return(InstallResult.CreateFailure(
                           installRequest,
                           InstallerErrorCode.DownloadFailed,
                           string.Format(LocalizableStrings.NuGetInstaller_InstallResut_Error_DownloadFailed, installRequest.DisplayName, packageLocation)));
            }
            catch (PackageNotFoundException e)
            {
                return(InstallResult.CreateFailure(
                           installRequest,
                           InstallerErrorCode.PackageNotFound,
                           string.Format(LocalizableStrings.NuGetInstaller_Error_FailedToReadPackage, e.PackageIdentifier, string.Join(", ", e.SourcesList))));
            }
            catch (InvalidNuGetSourceException e)
            {
                string message = e.SourcesList == null || !e.SourcesList.Any()
                    ? LocalizableStrings.NuGetInstaller_InstallResut_Error_InvalidSources_None
                    : string.Format(LocalizableStrings.NuGetInstaller_InstallResut_Error_InvalidSources, string.Join(", ", e.SourcesList));

                return(InstallResult.CreateFailure(
                           installRequest,
                           InstallerErrorCode.InvalidSource,
                           message));
            }
            catch (InvalidNuGetPackageException e)
            {
                return(InstallResult.CreateFailure(
                           installRequest,
                           InstallerErrorCode.InvalidPackage,
                           string.Format(LocalizableStrings.NuGetInstaller_InstallResut_Error_InvalidPackage, e.PackageLocation)));
            }
            catch (OperationCanceledException)
            {
                return(InstallResult.CreateFailure(
                           installRequest,
                           InstallerErrorCode.GenericError,
                           LocalizableStrings.NuGetInstaller_InstallResut_Error_OperationCancelled));
            }
            catch (Exception e)
            {
                _logger.LogDebug($"Installing {installRequest.DisplayName} failed. Details:{e.ToString()}");
                return(InstallResult.CreateFailure(
                           installRequest,
                           InstallerErrorCode.GenericError,
                           string.Format(LocalizableStrings.NuGetInstaller_InstallResut_Error_InstallGeneric, installRequest.DisplayName, e.Message)));
            }
        }
        public async Task <InstallResult> InstallAsync(InstallRequest installRequest, IManagedTemplatePackageProvider provider, CancellationToken cancellationToken)
        {
            _ = installRequest ?? throw new ArgumentNullException(nameof(installRequest));
            _ = provider ?? throw new ArgumentNullException(nameof(provider));

            if (!await CanInstallAsync(installRequest, cancellationToken).ConfigureAwait(false))
            {
                return(InstallResult.CreateFailure(installRequest, InstallerErrorCode.UnsupportedRequest, $"The install request {installRequest} cannot be processed by installer {Factory.Name}"));
            }

            try
            {
                bool             isLocalPackage = IsLocalPackage(installRequest);
                NuGetPackageInfo nuGetPackageInfo;
                if (isLocalPackage)
                {
                    nuGetPackageInfo = InstallLocalPackage(installRequest);
                }
                else
                {
                    string[] additionalNuGetSources = Array.Empty <string>();
                    if (installRequest.Details != null && installRequest.Details.TryGetValue(InstallerConstants.NuGetSourcesKey, out string nugetSources))
                    {
                        additionalNuGetSources = nugetSources.Split(InstallerConstants.NuGetSourcesSeparator);
                    }

                    nuGetPackageInfo = await _packageDownloader.DownloadPackageAsync(
                        _installPath,
                        installRequest.PackageIdentifier,
                        installRequest.Version,
                        additionalNuGetSources,
                        cancellationToken)
                                       .ConfigureAwait(false);
                }

                NuGetManagedTemplatePackage package = new NuGetManagedTemplatePackage(
                    _environmentSettings,
                    installer: this,
                    provider,
                    nuGetPackageInfo.FullPath,
                    nuGetPackageInfo.PackageIdentifier)
                {
                    Author       = nuGetPackageInfo.Author,
                    NuGetSource  = nuGetPackageInfo.NuGetSource,
                    Version      = nuGetPackageInfo.PackageVersion.ToString(),
                    LocalPackage = isLocalPackage
                };

                return(InstallResult.CreateSuccess(installRequest, package));
            }
            catch (DownloadException e)
            {
                return(InstallResult.CreateFailure(installRequest, InstallerErrorCode.DownloadFailed, e.Message));
            }
            catch (PackageNotFoundException e)
            {
                return(InstallResult.CreateFailure(installRequest, InstallerErrorCode.PackageNotFound, e.Message));
            }
            catch (InvalidNuGetSourceException e)
            {
                return(InstallResult.CreateFailure(installRequest, InstallerErrorCode.InvalidSource, e.Message));
            }
            catch (InvalidNuGetPackageException e)
            {
                return(InstallResult.CreateFailure(installRequest, InstallerErrorCode.InvalidPackage, e.Message));
            }
            catch (Exception e)
            {
                _environmentSettings.Host.LogDiagnosticMessage($"Installing {installRequest.DisplayName} failed.", DebugLogCategory);
                _environmentSettings.Host.LogDiagnosticMessage($"Details:{e.ToString()}", DebugLogCategory);
                return(InstallResult.CreateFailure(installRequest, InstallerErrorCode.GenericError, $"Failed to install the package {installRequest.DisplayName}, reason: {e.Message}"));
            }
        }
Esempio n. 30
0
 internal Compiler(Env env, InstallResult result, CancellationToken cancel)
 {
     Env         = env;
     Result      = result;
     this.cancel = cancel;
 }
Esempio n. 31
0
 private void updaterWorker_finished(InstallResult r)
 {
     switch (r)
     {
         case InstallResult.Success:
             TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress);
             changeLocalVersion(updaterWorker.latestRevision.ToString());
             displayStatus("Revision " + '"' + updaterWorker.latestRevision + '"' + " installed successfully");
             changeNextAction("Check");
             break;
         case InstallResult.Fail:
             TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Error);
             MessageBox.Show("There was trouble running the update file");
             changeNextAction("Install");
             break;
         case InstallResult.ChromiumRunning:
             TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Paused);
             displayStatus("Chromium is currently running");
             changeNextAction("Install");
             break;
     }
 }
Esempio n. 32
0
        /// <summary>
        /// DT_ALARM_DEF_INSTALL_RESULT_MONITORテーブルからDtAlarmDefInstallResultMonitorを取得する
        /// </summary>
        /// <param name="installResult">適用結果</param>
        /// <returns>取得したデータ</returns>
        public IEnumerable <DtAlarmDefInstallResultMonitor> ReadDtAlarmDefInstallResultMonitor(InstallResult installResult)
        {
            IEnumerable <DtAlarmDefInstallResultMonitor> models = null;

            try
            {
                _logger.EnterJson("{0}", installResult);

                List <DBAccessor.Models.DtAlarmDefInstallResultMonitor> entities = null;
                _dbPolly.Execute(() =>
                {
                    using (DBAccessor.Models.RmsDbContext db = new DBAccessor.Models.RmsDbContext(_appSettings))
                    {
                        entities = db.DtAlarmDefInstallResultMonitor
                                   .Where(x => string.IsNullOrEmpty(x.TypeCode) || x.TypeCode == installResult.TypeCode)
                                   .Where(x => string.IsNullOrEmpty(x.ErrorCode) || x.ErrorCode == installResult.ErrorCode)
                                   .Where(x => x.IsAuto == installResult.Auto)
                                   .Where(x => string.IsNullOrEmpty(x.Process) || x.Process == installResult.Process)
                                   .Where(x => x.IsSuccess == null || x.IsSuccess == installResult.Success)
                                   .ToList();
                    }
                });

                if (entities != null)
                {
                    models = entities.Select(x => x.ToModel());
                }

                return(models);
            }
            catch (Exception e)
            {
                throw new RmsException("DT_ALARM_DEF_INSTALL_RESULT_MONITORテーブルのSelectに失敗しました。", e);
            }
            finally
            {
                _logger.LeaveJson("{0}", models);
            }
        }