Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
a56091b6
Commit
a56091b6
authored
Sep 02, 2021
by
黄奎
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.oytour.com/Kui2/mall.oytour.com
parents
de681e9e
675b3c19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
654 additions
and
1 deletion
+654
-1
Mall.Common.csproj
Mall.Common/Mall.Common.csproj
+1
-1
NPOIWordHelper.cs
Mall.Common/Plugin/NPOIWordHelper.cs
+350
-0
ZipHelper.cs
Mall.Common/Plugin/ZipHelper.cs
+192
-0
FirstShopListModule.cs
Mall.Module.TradePavilion/FirstShopListModule.cs
+68
-0
TradeController.cs
Mall.WebApi/Controllers/TradePavilion/TradeController.cs
+43
-0
No files found.
Mall.Common/Mall.Common.csproj
View file @
a56091b6
...
...
@@ -23,7 +23,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NPOI" Version="2.
4.1
" />
<PackageReference Include="NPOI" Version="2.
5.4
" />
<PackageReference Include="PinYinConverterCore" Version="1.0.2" />
<PackageReference Include="QRCoder" Version="1.3.9" />
<PackageReference Include="RabbitMQ.Client" Version="5.2.0" />
...
...
Mall.Common/Plugin/NPOIWordHelper.cs
0 → 100644
View file @
a56091b6
This diff is collapsed.
Click to expand it.
Mall.Common/Plugin/ZipHelper.cs
0 → 100644
View file @
a56091b6
using
ICSharpCode.SharpZipLib.Checksum
;
using
ICSharpCode.SharpZipLib.Zip
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Mall.Common.Plugin
{
/// <summary>
/// 枚举帮助类
/// </summary>
public
class
ZipHelper
{
#
region
zip
压缩
/// <summary>
/// 压缩文件或文件夹 ----无密码
/// </summary>
/// <param name="fileToZip">要压缩的路径-文件夹或者文件</param>
/// <param name="zipedFile">压缩后的文件名</param>
/// <param name="errorOut">如果失败返回失败信息</param>
/// <returns>压缩结果</returns>
public
static
bool
Zip
(
string
fileToZip
,
string
zipedFile
,
ref
string
errorOut
)
{
bool
result
=
false
;
try
{
if
(
Directory
.
Exists
(
fileToZip
))
result
=
ZipDirectory
(
fileToZip
,
zipedFile
,
null
);
else
if
(
File
.
Exists
(
fileToZip
))
result
=
ZipFile
(
fileToZip
,
zipedFile
,
null
);
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"Zip"
);
errorOut
=
ex
.
Message
;
}
return
result
;
}
/// <summary>
/// 压缩文件
/// </summary>
/// <param name="fileToZip">要压缩的文件全名</param>
/// <param name="zipedFile">压缩后的文件名</param>
/// <param name="password">密码</param>
/// <returns>压缩结果</returns>
private
static
bool
ZipFile
(
string
fileToZip
,
string
zipedFile
,
string
password
)
{
bool
result
=
true
;
ZipOutputStream
zipStream
=
null
;
FileStream
fs
=
null
;
ZipEntry
ent
=
null
;
if
(!
File
.
Exists
(
fileToZip
))
return
false
;
try
{
fs
=
File
.
OpenRead
(
fileToZip
);
byte
[]
buffer
=
new
byte
[
fs
.
Length
];
fs
.
Read
(
buffer
,
0
,
buffer
.
Length
);
fs
.
Close
();
fs
=
File
.
Create
(
zipedFile
);
zipStream
=
new
ZipOutputStream
(
fs
);
if
(!
string
.
IsNullOrEmpty
(
password
))
zipStream
.
Password
=
password
;
ent
=
new
ZipEntry
(
Path
.
GetFileName
(
fileToZip
));
zipStream
.
PutNextEntry
(
ent
);
zipStream
.
SetLevel
(
6
);
zipStream
.
Write
(
buffer
,
0
,
buffer
.
Length
);
}
catch
(
Exception
ex
)
{
result
=
false
;
throw
ex
;
}
finally
{
if
(
zipStream
!=
null
)
{
zipStream
.
Finish
();
zipStream
.
Close
();
}
if
(
ent
!=
null
)
{
ent
=
null
;
}
if
(
fs
!=
null
)
{
fs
.
Close
();
fs
.
Dispose
();
}
}
GC
.
Collect
();
GC
.
Collect
(
1
);
return
result
;
}
/// <summary>
/// 压缩文件夹
/// </summary>
/// <param name="strFile">带压缩的文件夹目录</param>
/// <param name="strZip">压缩后的文件名</param>
/// <param name="password">压缩密码</param>
/// <returns>是否压缩成功</returns>
private
static
bool
ZipDirectory
(
string
strFile
,
string
strZip
,
string
password
)
{
bool
result
=
false
;
if
(!
Directory
.
Exists
(
strFile
))
return
false
;
if
(
strFile
[
strFile
.
Length
-
1
]
!=
Path
.
DirectorySeparatorChar
)
strFile
+=
Path
.
DirectorySeparatorChar
;
ZipOutputStream
s
=
new
ZipOutputStream
(
File
.
Create
(
strZip
));
s
.
SetLevel
(
6
);
// 0 - store only to 9 - means best compression
if
(!
string
.
IsNullOrEmpty
(
password
))
s
.
Password
=
password
;
try
{
result
=
Zip
(
strFile
,
s
,
strFile
);
}
catch
(
Exception
ex
)
{
throw
ex
;
}
finally
{
s
.
Finish
();
s
.
Close
();
}
return
result
;
}
/// <summary>
/// 压缩文件夹内部方法
/// </summary>
/// <param name="strFile"></param>
/// <param name="s"></param>
/// <param name="staticFile"></param>
/// <returns></returns>
private
static
bool
Zip
(
string
strFile
,
ZipOutputStream
s
,
string
staticFile
)
{
bool
result
=
true
;
if
(
strFile
[
strFile
.
Length
-
1
]
!=
Path
.
DirectorySeparatorChar
)
strFile
+=
Path
.
DirectorySeparatorChar
;
Crc32
crc
=
new
Crc32
();
try
{
string
[]
filenames
=
Directory
.
GetFileSystemEntries
(
strFile
);
foreach
(
string
file
in
filenames
)
{
if
(
Directory
.
Exists
(
file
))
{
Zip
(
file
,
s
,
staticFile
);
}
else
// 否则直接压缩文件
{
//打开压缩文件
FileStream
fs
=
File
.
OpenRead
(
file
);
byte
[]
buffer
=
new
byte
[
fs
.
Length
];
fs
.
Read
(
buffer
,
0
,
buffer
.
Length
);
string
tempfile
=
file
.
Substring
(
staticFile
.
LastIndexOf
(
"\\"
)
+
1
);
ZipEntry
entry
=
new
ZipEntry
(
tempfile
)
{
DateTime
=
DateTime
.
Now
,
Size
=
fs
.
Length
};
fs
.
Close
();
crc
.
Reset
();
crc
.
Update
(
buffer
);
entry
.
Crc
=
crc
.
Value
;
s
.
PutNextEntry
(
entry
);
s
.
Write
(
buffer
,
0
,
buffer
.
Length
);
}
}
}
catch
(
Exception
ex
)
{
result
=
false
;
throw
ex
;
}
return
result
;
}
#
endregion
}
}
Mall.Module.TradePavilion/FirstShopListModule.cs
View file @
a56091b6
...
...
@@ -767,5 +767,73 @@ namespace Mall.Module.TradePavilion
{
return
firstShop_ListEnrollRepository
.
GetList
(
dmodel
);
}
/// <summary>
/// 榜单报名下载word 单次
/// </summary>
/// <param name="enrollId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
string
GetFirstShopEnrollWordExport
(
int
enrollId
,
int
mallBaseId
,
out
string
errorMsg
)
{
errorMsg
=
""
;
//存储的临时文件地址
string
rootBook
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
string
tempPath
=
rootBook
+
"/upfile/temporary/listenroll"
;
var
enrollModel
=
firstShop_ListEnrollRepository
.
GetEntity
(
enrollId
);
if
(
enrollModel
==
null
)
{
errorMsg
=
"报名信息不存在"
;
return
""
;
}
//获取榜单信息
var
listModel
=
firstShop_ListRepository
.
GetEntity
(
enrollModel
.
ListId
);
if
(
listModel
==
null
)
{
errorMsg
=
"榜单不存在"
;
return
""
;
}
//创建一个临时文件夹
string
tempFoldr
=
""
;
#
region
解析表单内容
if
(
string
.
IsNullOrEmpty
(
enrollModel
.
Content
))
{
errorMsg
=
"报名内容不存在,请核实后再试"
;
return
""
;
}
List
<
FormDataItem
>
elist
=
JsonHelper
.
DeserializeObject
<
List
<
FormDataItem
>>(
enrollModel
.
Content
);
elist
=
elist
.
Where
(
x
=>
x
.
CompKey
==
"ImageUploadComp"
||
x
.
CompKey
==
"VideoUploadComp"
).
ToList
();
if
(
elist
.
Any
())
{
//开始下载图片视频至临时文件
foreach
(
var
item
in
elist
)
{
var
obj
=
JsonHelper
.
DeserializeObject
<
UploadItem
>(
item
.
CompData
.
ToString
());
if
(
item
.
CompKey
==
"ImageUploadComp"
)
{
//图片处理
string
Name
=
obj
.
Name
;
foreach
(
var
qitem
in
obj
.
FileList
)
{
//FileHelper.CreateImage(); 下载腾讯云至本地
}
}
else
if
(
item
.
CompKey
==
"VideoUploadComp"
)
{
//视频处理
}
}
}
//ZipHelper.Zip(); 打包方法
#
endregion
return
""
;
}
/// <summary>
/// 榜单报名下载word
/// </summary>
/// <param name="enrollIdList"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
string
GetFirstShopEnrollWordExport
(
List
<
int
>
enrollIdList
,
int
mallBaseId
)
{
return
""
;
}
}
}
Mall.WebApi/Controllers/TradePavilion/TradeController.cs
View file @
a56091b6
...
...
@@ -2195,6 +2195,49 @@ namespace Mall.WebApi.Controllers.TradePavilion
return
ApiResult
.
Success
(
""
,
pageModel
);
}
/// <summary>
/// 报名列表word导出
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetFirstShopEnrollWordExport
()
{
var
req
=
base
.
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
EnrollId
=
parms
.
GetInt
(
"EnrollId"
,
0
);
if
(
EnrollId
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递报名id"
);
}
string
path
=
firstShopListModule
.
GetFirstShopEnrollWordExport
(
EnrollId
,
req
.
MallBaseId
,
out
string
errmsg
);
if
(
errmsg
==
""
)
{
return
ApiResult
.
Success
(
""
,
path
);
}
else
{
return
ApiResult
.
Failed
(
errmsg
);
}
}
/// <summary>
/// 报名列表word导出
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetFirstShopEnrollWordExportBatch
()
{
var
req
=
base
.
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
string
EnrollIds
=
parms
.
GetStringValue
(
"EnrollIds"
);
//报名ids 英文逗号分隔
if
(
string
.
IsNullOrEmpty
(
EnrollIds
))
{
return
ApiResult
.
ParamIsNull
(
"请传递报名ids"
);
}
List
<
int
>
EnrollIdList
=
JsonHelper
.
DeserializeObject
<
List
<
int
>>(
"["
+
EnrollIds
+
"]"
);
string
path
=
firstShopListModule
.
GetFirstShopEnrollWordExport
(
EnrollIdList
,
req
.
MallBaseId
);
return
ApiResult
.
Success
(
""
,
path
);
}
/// <summary>
/// 设置报名状态
/// </summary>
...
...
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