diff --git a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs index 2ec81d139..24db43363 100644 --- a/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs +++ b/roles/lib/files/FWO.Services/ModellingVarianceAnalysis.cs @@ -258,9 +258,10 @@ private async Task AnalyseAppZones(Management mgt, FwoOwner owner) else if (AppZoneChanged(appZone)) { RequestUpdateAppZone(appZone, mgt); - allExistingAppZones[mgt.Id] = existingAppZones; } } + + allExistingAppZones[mgt.Id] = existingAppZones; } if (existingAppZones is null || existingAppZones.Count == 0) @@ -311,13 +312,13 @@ private bool ResolveExistingAppRole(ModellingAppRole appRole, Management mgt) private bool ResolveExistingAppZone(ModellingAppZone appZone, Management mgt) { - if (allExistingAppZones.ContainsKey(mgt.Id)) + if (allExistingAppZones.TryGetValue(mgt.Id, out List? mgtAppZones)) { - existingAppZone = allExistingAppZones[mgt.Id].FirstOrDefault(_ => new AppZoneComparer().Equals(_, appZone)); + existingAppZone = mgtAppZones.FirstOrDefault(_ => new AppZoneComparer().Equals(_, appZone)); } if (existingAppZone != null) { - //Log.WriteDebug("Search AppRole", $"Found!!"); + Log.WriteDebug("Search AppZone", $"Found!!"); } return existingAppZone != null; } @@ -326,14 +327,15 @@ private bool AppZoneAlreadyRequested(ModellingAppZone appZone, Management mgt) { Log.WriteDebug("Search AppZone", $"Name: {appZone.Name}, AppId: {appZone.AppId}, Management: {mgt.Name}"); - if (alreadyCreatedAppZones.TryGetValue(mgt.Id, out List? alreadyRequestedAppZones) && alreadyRequestedAppZones.Contains(appZone, new AppZoneComparer())) - { - return true; - } - else - { - return false; - } + return ( alreadyCreatedAppZones.TryGetValue(mgt.Id, out List? alreadyRequestedAppZones) + && alreadyRequestedAppZones.Contains(appZone, new AppZoneComparer()) ); + } + private bool AppServerAlreadyRequested(ModellingAppServer appServer, Management mgt) + { + Log.WriteDebug("Search AppServer", $"Name: {appServer.Name}, AppId: {appServer.AppId}, Management: {mgt.Name}"); + + return ( alreadyCreatedAppServers.TryGetValue(mgt.Id, out List? alreadyRequestedAppServers) + && alreadyRequestedAppServers.Contains(appServer, new AppServerComparer()) ); } private bool AreEqual(ModellingAppServer appServer1, ModellingAppServer appServer2) @@ -342,7 +344,6 @@ private bool AreEqual(ModellingAppServer appServer1, ModellingAppServer appServe return appServer1.Name.ToLower().Trim() == appServer2Name.ToLower().Trim(); } - private bool AppRoleChanged(ModellingAppRole appRole) { newAppServers = []; @@ -617,7 +618,8 @@ private void FillGroupMembersAppZone(ModellingAppZone appZone, Management mgt) unchangedGroupMembersDuringCreate = []; foreach (ModellingAppServerWrapper appServer in newAppServers) { - (long? networkId, bool alreadyRequested) = ResolveAppServerId(appServer.Content, mgt); + bool alreadyRequested = AppServerAlreadyRequested(appServer.Content, mgt); + newGroupMembers.Add(new() { RequestAction = alreadyRequested ? RequestAction.addAfterCreation.ToString() : RequestAction.create.ToString(), @@ -626,7 +628,7 @@ private void FillGroupMembersAppZone(ModellingAppZone appZone, Management mgt) IpString = appServer.Content.Ip, IpEnd = appServer.Content.IpEnd, GroupName = appZone.IdString, - NetworkId = networkId + //NetworkId = networkId }); newCreatedGroupMembers.Add(new() { @@ -636,8 +638,14 @@ private void FillGroupMembersAppZone(ModellingAppZone appZone, Management mgt) IpString = appServer.Content.Ip, IpEnd = appServer.Content.IpEnd, GroupName = appZone.IdString, - NetworkId = networkId + //NetworkId = networkId }); + + if (!alreadyCreatedAppServers.ContainsKey(mgt.Id)) + { + alreadyCreatedAppServers.Add(mgt.Id, []); + } + alreadyCreatedAppServers[mgt.Id].Add(appServer.Content); } foreach (ModellingAppServerWrapper appServer in unchangedAppServers) { @@ -653,7 +661,6 @@ private void FillGroupMembersAppZone(ModellingAppZone appZone, Management mgt) } foreach (ModellingAppServerWrapper appServer in deletedAppServers) { - //warum unchanged hier? unchangedGroupMembersDuringCreate.Add(new() { RequestAction = RequestAction.unchanged.ToString(), diff --git a/roles/ui/files/FWO.UI/Pages/Settings/EditExtStates.razor b/roles/ui/files/FWO.UI/Pages/Settings/EditExtStates.razor index 78e72bfc9..9fa5a9b14 100644 --- a/roles/ui/files/FWO.UI/Pages/Settings/EditExtStates.razor +++ b/roles/ui/files/FWO.UI/Pages/Settings/EditExtStates.razor @@ -140,7 +140,7 @@ actExtState.Id = returnIds[0].NewId; } } - RefreshExtStates(); + await RefreshExtStates(); } CloseSelect(); }