57 lines
2.3 KiB
C#
57 lines
2.3 KiB
C#
using SewerStammGen.Shared;
|
|
using SewerStammGen.Shared.Contracts;
|
|
using SewerStammGen.Shared.Domain;
|
|
using Shared.Contracts;
|
|
using StammGenerator.Commands;
|
|
using StammGenerator.ViewModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using WWTech_KanalSchnittstelle.Exporter;
|
|
|
|
namespace StammGenerator.Commands
|
|
{
|
|
internal class ProjectExportCommand : AsyncCommandBase
|
|
{
|
|
private readonly ProjektListViewModel _projektListViewModel;
|
|
//private Projekt _selectedProjekt;
|
|
private readonly IHaltungDataService _haltungDataService;
|
|
private readonly ISchachtDataService _schachtDataService;
|
|
|
|
|
|
public ProjectExportCommand(ProjektListViewModel projektListViewModel, IHaltungDataService haltungDataService, ISchachtDataService schachtDataService)
|
|
{
|
|
_projektListViewModel = projektListViewModel;
|
|
_haltungDataService = haltungDataService;
|
|
_schachtDataService = schachtDataService;
|
|
|
|
}
|
|
|
|
public override async Task ExecuteAsync(object? parameter)
|
|
{
|
|
if (_projektListViewModel.SelectedProjekt == null) return;
|
|
IWWLog wwLog = null ;
|
|
Projekt _selectedProjekt = _projektListViewModel.SelectedProjekt;
|
|
try
|
|
{
|
|
IExport export = ExporterFactory.Export(_selectedProjekt.ExportType);
|
|
IEnumerable<Kanal> haltungen = await _haltungDataService.GetAllByProjekt(_selectedProjekt);
|
|
IEnumerable<Schacht> schaechte = await _schachtDataService.GetAllByProjekt(_selectedProjekt);
|
|
|
|
await export.Export(_selectedProjekt.Id.ToString(), _selectedProjekt.Kodierungssystem, haltungen.ToList(), schaechte.ToList(), wwLog);
|
|
}
|
|
catch(NotImplementedException)
|
|
{
|
|
MessageBoxResult result = MessageBox.Show(string.Format("Schnittstelle Export format: {0} ist nicht Implementiert", _selectedProjekt.ExportType), "Fehlende Implementation", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
}
|
|
catch(DongleNotFoundException)
|
|
{
|
|
MessageBoxResult result = MessageBox.Show("Dongle nicht vorhanden");
|
|
}
|
|
}
|
|
}
|
|
}
|