Testdateien hinzugefügt.
Schächte werden Importiert
This commit is contained in:
@@ -32,6 +32,7 @@ namespace SewerStammGen.HostBuilders
|
||||
|
||||
services.AddSingleton<ViewModelDelegateRenavigator<ManholeListViewModel>>();
|
||||
services.AddSingleton<ViewModelDelegateRenavigator<ManholeEditViewModel>>();
|
||||
services.AddSingleton<ViewModelDelegateRenavigator<ManholeImportViewModel>>();
|
||||
|
||||
services.AddSingleton<ViewModelDelegateRenavigator<HaltungListViewModel>>();
|
||||
services.AddSingleton<ViewModelDelegateRenavigator<HaltungEditViewModel>>();
|
||||
@@ -47,8 +48,8 @@ namespace SewerStammGen.HostBuilders
|
||||
return () => new ManholeListViewModel(
|
||||
services.GetRequiredService<ISchachtDataService>(),
|
||||
services.GetRequiredService<ViewModelDelegateRenavigator<ManholeEditViewModel>>(),
|
||||
services.GetRequiredService<IActualState>()
|
||||
|
||||
services.GetRequiredService<IActualState>(),
|
||||
services.GetRequiredService<ViewModelDelegateRenavigator<ManholeImportViewModel>>()
|
||||
);
|
||||
});
|
||||
|
||||
@@ -60,6 +61,15 @@ namespace SewerStammGen.HostBuilders
|
||||
services.GetRequiredService<ViewModelDelegateRenavigator<ManholeListViewModel>>()
|
||||
);
|
||||
});
|
||||
|
||||
services.AddSingleton<CreateViewModel<ManholeImportViewModel>>(services =>
|
||||
{
|
||||
return () => new ManholeImportViewModel(
|
||||
services.GetRequiredService<ISchachtDataService>(),
|
||||
services.GetRequiredService<ViewModelDelegateRenavigator<ManholeListViewModel>>(),
|
||||
services.GetRequiredService<IActualState>()
|
||||
);
|
||||
});
|
||||
#endregion
|
||||
|
||||
#region Haltungen
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
<DataTemplate DataType="{x:Type viewmodel:ManholeEditViewModel}">
|
||||
<view:SchachtEditView />
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type viewmodel:ManholeImportViewModel}">
|
||||
<view:SchachtImportView />
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type viewmodel:HaltungListViewModel}">
|
||||
<view:HaltungListView />
|
||||
</DataTemplate>
|
||||
|
||||
26
SewerStammGen.WPF/Services/OpenFileDialogService.cs
Normal file
26
SewerStammGen.WPF/Services/OpenFileDialogService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.WPF.Services
|
||||
{
|
||||
internal class OpenFileDialogService
|
||||
{
|
||||
public string OpenFileDialog()
|
||||
{
|
||||
OpenFileDialog dialog = new OpenFileDialog();
|
||||
dialog.Filter = "CSV Files(.csv)|.csv";
|
||||
dialog.FilterIndex = 1;
|
||||
dialog.Multiselect = false;
|
||||
if(dialog.ShowDialog() == true)
|
||||
{
|
||||
return dialog.FileName;
|
||||
}
|
||||
return string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SewerStammGen.DAL\SewerStammGen.DAL.csproj" />
|
||||
<ProjectReference Include="..\SewerStammGen.Shared\SewerStammGen.Shared.csproj" />
|
||||
<ProjectReference Include="..\WWTech_KanalSchnittstelle\WWTech_KanalSchnittstelle.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
<Compile Update="Views\Projekt\ProjektListView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Views\Schacht\SchachtImportView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Views\Schacht\SchachtListView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -57,6 +60,9 @@
|
||||
<Page Update="Views\Projekt\ProjektListView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Views\Schacht\SchachtImportView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Views\Schacht\SchachtListView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.Services;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Contracts;
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using WWTech_KanalSchnittstelle.Importer;
|
||||
|
||||
namespace SewerStammGen.WPF.ViewModel
|
||||
{
|
||||
public class ManholeImportViewModel : BaseViewModel
|
||||
{
|
||||
private readonly ISchachtDataService schachtDataService;
|
||||
private readonly IRenavigator renavigator;
|
||||
private OpenFileDialogService fileDialogService;
|
||||
|
||||
private string filename = string.Empty;
|
||||
public string FileName
|
||||
{
|
||||
get => filename;
|
||||
set
|
||||
{
|
||||
if (filename == value) return;
|
||||
filename = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand LoadFile { get; set; }
|
||||
public ICommand OpenFileDialogCommand { get; set; }
|
||||
|
||||
private readonly IImport importer;
|
||||
|
||||
public ManholeImportViewModel(ISchachtDataService schachtDataService, IRenavigator renavigator, IActualState actualState)
|
||||
{
|
||||
#if DEBUG
|
||||
FileName = @"C:\Users\damia\source\repos\Stammdatengenerator\Beispieldaten\Koordinatendatei.csv";
|
||||
#endif
|
||||
LoadFile = new RelayCommand((x) => importFile());
|
||||
this.schachtDataService = schachtDataService;
|
||||
|
||||
importer = new CSVImporter(actualState.ProjektID);
|
||||
this.renavigator = renavigator;
|
||||
this.fileDialogService = new OpenFileDialogService();
|
||||
this.OpenFileDialogCommand = new RelayCommand((x) =>
|
||||
{
|
||||
FileName = fileDialogService.OpenFileDialog();
|
||||
});
|
||||
}
|
||||
|
||||
private async void importFile()
|
||||
{
|
||||
var schaechte = importer.LoadSchaechte(FileName, EEntwaeserung.Mischwasser);
|
||||
if (schaechte != null)
|
||||
{
|
||||
await schachtDataService.InsertSchachtBulk(schaechte);
|
||||
}
|
||||
renavigator.Renavigate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,8 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
private readonly ISchachtDataService _schachtDataService;
|
||||
private readonly ObservableCollection<Schacht> _schaechte;
|
||||
private readonly IActualState _actualState;
|
||||
|
||||
private readonly IRenavigator renavigateToImport;
|
||||
|
||||
public ObservableCollection<Schacht> Schaechte { get => _schaechte; }
|
||||
|
||||
public Schacht? SelectedSchacht { get; set; }
|
||||
@@ -27,20 +28,27 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
public ICommand AddSchachtCommand { get; set; }
|
||||
public ICommand EditSchachtCommand { get; set; }
|
||||
public ICommand DeleteSchachtCommand { get; set; }
|
||||
public ICommand ImportSchachtCommand { get; set; }
|
||||
|
||||
|
||||
|
||||
public ManholeListViewModel(ISchachtDataService schachtDataService, IRenavigator renavigator ,IActualState actualState)
|
||||
public ManholeListViewModel(ISchachtDataService schachtDataService, IRenavigator renavigator ,IActualState actualState, IRenavigator navigatetoImport)
|
||||
{
|
||||
_schachtDataService = schachtDataService;
|
||||
_actualState = actualState;
|
||||
|
||||
_schaechte = new ObservableCollection<Schacht>();
|
||||
|
||||
renavigateToImport = navigatetoImport;
|
||||
|
||||
AddSchachtCommand = new SchachtAddCommand(actualState,renavigator);
|
||||
EditSchachtCommand = new SchachtEditCommand(actualState, renavigator,this);
|
||||
DeleteSchachtCommand = new SchachtDeleteCommand(schachtDataService, actualState, renavigator, this);
|
||||
ImportSchachtCommand = new RelayCommand((x) =>
|
||||
{
|
||||
navigatetoImport.Renavigate();
|
||||
});
|
||||
|
||||
|
||||
LoadSchaechte();
|
||||
}
|
||||
|
||||
|
||||
24
SewerStammGen.WPF/Views/Schacht/SchachtImportView.xaml
Normal file
24
SewerStammGen.WPF/Views/Schacht/SchachtImportView.xaml
Normal file
@@ -0,0 +1,24 @@
|
||||
<UserControl x:Class="SewerStammGen.WPF.Views.SchachtImportView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SewerStammGen.WPF.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Row="0" Grid.Column="0" Content="Dateiname" />
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding FileName}" Margin="20,20,20,132" />
|
||||
<Button Grid.Row="0" Grid.Column="1" Content="Datei wählen" Margin="120,170,200,4" Command="{Binding OpenFileDialogCommand}" />
|
||||
|
||||
<Button Grid.Row="1" Grid.ColumnSpan="2" Content="Laden" Command="{Binding LoadFile}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
SewerStammGen.WPF/Views/Schacht/SchachtImportView.xaml.cs
Normal file
28
SewerStammGen.WPF/Views/Schacht/SchachtImportView.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SewerStammGen.WPF.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für SchachtImportView.xaml
|
||||
/// </summary>
|
||||
public partial class SchachtImportView : UserControl
|
||||
{
|
||||
public SchachtImportView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,20 +7,26 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<StackPanel>
|
||||
<DataGrid ItemsSource="{Binding Schaechte}" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" SelectedItem="{Binding SelectedSchacht}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Schachtnummer" Binding="{Binding Objektbezeichnung}" />
|
||||
<DataGridTextColumn Header="Rechtswert" Binding="{Binding RechtsWert}" />
|
||||
<DataGridTextColumn Header="Hochwert" Binding="{Binding HochWert}" />
|
||||
<DataGridTextColumn Header="Sohlhöhe" Binding="{Binding SohlHoehe}" />
|
||||
<DataGridTextColumn Header="Deckelhöhe" Binding="{Binding DeckelHoehe}" />
|
||||
<DataGridTextColumn Header="Entwässerung" Binding="{Binding Entwaesserung}" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<DataGrid Grid.Row="0" ItemsSource="{Binding Schaechte}" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" SelectedItem="{Binding SelectedSchacht}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Schachtnummer" Binding="{Binding Objektbezeichnung}" />
|
||||
<DataGridTextColumn Header="Rechtswert" Binding="{Binding RechtsWert}" />
|
||||
<DataGridTextColumn Header="Hochwert" Binding="{Binding HochWert}" />
|
||||
<DataGridTextColumn Header="Sohlhöhe" Binding="{Binding SohlHoehe}" />
|
||||
<DataGridTextColumn Header="Deckelhöhe" Binding="{Binding DeckelHoehe}" />
|
||||
<DataGridTextColumn Header="Entwässerung" Binding="{Binding Entwaesserung}" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<StackPanel Grid.Row="1">
|
||||
<Button Content="Schacht hinzufügen" Command="{Binding AddSchachtCommand}" />
|
||||
<Button Content="Schacht Editieren" Command="{Binding EditSchachtCommand}" />
|
||||
<Button Content="Schacht Löschen" Command="{Binding DeleteSchachtCommand}" />
|
||||
<Button Content="Schächte aus CSV Laden" Command="{Binding ImportSchachtCommand}" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user