46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using System;
|
|
using System.Linq;
|
|
using JD.LogService;
|
|
using File = System.IO.File;
|
|
using TeaBox.ObjectModel;
|
|
|
|
namespace JD.Serialization
|
|
{
|
|
public partial class VibrationClip : IDisposable
|
|
{
|
|
private readonly OperationTaskCollector _taskCollector = new OperationTaskCollector();
|
|
private LoggingContext _loggingContext;
|
|
|
|
partial void OnVibrationFilePathChanged()
|
|
{
|
|
if (!File.Exists(VibrationFilePath.getAbsolute()))
|
|
{
|
|
using (_taskCollector.OperationScope(out _loggingContext))
|
|
{
|
|
_loggingContext.LogError($"Wrong VibrationFilePath ! Can't find \"{VibrationFilePath}\" for {this} with Id {Id}.");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DeleteErrorLogsForClip();
|
|
}
|
|
}
|
|
|
|
public void DeleteErrorLogsForClip()
|
|
{
|
|
using (_taskCollector.OperationScope(out _loggingContext))
|
|
{
|
|
Error pathError = _loggingContext.Errors.FirstOrDefault(error => error.Message.Contains(Id.ToString()) && error.Message.Contains("VibrationFilePath"));
|
|
if (pathError != null)
|
|
{
|
|
_loggingContext.Errors.Remove(pathError);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_taskCollector?.Dispose();
|
|
}
|
|
}
|
|
}
|