-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from RapidScada/develop
Merge Develop to Master
- Loading branch information
Showing
133 changed files
with
7,586 additions
and
1,821 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
84 changes: 84 additions & 0 deletions
84
ScadaAdmin/OpenExtensions/ExtProjectTools/Code/ObjectMap.cs
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,84 @@ | ||
// Copyright (c) Rapid Software LLC. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Scada.Admin.Project; | ||
using Scada.Data.Entities; | ||
using Scada.Data.Tables; | ||
using Scada.Forms; | ||
using Scada.Lang; | ||
using Scada.Log; | ||
using System.Text; | ||
|
||
namespace Scada.Admin.Extensions.ExtProjectTools.Code | ||
{ | ||
/// <summary> | ||
/// Generates an object map of the configuration database. | ||
/// <para>Генерирует карту объектов базы конфигурации.</para> | ||
/// </summary> | ||
internal class ObjectMap | ||
{ | ||
/// <summary> | ||
/// The file name of newly created maps. | ||
/// </summary> | ||
public const string MapFileName = "ScadaAdmin_ObjectMap.txt"; | ||
|
||
private readonly ILog log; // the application log | ||
private readonly ConfigDatabase configDatabase; // the configuration database | ||
|
||
|
||
/// <summary> | ||
/// Initializes a new instance of the class. | ||
/// </summary> | ||
public ObjectMap(ILog log, ConfigDatabase configDatabase) | ||
{ | ||
this.log = log ?? throw new ArgumentNullException(nameof(log)); | ||
this.configDatabase = configDatabase ?? throw new ArgumentNullException(nameof(configDatabase)); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Writes objects recursively. | ||
/// </summary> | ||
private static void WriteChildObjects(StreamWriter writer, ITableIndex parentObjIndex, | ||
int parentObjNum, int level) | ||
{ | ||
// infinite recursion is not possible for objects | ||
foreach (Obj childObj in parentObjIndex.SelectItems(parentObjNum)) | ||
{ | ||
if (level > 0) | ||
writer.Write(new string('-', level * 2) + " "); | ||
|
||
writer.WriteLine(string.Format(CommonPhrases.EntityCaption, childObj.ObjNum, childObj.Name)); | ||
WriteChildObjects(writer, parentObjIndex, childObj.ObjNum, level + 1); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Generates an object map. | ||
/// </summary> | ||
public void Generate(string mapFileName) | ||
{ | ||
try | ||
{ | ||
using (StreamWriter writer = new(mapFileName, false, Encoding.UTF8)) | ||
{ | ||
writer.WriteLine(ExtensionPhrases.ObjectMapTitle); | ||
writer.WriteLine(new string('-', ExtensionPhrases.ObjectMapTitle.Length)); | ||
|
||
if (configDatabase.ObjTable.ItemCount == 0) | ||
writer.WriteLine(ExtensionPhrases.NoObjects); | ||
else if (configDatabase.ObjTable.TryGetIndex("ParentObjNum", out ITableIndex parentObjIndex)) | ||
WriteChildObjects(writer, parentObjIndex, 0, 0); | ||
else | ||
throw new ScadaException(CommonPhrases.IndexNotFound); | ||
} | ||
|
||
ScadaUiUtils.StartProcess(mapFileName); | ||
} | ||
catch (Exception ex) | ||
{ | ||
log.HandleError(ex, ExtensionPhrases.GenerateObjectMapError); | ||
} | ||
} | ||
} | ||
} |
185 changes: 91 additions & 94 deletions
185
ScadaAdmin/OpenExtensions/ExtProjectTools/Controls/CtrlMainMenu.Designer.cs
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.