Exemplo n.º 1
0
        public virtual async Task ExecuteAsync(HttpContext context, StartPageOptions _options, Service hostedService = null)
        {
            var s = await GetPageStringAsync();

            var serviceName = _options.ServiceName;

            if (!string.IsNullOrEmpty(_options.ApplicationName))
            {
                serviceName = _options.ApplicationName + " - " + serviceName;
            }

            s = s.Replace("{{ServiceName}}", serviceName);

            var servicesString = "<table style='width: 100 % '>";

            servicesString += "<tr><th> Service </th><th> Branch </th><th> Status </th></tr>";

            hostedService?.Children.Where(x => x.Options.Discoverable).ToList().ForEach(x =>
            {
                servicesString += "<tr><td> " + x.Options.Name + " </td><td> /" + x.Options.Branch + " </td><td> " + Enum.GetName(typeof(ServiceState), x.Status.State) + " </td></tr>";
            });

            servicesString += "</table>";

            s = s.Replace("{{Services}}", servicesString);

            await context.Response.WriteAsync(s);
        }
        public StartPageMiddleware(RequestDelegate next, IOptions <StartPageOptions> options)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _next    = next;
            _options = options.Value;
        }