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
1dcd666a
Commit
1dcd666a
authored
Mar 18, 2024
by
ruyun.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
多线程保存数据
parent
9a0ed827
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
performance/Performance.Services/AllotCompute/EPImportDataService.cs
+18
-7
No files found.
performance/Performance.Services/AllotCompute/EPImportDataService.cs
View file @
1dcd666a
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
using
System.Drawing
;
using
System.Drawing
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Performance.Services.AllotCompute
namespace
Performance.Services.AllotCompute
{
{
...
@@ -102,7 +103,7 @@ public List<ImportData> ReadSheetData(per_allot allot)
...
@@ -102,7 +103,7 @@ public List<ImportData> ReadSheetData(per_allot allot)
Address
=
cell
.
Address
,
Address
=
cell
.
Address
,
Text
=
cell
.
Text
?.
Clean
()
??
""
,
Text
=
cell
.
Text
?.
Clean
()
??
""
,
Value
=
cell
.
Value
?.
ToString
()?.
Clean
()
??
""
,
Value
=
cell
.
Value
?.
ToString
()?.
Clean
()
??
""
,
Comment
=
cell
.
Comment
?.
Text
??
""
,
//
Comment = cell.Comment?.Text ?? "",
EndRowIndex
=
endRowIndex
,
EndRowIndex
=
endRowIndex
,
EndColIndex
=
endColIndex
,
EndColIndex
=
endColIndex
,
Sign
=
SnowFlake
.
GetInstance
().
GetUniqueShortId
(),
Sign
=
SnowFlake
.
GetInstance
().
GetUniqueShortId
(),
...
@@ -131,14 +132,24 @@ public List<ImportData> ReadSheetData(per_allot allot)
...
@@ -131,14 +132,24 @@ public List<ImportData> ReadSheetData(per_allot allot)
try
try
{
{
var
connectionString
=
_configuration
.
GetValue
(
"AppConnection:PerformanceConnectionString"
,
""
);
var
connectionString
=
_configuration
.
GetValue
(
"AppConnection:PerformanceConnectionString"
,
""
);
DapperExtensions
.
BulkInsert
(
connectionString
,
importDatas
,
tableName
:
"im_orig_data"
,
commandTimeout
:
60
*
60
*
5
);
var
tasks
=
new
List
<
Task
>();
foreach
(
var
sheetName
in
importDatas
.
Select
(
w
=>
w
.
SheetName
).
Distinct
())
{
var
task
=
Task
.
Factory
.
StartNew
(()
=>
{
var
items
=
importDatas
.
Where
(
w
=>
w
.
SheetName
==
sheetName
).
ToList
();
DapperExtensions
.
BulkInsert
(
connectionString
,
items
,
tableName
:
"im_orig_data"
,
commandTimeout
:
60
*
60
*
5
);
});
tasks
.
Add
(
task
);
}
Task
.
WaitAll
(
tasks
.
ToArray
());
_logManageService
.
WriteMsg
(
"保存基础数据"
,
$"基础数据保存完成!"
,
1
,
allot
.
ID
,
"ReceiveMessage"
,
true
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
_logManageService
.
WriteMsg
(
"保存数据失败"
,
ex
.
Message
.
ToString
(),
4
,
allot
.
ID
,
"ReceiveMessage"
,
true
);
_logManageService
.
WriteMsg
(
"保存数据失败"
,
ex
.
Message
.
ToString
(),
4
,
allot
.
ID
,
"ReceiveMessage"
,
true
);
throw
;
throw
;
}
}
_logManageService
.
WriteMsg
(
"保存基础数据"
,
$"基础数据保存完成!"
,
1
,
allot
.
ID
,
"ReceiveMessage"
,
true
);
return
importDatas
;
return
importDatas
;
}
}
...
@@ -373,10 +384,10 @@ public class ImportData
...
@@ -373,10 +384,10 @@ public class ImportData
/// </summary>
/// </summary>
public
string
ColName
{
get
;
set
;
}
public
string
ColName
{
get
;
set
;
}
/// <summary>
///
//
<summary>
/// 单元格备注
///
//
单元格备注
/// </summary>
///
//
</summary>
public
string
Comment
{
get
;
set
;
}
//
public string Comment { get; set; }
public
int
SheetType
{
get
;
set
;
}
public
int
SheetType
{
get
;
set
;
}
public
long
Version
{
get
;
set
;
}
public
long
Version
{
get
;
set
;
}
...
...
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