Commit 1b8a452a by lcx Committed by 纪旭 韦

记录过期限制异常

parent 745414c8
......@@ -14,17 +14,19 @@ public class LimitInformation
public class FunctionLimit
{
public static LimitInformation Limit { get; } = new LimitInformation();
public static void Init()
public static void Init(NLog.Logger logger)
{
string message = "此网站的验证证书有问题,验证证书已过期或还未生效,请及时联系供应厂商进行维护升级。";
var filePath = Path.Combine(Environment.CurrentDirectory, "secret.key");
logger.Info(filePath);
if (!File.Exists(filePath))
{
Limit.ExpirationTime = DateTime.MinValue;
Limit.Remark = message;
return;
}
string content = ReadLimitContent(filePath);
string content = ReadLimitContent(filePath, logger);
logger.Info(content);
if (string.IsNullOrEmpty(content))
{
Limit.ExpirationTime = DateTime.MinValue;
......@@ -57,7 +59,7 @@ private static long ConvertToExpiration(string content)
return result;
}
private static string ReadLimitContent(string filePath)
private static string ReadLimitContent(string filePath, NLog.Logger logger)
{
var content = "";
try
......@@ -68,7 +70,7 @@ private static string ReadLimitContent(string filePath)
content = reader.ReadToEnd();
}
}
catch (Exception) { }
catch (Exception ex) { logger.Error(ex); }
return content;
}
......@@ -99,6 +101,6 @@ private static string ReadLimitContent(string filePath)
RNKJaMz1q0GM3KPC4MuM8gPkWBRnrGZ67J3bTpgPYVVFxxyIspDG6miMATfZXnDF
OKst4raozj7kX5ghZRZCI2okvFEipVkBSwPdAB20mx5DENXOtpr2h+V/57AgD8Ua
UGTpnMMY2uONH/H/mMPny8D5LA==
-----END PRIVATE KEY-----";
-----END PRIVATE KEY-----";
}
}
......@@ -11,8 +11,8 @@ public class Program
{
public static void Main(string[] args)
{
FunctionLimit.Init();
var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
FunctionLimit.Init(logger);
try
{
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