Code:
using System;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;public class Export
{
[DeclareAction("Pulseroller")]
public void PostAndExecuteVoid()
{
// < Allgemeine Daten: Anfang >
// Projektdatei, Projektpfad, Projektname
string sSelectedProjectData_1 = string.Empty; // kompletter Pfad + Projektdateinamen + Erweiterung
string sSelectedProjectName_1 = string.Empty; // Projektname
string sSelectedProjectPath_1 = string.Empty; // Projektpfad
// 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);
// Bugfix 1.9.10
oCLI_1.Execute("EsGenerateConnections");
// Dateinamen
string sDestFile_1 = @"C:\Temp\Eplan P8\Pulseroller\" + sSelectedProjectName_1 + ".xls"; // Zieldatei
string sPost_1 = @"Script_Pulseroller_Funktionstexte"; // Schema Extern bearbeiten
// Abfrage: YES/NO
DialogResult oDialogResult_1 = new DialogResult();
oDialogResult_1 = MessageBox.Show("Soll " + sDestFile_1 + " erzeugt werden?", "Pulseroller Funktionstexte [" + sSelectedProjectName_1 + "]", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (oDialogResult_1 == DialogResult.Yes)
{
// Extern bearbeiten
Progress progress = new Progress("SimpleProgress");
progress.SetAllowCancel(true);
progress.SetAskOnCancel(true);
progress.SetTitle("Funktionstexte werden erzeugt...");
progress.SetActionText(sDestFile_1 + " wird erzeugt...");
progress.ShowImmediately();
progress.BeginPart(100,"");
progress.SetAllowCancel(true);
if(!progress.Canceled())
{
CommandLineInterpreter oCLI_0 = new CommandLineInterpreter();
ActionCallingContext CommonExport = new ActionCallingContext();
CommonExport.AddParameter("CONFIGSCHEME", sPost_1); // Name des Konfigurationsschema
CommonExport.AddParameter("COMPLETEPROJECT", "1"); // Das ganze Projekt wird exportiert, nicht nur die ausgewählten Objekte (0 = Nein, 1 = Ja).
CommonExport.AddParameter("LANGUAGE", "de_DE"); // Sprache
CommonExport.AddParameter("DESTINATIONFILE", sDestFile_1); // Zieldatei
CommonExport.AddParameter("EXECUTIONMODE", "1"); // Ausgabeart: 0: Exportieren, 1: Exportieren und Anwendung starten, 2: In externer Anwendung bearbeiten und zurücklesen.
oCLI_0.Execute("XMActionDCCommonExport", CommonExport);
MessageBox.Show("Action ausgeführt.");
}
progress.EndPart(true);
}
}