aktueller stand

This commit is contained in:
Meik
2026-02-10 16:53:29 +01:00
parent 38a42964d2
commit 55459bdcf3
2 changed files with 163 additions and 58 deletions

View File

@@ -56,6 +56,8 @@ namespace C4IT.DataHistoryProvider
private const string constUrlActivityReopen = "m42Services/api/activity/reopen";
private const string constUrlGenerateApiTokenForMe = "m42Services/api/apitoken/generateapitokenforme";
private const string constUrlGenerateAccessTokenFromApiToken = "m42Services/api/apitoken/generateaccesstokenfromapitoken";
private const string constActivityTypeTicket = "SPSActivityTypeTicket";
private static readonly Guid constActivityTypeTicketTypeId = new Guid("13F950A8-F2F8-E611-E182-60E327035D31");
public const string constTableNameTicketDetails = "M42Wpm-Tickets";
@@ -3266,15 +3268,18 @@ namespace C4IT.DataHistoryProvider
ticketId = (Guid)ticketInfo.Ticket;
}
bool isTicket = false;
if (ticketInfo.AdditionalValues.TryGetValue("IsTicket", out object value) && value is bool boolValue)
if ((!ticketInfo.Ticket.HasValue || ticketInfo.Ticket.Value == Guid.Empty) && ticketId != Guid.Empty)
{
isTicket = boolValue;
ticketInfo.Ticket = ticketId;
}
var isTicket = await ResolveIsTicketAsync(ticketInfo, ticketId, requestInfo, LogDeep + 1, token);
if (token.IsCancellationRequested) return null;
if (isTicket)
{
await TransformM42TicketAsync(ticketInfo, requestInfo, LogDeep + 1, token);
}
}
var url = constUrlTicketClose;
var ticket = new cApiM42TicketClosureInfo()
@@ -3481,6 +3486,103 @@ namespace C4IT.DataHistoryProvider
return null;
}
private async Task<bool> IsTicketActivityAsync(Guid ticketId, cF4sdWebRequestInfo requestInfo, int logDeep, CancellationToken token)
{
MethodBase CM = null; if (cLogManager.DefaultLogger.IsDebug) { CM = MethodBase.GetCurrentMethod(); LogMethodBegin(CM); }
if (cPerformanceLogger.IsActive && requestInfo != null) { if (CM == null) CM = MethodBase.GetCurrentMethod(); cPerformanceLogger.LogPerformanceStart(logDeep, CM, requestInfo.id, requestInfo.created); }
var _startTime = DateTime.UtcNow;
try
{
if (ticketId == Guid.Empty)
return false;
var fragments = await GetFragmentListAsync(new cDataFragmentsParams()
{
Columns = "TypeID",
Ddname = "SPSCommonClassBase",
Pagenumber = 0,
Pagesize = 1,
Where = string.Format("[Expression-ObjectId] = '{0}'", ticketId),
Sort = "TypeID"
}, requestInfo, logDeep + 1, token);
if (token.IsCancellationRequested || fragments == null || fragments.Count == 0)
return false;
var activityTypeRawValue = fragments[0]?.TypeID;
Guid activityTypeId = Guid.Empty;
if (activityTypeRawValue is Guid guidValue)
{
activityTypeId = guidValue;
}
else
{
var activityTypeText = Convert.ToString(activityTypeRawValue);
Guid.TryParse(activityTypeText, out activityTypeId);
}
if (activityTypeId == Guid.Empty)
return false;
return activityTypeId == constActivityTypeTicketTypeId;
}
catch (Exception e)
{
LogException(e);
}
finally
{
if (cPerformanceLogger.IsActive && requestInfo != null) { cPerformanceLogger.LogPerformanceEnd(logDeep, CM, requestInfo.id, requestInfo.created, _startTime); }
if (CM != null) LogMethodEnd(CM);
}
return false;
}
private async Task<bool> ResolveIsTicketAsync(cApiM42Ticket ticketInfo, Guid ticketId, cF4sdWebRequestInfo requestInfo, int logDeep, CancellationToken token)
{
if (ticketInfo != null && ticketInfo.AdditionalValues != null)
{
object additionalValue;
if (ticketInfo.AdditionalValues.TryGetValue("IsTicket", out additionalValue) && additionalValue is bool boolValue && boolValue)
return true;
if (ticketInfo.AdditionalValues.TryGetValue("TypeID", out additionalValue) && IsTicketActivityTypeValue(additionalValue))
return true;
if (ticketInfo.AdditionalValues.TryGetValue("ActivityType", out additionalValue) && IsTicketActivityTypeValue(additionalValue))
return true;
}
if (ticketId == Guid.Empty)
return false;
return await IsTicketActivityAsync(ticketId, requestInfo, logDeep, token);
}
private static bool IsTicketActivityTypeValue(object activityTypeValue)
{
if (activityTypeValue == null)
return false;
if (activityTypeValue is Guid guidValue)
return guidValue == constActivityTypeTicketTypeId;
var activityTypeText = activityTypeValue as string;
if (string.IsNullOrWhiteSpace(activityTypeText))
activityTypeText = Convert.ToString(activityTypeValue);
if (string.IsNullOrWhiteSpace(activityTypeText))
return false;
Guid activityTypeGuid;
if (Guid.TryParse(activityTypeText, out activityTypeGuid))
return activityTypeGuid == constActivityTypeTicketTypeId;
return string.Equals(activityTypeText, constActivityTypeTicket, StringComparison.OrdinalIgnoreCase);
}
public async Task<dynamic> GetQuickCallTemplateInfoAsync(Guid quickCallId, cF4sdWebRequestInfo requestInfo, int LogDeep, CancellationToken token)
{
MethodBase CM = null; if (cLogManager.DefaultLogger.IsDebug) { CM = MethodBase.GetCurrentMethod(); LogMethodBegin(CM); }
@@ -3604,15 +3706,18 @@ namespace C4IT.DataHistoryProvider
ticketId = (Guid)ticketInfo.Ticket;
}
bool isTicket = false;
if (ticketInfo.AdditionalValues.TryGetValue("IsTicket", out object value) && value is bool boolValue)
if ((!ticketInfo.Ticket.HasValue || ticketInfo.Ticket.Value == Guid.Empty) && ticketId != Guid.Empty)
{
isTicket = boolValue;
ticketInfo.Ticket = ticketId;
}
var isTicket = await ResolveIsTicketAsync(ticketInfo, ticketId, requestInfo, LogDeep + 1, token);
if (token.IsCancellationRequested) return null;
if (isTicket)
{
await TransformM42TicketAsync(ticketInfo, requestInfo, LogDeep + 1, token);
}
}
var url = constUrlActivityPause;
var ticket = new cApiM42TicketPauseInfo()