Skip to content

Commit

Permalink
Fix some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
realLiangshiwei committed Jun 9, 2021
1 parent 2a2821e commit 75fe55e
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 18 deletions.
15 changes: 10 additions & 5 deletions src/LogDashboard/EmbeddedFiles/LogDashboardEmbeddedFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ public class LogDashboardEmbeddedFiles
{".ttf","application/octet-stream" },
};

private static Assembly _assembly;
private static readonly Assembly Assembly;

static LogDashboardEmbeddedFiles()
{
_assembly = Assembly.GetExecutingAssembly();
Assembly = Assembly.GetExecutingAssembly();
}

public static async Task IncludeEmbeddedFile(HttpContext context, string path)
{

context.Response.OnStarting(() =>
{
if (context.Response.StatusCode == (int)HttpStatusCode.OK)
Expand All @@ -41,14 +40,20 @@ public static async Task IncludeEmbeddedFile(HttpContext context, string path)
return Task.CompletedTask;
});

using (var inputStream = _assembly.GetManifestResourceStream($"{LogDashboardConsts.Root}.{path.Substring(1)}"))
try
{
using var inputStream = Assembly.GetManifestResourceStream($"{LogDashboardConsts.Root}.{path.Substring(1)}");
if (inputStream == null)
{
throw new ArgumentException($@"Resource with name {path.Substring(1)} not found in assembly {_assembly}.");
throw new ArgumentException($@"Resource with name {path.Substring(1)} not found in assembly {Assembly}.");
}
await inputStream.CopyToAsync(context.Response.Body).ConfigureAwait(false);
}
catch (Exception e)
{
await context.Response.WriteAsync($"{e.StackTrace}");
}

}
}
}
2 changes: 1 addition & 1 deletion src/LogDashboard/Extensions/StringArrayExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static string TryGetValue(this string[] array, int index)
{
try
{
return array[index].Trim().Replace(',', '.');
return array[index].Trim();
}
catch
{
Expand Down
5 changes: 4 additions & 1 deletion src/LogDashboard/Handle/DashboardHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ private async Task<PagedResultModel<T>> GetPageResult(SearchLogInput input)

expression = expression.AndIf(!string.IsNullOrWhiteSpace(input.Level), () => { return x => x.Level == input.Level; });

expression = expression.AndIf(!string.IsNullOrWhiteSpace(input.Message), () => { return x => x.Message.Contains(input.Message); });
expression = expression.AndIf(!string.IsNullOrWhiteSpace(input.Message), () =>
{
return x => x.Message.Contains(input.Message) || x.Logger.Contains(input.Message);
});

if (input.Unique)
{
Expand Down
5 changes: 3 additions & 2 deletions src/LogDashboard/LogDashboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<Company>liangshiwei</Company>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<LangVersion>8.0</LangVersion>
<PackageVersion>1.4.7</PackageVersion>
<PackageVersion>1.4.8</PackageVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -59,7 +60,7 @@
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.78" />
<PackageReference Include="DapperExtensions.Standard" Version="1.1.0" />
Expand Down
12 changes: 6 additions & 6 deletions src/LogDashboard/LogDashboardMiddleware.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
Expand Down Expand Up @@ -116,12 +117,11 @@ public async Task InvokeAsync(HttpContext httpContext)
}
else
{
// ReSharper disable once PossibleInvalidOperationException
var bytes = new byte[(int)httpContext.Request.ContentLength];
await httpContext.Request.Body.ReadAsync(bytes, 0, (int)httpContext.Request.ContentLength);
string requestJson = Encoding.Default.GetString(bytes);

args = JsonConvert.DeserializeObject(requestJson,
using var reader = new StreamReader(httpContext.Request.Body);
var requestJson = await reader.ReadToEndAsync();

args = JsonConvert.DeserializeObject(requestJson,
method.GetParameters().First().ParameterType);

}
Expand All @@ -134,4 +134,4 @@ public async Task InvokeAsync(HttpContext httpContext)
await httpContext.Response.WriteAsync(html);
}
}
}
}
1 change: 0 additions & 1 deletion src/LogDashboard/css/bootstrap.min.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/LogDashboard/js/bootstrap.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/LogDashboard/js/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ $(function () {
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: 'auto', // Top position relative to parent
top: 'auto', // Top position relative to parent
left: 'auto' // Left position relative to parent in px
};

Expand All @@ -175,6 +175,7 @@ function loadList(page, pageSize) {
$.ajax({
method: "post",
url: mapPath + "/Dashboard/Searchlog",
contentType: "application/json",
data: JSON.stringify(params)

}).done(function (data) {
Expand Down Expand Up @@ -203,6 +204,7 @@ function doSearch() {
$.ajax({
method: "post",
url: mapPath + "/Dashboard/Searchlog",
contentType: "application/json",
data: JSON.stringify(searchInput)

}).done(function (data) {
Expand All @@ -216,6 +218,7 @@ function requestTrace(id) {
$.ajax({
method: "post",
url: mapPath + "/Dashboard/RequestTrace",
contentType: "application/json",
data: JSON.stringify({ id: id })

}).done(function (data) {
Expand All @@ -237,6 +240,7 @@ function logInfo(id, modalId, bodyId) {
$.ajax({
method: "post",
url: mapPath + "/Dashboard/LogInfo",
contentType: "application/json",
data: JSON.stringify(log)
}).done(function (html) {
$("#" + bodyId).html(html);
Expand Down

0 comments on commit 75fe55e

Please sign in to comment.