|
@@ -2416,17 +2416,17 @@ namespace MainForm
|
|
isCollectingFlagRight = false;
|
|
isCollectingFlagRight = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- public static void CompressFolder(string folderPath, string zipFilePath)
|
|
|
|
|
|
+ public static (int,string) CompressFolder(string folderPath, string zipFilePath)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
// 创建zip文件,将指定文件夹内的所有内容压缩到这个zip文件中
|
|
// 创建zip文件,将指定文件夹内的所有内容压缩到这个zip文件中
|
|
System.IO.Compression.ZipFile.CreateFromDirectory(folderPath, zipFilePath);
|
|
System.IO.Compression.ZipFile.CreateFromDirectory(folderPath, zipFilePath);
|
|
- Console.WriteLine("文件夹已成功压缩!");
|
|
|
|
|
|
+ return (1, "文件夹已成功压缩!");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
- Console.WriteLine($"发生错误: {ex.Message}");
|
|
|
|
|
|
+ return (0, "文件压缩出错!"+ ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -2443,7 +2443,7 @@ namespace MainForm
|
|
int result = 0;
|
|
int result = 0;
|
|
var formData = new MultipartFormDataContent();
|
|
var formData = new MultipartFormDataContent();
|
|
string msg = "";
|
|
string msg = "";
|
|
- string file_category = "IMAGE"; //IMAGE 、TEXT 、UNKNOWN 这里上传图片
|
|
|
|
|
|
+ string file_category = "IMAGE"; //IMAGE 、TEXT 、UNKNOWN
|
|
string file_type = "IMAGE";
|
|
string file_type = "IMAGE";
|
|
string project = GlobalContext.ProgramName;
|
|
string project = GlobalContext.ProgramName;
|
|
string run_mode = GlobalContext.run_mode;
|
|
string run_mode = GlobalContext.run_mode;
|
|
@@ -2464,10 +2464,17 @@ namespace MainForm
|
|
if (GlobalContext.MESIsSendUpFile)
|
|
if (GlobalContext.MESIsSendUpFile)
|
|
{
|
|
{
|
|
string toPath = GlobalContext.MqttFileBackupLogDir;
|
|
string toPath = GlobalContext.MqttFileBackupLogDir;
|
|
- string toFileName = $"[{xiaomiParm.workstation}]_{file_type}_{sn}_{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}.zip";
|
|
|
|
- string directoryPath = Path.GetDirectoryName(path);
|
|
|
|
- string strFilePath = toPath + toFileName;
|
|
|
|
- CompressFolder(directoryPath, strFilePath);
|
|
|
|
|
|
+ string toFileName = $"[{xiaomiParm.workstation}]_{file_type}_{sn}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.zip";
|
|
|
|
+ //string directoryPath = Path.GetDirectoryName(path);
|
|
|
|
+ string strFilePath = toPath+ "\\"+ toFileName;
|
|
|
|
+ var r=CompressFolder(path, strFilePath);
|
|
|
|
+ if (r.Item1 == 0)
|
|
|
|
+ {
|
|
|
|
+ return (0, r.Item2);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ msg = r.Item2+"\r\n";
|
|
|
|
+ }
|
|
|
|
|
|
FileUpload_X5 fileUpload_X5 = new FileUpload_X5();
|
|
FileUpload_X5 fileUpload_X5 = new FileUpload_X5();
|
|
fileUpload_X5.bucket = bucket;
|
|
fileUpload_X5.bucket = bucket;
|
|
@@ -2499,8 +2506,14 @@ namespace MainForm
|
|
|
|
|
|
var fileresult =await
|
|
var fileresult =await
|
|
XiaomiMESHttp_UpLoadFile.FileUoladToMes(strFilePath, fileUpload_X5, fileMqttPayload);
|
|
XiaomiMESHttp_UpLoadFile.FileUoladToMes(strFilePath, fileUpload_X5, fileMqttPayload);
|
|
-
|
|
|
|
- msg = msg + $"{fileresult.Item2}\r\n";
|
|
|
|
|
|
+ if (fileresult.Item1 != 1)
|
|
|
|
+ {
|
|
|
|
+ return (0, msg + fileresult.Item2 + "\r\n");
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ msg = msg + fileresult.Item2 + "\r\n";
|
|
|
|
+ }
|
|
|
|
|
|
// 获取所有图片文件
|
|
// 获取所有图片文件
|
|
List<string> imageFiles = GetAllImageFiles(path);
|
|
List<string> imageFiles = GetAllImageFiles(path);
|