Commit dce20310 authored by 吴春's avatar 吴春

提交代码

parent 9afa17cf
...@@ -1056,26 +1056,34 @@ namespace Mall.Module.TradePavilion ...@@ -1056,26 +1056,34 @@ namespace Mall.Module.TradePavilion
string tempFoldr = ""; string tempFoldr = "";
#region 解析表单内容 #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)) Directory.CreateDirectory(templistPath);
{ }
errorMsg = "报名内容不存在,请核实后再试"; foreach (var item in nowEnroList)
return ""; {
} var enrollModel = listModel.Where(x => x.Id == item.ListId).FirstOrDefault();
List<FormDataItem> elist = JsonHelper.DeserializeObject<List<FormDataItem>>(enrollModel.Content); if (enrollModel != null && enrollModel.Id > 0)
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"); if (string.IsNullOrEmpty(item.Content))
var templistPath = Path.Combine(tempPath + "file\\" + timeStr + "\\" + listItem.ListName + "\\" + companyName + "\\");//路径 {
if (!Directory.Exists(templistPath)) 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(templistnowPath);
} }
//开始下载图片视频至临时文件
foreach (var itemFile in elist) foreach (var itemFile in elist)
{ {
...@@ -1096,7 +1104,7 @@ namespace Mall.Module.TradePavilion ...@@ -1096,7 +1104,7 @@ namespace Mall.Module.TradePavilion
{ {
Bitmap bitmap = new Bitmap(webResponse.GetResponseStream()); Bitmap bitmap = new Bitmap(webResponse.GetResponseStream());
bitmap.Save(templistPath + Path.GetFileName(qitem), System.Drawing.Imaging.ImageFormat.Jpeg); bitmap.Save(templistnowPath + Path.GetFileName(qitem), System.Drawing.Imaging.ImageFormat.Jpeg);
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -1105,12 +1113,11 @@ namespace Mall.Module.TradePavilion ...@@ -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) foreach (var qitem in obj.FileList)
{ {
try try
{ {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(qitem); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(qitem);
...@@ -1133,7 +1140,7 @@ namespace Mall.Module.TradePavilion ...@@ -1133,7 +1140,7 @@ namespace Mall.Module.TradePavilion
stmMemory.Write(buffer, 0, i); stmMemory.Write(buffer, 0, i);
} }
fileBytes = stmMemory.ToArray();//文件流Byte fileBytes = stmMemory.ToArray();//文件流Byte
FileStream fs = new FileStream(templistPath + Path.GetFileName(qitem), FileMode.OpenOrCreate); FileStream fs = new FileStream(templistnowPath + Path.GetFileName(qitem), FileMode.OpenOrCreate);
stmMemory.WriteTo(fs); stmMemory.WriteTo(fs);
stmMemory.Close(); stmMemory.Close();
fs.Close(); fs.Close();
...@@ -1149,6 +1156,104 @@ namespace Mall.Module.TradePavilion ...@@ -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 + "\\");//路径 var templistZipPath = Path.Combine(tempPath + "zip\\" + timeStr + "\\");//路径
if (!Directory.Exists(templistZipPath)) if (!Directory.Exists(templistZipPath))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment