Archiv für das Jahr: 2018

ExportProjectMissingTranslation

Luc S. hat ein Script erstellt um fehlende Übersetzungen eines Projektes zu exportieren bzw. anzuzeigen. Vielen Dank für das Bereitstellen!

Download auf GitHub

//===================================================
// LUC S.  04-07-2018
// Script Exportiert die Fehlworteliste für die eingestellte Projektsprache
//===================================================
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.IO;

//==========================================
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

//==========================================
public class Export_Project_Missing_Translation
{
    [DeclareAction("Export_Project_Missing_Translation")]
    //[Start]
    public void Export_Txt_Fehlworte()
    {
    //=======================================================================  
    // Dialogabfrage
        const string message = "Prüfung von fehlenden Übersetzungen durchführen?";
        const string caption = "Export Fehlworteliste";
        var result = MessageBox.Show(message, caption,
                                     MessageBoxButtons.YesNo,
                                     MessageBoxIcon.Question);

        if (result == DialogResult.No)
        {
           return;
        }
     //=======================================================================
     // aktuelles Projektpfad ermitteln	
        string sProject = Get_Project();
		//sProject = sProject.Replace("File-2", "K-ELT-01");

        if (sProject == "")
        {
            MessageBox.Show("Projekt auswählen !");
            return;
        }
        //MessageBox.Show(sProject);
        
        // Projektname ermitteln
        string strProjectname = Get_Name(sProject);

     //=======================================================================
     //eingestellte Projektsprache EPLAN ermitteln 
        string strDisplayLanguage = null;
        ActionCallingContext ACCDisplay = new ActionCallingContext();
        new CommandLineInterpreter().Execute("GetDisplayLanguage", ACCDisplay);
        ACCDisplay.GetParameter("value", ref strDisplayLanguage);
        //MessageBox.Show("Language : " + strDisplayLanguage);
			
    //=======================================================================    
  	//Fehlworteliste erzeugen :
         Eplan.EplApi.ApplicationFramework.ActionCallingContext acctranslate = new Eplan.EplApi.ApplicationFramework.ActionCallingContext();
	     Eplan.EplApi.ApplicationFramework.CommandLineInterpreter CLItranslate = new Eplan.EplApi.ApplicationFramework.CommandLineInterpreter(); 
         Eplan.EplApi.Base.Progress progress = new Eplan.EplApi.Base.Progress("SimpleProgress");
         progress.BeginPart(100, "");
         progress.SetAllowCancel(true);


         string MisTranslateFile = @"c:\TEMP\EPLAN\EPLAN_Fehlworteliste_" + strProjectname + "_" + strDisplayLanguage + ".txt";
	     acctranslate.AddParameter("TYPE", "EXPORTMISSINGTRANSLATIONS");
         acctranslate.AddParameter("LANGUAGE", strDisplayLanguage);
	     acctranslate.AddParameter("EXPORTFILE", MisTranslateFile);
	     acctranslate.AddParameter("CONVERTER", "XTrLanguageDbXml2TabConverterImpl");        

	     bool sRet = CLItranslate.Execute("translate", acctranslate);

        if (!sRet)
        {
            MessageBox.Show("Fehler bei Export fehlende Übersetzungen!");
            return;
        }

       // MessageBox.Show("Fehlende Übersetzungen exportiert in : " + MisTranslateFile);

    //=================================================================
    //Fehlworteliste lesen und Zeilenanzahl ermitteln :

        int counter = 0;
        string line;
        
           if (File.Exists(MisTranslateFile))
            { 
                using (StreamReader countReader = new StreamReader(MisTranslateFile))
                {
                    while (countReader.ReadLine() != null)
                        counter++;
                }
                // MessageBox.Show("Zeilenanzahl in " + MisTranslateFile + " : " + counter);

             if (counter > 1)

                    //=================================================================
                    //Fehlworteliste öffnen falls Zeilenanzahl > 1 :

                    {
                        // MessageBox.Show("Fehlende Übersetzungen gefunden !");       
                        // Open the txt file with missing translation
                        System.Diagnostics.Process.Start("notepad.exe", MisTranslateFile);
                    }

            }  

        progress.EndPart(true);
     return;
    }

 //=======================================================================
   public string Get_Project()
    {
	try
	    {
		    // aktuelles Projekt ermitteln
		    //==========================================
		    Eplan.EplApi.ApplicationFramework.ActionManager oMngr = new Eplan.EplApi.ApplicationFramework.ActionManager();
		    Eplan.EplApi.ApplicationFramework.Action oSelSetAction = oMngr.FindAction("selectionset");
		    string sProjektT = "";
		    if (oMngr != null)
		    {
			    Eplan.EplApi.ApplicationFramework.ActionCallingContext ctx = new Eplan.EplApi.ApplicationFramework.ActionCallingContext();
			    ctx.AddParameter("TYPE", "PROJECT");
			    bool sRet = oSelSetAction.Execute(ctx);

			    if (sRet)
			    {ctx.GetParameter("PROJECT",ref sProjektT);}
			    //MessageBox.Show("Projekt: " + sProjektT);
		    }
		    return sProjektT;
        }
	    catch
 		    {return "";}
    }

   //################################################################################################
   public string Get_Name(string sProj)
   {
       try
       {
           // Projektname ermitteln
           //==========================================
           int i = sProj.Length - 5;
           string sTemp = sProj.Substring(1, i);
           i = sTemp.LastIndexOf(@"\");
           sTemp = sTemp.Substring(i + 1);
           //MessageBox.Show("Ausgabe: " + sTemp);
           return sTemp;
       }
       catch
       { return "ERROR"; }
   }

}
Von |2018-08-17T12:30:47+02:002018-07-09|EPLAN, EPLAN-Scripts|

Serverumzug von Uberspace zu Uberspace

Hört sich komisch an, ist aber so…
Uberspace stellt eine neue Version ihrer Dienstleistung bereit: Uberspace7

Viele Verbesserungen und zwei davon haben mich überzeugt den Aufwand für einen Umzug in Kauf zu nehmen. Habe viele Domain auf Uberspace6 liegen, welche diese Features nicht benötigen. Darum habe ich noch nur meine private (weiher.io) und geschäftliche (suplanus.de) Domain umgezogen. Hauptgründe:

  • PHP Instanz sofort verfügbar (Performance)
  • Rspamd (Spam Schutz, derzeit wohl der meist gelobte)

Mit dieser Anleitung ging das relativ schnell und einfach.
Dennoch musste ich meine SQL Datenbanken dann nochmal neu verknüpfen und im WordPress paar Links ersetzen, was aber überschaubar war.

Domains hab ich gleich zu Gandi umgezogen. Für mich der beste Platz für Domains.

Mit Mail musste ich mich mehr ärgern, aber da hab ich mir mein eigenes Grab mit Namespaces im U6 geschaufelt. Wusste es nicht besser und darum hab ich Sie auf dem neuen Server dann wieder aufgetrennt in eigene User.

Mein User bekommt mehr Email-Aliase, Familienmitglieder nur jeweils eine (pro Domain, automatisch).
Rspamd hab ich mit dieser Anleitung noch geändert. Alles in die Datei .mailfilter , diese wird per default ausgeführt. Trefferquote scheint wirklich gut zu sein.

Es war schon eine Nacht Arbeit, aber es hat sich gelohnt, vor allem das Aufräumen von Altlasten. Nach wie vor kann ich Uberspace nur empfehlen, für Leute die ein bisschen mehr aus ihrem Webspace rausholen wollen und keine Angst vor einem Terminal haben.

Von |2018-06-06T12:08:00+02:002018-06-06|Allgemein|

BackgroundWorker in der EPLAN API

… geht offiziell nicht. Steht auch so in der Dokumentation. Darum hier gleich der Vermerk: Es handelt sich um eine interne Funktionalität welche nicht supported wird.

Dennoch hat es genau mein Problem gelöst:
Ich habe eine ProgressBar welche über einen BackgroundWorker viel Arbeit macht. An paar Stellen brauche ich die EPLAN API. Hier hatte ich aber komisches Verhalten (DLLs wurden nicht gefunden, usw.).
Zurückzuführen war es darauf dass der EPLAN Thread nicht wusste wo er suchen soll.

Mit EplanMainThreadDispatcher  gibt es die Möglichkeit Code im Dispatcher und somit im Thread von EPLAN auszuführen. Hier ein Beispiel:

new EplanMainThreadDispatcher().ExecuteInMainThreadSync(o =>
{
  new CommandLineInterpreter().Execute("reports /TYPE:PROJECT");
  return null;
}, null);

Hab mir das mal bisl vereinfacht mit einer Helper-Klasse:

using Eplan.EplApi.Base.Internal;
using Action = System.Action;

namespace Suplanus.Sepla.Application
{
  public class EplanDispatcher
  {
    public static void ExecuteInMainThread(Action action)
    {
      new EplanMainThreadDispatcher().ExecuteInMainThreadSync(o =>
      {
        action.Invoke();
        return null;
      }, null);
    }
  }
}

Dann brauch ich nur noch:

EplanDispatcher.ExecuteInMainThread(() =>
  {
    new CommandLineInterpreter().Execute("reports /TYPE:PROJECT");
  }
);
Von |2018-07-19T10:53:25+02:002018-06-01|EPLAN, EPLAN-API|

GetProjectProperty

Dieses Script gibt es nun schon in der dritten Auflage. Ich habe die Unterstützung für benutzerdefinierte Eigenschaften hinzugefügt. Im Test des Scriptes seht ihr die verschiedenen Aufrufe:

[Start]
public void Test()
{
  string projectProperty;

  // No index
  projectProperty = GetProjectPropertyAction("10000", "0");
  MessageBox.Show("No index: " + Environment.NewLine +  projectProperty);

  // Index
  projectProperty = GetProjectPropertyAction("10901", "1");
  MessageBox.Show("Index: " + Environment.NewLine + projectProperty);

  // UserDefinied
  projectProperty = GetProjectPropertyAction("Suplanus.Project.Test", null);
  MessageBox.Show("UserDefinied: " + Environment.NewLine + projectProperty);
}

 

Script:

using System;
using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

namespace EplanScriptingProjectBySuplanus.GetProjectProperty
{
  class GetProjectProperty
  {
    private string GetProjectPropertyAction(string id, string index)
    {
      string value = null;
      ActionCallingContext actionCallingContext = new ActionCallingContext();
      actionCallingContext.AddParameter("id", id);
      actionCallingContext.AddParameter("index", index);
      new CommandLineInterpreter().Execute("GetProjectProperty", actionCallingContext);
      actionCallingContext.GetParameter("value", ref value);
      return value;
    }

    [DeclareAction("GetProjectProperty")]
    public void Action(string id, string index, out string value)
    {
      string pathTemplate = Path.Combine(PathMap.SubstitutePath("$(MD_SCRIPTS)"),
          "GetProjectProperty", "GetProjectProperty_Template.xml");
      string pathScheme = Path.Combine(PathMap.SubstitutePath("$(MD_SCRIPTS)"),
          "GetProjectProperty", "GetProjectProperty_Scheme.xml");

      bool isUserDefinied = string.IsNullOrEmpty(index) || index.ToUpper().Equals("NULL");

      try
      {
        // Set scheme
        const string QUOTE = "\"";
        string content = File.ReadAllText(pathTemplate);

        if (isUserDefinied)
        {
          string isSelectedPropertyUserDef =
            @"<Setting name=" + QUOTE + "SelectedPropertyIdUserDef" + QUOTE + " type=" + QUOTE + "string" + QUOTE + ">" +
            "<Val>" + id + "</Val>" +
            "</Setting>";

          content = content.Replace("GetProjectProperty_ID_SelectedPropertyId", "0");
          content = content.Replace("IsSelectedPropertyIdUserDef", isSelectedPropertyUserDef);
          content = content.Replace("GetProjectProperty_INDEX", "0");
          content = content.Replace("GetProjectProperty_ID", id);
        }
        else
        {
          content = content.Replace("GetProjectProperty_ID_SelectedPropertyId", id);
          content = content.Replace("IsSelectedPropertyIdUserDef", "");
          content = content.Replace("GetProjectProperty_INDEX", index);
          content = content.Replace("GetProjectProperty_ID", id);
        }

        File.WriteAllText(pathScheme, content);

        new Settings().ReadSettings(pathScheme);

        string pathOutput = Path.Combine(
            PathMap.SubstitutePath("$(MD_SCRIPTS)"), "GetProjectProperty",
            "GetProjectProperty_Output.txt");

        // Export
        ActionCallingContext actionCallingContext = new ActionCallingContext();
        actionCallingContext.AddParameter("configscheme", "GetProjectProperty");
        actionCallingContext.AddParameter("destinationfile", pathOutput);
        actionCallingContext.AddParameter("language", "de_DE");
        new CommandLineInterpreter().Execute("label", actionCallingContext);

        // Read
        value = File.ReadAllLines(pathOutput)[0];
      }
      catch (Exception exception)
      {
        MessageBox.Show(exception.Message, "GetProjectProperty", MessageBoxButtons.OK,
            MessageBoxIcon.Error);
        value = "[Error]";
      }

    }
  }
}

 

Das Script findet Ihr wie gewohnt auf GitHub.

Von |2026-07-23T12:50:02+02:002018-03-13|EPLAN, EPLAN-Scripts|
Nach oben