Beispiel #1
0
        /// <summary>
        /// Deploys the selected items
        /// </summary>
        private void Deploy()
        {
            Tracker.TrackEvent(TrackerEventGroup.Deploy, TrackerEventName.DeployClicked);
            if (_deployStatsCalculator != null &&
                _deployStatsCalculator.ConflictingResources != null &&
                _deployStatsCalculator.ConflictingResources.Count > 0)
            {
                var deployDialogViewModel = new DeployDialogViewModel(_deployStatsCalculator.ConflictingResources);
                ShowDialog(deployDialogViewModel);
                if (deployDialogViewModel.DialogResult == ViewModelDialogResults.Cancel)
                {
                    return;
                }
            }

            //
            //Get the resources to deploy
            //
            if (_deployStatsCalculator != null)
            {
                var deployResourceRepo = SelectedSourceServer.ResourceRepository;

                var resourcesToDeploy = Source.ExplorerItemModels.SelectMany(model => model.Descendants()).Where(_deployStatsCalculator.SelectForDeployPredicate).Select(model => deployResourceRepo.FindSingle(resourceModel => resourceModel.ID == model.ResourceId)).ToList();

                if (HasNoResourcesToDeploy(resourcesToDeploy, deployResourceRepo))
                {
                    return;
                }
                //
                // Deploy the resources
                //
                var deployDto = new DeployDto {
                    ResourceModels = resourcesToDeploy
                };

                try
                {
                    IsDeploying = true;
                    var env = _getActive();
                    _setActive(SelectedDestinationServer);
                    deployResourceRepo.DeployResources(SelectedSourceServer, SelectedDestinationServer, deployDto, EventPublisher);
                    _setActive(env);
                    DeploySuccessfull = true;
                }
                catch (Exception)
                {
                    DeploySuccessfull = false;
                    IsDeploying       = false;
                }
                finally
                {
                    IsDeploying = false;
                }
            }

            _source.Update();
            _target.Update();
            CalculateStats(false);
        }
Beispiel #2
0
        public void DeployNavigationViewMode_Update_FiltersAndCallsStudio()
        {
            // base case
            Init(false, true);
            var           studio = new Mock <IStudioResourceRepository>();
            PrivateObject p      = new PrivateObject(_vm, new PrivateType(typeof(NavigationViewModelBase)));

            p.SetField("_studioResourceRepository", studio.Object);
            _vm.Update();
            studio.Verify(a => a.Load(It.IsAny <Guid>(), It.IsAny <IAsyncWorker>()));
        }
Beispiel #3
0
        /// <summary>
        /// Deploys the selected items
        /// </summary>
        private void Deploy()
        {
            Tracker.TrackEvent(TrackerEventGroup.Deploy, TrackerEventName.DeployClicked);
            if (_deployStatsCalculator != null &&
                _deployStatsCalculator.ConflictingResources != null &&
                _deployStatsCalculator.ConflictingResources.Count > 0)
            {
                var deployDialogViewModel = new DeployDialogViewModel(_deployStatsCalculator.ConflictingResources);
                ShowDialog(deployDialogViewModel);
                if (deployDialogViewModel.DialogResult == ViewModelDialogResults.Cancel)
                {
                    return;
                }
            }

            if (SelectedDestinationServer != null && (SelectedDestinationServer.Connection.WebServerUri != null && (SelectedDestinationServer.Connection != null && (SelectedDestinationServer != null && SelectedDestinationServer.Connection.WebServerUri.Scheme == "http"))))
            {
                var popupController = CustomContainer.Get <IPopupController>();
                if (popupController != null)
                {
                    var messageBuilder = new StringBuilder();
                    messageBuilder.AppendLine("The destination server selected is not connected via https");
                    messageBuilder.AppendLine("This means that all sensitive information such as passwords will not be encrypted during deployment.");
                    messageBuilder.AppendLine("Are you sure you wish to continue deployment?");
                    var messageBoxResult = popupController.Show(messageBuilder.ToString(), "Unsecure Destination Server", MessageBoxButton.YesNo, MessageBoxImage.Exclamation, null);
                    if (messageBoxResult == MessageBoxResult.No || messageBoxResult == MessageBoxResult.Cancel || messageBoxResult == MessageBoxResult.None)
                    {
                        return;
                    }
                }
            }
            //
            //Get the resources to deploy
            //
            if (_deployStatsCalculator != null)
            {
                var deployResourceRepo = SelectedSourceServer.ResourceRepository;

                var resourcesToDeploy = Source.ExplorerItemModels.SelectMany(model => model.Descendants()).Where(_deployStatsCalculator.SelectForDeployPredicate).Select(model => deployResourceRepo.FindSingle(resourceModel => resourceModel.ID == model.ResourceId)).ToList();

                if (HasNoResourcesToDeploy(resourcesToDeploy, deployResourceRepo))
                {
                    return;
                }
                //
                // Deploy the resources
                //
                var deployDto = new DeployDto {
                    ResourceModels = resourcesToDeploy
                };

                try
                {
                    IsDeploying = true;
                    var env = _getActive();
                    _setActive(SelectedDestinationServer);
                    // bobcar
                    deployResourceRepo.DeployResources(SelectedSourceServer, SelectedDestinationServer, deployDto, EventPublisher);
                    _setActive(env);
                    DeploySuccessfull = true;
                }
                catch (Exception)
                {
                    DeploySuccessfull = false;
                    IsDeploying       = false;
                }
                finally
                {
                    IsDeploying = false;
                }
            }

            _source.Update();
            _target.Update();
            CalculateStats(false);
        }