//################################################################################################ // PDF Export public void Export_PDF() { try { // MessageBox.Show(sDirPDF); // Path of the selected Eplan project sProject = Get_Project(); if (sProject == "") { return; } // Name of the Eplan project sProjectName = Get_Name(sProject); // PDF - Export file name / path sFileExport = sDirPDF + sProjectName + ".pdf"; //MessageBox.Show("Pfad : " + sFileExport); Eplan.EplApi.ApplicationFramework.ActionCallingContext aPDF = new Eplan.EplApi.ApplicationFramework.ActionCallingContext(); aPDF.AddParameter("TYPE", "PDFPROJECTSCHEME"); aPDF.AddParameter("PROJECTNAME", sProject); aPDF.AddParameter("EXPORTFILE", sFileExport); //aPDF.AddParameter("EXPORTSCHEME", "Standard"); // Optional - enter here your EPLAN Export Scheme instead of "Standard" aPDF.AddParameter("BLACKWHITE", "1"); // PDF Print as Black & White Eplan.EplApi.ApplicationFramework.CommandLineInterpreter aEx = new Eplan.EplApi.ApplicationFramework.CommandLineInterpreter(); bool sRet = aEx.Execute("export", aPDF); if (!sRet) { System.Windows.Forms.MessageBox.Show("ERROR : PDF EXPORT"); } string SUBJECT = "Eplan Schematic : " + sProjectName; string BODY = "Original file path : " + sFileExport; string ATTACH = sFileExport; MAPI mapi = new MAPI(); // Definition email adresse / Optional //string ADDRESS = "YourEmail@...."; //mapi.AddRecipientTo(ADDRESS); //string ADDRESS2 = "YourEmail@...."; //mapi.AddRecipientTo(ADDRESS2); if (File.Exists(ATTACH)) { mapi.AddAttachment(ATTACH); } mapi.SendMailPopup(SUBJECT, BODY); // show E-mail before sending // mapi.SendMailDirect(SUBJECT, BODY); // or send E-mail directly } catch { return; } }
public bool FuncToggleDT(string MODE) { //Modus festlegen string _sMode = MODE.ToUpper(); //BMK (sichtbar) ändern Eplan.EplApi.ApplicationFramework.CommandLineInterpreter oComLineInter = new Eplan.EplApi.ApplicationFramework.CommandLineInterpreter(); #region delete DT (visible) if (System.IO.File.Exists(PathMap.SubstitutePath(sExportFileName))) { try { System.IO.File.Delete(PathMap.SubstitutePath(sExportFileName)); } catch { return(false); } } //BMK (sichtbar) kann nicht direkt gesetzt werden --> Umweg über ext. Bearbeiten oComLineInter.Execute("XMExportFunctionAction /ConfigScheme:[ESS]_MacroScriptHelper_MultiLine_DT /CompleteProject:0 /Destination:" + sQuote + sExportFileName + sQuote + "/ExecutionMode:0"); //Textedatei einlesen und ändern #region read / change export file System.IO.FileInfo oFI = new System.IO.FileInfo(PathMap.SubstitutePath(sExportFileName)); if (oFI.Exists) { string sFileContentOld = ReadFile(PathMap.SubstitutePath(sExportFileName)); string sFileContentNew = string.Empty; string[] sAllLines = sFileContentOld.Split('\n'); int nLineCnt = 0; foreach (string sTempLine in sAllLines) { nLineCnt++; string[] sCols = sTempLine.Split('\t'); if (sCols.Length >= 4 && nLineCnt > 2) { //get actual visible DT string _sOldDTVisible = sCols[4]; string _sNewDTVisible = null; //add line break (ONLY, if there is NO line-break already existing in visile DT) #region add line-break if (_sMode == "ADD" && !string.IsNullOrEmpty(_sOldDTVisible)) { if (!_sOldDTVisible.Contains(@"\n")) { _sNewDTVisible = _sOldDTVisible.Replace("==", "$").Replace("++", "%"); _sNewDTVisible = _sNewDTVisible.Replace("$", @"\n$").Replace("=", @"\n=").Replace("%", @"\n%").Replace("+", @"\n+").Replace("-", @"\n-").Replace("#", @"\n#"); _sNewDTVisible = _sNewDTVisible.Replace("$", "==").Replace("%", "++"); } } #endregion //remove line-breaks #region REMOVE line-break if (_sMode == "REMOVE" && !string.IsNullOrEmpty(_sOldDTVisible)) { _sNewDTVisible = _sOldDTVisible.Replace(@"\n", string.Empty); } #endregion //correct beginning line-break if (!string.IsNullOrEmpty(_sNewDTVisible)) { if (_sNewDTVisible.StartsWith(@"\n")) { _sNewDTVisible = _sNewDTVisible.Substring(2); } } //create new-text-content for import of external editing if (_sNewDTVisible != null) { sFileContentNew = sFileContentNew + sCols[0] + "\t" + sCols[1] + "\t" + sCols[2] + "\t" + sCols[3] + "\t" + _sNewDTVisible + System.Environment.NewLine; } else { sFileContentNew = sFileContentNew + sCols[0] + "\t" + sCols[1] + "\t" + sCols[2] + "\t" + sCols[3] + "\t" + _sOldDTVisible + System.Environment.NewLine; } } else { //create new-text-content for import of external editing sFileContentNew = sFileContentNew + sTempLine + System.Environment.NewLine; } } //veränderte Textdatei schreiben WriteFile(PathMap.SubstitutePath(sExportFileName), sFileContentNew); } else { Decider eDecision = new Decider(); EnumDecisionReturn eAnswer = eDecision.Decide(Eplan.EplApi.Base.EnumDecisionType.eOkDecision, "Keine temporäre Importdatei\n'" + sExportFileName + "'\ngefunden !\n\n(Wurden passende Funktionen markiert ?)", "Eplan Decider", Eplan.EplApi.Base.EnumDecisionReturn.eOK, Eplan.EplApi.Base.EnumDecisionReturn.eOK); return(false); } #endregion //veränderte Text-Datei wieder in EPLAN einlesen oComLineInter.Execute("XMActionDCImport /DataConfigurationFile:" + sQuote + sExportFileName + sQuote + " /ProgressTitle:" + sQuote + "change visible DT..." + sQuote); #endregion return(true); }
//[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; }