From cdde5f5004342220000e98c032dc7fdd886be048 Mon Sep 17 00:00:00 2001 From: Husky Date: Sun, 4 Jul 2021 18:40:30 +0200 Subject: [PATCH] =?UTF-8?q?B=C3=BCroexporter=20geschrieben?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug behoben, falls der Ordner von K2000 nicht excistiert --- SanSystem/BüroExporter.cs | 83 ++++++++++++++++++++++++ SanSystem/SanSystem.csproj | 3 +- SanSystem/UCWeitereFotos.cs | 19 ++++-- SanSystem/frmMain.Designer.cs | 22 +++++-- SanSystem/frmMain.cs | 16 +++++ create_setup.iss | 119 ++++++++++++++++++++++++++++++++++ 6 files changed, 250 insertions(+), 12 deletions(-) create mode 100644 SanSystem/BüroExporter.cs create mode 100644 create_setup.iss diff --git a/SanSystem/BüroExporter.cs b/SanSystem/BüroExporter.cs new file mode 100644 index 0000000..77c1f1d --- /dev/null +++ b/SanSystem/BüroExporter.cs @@ -0,0 +1,83 @@ +using KlassenBIB; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SanSystem +{ + static class BüroExporter + { + private static int getNextFotoNumber(string destinationPath,string fotoname) + { + IEnumerable Content = Directory.EnumerateFiles(destinationPath,fotoname); + return Content.Count() + 1; + } + + public static Task ExportAsync(Projekt projekt, string destinationPath = "./") + { + return Task.Factory.StartNew(() => + { + 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)) + { + try + { + Directory.Delete(tempPath, true); + } + catch (UnauthorizedAccessException) + { + + } + } + 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)); + } + + } + } + } + }); + + } + } +} diff --git a/SanSystem/SanSystem.csproj b/SanSystem/SanSystem.csproj index 8774b9d..ddeee07 100644 --- a/SanSystem/SanSystem.csproj +++ b/SanSystem/SanSystem.csproj @@ -116,6 +116,7 @@ + @@ -520,4 +521,4 @@ - \ No newline at end of file + diff --git a/SanSystem/UCWeitereFotos.cs b/SanSystem/UCWeitereFotos.cs index 3998862..aa2acea 100644 --- a/SanSystem/UCWeitereFotos.cs +++ b/SanSystem/UCWeitereFotos.cs @@ -63,15 +63,24 @@ namespace SanSystem if (txt_schachtnummer.Text == "") { bool found = false; - foreach(string directory in Directory.EnumerateDirectories(@"C:\K2000w\BILDER")) + try { - if(directory.Contains(Global.Instance.ProjektNummer)) + IEnumerable directories = Directory.EnumerateDirectories(@"C:\K2000w\BILDER"); + foreach (string directory in directories) { - found = true; - openFileDialog.InitialDirectory = directory; - break; + if(directory.Contains(Global.Instance.ProjektNummer)) + { + found = true; + openFileDialog.InitialDirectory = directory; + break; + } } } + catch(DirectoryNotFoundException) + { + // Do Nothing + } + if(!found) { openFileDialog.InitialDirectory = @"C:\K2000w\BILDER"; diff --git a/SanSystem/frmMain.Designer.cs b/SanSystem/frmMain.Designer.cs index 78eba88..6781c02 100644 --- a/SanSystem/frmMain.Designer.cs +++ b/SanSystem/frmMain.Designer.cs @@ -49,8 +49,9 @@ this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatus_projekt_Label = new System.Windows.Forms.ToolStripStatusLabel(); this.toolstrip_gesamtLiner = new System.Windows.Forms.ToolStripStatusLabel(); - this.update = new UpdateLib.Updater(); this.toolstrip_messages = new System.Windows.Forms.ToolStripStatusLabel(); + this.update = new UpdateLib.Updater(); + this.exportFürBüroErstellenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mainmenu.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -80,7 +81,8 @@ this.öffnenToolStripMenuItem, this.stammdatenImportierenToolStripMenuItem, this.auftraggeberToolStripMenuItem, - this.prefixSuffixToolStripMenuItem}); + this.prefixSuffixToolStripMenuItem, + this.exportFürBüroErstellenToolStripMenuItem}); this.projektToolStripMenuItem.Name = "projektToolStripMenuItem"; this.projektToolStripMenuItem.Size = new System.Drawing.Size(71, 25); this.projektToolStripMenuItem.Text = "Projekt"; @@ -201,10 +203,6 @@ this.toolstrip_gesamtLiner.Size = new System.Drawing.Size(111, 17); this.toolstrip_gesamtLiner.Text = "Insgesammt Einbau"; // - // update - // - this.update.UpdateUrl = "http://home.cosysda.de/sanverwaltung/UpdateInfo.dat"; - // // toolstrip_messages // this.toolstrip_messages.Name = "toolstrip_messages"; @@ -212,6 +210,17 @@ this.toolstrip_messages.Size = new System.Drawing.Size(16, 17); this.toolstrip_messages.Text = "..."; // + // update + // + this.update.UpdateUrl = "http://home.cosysda.de/sanverwaltung/UpdateInfo.dat"; + // + // exportFürBüroErstellenToolStripMenuItem + // + this.exportFürBüroErstellenToolStripMenuItem.Name = "exportFürBüroErstellenToolStripMenuItem"; + this.exportFürBüroErstellenToolStripMenuItem.Size = new System.Drawing.Size(254, 26); + this.exportFürBüroErstellenToolStripMenuItem.Text = "Export für Büro erstellen"; + this.exportFürBüroErstellenToolStripMenuItem.Click += new System.EventHandler(this.exportFürBüroErstellenToolStripMenuItem_Click); + // // frmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -257,6 +266,7 @@ private System.Windows.Forms.ToolStripMenuItem prefixSuffixToolStripMenuItem; private UpdateLib.Updater update; private System.Windows.Forms.ToolStripStatusLabel toolstrip_messages; + private System.Windows.Forms.ToolStripMenuItem exportFürBüroErstellenToolStripMenuItem; } } diff --git a/SanSystem/frmMain.cs b/SanSystem/frmMain.cs index 412e024..a87c510 100644 --- a/SanSystem/frmMain.cs +++ b/SanSystem/frmMain.cs @@ -362,5 +362,21 @@ namespace SanSystem FrmPrefixSuffix frmPrefixSuffix = new FrmPrefixSuffix(); frmPrefixSuffix.ShowDialog(); } + + private void exportFürBüroErstellenToolStripMenuItem_Click(object sender, EventArgs e) + { + using (FolderBrowserDialog fdb = new FolderBrowserDialog()) + { + if(fdb.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(fdb.SelectedPath)) + { + OnExportedExecuted(fdb.SelectedPath); + } + } + } + + private async void OnExportedExecuted(string destinationPath) + { + await BüroExporter.ExportAsync(Datenbank.Instance.loadedProjekt,destinationPath); + } } } diff --git a/create_setup.iss b/create_setup.iss new file mode 100644 index 0000000..881fd73 --- /dev/null +++ b/create_setup.iss @@ -0,0 +1,119 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "Sansystem" +#define MyAppVersion "0.1" +#define MyAppPublisher "Cosysda" +#define MyAppURL "http://www.cosysda.de" +#define MyAppExeName "SanSystem.exe" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{8DAC31A8-8FF3-4E41-86B0-15BFCBE622F3} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={autopf}\{#MyAppName} +DisableProgramGroupPage=yes +; Uncomment the following line to run in non administrative install mode (install for current user only.) +;PrivilegesRequired=lowest +PrivilegesRequiredOverridesAllowed=dialog +OutputDir=D:\Development\SanVerwaltung\Release +OutputBaseFilename=Sanverwalter +Password=junkermeves +Encryption=yes +Compression=lzma +SolidCompression=yes +WizardStyle=modern + +[Languages] +Name: "german"; MessagesFile: "compiler:Languages\German.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\BerichtGen.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\BerichtGen.dll.config"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\CSVParser.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Database.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Database.dll.config"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\DE.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Dichtheitsprüfung.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\FluentFTP.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\FluentFTP.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\input.txt"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Ionic.Zip.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\KlassenBIB.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\KlassenBIB.dll.config"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\KlassenBIB.pdb"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Language.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Newtonsoft.Json.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Newtonsoft.Json.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\SanShared.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\SanSystem.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\SanSystem.exe.config"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\SchnittstelleImporter.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\SchnittstelleImporter.dll.config"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Chart.Base.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Chart.Base.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Chart.Windows.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Chart.Windows.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Compression.Base.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Compression.Base.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Core.WinForms.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Core.WinForms.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.DocIO.Base.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.DocIO.Base.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.DocToPDFConverter.Base.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.DocToPDFConverter.Base.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Grid.Base.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Grid.Base.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Grid.Windows.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Grid.Windows.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Grouping.Base.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Grouping.Base.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Licensing.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.OfficeChart.Base.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.OfficeChart.Base.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Pdf.Base.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Pdf.Base.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.PdfViewer.Windows.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.PdfViewer.Windows.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.SfInput.WinForms.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.SfInput.WinForms.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.SfSpellChecker.WPF.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.SfSpellChecker.WPF.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Shared.Base.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Shared.Base.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Shared.Windows.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Shared.Windows.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.SpellChecker.Base.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.SpellChecker.Base.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Tools.Base.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Tools.Base.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Tools.Windows.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Syncfusion.Tools.Windows.xml"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\TempCAN.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\Tinkerforge.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\UpdateLib.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\version.txt"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\vorlage.txt"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\WibuCmNET.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\wupi.net.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "D:\Development\SanVerwaltung\SanSystem\bin\Release\WupiEngineNet.dll"; DestDir: "{app}"; Flags: ignoreversion +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" +Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon + +[Run] +Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent +