db620d33df
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
86 lines
2.3 KiB
C#
86 lines
2.3 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.ComponentModel;
|
|
|
|
namespace Demo.Workflows.Declarative.CustomerSupport;
|
|
|
|
internal sealed class TicketingPlugin
|
|
{
|
|
private readonly Dictionary<string, TicketItem> _ticketStore = [];
|
|
|
|
[Description("Retrieve a ticket by identifier from Azure DevOps.")]
|
|
public TicketItem? GetTicket(string id)
|
|
{
|
|
Trace(nameof(GetTicket));
|
|
|
|
this._ticketStore.TryGetValue(id, out TicketItem? ticket);
|
|
|
|
return ticket;
|
|
}
|
|
|
|
[Description("Create a ticket in Azure DevOps and return its identifier.")]
|
|
public string CreateTicket(string subject, string description, string notes)
|
|
{
|
|
Trace(nameof(CreateTicket));
|
|
|
|
TicketItem ticket = new()
|
|
{
|
|
Subject = subject,
|
|
Description = description,
|
|
Notes = notes,
|
|
Id = Guid.NewGuid().ToString("N"),
|
|
};
|
|
|
|
this._ticketStore[ticket.Id] = ticket;
|
|
|
|
return ticket.Id;
|
|
}
|
|
|
|
[Description("Resolve an existing ticket in Azure DevOps given its identifier.")]
|
|
public void ResolveTicket(string id, string resolutionSummary)
|
|
{
|
|
Trace(nameof(ResolveTicket));
|
|
|
|
if (this._ticketStore.TryGetValue(id, out TicketItem? ticket))
|
|
{
|
|
ticket.Status = TicketStatus.Resolved;
|
|
}
|
|
}
|
|
|
|
[Description("Send an email notification to escalate ticket engagement.")]
|
|
public void SendNotification(string id, string email, string cc, string body)
|
|
{
|
|
Trace(nameof(SendNotification));
|
|
}
|
|
|
|
private static void Trace(string functionName)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.DarkMagenta;
|
|
try
|
|
{
|
|
Console.WriteLine($"\nFUNCTION: {functionName}");
|
|
}
|
|
finally
|
|
{
|
|
Console.ResetColor();
|
|
}
|
|
}
|
|
|
|
public enum TicketStatus
|
|
{
|
|
Open,
|
|
InProgress,
|
|
Resolved,
|
|
Closed,
|
|
}
|
|
|
|
public sealed class TicketItem
|
|
{
|
|
public TicketStatus Status { get; set; } = TicketStatus.Open;
|
|
public string Subject { get; init; } = string.Empty;
|
|
public string Id { get; init; } = string.Empty;
|
|
public string Description { get; init; } = string.Empty;
|
|
public string Notes { get; init; } = string.Empty;
|
|
}
|
|
}
|