private async Task GenerateOutageLogic() { if (!(OutageElement.Count == 1 && OptimumIsolationPoints.Count > 0 && DefaultIsolationPoints.Count > 0)) { string message = $"Rules: OutageElement.Count == 1 && OptimumIsolationPoints.Count > 0 && DefaultIsolationPoints.Count > 0"; MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } var outage = new SimulatedOutage(); outage.OutageElementGid = OutageElement.First().GID; outage.OptimumIsolationPointGids.AddRange(OptimumIsolationPoints.Select(point => point.GID)); outage.DefaultIsolationPointGids.AddRange(DefaultIsolationPoints.Select(point => point.GID)); for (int i = 0; i < DefaultIsolationPoints.Count; i++) { if (!outage.DefaultToOptimumIsolationPointMap.ContainsKey(DefaultIsolationPoints[i].GID) && i < OptimumIsolationPoints.Count) { outage.DefaultToOptimumIsolationPointMap.Add(DefaultIsolationPoints[i].GID, OptimumIsolationPoints[i].GID); } } var outageSimulatorUIClient = OutageSimulatorUIClient.CreateClient(); await outageSimulatorUIClient.GenerateOutage(outage); await parentWindow.ChangeTab(TabType.OVERVIEW); OutageElement.Clear(); outageElementGids.Clear(); OptimumIsolationPoints.Clear(); optimumIsolationPointsGids.Clear(); DefaultIsolationPoints.Clear(); defaultIsolationPointsGids.Clear(); SetGenerateOutageIsEnabled(); SetSelectOutageElementIsEnabled(); SetDeselectOutageElementIsEnabled(); SetAddOptimumIsolationPointIsEnabled(); SetRemoveOptimumIsolationPointIsEnabled(); SetAddDefaultIsolationPointIsEnabled(); SetRemoveDefaultIsolationPointIsEnabled(); //OnPropertyChanged("IsGenerateOutageEnabled"); //OnPropertyChanged("IsSelectOutageElementEnabled"); //OnPropertyChanged("IsDeSelectOutageElementEnabled"); //OnPropertyChanged("IsAddOptimumIsolationPointEnabled"); //OnPropertyChanged("IsRemoveOptimumIsolationPointEnabled"); //OnPropertyChanged("IsAddDefaultIsolationPointEnabled"); //OnPropertyChanged("IsRemoveDefaultIsolationPointEnabled"); }
private void GenerateOutageButton_Click(object sender, RoutedEventArgs e) { if (!(OutageElement.Count == 1 && OptimumIsolationPoints.Count > 0 && DefaultIsolationPoints.Count > 0)) { string message = $"Rules: OutageElement.Count == 1 && OptimumIsolationPoints.Count > 0 && DefaultIsolationPoints.Count > 0"; MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } ActiveOutageBindingModel outage = new ActiveOutageBindingModel(); outage.OutageElement = OutageElement.First(); outage.OptimumIsolationPoints.AddRange(OptimumIsolationPoints); outage.DefaultIsolationPoints.AddRange(DefaultIsolationPoints); for (int i = 0; i < DefaultIsolationPoints.Count; i++) { if (!outage.DefaultToOptimumIsolationPointMap.ContainsKey(DefaultIsolationPoints[i].GID) && i < OptimumIsolationPoints.Count) { outage.DefaultToOptimumIsolationPointMap.Add(DefaultIsolationPoints[i].GID, OptimumIsolationPoints[i].GID); } } overviewUserControl.GenerateOutage(outage); OutageElement.Clear(); outageElementGids.Clear(); OptimumIsolationPoints.Clear(); optimumIsolationPointsGids.Clear(); DefaultIsolationPoints.Clear(); defaultIsolationPointsGids.Clear(); OnPropertyChanged("IsGenerateOutageEnabled"); OnPropertyChanged("IsSelectOutageElementEnabled"); OnPropertyChanged("IsDeSelectOutageElementEnabled"); OnPropertyChanged("IsAddOptimumIsolationPointEnabled"); OnPropertyChanged("IsRemoveOptimumIsolationPointEnabled"); OnPropertyChanged("IsAddDefaultIsolationPointEnabled"); OnPropertyChanged("IsRemoveDefaultIsolationPointEnabled"); }