去除引用common.props

This commit is contained in:
2023-11-06 19:35:59 +08:00
parent 6a2154edd9
commit c6b8dfc861
810 changed files with 3910 additions and 6695 deletions

View File

@@ -1,8 +1,6 @@
using JNPF;
using JNPF.Common.Core;
using JNPF.Common.Options;
using JNPF.EventHandler;
using OnceMi.AspNetCore.OSS;
namespace Microsoft.Extensions.DependencyInjection;
@@ -11,13 +9,13 @@ namespace Microsoft.Extensions.DependencyInjection;
/// </summary>
public static class ConfigureEventBusExtensions
{
/// <summary>
/// OSS服务配置.
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection ConfigureEventBus(this IServiceCollection services)
{
/// <summary>
/// OSS服务配置.
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection ConfigureEventBus(this IServiceCollection services)
{
// 注册EventBus服务
// 注册EventBus服务
services.AddEventBus(options =>
@@ -66,5 +64,5 @@ public static class ConfigureEventBusExtensions
services.AddConfigurableOptions<EventBusOptions>();
return services;
}
}
}

View File

@@ -1,9 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using JNPF;
using JNPF.Logging;
using Spire.Xls;
using SqlSugar;
using JNPF.Logging;
namespace Microsoft.Extensions.DependencyInjection;
@@ -12,69 +7,69 @@ namespace Microsoft.Extensions.DependencyInjection;
/// </summary>
public static class ConfigureLoggingExtensions
{
const string DATEFORMAT = "HH:mm:ss.fff";
const string DATEFORMAT = "HH:mm:ss.fff";
public static IServiceCollection ConfigureLogging(this IServiceCollection services)
{
services.AddConsoleFormatter(option =>
public static IServiceCollection ConfigureLogging(this IServiceCollection services)
{
option.MessageFormat = LoggerConsoleFormat;
}).AddFileLogging(options =>
{
options.MessageFormat = LoggerFileFormat;
options.FileNameRule = fileName => string.Format(fileName, DateTime.Now); // 每天创建一个文件
options.HandleWriteError = (writeError) => // 写入失败时启用备用文件
{
writeError.UseRollbackFileName(Path.GetFileNameWithoutExtension(writeError.CurrentFileName) + "-oops" + Path.GetExtension(writeError.CurrentFileName));
};
});
// 日志监听
// services.AddMonitorLogging(options =>
//{
// options.IgnorePropertyNames = new[] { "Byte" };
// options.IgnorePropertyTypes = new[] { typeof(byte[]) };
//});
services.AddConsoleFormatter(option =>
{
option.MessageFormat = LoggerConsoleFormat;
}).AddFileLogging(options =>
{
options.MessageFormat = LoggerFileFormat;
options.FileNameRule = fileName => string.Format(fileName, DateTime.Now); // 每天创建一个文件
options.HandleWriteError = (writeError) => // 写入失败时启用备用文件
{
writeError.UseRollbackFileName(Path.GetFileNameWithoutExtension(writeError.CurrentFileName) + "-oops" + Path.GetExtension(writeError.CurrentFileName));
};
});
// 日志监听
// services.AddMonitorLogging(options =>
//{
// options.IgnorePropertyNames = new[] { "Byte" };
// options.IgnorePropertyTypes = new[] { typeof(byte[]) };
//});
return services;
}
private static string LoggerLevelName(LogLevel level)
{
return level switch
{
LogLevel.Trace => "Trace",
LogLevel.Debug => "Debug",
LogLevel.Information => "Info",
LogLevel.Warning => "Warn",
LogLevel.Error => "Error",
LogLevel.Critical => "Crit",
_ => "None"
};
}
private static string LoggerFileFormat(LogMessage msg)
{
var txt = $"{LoggerLevelName(msg.LogLevel)} {msg.LogDateTime.ToString(DATEFORMAT)} {msg.ThreadId}# {msg.Message}";
if (msg.Exception != null)
{
//var EXCEPTION_SEPARATOR_WITHCOLOR = AppendWithColor(default, EXCEPTION_SEPARATOR, logLevelColors).ToString();
txt += $"{Environment.NewLine}{msg.Exception}";
return services;
}
return txt;
}
private static string LoggerConsoleFormat(LogMessage msg)
{
var fclr = msg.LogLevel switch
private static string LoggerLevelName(LogLevel level)
{
LogLevel.Warning => "\u001b[1m\u001b[33m",
LogLevel.Error => "\u001b[1m\u001b[31m",
_ => "\u001b[39m\u001b[22m"
};
var txt = $"{fclr}{LoggerLevelName(msg.LogLevel)}\u001b[49m \u001b[36m{msg.LogDateTime.ToString(DATEFORMAT)}\u001b[49m \u001b[39m\u001b[22m{msg.ThreadId}#\u001b[49m {fclr}{msg.Message}\u001b[49m";
if (msg.Exception != null)
{
//var EXCEPTION_SEPARATOR_WITHCOLOR = AppendWithColor(default, EXCEPTION_SEPARATOR, logLevelColors).ToString();
txt += $"{Environment.NewLine}{fclr}{msg.Exception}\u001b[49m";
return level switch
{
LogLevel.Trace => "Trace",
LogLevel.Debug => "Debug",
LogLevel.Information => "Info",
LogLevel.Warning => "Warn",
LogLevel.Error => "Error",
LogLevel.Critical => "Crit",
_ => "None"
};
}
private static string LoggerFileFormat(LogMessage msg)
{
var txt = $"{LoggerLevelName(msg.LogLevel)} {msg.LogDateTime.ToString(DATEFORMAT)} {msg.ThreadId}# {msg.Message}";
if (msg.Exception != null)
{
//var EXCEPTION_SEPARATOR_WITHCOLOR = AppendWithColor(default, EXCEPTION_SEPARATOR, logLevelColors).ToString();
txt += $"{Environment.NewLine}{msg.Exception}";
}
return txt;
}
private static string LoggerConsoleFormat(LogMessage msg)
{
var fclr = msg.LogLevel switch
{
LogLevel.Warning => "\u001b[1m\u001b[33m",
LogLevel.Error => "\u001b[1m\u001b[31m",
_ => "\u001b[39m\u001b[22m"
};
var txt = $"{fclr}{LoggerLevelName(msg.LogLevel)}\u001b[49m \u001b[36m{msg.LogDateTime.ToString(DATEFORMAT)}\u001b[49m \u001b[39m\u001b[22m{msg.ThreadId}#\u001b[49m {fclr}{msg.Message}\u001b[49m";
if (msg.Exception != null)
{
//var EXCEPTION_SEPARATOR_WITHCOLOR = AppendWithColor(default, EXCEPTION_SEPARATOR, logLevelColors).ToString();
txt += $"{Environment.NewLine}{fclr}{msg.Exception}\u001b[49m";
}
return txt;
}
return txt;
}
}

View File

@@ -1,17 +1,12 @@
using System.Globalization;
using JNPF;
using JNPF.API.Entry.Handlers;
using JNPF.Common.Core.Filter;
using JNPF.Common.Options;
using JNPF.EventHandler;
using JNPF.JsonSerialization;
using JNPF.UnifyResult;
using Microsoft.AspNetCore.HttpOverrides;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
using OnceMi.AspNetCore.OSS;
using JNPF.API.Entry.Handlers;
using JNPF.Common.Cache;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.HttpOverrides;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Microsoft.Extensions.DependencyInjection;
@@ -125,7 +120,7 @@ public static class ConfigureMvcControllerExtensions
return services;
}
public class MyNewtonsoftDateTimeJsonConverter : NewtonsoftDateTimeJsonConverter
{
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
@@ -134,20 +129,20 @@ public static class ConfigureMvcControllerExtensions
if (reader.TokenType == JsonToken.Null || string.IsNullOrEmpty(reader.Value.ToString()))
{
if (!flag)
throw new JsonSerializationException(string.Format((IFormatProvider) CultureInfo.InvariantCulture, "Cannot convert null value to {0}.", (object) objectType));
return (object) null;
throw new JsonSerializationException(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "Cannot convert null value to {0}.", (object)objectType));
return (object)null;
}
long result = 0;
if (reader.TokenType == JsonToken.Integer)
result = (long) reader.Value;
result = (long)reader.Value;
else if (reader.TokenType == JsonToken.String)
{
if (!long.TryParse((string) reader.Value, out result))
return (object) Convert.ToDateTime(reader.Value.ToString());
return reader.TokenType == JsonToken.Date ? reader.Value : throw new JsonSerializationException(string.Format((IFormatProvider) CultureInfo.InvariantCulture, "Unexpected token parsing date. Expected Integer or String, got {0}.", (object) reader.TokenType));
if (!long.TryParse((string)reader.Value, out result))
return (object)Convert.ToDateTime(reader.Value.ToString());
return reader.TokenType == JsonToken.Date ? reader.Value : throw new JsonSerializationException(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "Unexpected token parsing date. Expected Integer or String, got {0}.", (object)reader.TokenType));
}
if (result < 0L)
return (object) DateTime.Now;
return (object)DateTime.Now;
try
{
DateTime dt = Convert.ToDateTime(reader.Value.ToString());
@@ -158,7 +153,7 @@ public static class ConfigureMvcControllerExtensions
DateTimeOffset dateTimeOffset = DateTimeOffset.FromUnixTimeMilliseconds(result);
dateTimeOffset = dateTimeOffset.ToLocalTime();
DateTime dateTime = dateTimeOffset.DateTime;
return (flag ? Nullable.GetUnderlyingType(objectType) : objectType) == typeof (DateTimeOffset) ? (object) new DateTimeOffset(dateTime, TimeSpan.Zero) : (object) dateTime;
return (flag ? Nullable.GetUnderlyingType(objectType) : objectType) == typeof(DateTimeOffset) ? (object)new DateTimeOffset(dateTime, TimeSpan.Zero) : (object)dateTime;
}
}
}

View File

@@ -1,9 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using JNPF;
using JNPF;
using JNPF.DatabaseAccessor;
using JNPF.Logging;
using Spire.Xls;
using SqlSugar;
namespace Microsoft.Extensions.DependencyInjection;