fix: fallback bind legacy query parameters
This commit is contained in:
@@ -89,6 +89,45 @@ namespace C4IT.F4SD
|
||||
throw new InvalidOperationException($"Required Matrix42 service is not registered: {typeof(T).FullName}");
|
||||
}
|
||||
|
||||
private string GetQueryValue(string name)
|
||||
{
|
||||
if (Request == null)
|
||||
return null;
|
||||
|
||||
return Request.GetQueryNameValuePairs()
|
||||
.FirstOrDefault(pair => string.Equals(pair.Key, name, StringComparison.OrdinalIgnoreCase))
|
||||
.Value;
|
||||
}
|
||||
|
||||
private string BindQueryString(string value, string name)
|
||||
{
|
||||
return string.IsNullOrEmpty(value) ? GetQueryValue(name) ?? string.Empty : value;
|
||||
}
|
||||
|
||||
private int BindQueryInt32(int value, string name, int defaultValue = 0)
|
||||
{
|
||||
if (value != defaultValue)
|
||||
return value;
|
||||
|
||||
var queryValue = GetQueryValue(name);
|
||||
return int.TryParse(queryValue, out var parsed) ? parsed : value;
|
||||
}
|
||||
|
||||
private Guid BindQueryGuid(Guid value, string name)
|
||||
{
|
||||
if (value != Guid.Empty)
|
||||
return value;
|
||||
|
||||
var queryValue = GetQueryValue(name);
|
||||
return Guid.TryParse(queryValue, out var parsed) ? parsed : value;
|
||||
}
|
||||
|
||||
private TEnum BindQueryEnum<TEnum>(TEnum value, string name) where TEnum : struct
|
||||
{
|
||||
var queryValue = GetQueryValue(name);
|
||||
return Enum.TryParse<TEnum>(queryValue, true, out var parsed) ? parsed : value;
|
||||
}
|
||||
|
||||
internal IJournalService GetJournalService()
|
||||
{
|
||||
return GetRequiredService<IJournalService>();
|
||||
@@ -98,12 +137,18 @@ namespace C4IT.F4SD
|
||||
public async Task<F4SDHelperService.DirectLink> getDirectLinkCreateTicket(string sid = "", string assetname = "")
|
||||
{
|
||||
await Task.Delay(0);
|
||||
sid = BindQueryString(sid, nameof(sid));
|
||||
assetname = BindQueryString(assetname, nameof(assetname));
|
||||
|
||||
return await _f4stHelperService.getDirectLinkCreateTicket(sid, assetname)
|
||||
?? new F4SDHelperService.DirectLink();
|
||||
}
|
||||
[Route("getDirectLinkF4SD"), HttpGet]
|
||||
public async Task<string> getDirectLinkF4SD(Guid eoid, string type = "")
|
||||
{
|
||||
eoid = BindQueryGuid(eoid, nameof(eoid));
|
||||
type = BindQueryString(type, nameof(type));
|
||||
|
||||
return await _f4stHelperService.getDirectLinkF4SD(eoid, type) ?? string.Empty;
|
||||
}
|
||||
|
||||
@@ -115,6 +160,11 @@ namespace C4IT.F4SD
|
||||
string queues = ""
|
||||
)
|
||||
{
|
||||
sid = BindQueryString(sid, nameof(sid));
|
||||
hours = BindQueryInt32(hours, nameof(hours));
|
||||
queueoption = BindQueryInt32(queueoption, nameof(queueoption));
|
||||
queues = BindQueryString(queues, nameof(queues));
|
||||
|
||||
var decodedPairs = ParseQueues(queues);
|
||||
|
||||
// Nun weiterreichen an Service
|
||||
@@ -216,6 +266,10 @@ namespace C4IT.F4SD
|
||||
public async Task<EntityEnumeration> getPickup(string name = "", EntityEnumerationVisibilityMode mode = EntityEnumerationVisibilityMode.None, Int32 group = -1)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
name = BindQueryString(name, nameof(name));
|
||||
mode = BindQueryEnum(mode, nameof(mode));
|
||||
group = BindQueryInt32(group, nameof(group), -1);
|
||||
|
||||
EntityEnumeration enumerationTemp = GetEnumeration(name, mode);
|
||||
var vals = enumerationTemp.Values;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user