|
|
@@ -3,7 +3,9 @@ using Newtonsoft.Json.Linq;
|
|
|
using System;
|
|
|
using System.Collections.Concurrent;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.IO.Compression;
|
|
|
using System.Linq;
|
|
|
+using System.Net.Mail;
|
|
|
using System.Reflection;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
@@ -763,7 +765,7 @@ namespace YSAI.RelayManage
|
|
|
/// </summary>
|
|
|
/// <param name="file">文件</param>
|
|
|
/// <param name="path">路径</param>
|
|
|
- private static void WriteFile(IFormFile file, string path)
|
|
|
+ private void WriteFile(IFormFile file, string path)
|
|
|
{
|
|
|
var stream = file.OpenReadStream();
|
|
|
|
|
|
@@ -804,25 +806,39 @@ namespace YSAI.RelayManage
|
|
|
ThisObjList = null;
|
|
|
}
|
|
|
/// <summary>
|
|
|
- /// 设置库文件
|
|
|
+ /// 设置库文件压缩包
|
|
|
/// </summary>
|
|
|
- /// <param name="FormFiles">文件集合</param>
|
|
|
+ /// <param name="FormFiles">压缩包集合</param>
|
|
|
/// <returns>统一出参</returns>
|
|
|
- public OperateResult SettingLib(List<IFormFile> FormFiles)
|
|
|
+ public OperateResult SettingLibZip(List<IFormFile> FormFiles)
|
|
|
{
|
|
|
- Depart("SettingLib");
|
|
|
+ Depart("SettingLibZip");
|
|
|
try
|
|
|
{
|
|
|
List<string> FailMessage = new List<string>();
|
|
|
FormFiles.ForEach(file =>
|
|
|
{
|
|
|
- var LibName = file.FileName;
|
|
|
+ string LibName = file.FileName;
|
|
|
|
|
|
string path = Path.Combine(basics.LibFolder, LibName);
|
|
|
|
|
|
+ string typePath = Path.Combine(basics.LibFolder, LibName.Split('.')[LibName.Split('.').Length - 2]);
|
|
|
+
|
|
|
if (!System.IO.File.Exists(path))
|
|
|
{
|
|
|
- WriteFile(file, path);
|
|
|
+ if (!System.IO.Directory.Exists(typePath))
|
|
|
+ {
|
|
|
+ //写入文件
|
|
|
+ WriteFile(file, path);
|
|
|
+ //解压压缩包
|
|
|
+ ZipFile.ExtractToDirectory(path, basics.LibFolder);
|
|
|
+ //删除压缩包
|
|
|
+ File.Delete(path);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FailMessage.Add($"{LibName} 已存在");
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -831,23 +847,23 @@ namespace YSAI.RelayManage
|
|
|
});
|
|
|
if (FailMessage.Count > 0)
|
|
|
{
|
|
|
- return Break("SettingLib", false, $"存在{FailMessage.Count}个失败信息", FailMessage, ResultType.Json);
|
|
|
+ return Break("SettingLibZip", false, $"存在 {FailMessage.Count} 个失败信息", FailMessage, ResultType.Json);
|
|
|
}
|
|
|
- return Break("SettingLib", true);
|
|
|
+ return Break("SettingLibZip", true);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- return Break("SettingLib", false, ex.Message, Exc: ex);
|
|
|
+ return Break("SettingLibZip", false, ex.Message, Exc: ex);
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
- /// 删除文件
|
|
|
+ /// 删除库文件夹(会自动释放此库的所有实例与程序集)
|
|
|
/// </summary>
|
|
|
- /// <param name="FileNames">文件名集合</param>
|
|
|
+ /// <param name="FileNames">文件夹名集合</param>
|
|
|
/// <returns>统一出参</returns>
|
|
|
- public OperateResult DeleteFile(List<string> FileNames)
|
|
|
+ public OperateResult DeleteLibFolder(List<string> FileNames)
|
|
|
{
|
|
|
- Depart("DeleteFile");
|
|
|
+ Depart("DeleteLibFolder");
|
|
|
try
|
|
|
{
|
|
|
List<string> FailMessage = new List<string>();
|
|
|
@@ -855,9 +871,40 @@ namespace YSAI.RelayManage
|
|
|
{
|
|
|
string path = Path.Combine(basics.LibFolder, LibName);
|
|
|
|
|
|
- if (System.IO.File.Exists(path))
|
|
|
+ if (System.IO.Directory.Exists(path))
|
|
|
{
|
|
|
- System.IO.File.Delete(path);
|
|
|
+ List<string> IArray = new List<string>();
|
|
|
+ List<string> TArray = new List<string>();
|
|
|
+ foreach (var item in InstanceIoc)
|
|
|
+ {
|
|
|
+ if (item.Key.Contains(LibName.Replace(".Pack", string.Empty)))
|
|
|
+ {
|
|
|
+ IArray.Add(item.Key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (var item in TypeIoc)
|
|
|
+ {
|
|
|
+ if (item.Key.Contains(LibName.Replace(".Pack", string.Empty)))
|
|
|
+ {
|
|
|
+ TArray.Add(item.Key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (IArray.Count.Equals(0) && TArray.Count.Equals(0))
|
|
|
+ {
|
|
|
+ System.IO.Directory.Delete(path);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foreach (var item in IArray)
|
|
|
+ {
|
|
|
+ DisposeISn(item);
|
|
|
+ }
|
|
|
+ foreach (var item in TArray)
|
|
|
+ {
|
|
|
+ TypeIoc.Remove(item, out _);
|
|
|
+ }
|
|
|
+ System.IO.Directory.Delete(path);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -866,15 +913,16 @@ namespace YSAI.RelayManage
|
|
|
}
|
|
|
if (FailMessage.Count > 0)
|
|
|
{
|
|
|
- return Break("DeleteFile", false, $"存在{FailMessage.Count}个失败信息", FailMessage, ResultType.Json);
|
|
|
+ return Break("DeleteLibFolder", false, $"存在{FailMessage.Count}个失败信息", FailMessage, ResultType.Json);
|
|
|
}
|
|
|
- return Break("DeleteFile", true);
|
|
|
+ return Break("DeleteLibFolder", true);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- return Break("DeleteFile", false, ex.Message, Exc: ex);
|
|
|
+ return Break("DeleteLibFolder", false, ex.Message, Exc: ex);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 设置库配置文件
|
|
|
/// </summary>
|
|
|
@@ -975,6 +1023,7 @@ namespace YSAI.RelayManage
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 程序集唯一标识符集合
|
|
|
/// </summary>
|