Skip to content

Commit

Permalink
Merge pull request #60 from RapidScada/develop
Browse files Browse the repository at this point in the history
Merge Develop to Master
  • Loading branch information
2mik authored Aug 3, 2023
2 parents f5a21e0 + e896b8b commit 150e3ea
Show file tree
Hide file tree
Showing 248 changed files with 24,740 additions and 33,253 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Plugin code="PlgMain" />
<Plugin code="PlgScheme" />
<Plugin code="PlgSchBasicComp" />
<Plugin code="PlgStore" />
<Plugin code="PlgWebPage" />
</Plugins>
<PluginAssignment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Plugin code="PlgMain" />
<Plugin code="PlgScheme" />
<Plugin code="PlgSchBasicComp" />
<Plugin code="PlgStore" />
<Plugin code="PlgWebPage" />
</Plugins>
<PluginAssignment>
Expand Down
4 changes: 2 additions & 2 deletions ScadaAdmin/ScadaAdmin/ScadaAdmin/Forms/Tools/FrmConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* Author : Mikhail Shiryaev
* Created : 2022
* Modified : 2022
* Modified : 2023
*/

using Microsoft.Win32;
Expand Down Expand Up @@ -317,7 +317,7 @@ private static string BuildExtensionDescr(ExtensionLogic extensionLogic)
{
string title = string.Format("{0} {1}",
extensionLogic.Name,
extensionLogic.GetType().Assembly.GetName().Version);
extensionLogic.Version);

return new StringBuilder()
.AppendLine(title)
Expand Down
2 changes: 1 addition & 1 deletion ScadaAdmin/ScadaAdmin/ScadaAdmin/ScadaAdmin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Copyright>Copyright © 2023</Copyright>
<ApplicationIcon>lamp.ico</ApplicationIcon>
<Version>6.1.0</Version>
<AssemblyVersion>6.1.0.2</AssemblyVersion>
<AssemblyVersion>6.1.0.3</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* Author : Mikhail Shiryaev
* Created : 2021
* Modified : 2022
* Modified : 2023
*/

using Scada.Lang;
Expand Down Expand Up @@ -56,7 +56,7 @@ public static bool GetExtensionLogic(string directory, string extensionCode, IAd
message = string.Format(Locale.IsRussian ?
"Расширение {0} {1} загружено из файла {2}" :
"Extension {0} {1} loaded from file {2}",
extensionCode, assembly.GetName().Version, fileName);
extensionCode, extensionLogic.Version, fileName);
return true;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* Author : Mikhail Shiryaev
* Created : 2021
* Modified : 2022
* Modified : 2023
*/

using Scada.Admin.Config;
Expand Down Expand Up @@ -72,6 +72,17 @@ public ExtensionLogic(IAdminContext adminContext)
/// </summary>
public abstract string Descr { get; }

/// <summary>
/// Gets the extension version.
/// </summary>
public virtual string Version
{
get
{
return GetType().Assembly.GetName().Version.ToString();
}
}

/// <summary>
/// Gets the file extensions for which the extension provides an editor.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>disable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Scada.Comm.Drivers.DrvDbImport.View</RootNamespace>
<Authors>Mikhail Shiryaev</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>disable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Scada.Comm.Drivers.DrvEnronModbus.View</RootNamespace>
<Authors>Mikhail Shiryaev</Authors>
Expand Down
1 change: 1 addition & 0 deletions ScadaComm/OpenDrivers2/DrvSnmp.View/DrvSnmp.View.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>disable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Scada.Comm.Drivers.DrvSnmp.View</RootNamespace>
<Authors>Mikhail Shiryaev</Authors>
Expand Down
2 changes: 1 addition & 1 deletion ScadaComm/ScadaComm/ScadaCommApp/ScadaCommApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.1.1</Version>
<AssemblyVersion>6.1.1.0</AssemblyVersion>
<AssemblyVersion>6.1.1.1</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions ScadaComm/ScadaComm/ScadaCommCommon/Drivers/DriverFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* Author : Mikhail Shiryaev
* Created : 2020
* Modified : 2022
* Modified : 2023
*/

using Scada.Lang;
Expand Down Expand Up @@ -56,7 +56,7 @@ public static bool GetDriverLogic(string directory, string driverCode, ICommCont
message = string.Format(Locale.IsRussian ?
"Драйвер {0} {1} загружен из файла {2}" :
"Driver {0} {1} loaded from file {2}",
driverCode, assembly.GetName().Version, fileName);
driverCode, driverLogic.Version, fileName);
return true;
}
else
Expand Down Expand Up @@ -99,7 +99,7 @@ public static bool GetDriverView(string directory, string driverCode,
message = string.Format(Locale.IsRussian ?
"Загружен интерфейс драйвера {0} {1} из файла {2}" :
"Loaded driver interface {0} {1} from file {2}",
driverCode, assembly.GetName().Version, fileName);
driverCode, driverView.Version, fileName);
return true;
}
else
Expand Down
13 changes: 12 additions & 1 deletion ScadaComm/ScadaComm/ScadaCommCommon/Drivers/DriverLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* Author : Mikhail Shiryaev
* Created : 2020
* Modified : 2021
* Modified : 2023
*/

using Scada.Comm.Channels;
Expand Down Expand Up @@ -76,6 +76,17 @@ public DriverLogic(ICommContext commContext)
/// </summary>
public abstract string Code { get; }

/// <summary>
/// Gets the driver version.
/// </summary>
public virtual string Version
{
get
{
return GetType().Assembly.GetName().Version.ToString();
}
}


/// <summary>
/// Creates a new data source.
Expand Down
10 changes: 0 additions & 10 deletions ScadaComm/ScadaComm/ScadaCommCommon/Drivers/DriverView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ public DriverView()
/// </summary>
public bool CanCreateDevice { get; protected set; }

/// <summary>
/// Gets the driver name.
/// </summary>
public abstract string Name { get; }

/// <summary>
/// Gets the driver description.
/// </summary>
public abstract string Descr { get; }

/// <summary>
/// Gets the communication channel types provided by the driver.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion ScadaComm/ScadaComm/ScadaCommEngine/ScadaCommEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.1.1</Version>
<AssemblyVersion>6.1.1.0</AssemblyVersion>
<AssemblyVersion>6.1.1.1</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ScadaComm/ScadaComm/ScadaCommWkr/ScadaCommWkr.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Product>Rapid SCADA</Product>
<Copyright>Copyright © 2023</Copyright>
<Version>6.1.1</Version>
<AssemblyVersion>6.1.1.0</AssemblyVersion>
<AssemblyVersion>6.1.1.1</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions ScadaCommon/ScadaCommon/Data/Entities/EntityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* Author : Mikhail Shiryaev
* Created : 2021
* Modified : 2021
* Modified : 2023
*/

using Scada.Data.Const;
Expand Down Expand Up @@ -107,7 +107,7 @@ public static int GetDataLength(this Cnl cnl)
}

/// <summary>
/// Gets the number of channels that should be joined to display the channel value.
/// Gets the number of channels that should be joined to display a string.
/// </summary>
public static int GetJoinLength(this Cnl cnl)
{
Expand Down
13 changes: 10 additions & 3 deletions ScadaCommon/ScadaCommon/Data/Models/Right.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* Author : Mikhail Shiryaev
* Created : 2016
* Modified : 2021
* Modified : 2023
*/

using Scada.Data.Entities;
Expand All @@ -46,22 +46,29 @@ public struct Right
/// <summary>
/// Initializes a new instance of the structure.
/// </summary>
public Right(bool viewRight, bool ctrlRight)
public Right(bool viewRight, bool controlRight)
{
List = viewRight;
View = viewRight;
Control = ctrlRight;
Control = controlRight;
}

/// <summary>
/// Initializes a new instance of the structure.
/// </summary>
public Right(ObjRight objRight)
{
List = objRight.View;
View = objRight.View;
Control = objRight.Control;
}


/// <summary>
/// Gets or sets the right to display in a list.
/// </summary>
public bool List { get; set; }

/// <summary>
/// Gets or sets the right to view.
/// </summary>
Expand Down
51 changes: 41 additions & 10 deletions ScadaCommon/ScadaCommon/Data/Models/RightMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using Scada.Lang;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Scada.Data.Models
{
Expand Down Expand Up @@ -69,7 +70,7 @@ public RightMatrix(ConfigDataset configDataset)
/// <summary>
/// Enumerates parent role IDs recursively.
/// </summary>
protected IEnumerable<int> EnumerateParentRoleIDs(ITableIndex roleRef_childRoleIndex, int childRoleID,
protected static IEnumerable<int> EnumerateParentRoleIDs(ITableIndex roleRef_childRoleIndex, int childRoleID,
HashSet<int> protectionSet = null)
{
if (protectionSet == null)
Expand All @@ -93,7 +94,7 @@ protected IEnumerable<int> EnumerateParentRoleIDs(ITableIndex roleRef_childRoleI
/// <summary>
/// Enumerates child objects recursively.
/// </summary>
protected IEnumerable<Obj> EnumerateChildObjects(ITableIndex obj_parentObjIndex, int parentObjNum,
protected static IEnumerable<Obj> EnumerateChildObjects(ITableIndex obj_parentObjIndex, int parentObjNum,
HashSet<int> protectionSet = null)
{
if (protectionSet == null)
Expand All @@ -114,20 +115,38 @@ protected IEnumerable<Obj> EnumerateChildObjects(ITableIndex obj_parentObjIndex,
}
}

/// <summary>
/// Enumerates parent objects.
/// </summary>
protected static IEnumerable<Obj> EnumerateParentObjects(BaseTable<Obj> objTable, int childObjNum)
{
if (objTable.GetItem(childObjNum) is Obj childObj)
{
while (childObj.ParentObjNum != null &&
objTable.GetItem(childObj.ParentObjNum.Value) is Obj parentObj)
{
yield return parentObj;
childObj = parentObj;
}
}
}

/// <summary>
/// Add rights for the specified role.
/// </summary>
protected void AddRoleRight(ITableIndex objRight_roleIndex, ITableIndex obj_parentObjIndex,
RightByObj rightByObj, int roleID)
protected static void AddRoleRight(BaseTable<Obj> objTable, ITableIndex objRight_roleIndex,
ITableIndex obj_parentObjIndex, RightByObj rightByObj, int roleID)
{
ObjRight[] objRightArr = objRight_roleIndex.SelectItems(roleID).Cast<ObjRight>().ToArray();

// explicitly defined rights have higher priority
foreach (ObjRight objRight in objRight_roleIndex.SelectItems(roleID))
foreach (ObjRight objRight in objRightArr)
{
AddObjRight(rightByObj, objRight.ObjNum, new Right(objRight));
}

// add rights on child objects
foreach (ObjRight objRight in objRight_roleIndex.SelectItems(roleID))
foreach (ObjRight objRight in objRightArr)
{
Right right = new Right(objRight);

Expand All @@ -136,12 +155,23 @@ protected void AddRoleRight(ITableIndex objRight_roleIndex, ITableIndex obj_pare
AddObjRight(rightByObj, childObj.ObjNum, right);
}
}

// add list rights on parent objects
foreach (ObjRight objRight in objRightArr)
{
Right right = new Right { List = true };

foreach (Obj parentObj in EnumerateParentObjects(objTable, objRight.ObjNum))
{
AddObjRight(rightByObj, parentObj.ObjNum, right);
}
}
}

/// <summary>
/// Add rights for the specified object.
/// Adds rights for the specified object if they are not set.
/// </summary>
protected void AddObjRight(RightByObj rightByObj, int objNum, Right right)
protected static void AddObjRight(RightByObj rightByObj, int objNum, Right right)
{
if (!rightByObj.ContainsKey(objNum))
rightByObj.Add(objNum, right);
Expand Down Expand Up @@ -175,11 +205,12 @@ public void Init(ConfigDataset configDataset)
int roleID = role.RoleID;
RightByObj rightByObj = new RightByObj();
Matrix.Add(roleID, rightByObj);
AddRoleRight(objRight_roleIndex, obj_parentObjIndex, rightByObj, roleID);
AddRoleRight(configDataset.ObjTable, objRight_roleIndex, obj_parentObjIndex, rightByObj, roleID);

foreach (int parentRoleID in EnumerateParentRoleIDs(roleRef_childRoleIndex, roleID))
{
AddRoleRight(objRight_roleIndex, obj_parentObjIndex, rightByObj, parentRoleID);
AddRoleRight(configDataset.ObjTable, objRight_roleIndex,
obj_parentObjIndex, rightByObj, parentRoleID);
}
}
}
Expand Down
Loading

0 comments on commit 150e3ea

Please sign in to comment.