Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
273b8d88
Commit
273b8d88
authored
Jan 11, 2022
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
记录过期限制异常
parent
9810a4f3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
performance/Performance.Api/Middlewares/FunctionLimit.cs
+6
-4
performance/Performance.Api/Program.cs
+1
-1
No files found.
performance/Performance.Api/Middlewares/FunctionLimit.cs
View file @
273b8d88
...
...
@@ -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
;
}
...
...
performance/Performance.Api/Program.cs
View file @
273b8d88
...
...
@@ -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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment