diff --git a/C4IT_DataHistoryProvider_Test/Config/F4SD-Global-Configuration.xml b/C4IT_DataHistoryProvider_Test/Config/F4SD-Global-Configuration.xml index abd254e..15e7965 100644 --- a/C4IT_DataHistoryProvider_Test/Config/F4SD-Global-Configuration.xml +++ b/C4IT_DataHistoryProvider_Test/Config/F4SD-Global-Configuration.xml @@ -15,6 +15,8 @@ + + diff --git a/C4IT_DataHistoryProvider_Test/Config/F4SD-Global-Configuration.xsd b/C4IT_DataHistoryProvider_Test/Config/F4SD-Global-Configuration.xsd index 07e37ef..3d01823 100644 --- a/C4IT_DataHistoryProvider_Test/Config/F4SD-Global-Configuration.xsd +++ b/C4IT_DataHistoryProvider_Test/Config/F4SD-Global-Configuration.xsd @@ -44,6 +44,14 @@ + + + + + + + + @@ -150,6 +158,22 @@ + + + + + + + + + + + + + + + + @@ -187,7 +211,7 @@ - + diff --git a/F4SD-Cockpit-ServerCore/DataHistoryCollector.cs b/F4SD-Cockpit-ServerCore/DataHistoryCollector.cs index a9863dc..4ee9172 100644 --- a/F4SD-Cockpit-ServerCore/DataHistoryCollector.cs +++ b/F4SD-Cockpit-ServerCore/DataHistoryCollector.cs @@ -606,6 +606,20 @@ namespace C4IT.DataHistoryProvider return GlobalConfig; } + public Task GetTicketExternalLinkAsync(Guid ticketId, enumTicketExternalOpenMode mode, cF4sdWebRequestInfo requestInfo, int logDeep, CancellationToken token) + { + if (M42WpmCollector == null) + { + return Task.FromResult(new cTicketExternalLinkResult + { + Success = false, + Mode = enumTicketExternalOpenMode.None + }); + } + + return M42WpmCollector.GetTicketExternalLinkAsync(ticketId, mode, requestInfo, logDeep, token); + } + private void RegisterSearchRelationProviders(IEnumerable providers) { _searchResultRelationProviders.AddRange(providers); diff --git a/F4SD-Cockpit-ServerCore/DataHistoryCollectorM42Wpm.cs b/F4SD-Cockpit-ServerCore/DataHistoryCollectorM42Wpm.cs index 46a7872..19aa0db 100644 --- a/F4SD-Cockpit-ServerCore/DataHistoryCollectorM42Wpm.cs +++ b/F4SD-Cockpit-ServerCore/DataHistoryCollectorM42Wpm.cs @@ -1574,6 +1574,49 @@ namespace C4IT.DataHistoryProvider return null; } + public async Task GetTicketExternalLinkAsync(Guid ticketId, enumTicketExternalOpenMode mode, cF4sdWebRequestInfo requestInfo, int logDeep, CancellationToken token) + { + var result = new cTicketExternalLinkResult + { + Success = false, + Mode = enumTicketExternalOpenMode.None + }; + + if (ticketId == Guid.Empty || mode == enumTicketExternalOpenMode.None) + return result; + + var ticketDetails = await GetTicketMainTableAsync(ticketId, requestInfo, logDeep + 1, token); + var ticketTable = ticketDetails?.FirstOrDefault(); + if (ticketTable?.Columns == null) + return result; + + string previewUrl = null; + if (ticketTable.Columns.TryGetValue("DirectLinkPreview", out var previewColumn)) + previewUrl = previewColumn.Values?.FirstOrDefault()?.ToString(); + + var resolvedMode = mode; + var url = previewUrl; + if (mode == enumTicketExternalOpenMode.Edit) + { + string editUrl = null; + if (ticketTable.Columns.TryGetValue("DirectLinkEdit", out var editColumn)) + editUrl = editColumn.Values?.FirstOrDefault()?.ToString(); + + if (!string.IsNullOrWhiteSpace(editUrl)) + url = editUrl; + else + resolvedMode = enumTicketExternalOpenMode.Preview; + } + + if (string.IsNullOrWhiteSpace(url)) + return result; + + result.Success = true; + result.Url = url; + result.Mode = resolvedMode; + return result; + } + private object ConvertToF4sdType(object objVal, enumFasdValueType ValueType) { try diff --git a/F4SD-Cockpit-ServerCore/DataHistoryConfigGolabalParameters.cs b/F4SD-Cockpit-ServerCore/DataHistoryConfigGolabalParameters.cs index 5314715..05d1632 100644 --- a/F4SD-Cockpit-ServerCore/DataHistoryConfigGolabalParameters.cs +++ b/F4SD-Cockpit-ServerCore/DataHistoryConfigGolabalParameters.cs @@ -472,6 +472,16 @@ namespace C4IT.DataHistoryProvider , "NotesMandatory" , "" ); + RetVal |= DoXmlInsertElement(XmlRoot + , "TicketConfiguration" + , "UseSimplifiedCaseCompletionDialog" + , "" + ); + RetVal |= DoXmlInsertElement(XmlRoot + , "TicketConfiguration" + , "SimplifiedCaseCompletionTicketOpenMode" + , $"" + ); RetVal |= DoXmlInsertElement(XmlRoot , "TicketConfiguration" , "ShowOverview" diff --git a/F4SDwebService/Config/F4SD-Global-Configuration.xml b/F4SDwebService/Config/F4SD-Global-Configuration.xml index abd254e..15e7965 100644 --- a/F4SDwebService/Config/F4SD-Global-Configuration.xml +++ b/F4SDwebService/Config/F4SD-Global-Configuration.xml @@ -15,6 +15,8 @@ + + diff --git a/F4SDwebService/Controllers/Matrix42/Matrix42TicketFinalization.cs b/F4SDwebService/Controllers/Matrix42/Matrix42TicketFinalization.cs index f293abb..1623221 100644 --- a/F4SDwebService/Controllers/Matrix42/Matrix42TicketFinalization.cs +++ b/F4SDwebService/Controllers/Matrix42/Matrix42TicketFinalization.cs @@ -18,32 +18,55 @@ namespace F4SDwebService.Controllers.Matrix42 public async Task Matrix42TicketFinalization([FromBody] cApiM42Ticket jsonRequest) { MethodBase CM = null; if (cLogManager.DefaultLogger.IsDebug) { CM = MethodBase.GetCurrentMethod(); LogMethodBegin(CM); } - var requestInfo = new cF4sdWebRequestInfo("Matrix42TicketFinalization", jsonRequest.Action?.ToString() + " + " + jsonRequest.Ticket?.ToString() ?? "", cAuthentication.GetUserInfo(ActionContext)); + var requestInfo = new cF4sdWebRequestInfo("Matrix42TicketFinalization", jsonRequest?.Action?.ToString() + " + " + jsonRequest?.Ticket?.ToString() ?? "", cAuthentication.GetUserInfo(ActionContext)); if (cPerformanceLogger.IsActive && requestInfo != null) { cPerformanceLogger.LogPerformanceStart(0, requestInfo.requestName, requestInfo.id, requestInfo.created); } var apiError = 0; try { + if (jsonRequest == null) + return BadRequest(); if (string.Equals(jsonRequest.StatusIdValue, "Closed", StringComparison.InvariantCultureIgnoreCase)) await WebApiApplication.Collector.M42WpmCollector.ReopenM42TicketAsync(jsonRequest, requestInfo, 1, CancellationToken.None); + + string operationResult = null; switch (jsonRequest.Action) { case enumCloseCaseTicketStatus.Save: if (jsonRequest.Ticket == null || jsonRequest.Ticket.HasValue && jsonRequest.Ticket.Equals(Guid.Empty)) - return Ok(await WebApiApplication.Collector.M42WpmCollector.CreateM42TicketAsync(jsonRequest, requestInfo, 1, CancellationToken.None)); + operationResult = await WebApiApplication.Collector.M42WpmCollector.CreateM42TicketAsync(jsonRequest, requestInfo, 1, CancellationToken.None); else - return Ok(await WebApiApplication.Collector.M42WpmCollector.UpdateM42TicketAsync(jsonRequest, requestInfo, 1, CancellationToken.None)); + operationResult = await WebApiApplication.Collector.M42WpmCollector.UpdateM42TicketAsync(jsonRequest, requestInfo, 1, CancellationToken.None); + break; case enumCloseCaseTicketStatus.Close: - return Ok(await WebApiApplication.Collector.M42WpmCollector.CloseM42TicketAsync(jsonRequest, requestInfo, 1, CancellationToken.None)); + operationResult = await WebApiApplication.Collector.M42WpmCollector.CloseM42TicketAsync(jsonRequest, requestInfo, 1, CancellationToken.None); + break; case enumCloseCaseTicketStatus.OnHold: - return Ok(await WebApiApplication.Collector.M42WpmCollector.PauseM42TicketAsync(jsonRequest, requestInfo, 1, CancellationToken.None)); + operationResult = await WebApiApplication.Collector.M42WpmCollector.PauseM42TicketAsync(jsonRequest, requestInfo, 1, CancellationToken.None); + break; case enumCloseCaseTicketStatus.Forward: - return Ok(await WebApiApplication.Collector.M42WpmCollector.ForwardM42TicketAsync(jsonRequest, requestInfo, 1, CancellationToken.None)); - - default: break; + operationResult = await WebApiApplication.Collector.M42WpmCollector.ForwardM42TicketAsync(jsonRequest, requestInfo, 1, CancellationToken.None); + break; + default: + return BadRequest(); } - return Ok(jsonRequest); + + if (operationResult == null) + return InternalServerError(); + + var ticketId = jsonRequest.Ticket; + if ((!ticketId.HasValue || ticketId.Value == Guid.Empty) && Guid.TryParse(operationResult, out var createdTicketId)) + ticketId = createdTicketId; + + if (!ticketId.HasValue || ticketId.Value == Guid.Empty) + return InternalServerError(); + + return Ok(new cTicketFinalizationResult + { + Success = true, + TicketId = ticketId + }); } catch (Exception E) { @@ -60,4 +83,4 @@ namespace F4SDwebService.Controllers.Matrix42 return BadRequest(); } } -} \ No newline at end of file +} diff --git a/F4SDwebService/Controllers/TicketingController.cs b/F4SDwebService/Controllers/TicketingController.cs new file mode 100644 index 0000000..be100c9 --- /dev/null +++ b/F4SDwebService/Controllers/TicketingController.cs @@ -0,0 +1,58 @@ +using C4IT.DataHistoryProvider; +using C4IT.FASD.Base; +using C4IT.Logging; +using F4SDwebService; +using System; +using System.Reflection; +using System.Threading; +using System.Threading.Tasks; +using System.Web.Http; +using static C4IT.Logging.cLogManager; + +namespace FasdWebService.Controllers +{ + [RoutePrefix("api/Ticketing")] + public class TicketingController : ApiController + { + [HttpGet] + [Route("GetExternalLink")] + public async Task GetExternalLink(Guid ticketId, enumTicketExternalOpenMode mode) + { + MethodBase CM = null; if (cLogManager.DefaultLogger.IsDebug) { CM = MethodBase.GetCurrentMethod(); LogMethodBegin(CM); } + + var requestInfo = new cF4sdWebRequestInfo("Ticketing.GetExternalLink", ticketId.ToString(), cAuthentication.GetUserInfo(ActionContext)); + if (cPerformanceLogger.IsActive && requestInfo != null) { cPerformanceLogger.LogPerformanceStart(0, requestInfo.requestName, requestInfo.id, requestInfo.created); } + + var apiError = 0; + try + { + if (ticketId == Guid.Empty || mode == enumTicketExternalOpenMode.None) + return BadRequest(); + + var result = await WebApiApplication.Collector.GetTicketExternalLinkAsync(ticketId, mode, requestInfo, 1, CancellationToken.None); + return Ok(result ?? new cTicketExternalLinkResult + { + Success = false, + Mode = enumTicketExternalOpenMode.None + }); + } + catch (Exception E) + { + apiError = E.HResult; + LogException(E); + } + finally + { + if (WebApiApplication.Debug_apiTiming) WebApiApplication.SaveApiTimingEntry(requestInfo.requestName, requestInfo.id, requestInfo.created, apiError); + if (cPerformanceLogger.IsActive && requestInfo != null) { cPerformanceLogger.LogPerformanceEnd(0, requestInfo.requestName, requestInfo.id, requestInfo.created, requestInfo.created, ErrorCode: apiError); } + if (CM != null) LogMethodEnd(CM); + } + + return Ok(new cTicketExternalLinkResult + { + Success = false, + Mode = enumTicketExternalOpenMode.None + }); + } + } +} diff --git a/F4SDwebService/F4SD-Cockpit-WebService.csproj b/F4SDwebService/F4SD-Cockpit-WebService.csproj index bd323af..e34e439 100644 --- a/F4SDwebService/F4SD-Cockpit-WebService.csproj +++ b/F4SDwebService/F4SD-Cockpit-WebService.csproj @@ -324,6 +324,7 @@ + diff --git a/F4SDwebService/Publish/Config/F4SD-Global-Configuration.xml b/F4SDwebService/Publish/Config/F4SD-Global-Configuration.xml index abd254e..15e7965 100644 --- a/F4SDwebService/Publish/Config/F4SD-Global-Configuration.xml +++ b/F4SDwebService/Publish/Config/F4SD-Global-Configuration.xml @@ -15,6 +15,8 @@ + + diff --git a/F4SDwebService/Publish/Config/F4SD-Global-Configuration.xsd b/F4SDwebService/Publish/Config/F4SD-Global-Configuration.xsd index 07e37ef..3d01823 100644 --- a/F4SDwebService/Publish/Config/F4SD-Global-Configuration.xsd +++ b/F4SDwebService/Publish/Config/F4SD-Global-Configuration.xsd @@ -44,6 +44,14 @@ + + + + + + + + @@ -150,6 +158,22 @@ + + + + + + + + + + + + + + + + @@ -187,7 +211,7 @@ - +