/// <summary> /// Recalculates /// </summary> private void CalculateStats(bool updateSuccess = true) { if (updateSuccess) { DeploySuccessfull = false; } if (Source != null && Source.ExplorerItemModels != null && Source.ExplorerItemModels.Count > 0) { Source.ClearConflictingNodesNodes(); IExplorerItemModel explorerItemModel = Source.ExplorerItemModels[0]; if (explorerItemModel != null) { var items = explorerItemModel.Descendants().Where(model => model.IsChecked.GetValueOrDefault(false)).ToList(); _deployStatsCalculator.ConflictingResources = new ObservableCollection <DeployDialogTO>(); _deployStatsCalculator.CalculateStats(items, _sourceStatPredicates, _sourceStats, out _sourceDeployItemCount); _deployStatsCalculator.CalculateStats(items, _targetStatPredicates, _targetStats, out _destinationDeployItemCount); RaiseDeployCommandCanExecuteChanged(); } } NotifyOfPropertyChange(() => CanDeploy); NotifyOfPropertyChange(() => SourceItemsSelected); }
/// <summary> /// handle resource checked /// </summary> /// <param name="checkStateChangedArgs"></param> void OnCheckedStateChangedAction(CheckStateChangedArgs checkStateChangedArgs) { if (checkStateChangedArgs != null && checkStateChangedArgs.PreviousState && checkStateChangedArgs.NewState == false) { if (Target != null) { if (checkStateChangedArgs.ResourceId != Guid.Empty) { if (SelectedDestinationServer != null) { if (SelectedDestinationServer.ResourceRepository != null) { var resourceModel = SelectedDestinationServer.ResourceRepository.FindSingle(model => model.ID == checkStateChangedArgs.ResourceId) as IContextualResourceModel; if (resourceModel != null) { Target.SetNodeOverwrite(resourceModel, false); } } } } } } if (checkStateChangedArgs != null && checkStateChangedArgs.UpdateStats) { CalculateStats(); } if (checkStateChangedArgs != null && checkStateChangedArgs.NewState && checkStateChangedArgs.PreviousState == false) { if (Source != null && Source.ExplorerItemModels.Any()) { IExplorerItemModel explorerItemModel = Source.ExplorerItemModels[0]; var items = explorerItemModel.Descendants().Where(model => model.IsChecked.GetValueOrDefault(false) && model.ResourceId == checkStateChangedArgs.ResourceId).ToList(); var namingConflicts = _deployStatsCalculator.CheckForNamingConflicts(items, Target).ToList(); if (namingConflicts.Any()) { StringBuilder message = new StringBuilder("The following items exist on the Destination Server with the same path and a different ID. Please rename, move or delete on the destination server before deploying:" + Environment.NewLine); foreach (var namingConflict in namingConflicts) { message.AppendLine(namingConflict.ResourcePath); namingConflict.IsChecked = false; } PopupController.Show(message.ToString(), "Resource Conflicts", MessageBoxButton.OK, MessageBoxImage.Error, null); } } } }