fix:excel占用和video生成修改

master
sunhonglei 5 months ago
parent 81a111f8c0
commit bc0bc0f552
  1. 2
      Language/en_US.xaml
  2. 1
      Language/zh_CN.xaml
  3. 18
      ViewModel/Grading/DiamondSelectVM.cs
  4. 23
      ViewModel/Grading/GradingResultVM.cs
  5. 2
      Views/UserControl/ViewportData/Helper/VideoHelper.cs

@ -153,6 +153,7 @@
<sys:String x:Key="ViewportSaveSucceed">Save Successful</sys:String>
<sys:String x:Key="ViewportSaveFail">Save Failed</sys:String>
<sys:String x:Key="ViewportSelectPath">Select Path</sys:String>
<sys:String x:Key="ViewportRightMenuReset">Reset grid lines</sys:String>
<!-- Login Page -->
<sys:String x:Key="LoginWindowTitle">SparkDetectionSystem</sys:String>
@ -205,6 +206,7 @@
<sys:String x:Key="MSVCRuntimeNoInstall">MSVC Runtime not installed, program may encounter errors during execution</sys:String>
<sys:String x:Key="FilePathNotExists">File path does not exist</sys:String>
<sys:String x:Key="LevelConfigFormatError">The file format is incorrect</sys:String>
<sys:String x:Key="FileOpened">The file is currently being opened</sys:String>
<sys:String x:Key="DateOfIssue">DateOfIssue</sys:String>
<sys:String x:Key="Organization">Organization</sys:String>
<sys:String x:Key="Code">Code</sys:String>

@ -206,6 +206,7 @@
<sys:String x:Key="MSVCRuntimeNoInstall">MSVC Runtime未安装,程序执行中可能会出错</sys:String>
<sys:String x:Key="FilePathNotExists">文件路径不存在</sys:String>
<sys:String x:Key="LevelConfigFormatError">文件格式不正确</sys:String>
<sys:String x:Key="FileOpened">文件正在被打开</sys:String>
<sys:String x:Key="DateOfIssue">签发日期</sys:String>
<sys:String x:Key="Organization">机构</sys:String>
<sys:String x:Key="Code">编码</sys:String>

@ -285,6 +285,11 @@ public class DiamondSelectVM : BaseViewModel
{
loading.Close();
new MessageBox().Show(MultilingualHelper.getString("SavePathIsnotExists"));
}
catch (IOException ex)
{
loading.Close();
new MessageBox().Show($"{MultilingualHelper.getString("FileOpened")}:{ex.Message}");
}
finally {
@ -400,6 +405,11 @@ public class DiamondSelectVM : BaseViewModel
loading.Close();
new MessageBox().Show(MultilingualHelper.getString("SavePathIsnotExists"));
}
catch (IOException ex)
{
loading.Close();
new MessageBox().Show($"{MultilingualHelper.getString("FileOpened")}:{ex.Message}");
}
catch (Exception ex)
{
new MessageBox().Show($"{MultilingualHelper.getString("ApplicationError")}{ex.Message}");
@ -501,13 +511,19 @@ public class DiamondSelectVM : BaseViewModel
[Log]
public void GradingResult(AlgorithmResultEntity param)
{
try
{
//WindowManager.mainViewModel.Content = WindowManager.PreviousVM();
BaseControlVM vm = new BaseControlVM(new GradingResultVM(param), MultilingualHelper.getString("DetectionResult"));
vm.ShowFunctionButton = System.Windows.Visibility.Hidden;
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
}
catch (IOException)
{
throw;
}
}
}
public class ButtonInfo

@ -197,6 +197,9 @@ public class GradingResultVM : BaseViewModel
}
SaveTestResult(SaveStatus.AutoSave);
SaveToCsv();
}catch(IOException)
{
throw;
}
catch (Exception ex)
{
@ -955,8 +958,8 @@ public class GradingResultVM : BaseViewModel
[Log]
private async void ExportFile(string filePath)
{
try {
ExportDialog exportDialog = new ExportDialog();
try {
var tcs = new TaskCompletionSource<bool>();
var progressTask = Task.Run(() => Application.Current.Dispatcher.Invoke(() => {
exportDialog.Closed += (s, e) => tcs.SetResult(true);
@ -1010,13 +1013,21 @@ public class GradingResultVM : BaseViewModel
// });
});
await Task.Delay(500);
exportDialog.Close();
}
catch (IOException ex)
{
new MessageBox().Show($"{MultilingualHelper.getString("FileOpened")}:{ex.Message}");
}
catch(Exception ex)
{
new MessageBox().Show($"{MultilingualHelper.getString("ApplicationError")}{ex.Message}");
Logger.Error($"全局异常捕获:{ex.Message}", ex);
}
finally
{
exportDialog.Close();
}
}
[Log]
private bool FileSaveEnabled(string Key)
@ -1118,9 +1129,9 @@ public class GradingResultVM : BaseViewModel
[Log]
private void ExcelFile(string filePath)
{
string fileName = filePath + ".xlsx";
try
{
string fileName = filePath + ".xlsx";
IWorkbook workbook = new XSSFWorkbook();
ISheet sheet = workbook.CreateSheet("Sheet1");
@ -1174,10 +1185,14 @@ public class GradingResultVM : BaseViewModel
workbook.Write(stream);
}
}
catch (IOException)
{
throw new IOException($"{fileName}");
}
catch (Exception ex)
{
new MessageBox().Show($"{MultilingualHelper.getString("ApplicationError")}{ex.Message}");
Logger.Error($"全局异常捕获:{ex.Message}", ex);
throw;
}
}

@ -107,7 +107,7 @@ public class VideoHelper
}
string framePattern = Path.Combine(tempDirectory, "frame_%05d.png").Replace("\\", "/"); // Replace backslashes with forward slashes for FFmpeg compatibility
string arguments = $"-framerate 30 -i \"{framePattern}\" -vf \"scale=640:480\" -c:v libx264 -pix_fmt yuv420p \"{outputPath}\"";
string arguments = $"-framerate 30 -i \"{framePattern}\" -vf \"scale=640:480\" -c:v libx264 -pix_fmt yuv420p -y \"{outputPath}\"";
var processInfo = new System.Diagnostics.ProcessStartInfo
{

Loading…
Cancel
Save