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
f803f268
Commit
f803f268
authored
Jan 20, 2022
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微调
parent
241f5a3f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
19 deletions
+92
-19
performance/Performance.Infrastructure/Extensions/Extensions.TimeStamp.cs
+54
-0
performance/Performance.Services/OnlineExcel/Model/EpChanage.cs
+1
-0
performance/Performance.Services/OnlineExcel/Model/ExcelSheetInfo.cs
+25
-0
performance/Performance.Services/OnlineExcel/OnlineExcelService.Read.cs
+7
-18
performance/Performance.Services/OnlineExcel/OnlineExcelService.Write.cs
+5
-1
No files found.
performance/Performance.Infrastructure/Extensions/Extensions.TimeStamp.cs
0 → 100644
View file @
f803f268
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.Infrastructure
{
public
static
partial
class
UtilExtensions
{
/// <summary>
/// 时间戳计时开始时间
/// </summary>
private
static
DateTime
timeStampStartTime
=
new
DateTime
(
1970
,
1
,
1
,
0
,
0
,
0
,
DateTimeKind
.
Utc
);
/// <summary>
/// DateTime转换为10位时间戳(单位:秒)
/// </summary>
/// <param name="dateTime"></param>
/// <returns></returns>
public
static
long
ToTimeStamp
(
this
DateTime
dateTime
)
{
return
(
long
)(
dateTime
.
ToUniversalTime
()
-
timeStampStartTime
).
TotalSeconds
;
}
/// <summary>
/// DateTime转换为13位时间戳(单位:毫秒)
/// </summary>
/// <param name="dateTime"> DateTime</param>
/// <returns>13位时间戳(单位:毫秒)</returns>
public
static
long
ToLongTimeStamp
(
this
DateTime
dateTime
)
{
return
(
long
)(
dateTime
.
ToUniversalTime
()
-
timeStampStartTime
).
TotalMilliseconds
;
}
/// <summary>
/// 10位时间戳(单位:秒)转换为DateTime
/// </summary>
/// <param name="timeStamp">10位时间戳(单位:秒)</param>
/// <returns>DateTime</returns>
public
static
DateTime
ToDateTime
(
this
long
timeStamp
)
{
return
timeStampStartTime
.
AddSeconds
(
timeStamp
).
ToLocalTime
();
}
/// <summary>
/// 13位时间戳(单位:毫秒)转换为DateTime
/// </summary>
/// <param name="longTimeStamp">13位时间戳(单位:毫秒)</param>
/// <returns>DateTime</returns>
public
static
DateTime
ToDateTimeLongTimeStamp
(
this
long
longTimeStamp
)
{
return
timeStampStartTime
.
AddMilliseconds
(
longTimeStamp
).
ToLocalTime
();
}
}
}
performance/Performance.Services/OnlineExcel/Model/EpChanage.cs
View file @
f803f268
...
...
@@ -26,6 +26,7 @@ public class OperationRecord
public
class
EpChanage
{
public
string
SheetName
{
get
;
set
;
}
public
string
Version
{
get
;
set
;
}
public
OperationRecord
[]
OperationRecord
{
get
;
set
;
}
public
List
<
dynamic
>
Data
{
get
;
set
;
}
}
...
...
performance/Performance.Services/OnlineExcel/Model/ExcelSheetInfo.cs
0 → 100644
View file @
f803f268
namespace
Performance.Services.OnlineExcel
{
public
partial
class
OnlineExcelService
{
public
class
ExcelSheetInfo
{
public
string
Name
{
get
;
set
;
}
public
int
Row
{
get
;
set
;
}
public
int
Column
{
get
;
set
;
}
public
string
Version
{
get
;
set
;
}
public
string
Message
{
get
{
if
(
Row
*
Column
>
500
*
50
)
return
"数据量很大,加载需要较长时间"
;
else
if
(
Row
*
Column
>
100
*
50
)
return
"数据较多,可能需要较长加载时间"
;
return
""
;
}
}
}
}
}
\ No newline at end of file
performance/Performance.Services/OnlineExcel/OnlineExcelService.Read.cs
View file @
f803f268
...
...
@@ -2,7 +2,9 @@
using
Newtonsoft.Json
;
using
OfficeOpenXml
;
using
OfficeOpenXml.Style
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Polly
;
using
System
;
using
System.Collections.Generic
;
...
...
@@ -38,24 +40,6 @@ public OnlineExcelService(IMemoryCache cache)
{
_cache
=
cache
;
}
public
class
ExcelSheetInfo
{
public
string
Name
{
get
;
set
;
}
public
int
Row
{
get
;
set
;
}
public
int
Column
{
get
;
set
;
}
public
string
Message
{
get
{
if
(
Row
*
Column
>
500
*
50
)
return
"数据量很大,加载需要较长时间"
;
else
if
(
Row
*
Column
>
100
*
50
)
return
"数据较多,可能需要较长加载时间"
;
return
""
;
}
}
}
/// <summary>
/// 读取Sheet名称
/// </summary>
...
...
@@ -70,6 +54,9 @@ public List<ExcelSheetInfo> GetExcelSheetName(per_allot allot)
sheetNames
=
sheetNames
??
new
List
<
ExcelSheetInfo
>();
FileInfo
file
=
new
FileInfo
(
allot
.
Path
);
var
version
=
file
.
LastWriteTimeUtc
.
ToTimeStamp
();
using
(
ExcelPackage
package
=
new
ExcelPackage
(
file
))
{
foreach
(
var
sheet
in
package
.
Workbook
.
Worksheets
)
...
...
@@ -79,6 +66,7 @@ public List<ExcelSheetInfo> GetExcelSheetName(per_allot allot)
Name
=
sheet
.
Name
,
Row
=
sheet
.
Dimension
.
End
.
Row
,
Column
=
sheet
.
Dimension
.
End
.
Column
,
Version
=
version
.
ToString
(),
});
}
}
...
...
@@ -100,6 +88,7 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
return
cacheSheet
;
FileInfo
file
=
new
FileInfo
(
allot
.
Path
);
using
(
ExcelPackage
package
=
new
ExcelPackage
(
file
))
{
foreach
(
var
sheet
in
package
.
Workbook
.
Worksheets
)
...
...
performance/Performance.Services/OnlineExcel/OnlineExcelService.Write.cs
View file @
f803f268
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
using
OfficeOpenXml
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
...
...
@@ -36,6 +37,9 @@ public void WriteSheet(per_allot allot, EpChanage chanage)
{
FileInfo
file
=
new
FileInfo
(
allot
.
Path
);
if
(
file
.
LastWriteTimeUtc
.
ToTimeStamp
().
ToString
()
!=
chanage
.
Version
)
throw
new
PerformanceException
(
"您读取的文件已被其他人更改"
);
using
(
ExcelPackage
package
=
new
ExcelPackage
(
file
))
{
foreach
(
var
sheet
in
package
.
Workbook
.
Worksheets
)
...
...
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