Queues Ticketoverview
This commit is contained in:
@@ -326,7 +326,12 @@ namespace C4IT.F4SD
|
|||||||
public bool IsIncident { get; set; }
|
public bool IsIncident { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<TicketOverviewCountsResult> getTicketOverviewCounts(string sid, string scope, IEnumerable<string> keys)
|
internal async Task<TicketOverviewCountsResult> getTicketOverviewCounts(
|
||||||
|
string sid,
|
||||||
|
string scope,
|
||||||
|
IEnumerable<string> keys,
|
||||||
|
int queueoption,
|
||||||
|
List<cApiM42TicketQueueInfo> queues)
|
||||||
{
|
{
|
||||||
var CM = MethodBase.GetCurrentMethod();
|
var CM = MethodBase.GetCurrentMethod();
|
||||||
LogMethodBegin(CM);
|
LogMethodBegin(CM);
|
||||||
@@ -343,7 +348,7 @@ namespace C4IT.F4SD
|
|||||||
normalizedKeys.AddRange(TicketOverviewKeys);
|
normalizedKeys.AddRange(TicketOverviewKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
var entries = await LoadTicketOverviewEntries(sid, useRoleScope);
|
var entries = await LoadTicketOverviewEntries(sid, useRoleScope, queueoption, queues);
|
||||||
var counts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
var counts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
foreach (var key in normalizedKeys)
|
foreach (var key in normalizedKeys)
|
||||||
@@ -364,7 +369,12 @@ namespace C4IT.F4SD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<TicketOverviewCountsByRoleResult> getTicketOverviewCountsByRoles(string sid, IEnumerable<Guid> roleGuids, IEnumerable<string> keys)
|
internal async Task<TicketOverviewCountsByRoleResult> getTicketOverviewCountsByRoles(
|
||||||
|
string sid,
|
||||||
|
IEnumerable<Guid> roleGuids,
|
||||||
|
IEnumerable<string> keys,
|
||||||
|
int queueoption,
|
||||||
|
List<cApiM42TicketQueueInfo> queues)
|
||||||
{
|
{
|
||||||
var CM = MethodBase.GetCurrentMethod();
|
var CM = MethodBase.GetCurrentMethod();
|
||||||
LogMethodBegin(CM);
|
LogMethodBegin(CM);
|
||||||
@@ -384,7 +394,7 @@ namespace C4IT.F4SD
|
|||||||
if (roleIds.Count == 0)
|
if (roleIds.Count == 0)
|
||||||
return new TicketOverviewCountsByRoleResult();
|
return new TicketOverviewCountsByRoleResult();
|
||||||
|
|
||||||
var entries = await LoadTicketOverviewEntriesByRoleIds(roleIds);
|
var entries = await LoadTicketOverviewEntriesByRoleIds(roleIds, queueoption, queues);
|
||||||
var entriesByRole = entries
|
var entriesByRole = entries
|
||||||
.GroupBy(entry => entry.RecipientRoleId)
|
.GroupBy(entry => entry.RecipientRoleId)
|
||||||
.ToDictionary(group => group.Key, group => group.ToList());
|
.ToDictionary(group => group.Key, group => group.ToList());
|
||||||
@@ -422,7 +432,13 @@ namespace C4IT.F4SD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<List<TicketOverviewRelationDto>> getTicketOverviewRelations(string sid, string scope, string key, int count)
|
internal async Task<List<TicketOverviewRelationDto>> getTicketOverviewRelations(
|
||||||
|
string sid,
|
||||||
|
string scope,
|
||||||
|
string key,
|
||||||
|
int count,
|
||||||
|
int queueoption,
|
||||||
|
List<cApiM42TicketQueueInfo> queues)
|
||||||
{
|
{
|
||||||
var CM = MethodBase.GetCurrentMethod();
|
var CM = MethodBase.GetCurrentMethod();
|
||||||
LogMethodBegin(CM);
|
LogMethodBegin(CM);
|
||||||
@@ -432,7 +448,7 @@ namespace C4IT.F4SD
|
|||||||
return new List<TicketOverviewRelationDto>();
|
return new List<TicketOverviewRelationDto>();
|
||||||
|
|
||||||
var useRoleScope = string.Equals(scope, "role", StringComparison.OrdinalIgnoreCase);
|
var useRoleScope = string.Equals(scope, "role", StringComparison.OrdinalIgnoreCase);
|
||||||
var entries = await LoadTicketOverviewEntries(sid, useRoleScope);
|
var entries = await LoadTicketOverviewEntries(sid, useRoleScope, queueoption, queues);
|
||||||
|
|
||||||
var filtered = entries
|
var filtered = entries
|
||||||
.Where(entry => MatchesTicketOverviewKey(entry, key))
|
.Where(entry => MatchesTicketOverviewKey(entry, key))
|
||||||
@@ -486,7 +502,11 @@ namespace C4IT.F4SD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<TicketOverviewEntry>> LoadTicketOverviewEntries(string sid, bool useRoleScope)
|
private async Task<List<TicketOverviewEntry>> LoadTicketOverviewEntries(
|
||||||
|
string sid,
|
||||||
|
bool useRoleScope,
|
||||||
|
int queueoption,
|
||||||
|
List<cApiM42TicketQueueInfo> queues)
|
||||||
{
|
{
|
||||||
var CM = MethodBase.GetCurrentMethod();
|
var CM = MethodBase.GetCurrentMethod();
|
||||||
LogMethodBegin(CM);
|
LogMethodBegin(CM);
|
||||||
@@ -497,7 +517,7 @@ namespace C4IT.F4SD
|
|||||||
if (string.IsNullOrWhiteSpace(sid))
|
if (string.IsNullOrWhiteSpace(sid))
|
||||||
return new List<TicketOverviewEntry>();
|
return new List<TicketOverviewEntry>();
|
||||||
|
|
||||||
var filter = await BuildTicketOverviewFilterAsync(sid, useRoleScope);
|
var filter = await BuildTicketOverviewFilterAsync(sid, useRoleScope, queueoption, queues);
|
||||||
return await LoadTicketOverviewEntriesByFilter(filter);
|
return await LoadTicketOverviewEntriesByFilter(filter);
|
||||||
}
|
}
|
||||||
catch (Exception E)
|
catch (Exception E)
|
||||||
@@ -511,7 +531,10 @@ namespace C4IT.F4SD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<TicketOverviewEntry>> LoadTicketOverviewEntriesByRoleIds(IEnumerable<Guid> roleIds)
|
private async Task<List<TicketOverviewEntry>> LoadTicketOverviewEntriesByRoleIds(
|
||||||
|
IEnumerable<Guid> roleIds,
|
||||||
|
int queueoption,
|
||||||
|
List<cApiM42TicketQueueInfo> queues)
|
||||||
{
|
{
|
||||||
var CM = MethodBase.GetCurrentMethod();
|
var CM = MethodBase.GetCurrentMethod();
|
||||||
LogMethodBegin(CM);
|
LogMethodBegin(CM);
|
||||||
@@ -519,7 +542,7 @@ namespace C4IT.F4SD
|
|||||||
{
|
{
|
||||||
await Task.Delay(0);
|
await Task.Delay(0);
|
||||||
|
|
||||||
var filter = BuildTicketOverviewFilterForRoleIds(roleIds);
|
var filter = BuildTicketOverviewFilterForRoleIds(roleIds, null, queueoption, queues);
|
||||||
return await LoadTicketOverviewEntriesByFilter(filter);
|
return await LoadTicketOverviewEntriesByFilter(filter);
|
||||||
}
|
}
|
||||||
catch (Exception E)
|
catch (Exception E)
|
||||||
@@ -607,9 +630,13 @@ namespace C4IT.F4SD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> BuildTicketOverviewFilterAsync(string sid, bool useRoleScope)
|
private async Task<string> BuildTicketOverviewFilterAsync(
|
||||||
|
string sid,
|
||||||
|
bool useRoleScope,
|
||||||
|
int queueoption,
|
||||||
|
List<cApiM42TicketQueueInfo> queues)
|
||||||
{
|
{
|
||||||
var filter = BuildTicketOverviewBaseFilter();
|
var filter = BuildTicketOverviewBaseFilter(queueoption, queues);
|
||||||
|
|
||||||
if (!useRoleScope)
|
if (!useRoleScope)
|
||||||
{
|
{
|
||||||
@@ -621,7 +648,7 @@ namespace C4IT.F4SD
|
|||||||
return BuildTicketOverviewFilterForRoleIds(roleIds, filter);
|
return BuildTicketOverviewFilterForRoleIds(roleIds, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string BuildTicketOverviewBaseFilter()
|
private string BuildTicketOverviewBaseFilter(int queueoption, List<cApiM42TicketQueueInfo> queues)
|
||||||
{
|
{
|
||||||
var filter = "T(SPSCommonClassBase).State <> 204";
|
var filter = "T(SPSCommonClassBase).State <> 204";
|
||||||
|
|
||||||
@@ -636,12 +663,19 @@ namespace C4IT.F4SD
|
|||||||
filter += " AND (UsedInTypeSPSActivityTypeIncident IS NOT NULL)";
|
filter += " AND (UsedInTypeSPSActivityTypeIncident IS NOT NULL)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filter = AppendQueueFilter(filter, queueoption, queues);
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string BuildTicketOverviewFilterForRoleIds(IEnumerable<Guid> roleIds, string baseFilter = null)
|
private string BuildTicketOverviewFilterForRoleIds(
|
||||||
|
IEnumerable<Guid> roleIds,
|
||||||
|
string baseFilter = null,
|
||||||
|
int queueoption = 0,
|
||||||
|
List<cApiM42TicketQueueInfo> queues = null)
|
||||||
{
|
{
|
||||||
var filter = string.IsNullOrWhiteSpace(baseFilter) ? BuildTicketOverviewBaseFilter() : baseFilter;
|
var filter = string.IsNullOrWhiteSpace(baseFilter)
|
||||||
|
? BuildTicketOverviewBaseFilter(queueoption, queues)
|
||||||
|
: baseFilter;
|
||||||
|
|
||||||
var roleIdList = (roleIds ?? Enumerable.Empty<Guid>())
|
var roleIdList = (roleIds ?? Enumerable.Empty<Guid>())
|
||||||
.Where(id => id != Guid.Empty)
|
.Where(id => id != Guid.Empty)
|
||||||
@@ -656,6 +690,53 @@ namespace C4IT.F4SD
|
|||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string AppendQueueFilter(string filter, int queueoption, List<cApiM42TicketQueueInfo> queues)
|
||||||
|
{
|
||||||
|
if (queues != null && queues.Count > 0)
|
||||||
|
{
|
||||||
|
var escapedNames = queues
|
||||||
|
.Select(q => $"'{Escape(q.QueueName)}'")
|
||||||
|
.ToList();
|
||||||
|
var escapedIds = queues
|
||||||
|
.Select(q => $"'{Escape(q.QueueID.ToString())}'")
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
string nameList = string.Join(", ", escapedNames);
|
||||||
|
string idList = string.Join(", ", escapedIds);
|
||||||
|
|
||||||
|
switch (queueoption)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
filter +=
|
||||||
|
$" AND (" +
|
||||||
|
"Queue IS NULL" +
|
||||||
|
$" OR Queue.Name IN ({nameList})" +
|
||||||
|
$" OR Queue.ID IN ({idList})" +
|
||||||
|
")";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
filter +=
|
||||||
|
$" AND (" +
|
||||||
|
"Queue IS NOT NULL" +
|
||||||
|
$" AND (Queue.Name IN ({nameList})" +
|
||||||
|
$" OR Queue.ID IN ({idList}))" +
|
||||||
|
")";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
filter += " AND Queue IS NULL";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (queueoption == 3)
|
||||||
|
{
|
||||||
|
filter += " AND Queue IS NULL";
|
||||||
|
}
|
||||||
|
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<List<Guid>> ResolveTicketOverviewRoleIdsAsync(string sid, IEnumerable<Guid> roleGuids)
|
private async Task<List<Guid>> ResolveTicketOverviewRoleIdsAsync(string sid, IEnumerable<Guid> roleGuids)
|
||||||
{
|
{
|
||||||
var roleIds = (roleGuids ?? Enumerable.Empty<Guid>())
|
var roleIds = (roleGuids ?? Enumerable.Empty<Guid>())
|
||||||
|
|||||||
@@ -105,24 +105,7 @@ namespace C4IT.F4SD
|
|||||||
string queues = ""
|
string queues = ""
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// "HR:2a7e..." → Tuple("HR", "2a7e..."), dann UrlDecode
|
var decodedPairs = ParseQueues(queues);
|
||||||
var decodedPairs = queues
|
|
||||||
.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
|
|
||||||
.Select(part =>
|
|
||||||
{
|
|
||||||
var segments = part.Split(':');
|
|
||||||
if (segments.Length != 2)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var name = HttpUtility.UrlDecode(segments[0]);
|
|
||||||
var idStr = HttpUtility.UrlDecode(segments[1]);
|
|
||||||
|
|
||||||
return Guid.TryParse(idStr, out var guid)
|
|
||||||
? new cApiM42TicketQueueInfo { QueueName = name, QueueID = guid }
|
|
||||||
: null;
|
|
||||||
})
|
|
||||||
.Where(q => q != null)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
// Nun weiterreichen an Service
|
// Nun weiterreichen an Service
|
||||||
return await _f4stHelperService.getTicketListByUser(
|
return await _f4stHelperService.getTicketListByUser(
|
||||||
@@ -151,7 +134,13 @@ namespace C4IT.F4SD
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Route("getTicketOverviewCounts"), HttpGet]
|
[Route("getTicketOverviewCounts"), HttpGet]
|
||||||
public async Task<F4SDHelperService.TicketOverviewCountsResult> getTicketOverviewCounts(string sid, string scope = "personal", string keys = "")
|
public async Task<F4SDHelperService.TicketOverviewCountsResult> getTicketOverviewCounts(
|
||||||
|
string sid,
|
||||||
|
string scope = "personal",
|
||||||
|
string keys = "",
|
||||||
|
int queueoption = 0,
|
||||||
|
string queues = ""
|
||||||
|
)
|
||||||
{
|
{
|
||||||
var parsedKeys = (keys ?? string.Empty)
|
var parsedKeys = (keys ?? string.Empty)
|
||||||
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
@@ -159,7 +148,8 @@ namespace C4IT.F4SD
|
|||||||
.Where(key => !string.IsNullOrWhiteSpace(key))
|
.Where(key => !string.IsNullOrWhiteSpace(key))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return await _f4stHelperService.getTicketOverviewCounts(sid, scope, parsedKeys);
|
var decodedQueues = ParseQueues(queues);
|
||||||
|
return await _f4stHelperService.getTicketOverviewCounts(sid, scope, parsedKeys, queueoption, decodedQueues);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("getTicketOverviewCountsByRoles"), HttpPost]
|
[Route("getTicketOverviewCountsByRoles"), HttpPost]
|
||||||
@@ -176,13 +166,28 @@ namespace C4IT.F4SD
|
|||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return await _f4stHelperService.getTicketOverviewCountsByRoles(request?.Sid, roleGuids, parsedKeys);
|
var decodedQueues = ParseQueues(request?.Queues ?? string.Empty);
|
||||||
|
return await _f4stHelperService.getTicketOverviewCountsByRoles(
|
||||||
|
request?.Sid,
|
||||||
|
roleGuids,
|
||||||
|
parsedKeys,
|
||||||
|
request?.QueueOption ?? 0,
|
||||||
|
decodedQueues
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("getTicketOverviewRelations"), HttpGet]
|
[Route("getTicketOverviewRelations"), HttpGet]
|
||||||
public async Task<List<F4SDHelperService.TicketOverviewRelationDto>> getTicketOverviewRelations(string sid, string scope = "personal", string key = "", int count = 0)
|
public async Task<List<F4SDHelperService.TicketOverviewRelationDto>> getTicketOverviewRelations(
|
||||||
|
string sid,
|
||||||
|
string scope = "personal",
|
||||||
|
string key = "",
|
||||||
|
int count = 0,
|
||||||
|
int queueoption = 0,
|
||||||
|
string queues = ""
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return await _f4stHelperService.getTicketOverviewRelations(sid, scope, key, count);
|
var decodedQueues = ParseQueues(queues);
|
||||||
|
return await _f4stHelperService.getTicketOverviewRelations(sid, scope, key, count, queueoption, decodedQueues);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
[Route("updateActivitySolution/{objectId}"), HttpPost]
|
[Route("updateActivitySolution/{objectId}"), HttpPost]
|
||||||
@@ -271,6 +276,29 @@ namespace C4IT.F4SD
|
|||||||
public string Sid { get; set; }
|
public string Sid { get; set; }
|
||||||
public List<Guid> RoleGuids { get; set; } = new List<Guid>();
|
public List<Guid> RoleGuids { get; set; } = new List<Guid>();
|
||||||
public List<string> Keys { get; set; } = new List<string>();
|
public List<string> Keys { get; set; } = new List<string>();
|
||||||
|
public int? QueueOption { get; set; }
|
||||||
|
public string Queues { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<cApiM42TicketQueueInfo> ParseQueues(string queues)
|
||||||
|
{
|
||||||
|
return (queues ?? string.Empty)
|
||||||
|
.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.Select(part =>
|
||||||
|
{
|
||||||
|
var segments = part.Split(':');
|
||||||
|
if (segments.Length != 2)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var name = HttpUtility.UrlDecode(segments[0]);
|
||||||
|
var idStr = HttpUtility.UrlDecode(segments[1]);
|
||||||
|
|
||||||
|
return Guid.TryParse(idStr, out var guid)
|
||||||
|
? new cApiM42TicketQueueInfo { QueueName = name, QueueID = guid }
|
||||||
|
: null;
|
||||||
|
})
|
||||||
|
.Where(q => q != null)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("isAlive"), HttpGet]
|
[Route("isAlive"), HttpGet]
|
||||||
|
|||||||
Reference in New Issue
Block a user