Beispiel #1
0
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var operation = Options switch
            {
                ReloadOptions reloadOptions => ReloadAsync(reloadOptions),
                CreateOptions createOptions => CreateAsync(createOptions),
                DeleteOptions deleteOptions => DeleteAsync(deleteOptions),
                ListOptions listOptions => ListAsync(listOptions),
                AddTripLinkOptions addOptions => AddTripLinkAsync(addOptions),
                RemoveTripLinkOptions removeOptions => RemoveTripLinkAsync(removeOptions),
                _ => throw new InvalidOperationException("Invalid options type!"),
            };

            _ = Host.StopAsync();
            return(operation);
        }
Beispiel #2
0
        public async Task RemoveTripLinkAsync(RemoveTripLinkOptions options)
        {
            if (!Uri.TryCreate(options.ReportServer, UriKind.Absolute, out var url) ||
                (url.Scheme != Uri.UriSchemeHttp && url.Scheme != Uri.UriSchemeHttps))
            {
                Logger.LogError("The report server address is not valid!");
                return;
            }
            if (!Configuration.StickyConfig.TripLinks.Any(x => x.Server == url))
            {
                Logger.LogWarning("There is no TripLink registered on this address!");
                return;
            }

            await Configuration.RemoveReportServerAsync(url);
        }