+ Added functions access
* Change db and added PLC_ID
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Step.Model.DatabaseModels;
|
||||
using Step.Model.DTOModels;
|
||||
using static CMS_CORE_Library.DataStructures;
|
||||
|
||||
namespace Step.Database.Controllers
|
||||
{
|
||||
@@ -43,7 +44,31 @@ namespace Step.Database.Controllers
|
||||
CanRead = f.ReadLevelMin < roleLevel,
|
||||
CanWrite = f.WriteLevelMin < roleLevel
|
||||
})
|
||||
.ToList() ;
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<DTORuntimeFunctionAccessModel> GetFunctionsMappedWithPlc(List<FunctionalityModel> functionalityList)
|
||||
{
|
||||
return dbCtx
|
||||
.FunctionsAccess
|
||||
.ToList() // Find all function access
|
||||
.Select(f => new DTORuntimeFunctionAccessModel()
|
||||
{
|
||||
Id = f.FunctionAccessId,
|
||||
Name = f.Name,
|
||||
Area = f.Area,
|
||||
Enabled = GetIfFunctionalityIsActive(functionalityList, f.PlcId, f.Enabled) // Get new enabled data
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private bool GetIfFunctionalityIsActive(List<FunctionalityModel> functionalityList, int id, bool functionAccessIsEnabled)
|
||||
{
|
||||
// If id is not mapped or function is false by database config return
|
||||
if (id == 0 || !functionAccessIsEnabled)
|
||||
return functionAccessIsEnabled;
|
||||
// Return PLC data
|
||||
return functionalityList[id - 1].isActive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user