diff --git a/SanSystem/BüroExporter.cs b/SanSystem/BüroExporter.cs index 77c1f1d..b527712 100644 --- a/SanSystem/BüroExporter.cs +++ b/SanSystem/BüroExporter.cs @@ -18,66 +18,63 @@ namespace SanSystem return Content.Count() + 1; } - public static Task ExportAsync(Projekt projekt, string destinationPath = "./") + public static bool Export(Projekt projekt, string destinationPath = "./") { - return Task.Factory.StartNew(() => + destinationPath = Path.Combine(destinationPath, "EXPORT"); + foreach (Inspektionsobjekt d in projekt.Objekte) { - destinationPath = Path.Combine(destinationPath, "EXPORT"); - foreach (Inspektionsobjekt d in projekt.Objekte) + KlassenBIB.Collections.Sanierung sanierungsliste = d.Sanierung; + + if (sanierungsliste.Count < 1) continue; + + string tempPath = Path.Combine(destinationPath, "ID" + d.Sanierungsnummer); + if (Directory.Exists(tempPath)) { - KlassenBIB.Collections.Sanierung sanierungsliste = d.Sanierung; - - if (sanierungsliste.Count < 1) continue; - - string tempPath = Path.Combine(destinationPath, "ID" + d.Sanierungsnummer); - if (Directory.Exists(tempPath)) + try { - try - { - Directory.Delete(tempPath, true); - } - catch (UnauthorizedAccessException) - { - - } + Directory.Delete(tempPath, true); } - Directory.CreateDirectory(tempPath); - - foreach (Sanierung san in sanierungsliste) + catch (UnauthorizedAccessException) { - if (san is KlassenBIB.InlinerSanierung) - { - // PDF - string sourceDirectory = Path.Combine(Global.Instance.Projektpfad, "Einbauprotokolle", d.Objektbezeichnung + ".pdf"); - if (!File.Exists(sourceDirectory)) - { - MessageBox.Show("Bitte Bericht erzeugen", "Haltung " + d.Objektbezeichnung + " noch nicht erstellt"); - } - else - { - File.Copy(sourceDirectory, tempPath + "/" + d.Objektbezeichnung + ".pdf"); - } - } - else if (san is KlassenBIB.SchachtAnbindung) - { - string sourceDirectory = san.CheckVerzeichnisse(Global.Instance.Projektpfad); - SchachtAnbindung fotoDokumentation = (san as SchachtAnbindung); - KlassenBIB.Collections.Bilder fotos = fotoDokumentation.SavedBilders; - foreach (SavedBilder foto in fotos) - { - // Prüfen welche der nächste Freie nummer ist - // Bildname_X, wobei X eine zahl der erhöht wird, angefangen bei 1 - int freeFotoNumber = getNextFotoNumber(tempPath, d.Objektbezeichnung + "*.jpg"); - string destinationName = string.Format("{0}_{1:d3}.jpg", d.Objektbezeichnung, freeFotoNumber); // 0 ist der Index, d3 => 3 Decimalstellen - File.Copy(foto.Speicherpfad, Path.Combine(tempPath, destinationName)); - } - - } } } - }); + Directory.CreateDirectory(tempPath); + foreach (Sanierung san in sanierungsliste) + { + if (san is KlassenBIB.InlinerSanierung) + { + // PDF + string sourceDirectory = Path.Combine(Global.Instance.Projektpfad, "Einbauprotokolle", d.Objektbezeichnung + ".pdf"); + if (!File.Exists(sourceDirectory)) + { + MessageBox.Show("Bitte Bericht erzeugen", "Haltung " + d.Objektbezeichnung + " noch nicht erstellt"); + } + else + { + File.Copy(sourceDirectory, tempPath + "/" + d.Objektbezeichnung + ".pdf"); + } + } + else if (san is KlassenBIB.SchachtAnbindung) + { + string sourceDirectory = san.CheckVerzeichnisse(Global.Instance.Projektpfad); + SchachtAnbindung fotoDokumentation = (san as SchachtAnbindung); + KlassenBIB.Collections.Bilder fotos = fotoDokumentation.SavedBilders; + foreach (SavedBilder foto in fotos) + { + // Prüfen welche der nächste Freie nummer ist + // Bildname_X, wobei X eine zahl der erhöht wird, angefangen bei 1 + int freeFotoNumber = getNextFotoNumber(tempPath, d.Objektbezeichnung + "*.jpg"); + string destinationName = string.Format("{0}_{1:d3}.jpg", d.Objektbezeichnung, freeFotoNumber); // 0 ist der Index, d3 => 3 Decimalstellen + + File.Copy(foto.Speicherpfad, Path.Combine(tempPath, destinationName)); + } + + } + } + } + return true; } } } diff --git a/SanSystem/SanSystem.csproj b/SanSystem/SanSystem.csproj index ddeee07..dc3e9f6 100644 --- a/SanSystem/SanSystem.csproj +++ b/SanSystem/SanSystem.csproj @@ -1,6 +1,5 @@  - Debug @@ -515,10 +514,4 @@ - - - Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}". - - - - + \ No newline at end of file diff --git a/SanSystem/frmMain.cs b/SanSystem/frmMain.cs index a87c510..1fab65b 100644 --- a/SanSystem/frmMain.cs +++ b/SanSystem/frmMain.cs @@ -376,7 +376,9 @@ namespace SanSystem private async void OnExportedExecuted(string destinationPath) { - await BüroExporter.ExportAsync(Datenbank.Instance.loadedProjekt,destinationPath); + Task export = Task.Factory.StartNew(() => BüroExporter.Export(Datenbank.Instance.loadedProjekt, destinationPath)); + export.ContinueWith(task => MessageBox.Show("Büro export abgeschlossen")); + } } }