Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/inconsistent database usage error #120

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions api/CESMII.ProfileDesigner.DAL/LookupDataTypeDAL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ProfileTypeDefinitionDAL _profileTypeDefinitionDAL
}
public override LookupDataType CheckForExisting(LookupDataTypeModel model, UserToken userToken, bool cacheOnly = false)
{
var entityResult = base.FindByCondition(userToken, dt =>
var matches = base.FindByCondition(userToken, dt =>
(
(model.ID != 0 && model.ID != null && dt.ID == model.ID)
|| ( dt.Name == model.Name && dt.Code == model.Code
Expand All @@ -64,9 +64,17 @@ public override LookupDataType CheckForExisting(LookupDataTypeModel model, UserT
&& dt.CustomType.Profile.Version == model.CustomType.Profile.Version
&& dt.CustomType.OpcNodeId == model.CustomType.OpcNodeId
))))
, cacheOnly);
var entity = entityResult?.FirstOrDefault();
return entity;
, cacheOnly).ToList();

//2024-08-12
//Issue - FIX - must also consider owner id match unless match comes from a core nodeset (/ua or /ua/di).
// We were having scenario if user 1 imports a nodeset A and then user 2 imports the same nodeset A, some of the attribute
// custom type of user 1's nodeset are getting assigned to user B.
matches = matches.Where(x =>
x.CustomType == null ||
!x.CustomType.OwnerId.HasValue ||
x.CustomType.OwnerId.Value == userToken.UserId).ToList();
return matches == null || matches.Count == 0 ? null : matches[0];
}

public override async Task<int?> UpdateAsync(LookupDataTypeModel model, UserToken userToken)
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/OnLoginHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const onAADLogin = (setLoadingProps) => {
//get current search criteria data
setLoadingProps({
loginStatusCode: 200,
refreshLookupData: true,
refreshSearchCriteria: true,
refreshProfileSearchCriteria: true,
refreshCloudLibImporterSearchCriteria: true,
Expand Down
Loading