Commit 1b8a452a by lcx Committed by 纪旭 韦

记录过期限制异常

parent 745414c8
...@@ -14,17 +14,19 @@ public class LimitInformation ...@@ -14,17 +14,19 @@ public class LimitInformation
public class FunctionLimit public class FunctionLimit
{ {
public static LimitInformation Limit { get; } = new LimitInformation(); public static LimitInformation Limit { get; } = new LimitInformation();
public static void Init() public static void Init(NLog.Logger logger)
{ {
string message = "此网站的验证证书有问题,验证证书已过期或还未生效,请及时联系供应厂商进行维护升级。"; string message = "此网站的验证证书有问题,验证证书已过期或还未生效,请及时联系供应厂商进行维护升级。";
var filePath = Path.Combine(Environment.CurrentDirectory, "secret.key"); var filePath = Path.Combine(Environment.CurrentDirectory, "secret.key");
logger.Info(filePath);
if (!File.Exists(filePath)) if (!File.Exists(filePath))
{ {
Limit.ExpirationTime = DateTime.MinValue; Limit.ExpirationTime = DateTime.MinValue;
Limit.Remark = message; Limit.Remark = message;
return; return;
} }
string content = ReadLimitContent(filePath); string content = ReadLimitContent(filePath, logger);
logger.Info(content);
if (string.IsNullOrEmpty(content)) if (string.IsNullOrEmpty(content))
{ {
Limit.ExpirationTime = DateTime.MinValue; Limit.ExpirationTime = DateTime.MinValue;
...@@ -57,7 +59,7 @@ private static long ConvertToExpiration(string content) ...@@ -57,7 +59,7 @@ private static long ConvertToExpiration(string content)
return result; return result;
} }
private static string ReadLimitContent(string filePath) private static string ReadLimitContent(string filePath, NLog.Logger logger)
{ {
var content = ""; var content = "";
try try
...@@ -68,7 +70,7 @@ private static string ReadLimitContent(string filePath) ...@@ -68,7 +70,7 @@ private static string ReadLimitContent(string filePath)
content = reader.ReadToEnd(); content = reader.ReadToEnd();
} }
} }
catch (Exception) { } catch (Exception ex) { logger.Error(ex); }
return content; return content;
} }
......
...@@ -11,8 +11,8 @@ public class Program ...@@ -11,8 +11,8 @@ public class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
FunctionLimit.Init();
var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger(); var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
FunctionLimit.Init(logger);
try try
{ {
CreateWebHostBuilder(args).Build().Run(); CreateWebHostBuilder(args).Build().Run();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment