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
dce20310
Commit
dce20310
authored
Sep 03, 2021
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交代码
parent
9afa17cf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
124 additions
and
19 deletions
+124
-19
FirstShopListModule.cs
Mall.Module.TradePavilion/FirstShopListModule.cs
+124
-19
No files found.
Mall.Module.TradePavilion/FirstShopListModule.cs
View file @
dce20310
...
...
@@ -1056,26 +1056,34 @@ namespace Mall.Module.TradePavilion
string
tempFoldr
=
""
;
#
region
解析表单内容
foreach
(
var
listItem
in
listModel
)
foreach
(
var
enrollItem
in
enrollList
.
GroupBy
(
x
=>
x
.
UserId
))
{
foreach
(
var
enrollModel
in
enrollList
.
Where
(
x
=>
x
.
ListId
==
listItem
.
Id
))
//榜单下面的公司
var
companyName
=
clist
.
Where
(
x
=>
x
.
CreateBy
==
enrollItem
.
Key
).
FirstOrDefault
()?.
CompanyName
??
System
.
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
nowEnroList
=
enrollList
.
Where
(
x
=>
x
.
UserId
==
enrollItem
.
Key
);
var
templistPath
=
Path
.
Combine
(
tempPath
+
"file\\"
+
timeStr
+
"\\"
+
companyName
+
"\\"
);
//路径
if
(!
Directory
.
Exists
(
templistPath
))
{
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
())
Directory
.
CreateDirectory
(
templistPath
);
}
foreach
(
var
item
in
nowEnroList
)
{
var
enrollModel
=
listModel
.
Where
(
x
=>
x
.
Id
==
item
.
ListId
).
FirstOrDefault
();
if
(
enrollModel
!=
null
&&
enrollModel
.
Id
>
0
)
{
var
companyName
=
clist
.
Where
(
x
=>
x
.
CreateBy
==
enrollModel
.
UserId
).
FirstOrDefault
()?.
CompanyName
??
System
.
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
);
var
templistPath
=
Path
.
Combine
(
tempPath
+
"file\\"
+
timeStr
+
"\\"
+
listItem
.
ListName
+
"\\"
+
companyName
+
"\\"
);
//路径
if
(!
Directory
.
Exists
(
templistPath
))
if
(
string
.
IsNullOrEmpty
(
item
.
Content
))
{
errorMsg
=
"报名内容不存在,请核实后再试"
;
return
""
;
}
List
<
FormDataItem
>
elist
=
JsonHelper
.
DeserializeObject
<
List
<
FormDataItem
>>(
item
.
Content
);
elist
=
elist
.
Where
(
x
=>
x
.
CompKey
==
"ImageUploadComp"
||
x
.
CompKey
==
"VideoUploadComp"
).
ToList
();
var
templistnowPath
=
Path
.
Combine
(
templistPath
+
enrollModel
.
ListName
+
"\\"
);
//路径
if
(!
Directory
.
Exists
(
templistnowPath
))
{
Directory
.
CreateDirectory
(
templistPath
);
Directory
.
CreateDirectory
(
templist
now
Path
);
}
//开始下载图片视频至临时文件
foreach
(
var
itemFile
in
elist
)
{
...
...
@@ -1096,7 +1104,7 @@ namespace Mall.Module.TradePavilion
{
Bitmap
bitmap
=
new
Bitmap
(
webResponse
.
GetResponseStream
());
bitmap
.
Save
(
templistPath
+
Path
.
GetFileName
(
qitem
),
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
bitmap
.
Save
(
templist
now
Path
+
Path
.
GetFileName
(
qitem
),
System
.
Drawing
.
Imaging
.
ImageFormat
.
Jpeg
);
}
}
catch
(
Exception
ex
)
...
...
@@ -1105,12 +1113,11 @@ namespace Mall.Module.TradePavilion
}
}
}
else
if
(
itemFile
.
CompKey
==
"VideoUploadComp"
)
else
if
(
itemFile
.
CompKey
==
"VideoUploadComp"
||
itemFile
.
CompKey
==
"CommonUploadComp"
)
{
//视频处理
foreach
(
var
qitem
in
obj
.
FileList
)
{
try
{
HttpWebRequest
request
=
(
HttpWebRequest
)
WebRequest
.
Create
(
qitem
);
...
...
@@ -1133,7 +1140,7 @@ namespace Mall.Module.TradePavilion
stmMemory
.
Write
(
buffer
,
0
,
i
);
}
fileBytes
=
stmMemory
.
ToArray
();
//文件流Byte
FileStream
fs
=
new
FileStream
(
templistPath
+
Path
.
GetFileName
(
qitem
),
FileMode
.
OpenOrCreate
);
FileStream
fs
=
new
FileStream
(
templist
now
Path
+
Path
.
GetFileName
(
qitem
),
FileMode
.
OpenOrCreate
);
stmMemory
.
WriteTo
(
fs
);
stmMemory
.
Close
();
fs
.
Close
();
...
...
@@ -1149,6 +1156,104 @@ namespace Mall.Module.TradePavilion
}
}
}
//foreach (var listItem in listModel)
//{
// foreach (var enrollModel in enrollList.Where(x => x.ListId == listItem.Id))//榜单下面的公司
// {
// 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())
// {
// var companyName = clist.Where(x => x.CreateBy == enrollModel.UserId).FirstOrDefault()?.CompanyName ?? System.DateTime.Now.ToString("yyyyMMddHHmmssfff");
// var templistPath = Path.Combine(tempPath + "file\\" + timeStr + "\\" + listItem.ListName + "\\" + companyName + "\\");//路径
// if (!Directory.Exists(templistPath))
// {
// Directory.CreateDirectory(templistPath);
// }
// //开始下载图片视频至临时文件
// foreach (var itemFile in elist)
// {
// var obj = JsonHelper.DeserializeObject<UploadItem>(itemFile.CompData.ToString());
// if (itemFile.CompKey == "ImageUploadComp")
// {
// //图片处理
// string Name = obj.Name;
// foreach (var qitem in obj.FileList)
// {
// try
// {
// Uri uri = new Uri(qitem); //imgPath :网络图片地址
// WebRequest webRequest = WebRequest.Create(uri);
// // byte[] bytes;
// using (WebResponse webResponse = webRequest.GetResponse())
// {
// Bitmap bitmap = new Bitmap(webResponse.GetResponseStream());
// bitmap.Save(templistPath + Path.GetFileName(qitem), System.Drawing.Imaging.ImageFormat.Jpeg);
// }
// }
// catch (Exception ex)
// {
// }
// }
// }
// else if (itemFile.CompKey == "VideoUploadComp"||itemFile.CompKey == "CommonUploadComp")
// {
// //视频处理
// foreach (var qitem in obj.FileList)
// {
// try
// {
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(qitem);
// request.Method = "GET";
// byte[] fileBytes;
// using (WebResponse webRes = request.GetResponse())
// {
// int length = (int)webRes.ContentLength;
// HttpWebResponse response = webRes as HttpWebResponse;
// Stream stream = response.GetResponseStream();
// var contentdisposition = response.Headers["Content-Disposition"];
// var filename = Path.GetFileName(qitem);
// //读取到内存
// MemoryStream stmMemory = new MemoryStream();
// byte[] buffer = new byte[length];
// int i;
// //将字节逐个放入到Byte中
// while ((i = stream.Read(buffer, 0, buffer.Length)) > 0)
// {
// stmMemory.Write(buffer, 0, i);
// }
// fileBytes = stmMemory.ToArray();//文件流Byte
// FileStream fs = new FileStream(templistPath + Path.GetFileName(qitem), FileMode.OpenOrCreate);
// stmMemory.WriteTo(fs);
// stmMemory.Close();
// fs.Close();
// }
// }
// catch (Exception ex)
// {
// }
// }
// }
// }
// }
// }
//}
var
templistZipPath
=
Path
.
Combine
(
tempPath
+
"zip\\"
+
timeStr
+
"\\"
);
//路径
if
(!
Directory
.
Exists
(
templistZipPath
))
{
...
...
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