/////////////////////////////////////////////////////////////////////////////////////////////////// // Ermittlung Verlsutleistung /////////////////////////////////////////////////////////////////////////////////////////////////// // Erstellt am: 2015-12-08 // Erstellt von: jn // Geändert am: - // Geändert von: - // Änderung: - /////////////////////////////////////////////////////////////////////////////////////////////////// using System.IO; using System.Diagnostics; public class Verlustleistung { [DeclareAction("Verlustleistung")] public void VerlustleistungVoid() { // < Allgemeine Daten: Anfang > // Projektdatei, Projektpfad, Projektname string sSelectedProjectData_1 = string.Empty; // kompletter Pfad + Projektdateinamen + Erweiterung string sSelectedProjectPath_1 = string.Empty; // Projektpfad string sSelectedProjectName_1 = string.Empty; // Projektname // Projektdatei komplett CommandLineInterpreter oCLI_1 = new CommandLineInterpreter(); Eplan.EplApi.ApplicationFramework.ActionCallingContext ctx_1 = new Eplan.EplApi.ApplicationFramework.ActionCallingContext(); ctx_1.AddParameter("TYPE", "PROJECT"); bool bRet_1 = oCLI_1.Execute("selectionset", ctx_1); // Action: Projektpfad if (bRet_1 == true) { ctx_1.GetParameter("PROJECT", ref sSelectedProjectData_1); } // Projektpfad sSelectedProjectPath_1 = System.IO.Path.GetDirectoryName(sSelectedProjectData_1); // Projektname sSelectedProjectName_1 = System.IO.Path.GetFileNameWithoutExtension(sSelectedProjectData_1); // Daten Aufbereitung string sSubstitutePath_1 = @sSelectedProjectPath_1 + @"\" + sSelectedProjectName_1 + @".edb\DOC\Verlustleistung\"; // Speicherort string sFilename_1 = @"xxxxxx_=Axx+Sxx_10.10_Ermittlung Verlustleistung.xlsx"; // Dateiname string sDestFile_1 = sSubstitutePath_1 + sFilename_1; // Zieldatei string sPost_1 = @"Script_Verlustleistung"; // Beschriftungsschema // < Allgemeine Daten: Ende > // Bugfix 1.9.10 oCLI_1.Execute("EsGenerateConnections"); // Abfrage: YES/NO DialogResult oDialogResult_1 = new DialogResult(); oDialogResult_1 = MessageBox.Show("Soll die Verlustleistung des ausgewaehlten Bereiches ermittelt werden? \n \nBitte im folgenden Fenster den Dateinamen anpassen!", "Ermittlung Verlustleistung [" + sSelectedProjectName_1 + "]", MessageBoxButtons.YesNo); if (oDialogResult_1 == DialogResult.Yes) { // Verzeichnis erzeugen Directory.CreateDirectory(sSubstitutePath_1); // Dialog "Speichern unter" SaveFileDialog sfd = new SaveFileDialog(); sfd.DefaultExt = "xlsx"; sfd.FileName = sFilename_1; sfd.Filter = "Exceldatei (*.xlsx)|*.xlsx"; sfd.InitialDirectory = sSubstitutePath_1; sfd.Title = "Speichern unter: Bitte Dateinamen anpassen!"; sfd.ValidateNames = true; if (sfd.ShowDialog() == DialogResult.OK) { { // Beschriftung Progress progress = new Progress("SimpleProgress"); progress.SetTitle("Datei wird erzeugt..."); progress.SetActionText(sDestFile_1 + " wird erzeugt..."); progress.ShowImmediately(); progress.BeginPart(100,""); progress.SetAllowCancel(true); if(!progress.Canceled()) { progress.BeginPart(100,"Verlustleistung"); ActionCallingContext labellingContext = new ActionCallingContext (); labellingContext.AddParameter("USESELECTION","1"); // Nur der selektierte Bereich wird ausgewertet labellingContext.AddParameter("CONFIGSCHEME", sPost_1); // Beschriftungsschema labellingContext.AddParameter("DESTINATIONFILE", sfd.FileName); // Zieldatei labellingContext.AddParameter("FILTERSCHEME",""); labellingContext.AddParameter("LANGUAGE","de_DE"); labellingContext.AddParameter("LogMsgActionDone","true"); labellingContext.AddParameter("SHOWOUTPUT","1"); labellingContext.AddParameter("RECREPEAT","1"); labellingContext.AddParameter("SORTSCHEME",""); labellingContext.AddParameter("TASKREPEAT","1"); new CommandLineInterpreter().Execute("label",labellingContext); progress.EndPart(); } MessageBox.Show( "Datei wurde erfolgreich gespeichert:\n" + sfd.FileName, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information ); progress.EndPart(true); } } } } }