fix: read GET parameters from request query
This commit is contained in:
@@ -102,11 +102,15 @@ namespace C4IT.F4SD
|
||||
public async Task<F4SDHelperService.DirectLink> getDirectLinkCreateTicket([FromUri] string sid = "", [FromUri] string assetname = "")
|
||||
{
|
||||
await Task.Delay(0);
|
||||
sid = GetQueryString("sid", sid);
|
||||
assetname = GetQueryString("assetname", assetname);
|
||||
return await _f4stHelperService.getDirectLinkCreateTicket(sid, assetname);
|
||||
}
|
||||
[Route("getDirectLinkF4SD"), HttpGet]
|
||||
public async Task<string> getDirectLinkF4SD([FromUri] Guid EOID, [FromUri] string Type)
|
||||
{
|
||||
EOID = GetQueryGuid("EOID", EOID);
|
||||
Type = GetQueryString("Type", Type);
|
||||
return await _f4stHelperService.getDirectLinkF4SD(EOID, Type);
|
||||
}
|
||||
|
||||
@@ -118,6 +122,11 @@ namespace C4IT.F4SD
|
||||
[FromUri] string queues = ""
|
||||
)
|
||||
{
|
||||
sid = GetQueryString("sid", sid);
|
||||
hours = GetQueryInt("hours", hours);
|
||||
queueoption = GetQueryInt("queueoption", queueoption);
|
||||
queues = GetQueryString("queues", queues);
|
||||
|
||||
var decodedPairs = ParseQueues(queues);
|
||||
|
||||
// Nun weiterreichen an Service
|
||||
@@ -133,6 +142,7 @@ namespace C4IT.F4SD
|
||||
[Route("getTicketDetails"), HttpGet]
|
||||
public async Task<cF4SDTicket> getTicketDetails([FromUri] Guid objectId)
|
||||
{
|
||||
objectId = GetQueryGuid("objectId", objectId);
|
||||
var tickets = await _f4stHelperService.getTicketDetails(new List<Guid>() { objectId });
|
||||
if (tickets.Count > 0)
|
||||
return tickets[0];
|
||||
@@ -143,6 +153,7 @@ namespace C4IT.F4SD
|
||||
[Route("getTicketHistory"), HttpGet]
|
||||
public async Task<List<cTicketJournalItem>> getTicketHistory([FromUri] Guid objectId)
|
||||
{
|
||||
objectId = GetQueryGuid("objectId", objectId);
|
||||
return await _f4stHelperService.GetJournalEntries(objectId);
|
||||
}
|
||||
|
||||
@@ -155,6 +166,12 @@ namespace C4IT.F4SD
|
||||
[FromUri] string queues = ""
|
||||
)
|
||||
{
|
||||
sid = GetQueryString("sid", sid);
|
||||
scope = GetQueryString("scope", scope);
|
||||
keys = GetQueryString("keys", keys);
|
||||
queueoption = GetQueryInt("queueoption", queueoption);
|
||||
queues = GetQueryString("queues", queues);
|
||||
|
||||
var parsedKeys = (keys ?? string.Empty)
|
||||
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(key => key.Trim())
|
||||
@@ -199,6 +216,13 @@ namespace C4IT.F4SD
|
||||
[FromUri] string queues = ""
|
||||
)
|
||||
{
|
||||
sid = GetQueryString("sid", sid);
|
||||
scope = GetQueryString("scope", scope);
|
||||
key = GetQueryString("key", key);
|
||||
count = GetQueryInt("count", count);
|
||||
queueoption = GetQueryInt("queueoption", queueoption);
|
||||
queues = GetQueryString("queues", queues);
|
||||
|
||||
var decodedQueues = ParseQueues(queues);
|
||||
return await _f4stHelperService.getTicketOverviewRelations(sid, scope, key, count, queueoption, decodedQueues);
|
||||
}
|
||||
@@ -217,6 +241,8 @@ namespace C4IT.F4SD
|
||||
public async Task<HttpResponseMessage> getPickup(string name, [FromUri] EntityEnumerationVisibilityMode mode = EntityEnumerationVisibilityMode.None, [FromUri] Int32 group = -1)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
mode = GetQueryEnum("mode", mode);
|
||||
group = GetQueryInt("group", group);
|
||||
EntityEnumeration enumerationTemp = GetEnumeration(name, mode);
|
||||
var vals = enumerationTemp.Values;
|
||||
|
||||
@@ -254,6 +280,11 @@ namespace C4IT.F4SD
|
||||
[Route("getRoleMemberships")]
|
||||
public async Task<HttpResponseMessage> getRoleMemberships([FromUri] GetRoleMembershipsRequest req)
|
||||
{
|
||||
req = req ?? new GetRoleMembershipsRequest();
|
||||
req.Id = GetQueryGuid("id", req.Id ?? Guid.Empty);
|
||||
req.Sid = GetQueryString("sid", req.Sid);
|
||||
req.Upn = GetQueryString("upn", req.Upn);
|
||||
|
||||
var filter = "";
|
||||
|
||||
if (req.Id != null && req.Id.Value != Guid.Empty)
|
||||
@@ -385,6 +416,49 @@ namespace C4IT.F4SD
|
||||
?? Guid.Empty;
|
||||
}
|
||||
|
||||
private string GetQueryString(string name, string currentValue)
|
||||
{
|
||||
var queryValue = GetQueryValue(name);
|
||||
return string.IsNullOrEmpty(queryValue) ? currentValue : queryValue;
|
||||
}
|
||||
|
||||
private int GetQueryInt(string name, int currentValue)
|
||||
{
|
||||
var queryValue = GetQueryValue(name);
|
||||
return int.TryParse(queryValue, out var parsedValue) ? parsedValue : currentValue;
|
||||
}
|
||||
|
||||
private Guid GetQueryGuid(string name, Guid currentValue)
|
||||
{
|
||||
var queryValue = GetQueryValue(name);
|
||||
return Guid.TryParse(queryValue, out var parsedValue) ? parsedValue : currentValue;
|
||||
}
|
||||
|
||||
private TEnum GetQueryEnum<TEnum>(string name, TEnum currentValue) where TEnum : struct
|
||||
{
|
||||
var queryValue = GetQueryValue(name);
|
||||
return Enum.TryParse<TEnum>(queryValue, true, out var parsedValue) ? parsedValue : currentValue;
|
||||
}
|
||||
|
||||
private string GetQueryValue(string name)
|
||||
{
|
||||
var query = Request?.RequestUri?.Query;
|
||||
if (string.IsNullOrWhiteSpace(query))
|
||||
return null;
|
||||
|
||||
foreach (var pair in query.TrimStart('?').Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
var parts = pair.Split(new[] { '=' }, 2);
|
||||
var key = WebUtility.UrlDecode(parts[0]);
|
||||
if (!string.Equals(key, name, StringComparison.OrdinalIgnoreCase))
|
||||
continue;
|
||||
|
||||
return parts.Length > 1 ? WebUtility.UrlDecode(parts[1]) : string.Empty;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<cApiM42TicketQueueInfo> ParseQueues(string queues)
|
||||
{
|
||||
return (queues ?? string.Empty)
|
||||
@@ -420,6 +494,7 @@ namespace C4IT.F4SD
|
||||
try
|
||||
{
|
||||
await Task.Delay(0);
|
||||
debug = GetQueryString("debug", debug);
|
||||
DefaultLogger.Manager.Level = debug == "1" || debug.Equals("true", StringComparison.OrdinalIgnoreCase) ? LogLevels.Debug : LogLevels.Info;
|
||||
return DefaultLogger.Manager.Level.ToString();
|
||||
}
|
||||
@@ -439,6 +514,9 @@ namespace C4IT.F4SD
|
||||
{
|
||||
try
|
||||
{
|
||||
download = GetQueryString("download", download);
|
||||
count = GetQueryInt("count", count);
|
||||
filter = GetQueryString("filter", filter);
|
||||
return _f4stHelperService.privGetLog(download, count, Request, filter);
|
||||
}
|
||||
catch (Exception E)
|
||||
|
||||
Reference in New Issue
Block a user