예제 #1
0
        public void Run()
        {
            LocalReleaseInfo releaseInfo = new LocalReleaseInfo {
                App = "VideoAnalyzer"
            };

            _scriptService.RunAfterMakeCurrent(releaseInfo);
        }
        public async Task Handle(MakeActiveSelectedReleaseCommand notification, CancellationToken cancellationToken)
        {
            _logCtrl.Info($"Begin activation process app: {notification.LocalReleaseInfoDto.Name}");

            await _mediator
            .Publish(new LongProcessStartedEvent($"Make active: {notification.LocalReleaseInfoDto.Name}",
                                                 int.MinValue,
                                                 LongProcessType.IsIndeterminate));

            await Task.Delay(500);

            var releaseOption = _localReleaseService.TryGetReleaseByName(notification.LocalReleaseInfoDto.Name);

            if (releaseOption.HasValue)
            {
                var release = releaseOption.ValueOrFailure();
                if (!release.IsLocalNuget && release.IsOnServer)
                {
                    _logCtrl.Info($"Begin donload file: {release.File}");
                    Misc.RemoveFilesInDir(_registry.SyrupTmpDirPath);
                    var p = Path.Combine(_registry.SyrupTmpDirPath, release.File);
                    await _fileDownloader.DownloadFile(release.FileUrl, p, Show);

                    _fileManagerService.PutReleaseToNugetDir(release, p);
                    _logCtrl.Info($"End donload file: {release.File}");
                }

                _logCtrl.Info($"Begin install file: {release.File}");
                _fileManagerService.ExtractNugetToApps(release);
                _logCtrl.Info($"File was instaled ");

                // run befor
                var r1 = _scriptService.RunBeforeMakeCurrent(release);
                if (!r1.Continue)
                {
                    MakeAbort(notification, r1);
                    return;
                }

                _logCtrl.Info($"Begin program activation process.");
                _fileManagerService.CopyToActiveDir(release);

                // run after
                var r2 = _scriptService.RunAfterMakeCurrent(release);
                if (!r2.Continue)
                {
                    MakeAbort(notification, r2);
                    return;
                }

                _logCtrl.Info($"End activation proces.");

                _localReleaseService.MakeActive(release);
            }

            await
            _mediator.Publish(
                new LongProcessEndedEvent($"{notification.LocalReleaseInfoDto.Name} was activated", int.MinValue,
                                          LongProcessType.IsIndeterminate));

            await _mediator.Publish(new LocalReleaseInfoListWasUpdatedEvent(), cancellationToken);
        }