-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ICP CON import] Generate renaming file and use it (#1491)
```ChangeLog Добалена генерация файла переименования устройств и его применение при импорте старого ICP CON проекта; ```
- Loading branch information
1 parent
52b117e
commit 5f3e21e
Showing
7 changed files
with
246 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using EasyEPlanner.ProjectImportICP; | ||
using Eplan.EplApi.ApplicationFramework; | ||
using Eplan.EplApi.DataModel; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace EasyEPlanner | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
public class ImportIcpCreateRenamingMap : IEplAction | ||
{ | ||
~ImportIcpCreateRenamingMap() { } | ||
|
||
public bool Execute(ActionCallingContext oActionCallingContext) | ||
{ | ||
try | ||
{ | ||
Project currentProject = EProjectManager.GetInstance() | ||
.GetCurrentPrj(); | ||
if (currentProject == null) | ||
{ | ||
MessageBox.Show("Нет открытого проекта!", "EPlaner", | ||
MessageBoxButtons.OK, MessageBoxIcon.Exclamation); | ||
return true; | ||
} | ||
|
||
var data = ImportIcpWagoProject.GetMainWagoPluaData(); | ||
if (string.IsNullOrEmpty(data)) | ||
return true; | ||
|
||
var devicesImporter = new DevicesImporter(currentProject, data, false); | ||
devicesImporter.Import(); | ||
|
||
var devices = devicesImporter.ImportDevices; | ||
|
||
var outputFileDialog = new SaveFileDialog | ||
{ | ||
Title = "Сохранение карты переименования устройств", | ||
Filter = "*.txt|*.txt", | ||
FileName = $"{currentProject.ProjectName}_devs_renaming", | ||
DefaultExt = "txt", | ||
}; | ||
|
||
if (outputFileDialog.ShowDialog() == DialogResult.Cancel) | ||
{ | ||
return true; | ||
} | ||
|
||
using (var writer = new StreamWriter(outputFileDialog.FileName, false)) | ||
{ | ||
foreach (var dev in devices) | ||
{ | ||
writer.Write($"{dev.WagoType + dev.FullNumber,10} => {dev.Object,10} | {dev.Type, 3} | {dev.Number}\n"); | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
MessageBox.Show(ex.Message); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public bool OnRegister(ref string Name, ref int Ordinal) | ||
{ | ||
Name = nameof(ImportIcpCreateRenamingMap); | ||
Ordinal = 30; | ||
|
||
return true; | ||
} | ||
|
||
public void GetActionProperties(ref ActionProperties actionProperties) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.