|
@@ -2,6 +2,7 @@
|
|
|
using Aspose.Words;
|
|
|
using Aspose.Words.Drawing;
|
|
|
using Aspose.Words.Tables;
|
|
|
+using EyeSoft.Collections.Generic;
|
|
|
using EyeSoft.IO;
|
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
using MySqlX.XDevAPI.Relational;
|
|
@@ -3801,6 +3802,8 @@ FROM
|
|
|
try
|
|
|
{
|
|
|
var TypeName = Request.Headers["TypeName"].ToString();
|
|
|
+ if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
|
|
|
+
|
|
|
string filePath = "";
|
|
|
var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
|
|
|
|
|
@@ -3821,20 +3824,49 @@ FROM
|
|
|
filePath = fileDir + "/商邀相关文件/" + dto.fileName;
|
|
|
|
|
|
System.IO.File.Delete(filePath);
|
|
|
- id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
|
|
|
- .Where(a => a.Id == dto.Id)
|
|
|
- .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" })
|
|
|
- .ExecuteCommandAsync();
|
|
|
- }
|
|
|
+
|
|
|
+ var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
|
|
|
+ if (info != null)
|
|
|
+ {
|
|
|
+ string[] files = new string[] { };
|
|
|
+ if (!string.IsNullOrEmpty(info.Attachment))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+
|
|
|
+ files = new List<string>() { info.Attachment }.ToArray();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (files.Length > 0)
|
|
|
+ {
|
|
|
+ var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
|
|
|
+
|
|
|
+ string filePath2 = string.Empty;
|
|
|
+ if (files1.Length > 0)
|
|
|
+ {
|
|
|
+ filePath2 = JsonConvert.SerializeObject( files1);
|
|
|
+ }
|
|
|
+
|
|
|
+ id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
|
|
|
+ .Where(a => a.Id == dto.Id)
|
|
|
+ .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
|
|
|
+ .ExecuteCommandAsync();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (id != 0)
|
|
|
- {
|
|
|
- return Ok(JsonView(true, "成功!"));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return Ok(JsonView(false, "失败!"));
|
|
|
- }
|
|
|
+ {
|
|
|
+ return Ok(JsonView(true, "成功!"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "失败!"));
|
|
|
}
|
|
|
+ }
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
return Ok(JsonView(false, "程序错误!"));
|
|
@@ -3925,7 +3957,68 @@ FROM
|
|
|
return Ok(JsonView(true, groupData.Msg, groupData.Data));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpGet("{id}")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
|
|
|
+ {
|
|
|
+ if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
|
|
|
+
|
|
|
+ var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
|
|
|
+
|
|
|
+ if (info == null) return Ok(JsonView(false, "数据不存在!"));
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
|
|
|
+
|
|
|
+ var filePaths = new List<string>();
|
|
|
+ var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ filePaths.Add(info.Attachment);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
|
|
|
+
|
|
|
+ for (int i = 0; i < filePaths.Count; i++)
|
|
|
+ {
|
|
|
+ filePaths[i] = $"{filePathBase}{filePaths[i]}";
|
|
|
+ }
|
|
|
+
|
|
|
+ var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
|
|
|
+ var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
|
|
|
+ using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
|
|
|
+ {
|
|
|
+ using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
|
|
|
+ {
|
|
|
+ foreach (string filePath in filePaths)
|
|
|
+ {
|
|
|
+ if (System.IO.File.Exists(filePath))
|
|
|
+ {
|
|
|
+
|
|
|
+ string fileName = Path.GetFileName(filePath);
|
|
|
+
|
|
|
+ zipArchive.CreateEntryFromFile(filePath, fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(JsonView(new {url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|