public class ESS_UpdateProjectsToPlatform2 { //###################################################################################### //# Upgrade all projects in selectable folder (incl. subfolders) to EPLAN Version 2.x) # //###################################################################################### //# REVISION INFOS: # //# --------------- # //# 2010-09-06: REF / 1st version of script # //# 2014-12-16: PEP / Automatische Anzeige der gestarteten Version # //# 2014-12-16: PEP / Menüeintrag Update Projects erstellt # //# 2016-11-04: Straight-Potter / Erweiterung um Schreibgeschützte Projekte # //###################################################################################### //Erstelle Menüeintrag unter Dienstprogramme [DeclareMenu] public void MyMenuFunction() { Eplan.EplApi.Gui.Menu oMenu = new Eplan.EplApi.Gui.Menu(); oMenu.AddMenuItem("Update Projects", "UpdateProjectFolderToVersion2", "Update Projects", 35284, 0, false, false); } [DeclareAction("UpdateProjectFolderToVersion2")] public void UpdateProjectFolder() { //Ermittle aktuelle Oberflächensprache Eplan.EplApi.Base.Settings oSettings = new Eplan.EplApi.Base.Settings(); string sGUILanguage = oSettings.GetStringSetting("USER.SYSTEM.GUI.LANGUAGE", 0); //Ermittle aktuelles Projektverzeichnis string sStandardProjectPath = PathMap.SubstitutePath("$(MD_PROJECTS)"); //Ermittle aktuelle Version string sVersion = PathMap.SubstitutePath("$(BIN)"); sVersion = sVersion.Substring(sVersion.Length-9,5); string sMessageText = string.Empty; string sMessageTitle = string.Empty; string sFolderDLGDescription = string.Empty; switch (sGUILanguage) { case "de_DE": sFolderDLGDescription = "Projektverzeichnis für Upgrade nach " + sVersion + " wählen:"; break; case "en_US": sFolderDLGDescription = "Select project-folder for upgrade to " + sVersion; break; default: sFolderDLGDescription = "Select project-folder for upgrade to " + sVersion; break; } //Pfad wähle für Projektupgrade FolderBrowserDialog dlgFolder = new FolderBrowserDialog(); dlgFolder.Description = sFolderDLGDescription; dlgFolder.SelectedPath = sStandardProjectPath; DialogResult oResult = dlgFolder.ShowDialog(); //Benutzerabfrage if (oResult == DialogResult.OK) { //sprachabhängiger Meldungstext #region language texts switch (sGUILanguage) { case "de_DE": sMessageText = "Alle Projekte im Verzeichnis (inkl. Unterordner!)\n\n'" + dlgFolder.SelectedPath + "'\n\nauf die EPLAN Version " + sVersion + " aktualisieren ?\n\nACHTUNG:\nDer Vorgang kann nicht rückgängig gemacht werden.\nEin Backup der Projekte wird angelegt."; sMessageTitle = "Projekte upgraden..."; break; case "en_US": sMessageText = "Upgrade all projects in folder (incl. all sub-folders!)\n\n'" + dlgFolder.SelectedPath + "'\n\nto EPLAN Version " + sVersion + "?\n\nATTENTION:\nThis action can not be undone.\nA backup of upgraded projects will be created."; sMessageTitle = "Upgrade projects..."; break; default: sMessageText = "Upgrade all projects in folder (incl. all sub-folders!)\n\n'" + dlgFolder.SelectedPath + "'\n\nto EPLAN Version " + sVersion + "?\n\nATTENTION:\nThis action can not be undone.\nA backup of upgraded projects will be created."; sMessageTitle = "Upgrade projects..."; break; } #endregion if (System.Windows.Forms.MessageBox.Show(sMessageText, sMessageTitle, MessageBoxButtons.YesNo) == DialogResult.Yes) { //Projekte in Ordner & Unterordner auf Version 2.4 upgraden Eplan.EplApi.ApplicationFramework.CommandLineInterpreter oCli = new Eplan.EplApi.ApplicationFramework.CommandLineInterpreter(); ActionCallingContext context = new ActionCallingContext(); context.AddParameter("Folder", dlgFolder.SelectedPath); context.AddParameter("UpgradeWriteProtectedProjects", "1"); bool bRetVal = oCli.Execute("XprjActionUpgradeProjects", context); } } } }