private HElement GetDebugResponse(SessionData sessionData) { HMultipleElements ret = new HMultipleElements(); ret += new HText($"Currently Enqueued tasks: {TaskCount}"); ret += new HText($"Worker Count: {WorkerCount}"); if (TaskCount > 0) { using (_writeLock.LockRead()) { ret += new HTable((from x in _tasks select new object[] { x.Task.Method?.Name, x.Task.Target?.GetType().Name, x.Parameters.ToSeparatedValueString(), x.State, x.ExceptionThrown?.GetType().Name, x.ReturnedValue?.GetType().Name }).ToList()) { TableHeader = new string[] { "Method Name", "Target Type", "Parameters", "State", "Thrown Exception", "Returned Value" } }; } } return(ret); }
private HElement GetDebugResponse(SessionData sessionData) { HMultipleElements ret = new HMultipleElements(); ret += new HText($"Current Response Count: {StringResponses.Count} ({CurrentStringResponseCacheSize * sizeof(char)} bytes)."); if (MaximumStringResponseCacheSize > 0) { ret += new HText($"Cache Fillrate: {CurrentStringResponseCacheSize} / {MaximumStringResponseCacheSize} = {((CurrentStringResponseCacheSize / MaximumStringResponseCacheSize) * 100f):0.000}%."); string request; using (StringResponseLock.LockRead()) { if (sessionData.HttpHeadVariables.TryGetValue("key", out request)) { ret += new HButton("Back to all entries", "?all=true"); ResponseCacheEntry <string> response; if (StringResponses.TryGetValue(request, out response)) { ret += new HHeadline($"Entry '{request}'", 2); ret += new HText("Requested Times: " + response.Count); ret += new HText("Response Length: " + response.Response.Length); ret += new HText("Last Requested: " + response.LastRequestedDateTime); ret += new HText("Last Updated Times: " + response.LastUpdatedDateTime); ret += new HText("Lifetime: " + response.RefreshTime); ret += new HLine(); ret += new HText("Contents:"); ret += new HText(response.Response) { Class = "code" }; } else { ret += new HText($"The requested entry '{request}' could not be found.") { Class = "error" }; } } else if (sessionData.HttpHeadVariables.ContainsKey("all")) { ret += new HTable((from e in StringResponses select new object[] { e.Key, e.Value.Count, e.Value.Response.Length, e.Value.LastRequestedDateTime, e.Value.LastUpdatedDateTime, e.Value.RefreshTime, new HLink("Show Contents", "?key=" + e.Key.EncodeUrl()) } ).OrderByDescending(e => (int)(ulong)e[1] * (int)e[2])) { TableHeader = new string[] { "Key", "Request Count", "Response Length", "Last Request Time", "Last Updated Time", "Lifetime", "Contents" } }; } else { ret += new HButton("Show all entries (might take a long time to load)", HButton.EButtonType.button, "?all=true"); } } } return(ret); }
private IEnumerable <HElement> GetElements(SessionData sessionData) { if (!sessionData.KnownUser || !sessionData.HttpHeadVariables.ContainsKey("id")) { yield return(new HScript(ScriptCollection.GetPageReferalToX, "/")); yield break; } User user = sessionData.GetUserVariable <User>(nameof(User)); Project project = Project.Projects[sessionData.HttpHeadVariables["id"]]; if (project == null || !project.IsAccessible(user)) { yield return(new HString("Invalid Project ID")); yield return(new HButton("Back", "/")); yield break; } if (user.IsAdmin) { yield return(new HButton("Update Tasks", InstantPageResponse.AddOneTimeRedirectWithCode(nameof(ViewProject) + "?id=" + sessionData.HttpHeadVariables["id"], true, sessData => new Thread(() => { try { Project.Projects[sessionData.HttpHeadVariables["id"]].UpdateRepository(); Project.Projects[sessionData.HttpHeadVariables["id"]].UpdateTasks(); } catch (Exception e) { Logger.LogError(e.Message); } }).Start()))); } yield return(new HButton("Back", "/")); foreach (var l in project.Tasks) { if (l.TaskState == ETaskState.Closed || l.TaskState == ETaskState.Resolved || l.TaskState == ETaskState.Dummy) { continue; } string hash = Hash.GetComplexHash(); switch (l.TaskState) { case ETaskState.MaybeResolved: { HMultipleElements start = new HMultipleElements(new HText("Resolved?") { Class = "mayberesolved" }); if (l.AssignedTo != null && l.AssignedTo == user.UserName) { start += new HText("This task is assigned to you!") { Class = "assigned" } } ; yield return(new HContainer() { Elements = { start, new HText(l.Text), new HText(l.Region) { Class = "region" }, new HText(l.File + " Line: " + l.Line) { Class = "file" }, new HText(l.Version) { Class = "version" }, new JSButton("Show Context") { ID = hash + "button", DescriptionTags = $"onclick=\"document.getElementById(document.getElementById('{hash}').id).style.display = 'block';document.getElementById(document.getElementById('{hash}button').id).style.display = 'none';\"", Class = "showcontext" }, new HPlainText($"<p id='{hash}' class='source'>{project.GetLines(l.File, l.Line)}</p>") }, Class = "task" }); break; } default: yield return(new HContainer() { Elements = { new HText(l.Text), new HText(l.Region) { Class = "region" }, new HText(l.File + " Line: " + l.Line) { Class = "file" }, new HText(l.Version) { Class = "version" }, new JSButton("Show Context") { ID = hash + "button", DescriptionTags = $"onclick=\"document.getElementById(document.getElementById('{hash}').id).style.display = 'block';document.getElementById(document.getElementById('{hash}button').id).style.display = 'none';\"", Class = "showcontext" }, new HPlainText($"<p id='{hash}' class='source'>{project.GetLines(l.File, l.Line)}</p>") }, Class = "task" }); break; } } }