Messagebox wird angezeigt wenn export fertiggestellt wurde
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user