|
@@ -3714,28 +3714,62 @@ namespace OASystem.API.Controllers
|
|
|
return Ok(jw);
|
|
|
}
|
|
|
var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
|
|
|
+ var isModule = Convert.ToBoolean(dto.isModule);
|
|
|
|
|
|
Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
|
|
|
+ IOOperatorHelper io = new IOOperatorHelper();
|
|
|
|
|
|
- foreach (var item in dbQuery)
|
|
|
+ if (isModule)
|
|
|
{
|
|
|
- using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
|
|
|
+ var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
|
|
|
+ foreach (var moduleArr in moduleGroup)
|
|
|
{
|
|
|
- byte[] bytes = new byte[fileStream.Length];
|
|
|
- fileStream.Read(bytes, 0, bytes.Length);
|
|
|
- fileStream.Close();
|
|
|
- Stream stream = new MemoryStream(bytes);
|
|
|
- Zips.Add(item.FileName, stream);
|
|
|
+ var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
|
|
|
+ key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
|
|
|
+ RegexOptions.None, TimeSpan.FromSeconds(1.5));
|
|
|
+ Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
|
|
|
+ foreach (var item in moduleArr)
|
|
|
+ {
|
|
|
+ if (System.IO.File.Exists(item.FilePath))
|
|
|
+ {
|
|
|
+ using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
|
|
|
+ {
|
|
|
+ byte[] bytes = new byte[fileStream.Length];
|
|
|
+ fileStream.Read(bytes, 0, bytes.Length);
|
|
|
+ fileStream.Close();
|
|
|
+ Stream stream = new MemoryStream(bytes);
|
|
|
+ chiZips.Add(item.FileName, stream);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (chiZips.Count > 0)
|
|
|
+ {
|
|
|
+ var byts = io.ConvertZipStream(chiZips);
|
|
|
+ Stream stream = new MemoryStream(byts);
|
|
|
+ Zips.Add(key.Name+"_.zip", stream);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foreach (var item in dbQuery)
|
|
|
+ {
|
|
|
+ using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
|
|
|
+ {
|
|
|
+ byte[] bytes = new byte[fileStream.Length];
|
|
|
+ fileStream.Read(bytes, 0, bytes.Length);
|
|
|
+ fileStream.Close();
|
|
|
+ Stream stream = new MemoryStream(bytes);
|
|
|
+ Zips.Add(item.FileName, stream);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
|
|
|
RegexOptions.None, TimeSpan.FromSeconds(1.5));
|
|
|
|
|
|
-
|
|
|
if (Zips.Count > 0)
|
|
|
{
|
|
|
- IOOperatorHelper io = new IOOperatorHelper();
|
|
|
var byts = io.ConvertZipStream(Zips);
|
|
|
var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
|
|
|
io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
|