aktueller Stand
This commit is contained in:
@@ -107,15 +107,17 @@ namespace FasdDesktopUi.Basics
|
||||
{
|
||||
try
|
||||
{
|
||||
if (selectedRelation == null)
|
||||
{
|
||||
Debug.Assert(true, "The selected relation must not be null here!");
|
||||
LogEntry("The selected relation must not be null here!", LogLevels.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
// get the identities of the selected relation
|
||||
var Identities = selectedRelation.Identities.Clone();
|
||||
if (selectedRelation == null)
|
||||
{
|
||||
Debug.Assert(true, "The selected relation must not be null here!");
|
||||
LogEntry("The selected relation must not be null here!", LogLevels.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
await EnsureUserIdentityForTicketAsync(selectedRelation);
|
||||
|
||||
// get the identities of the selected relation
|
||||
var Identities = selectedRelation.Identities.Clone();
|
||||
|
||||
// get the main indentities from all identites (normally this is the user, in a special case, where a computer was searched and found without any user activities, it could be the computer)
|
||||
var MainIdentity = Identities.FirstOrDefault(identity => identity.Class == enumFasdInformationClass.User);
|
||||
@@ -312,6 +314,87 @@ namespace FasdDesktopUi.Basics
|
||||
detailsPage = new Pages.DetailsPage.DetailsPageView();
|
||||
}, DispatcherPriority.Normal);
|
||||
}
|
||||
|
||||
private static async Task EnsureUserIdentityForTicketAsync(cF4sdApiSearchResultRelation relation)
|
||||
{
|
||||
if (relation == null || relation.Type != enumF4sdSearchResultClass.Ticket)
|
||||
return;
|
||||
|
||||
if (relation.Identities == null)
|
||||
relation.Identities = new cF4sdIdentityList();
|
||||
|
||||
var existingUsers = relation.Identities
|
||||
.Where(identity => identity.Class == enumFasdInformationClass.User)
|
||||
.ToList();
|
||||
|
||||
Guid userId = Guid.Empty;
|
||||
if (relation.Infos != null)
|
||||
{
|
||||
if (relation.Infos.TryGetValue("Sids", out var sidsValue) ||
|
||||
relation.Infos.TryGetValue("UserSid", out sidsValue))
|
||||
{
|
||||
var sids = sidsValue?.Split(',')
|
||||
.Select(v => v.Trim())
|
||||
.Where(v => !string.IsNullOrWhiteSpace(v))
|
||||
.ToList();
|
||||
|
||||
if (sids != null && sids.Count > 0)
|
||||
{
|
||||
var communication = cFasdCockpitCommunicationBase.Instance;
|
||||
if (communication != null)
|
||||
{
|
||||
relation.Infos.TryGetValue("UserDisplayName", out var userDisplayName);
|
||||
var result = await communication.GetUserSearchResults(userDisplayName, sids);
|
||||
var user = result?.Values?.FirstOrDefault()?.FirstOrDefault();
|
||||
if (user != null)
|
||||
userId = user.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (userId == Guid.Empty && relation.Infos.TryGetValue("UserAccount", out var userAccount))
|
||||
{
|
||||
relation.Infos.TryGetValue("UserDomain", out var userDomain);
|
||||
if (!string.IsNullOrWhiteSpace(userAccount))
|
||||
{
|
||||
var communication = cFasdCockpitCommunicationBase.Instance;
|
||||
if (communication != null)
|
||||
{
|
||||
userId = await communication.GetUserIdByAccount(userAccount, userDomain ?? string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (userId == Guid.Empty)
|
||||
{
|
||||
if (relation.Infos.TryGetValue("UserId", out var userIdString) ||
|
||||
relation.Infos.TryGetValue("UserGuid", out userIdString) ||
|
||||
relation.Infos.TryGetValue("UserIdentityId", out userIdString))
|
||||
{
|
||||
Guid.TryParse(userIdString, out userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (userId == Guid.Empty)
|
||||
return;
|
||||
|
||||
if (existingUsers.Count == 0 || existingUsers.Any(identity => identity.Id != userId))
|
||||
{
|
||||
relation.Identities.RemoveAll(identity => identity.Class == enumFasdInformationClass.User);
|
||||
relation.Identities.Add(new cF4sdIdentityEntry
|
||||
{
|
||||
Class = enumFasdInformationClass.User,
|
||||
Id = userId
|
||||
});
|
||||
}
|
||||
|
||||
if (relation.Infos == null)
|
||||
relation.Infos = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
relation.Infos["UserId"] = userId.ToString();
|
||||
relation.Infos["UserGuid"] = userId.ToString();
|
||||
}
|
||||
|
||||
public async Task CloseCaseAsync()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user