示例#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);
        }
示例#2
0
 public static Deploy FromDto(DeployDto deployDto)
 {
     return(new Deploy
     {
         Branch = deployDto.Branch,
         CommitHash = deployDto.CommitHash,
         State = deployDto.State
     });
 }
        public void DeployDto_GivenInstance_ShouldInheritFromIdeployDto()
        {
            //---------------Set up test pack-------------------
            var deployDto = new DeployDto();

            //---------------Assert Precondition----------------
            Assert.AreEqual(default(bool), deployDto.DeployTests);
            Assert.AreEqual(default(IList <ResourceModel>), deployDto.ResourceModels);
            //---------------Execute Test ----------------------
            //---------------Test Result -----------------------
            Assert.IsInstanceOfType(deployDto, typeof(IDeployDto));
        }
        public void DeployDto_GivenInstance_ShouldHaveEmptyValues()
        {
            //---------------Set up test pack-------------------
            var deployDto = new DeployDto();

            //---------------Assert Precondition----------------
            Assert.IsNotNull(deployDto);
            //---------------Execute Test ----------------------
            //---------------Test Result -----------------------
            Assert.AreEqual(default(bool), deployDto.DeployTests);
            Assert.AreEqual(default(IList <ResourceModel>), deployDto.ResourceModels);
        }
示例#5
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);
        }