using JdeScoping.ConfigManager.Models; namespace JdeScoping.ConfigManager.ViewModels.Forms; /// /// ViewModel for editing DataSync configuration section. /// public class DataSyncFormViewModel : ViewModelBase { private readonly DataSyncSection _model; private readonly Action _onChanged; /// /// Initializes a new instance of the class. /// /// The data sync section model to edit. /// The callback to invoke when configuration changes. public DataSyncFormViewModel(DataSyncSection model, Action onChanged) { _model = model ?? throw new ArgumentNullException(nameof(model)); _onChanged = onChanged ?? throw new ArgumentNullException(nameof(onChanged)); } /// /// Gets or sets whether data synchronization is enabled. /// public bool Enabled { get => _model.Enabled; set { if (_model.Enabled != value) { _model.Enabled = value; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets the check interval in minutes. /// public int CheckIntervalMinutes { get => (int)_model.CheckInterval.TotalMinutes; set { var newValue = TimeSpan.FromMinutes(value); if (_model.CheckInterval != newValue) { _model.CheckInterval = newValue; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets the maximum degree of parallelism. /// public int MaxDegreeOfParallelism { get => _model.MaxDegreeOfParallelism; set { if (_model.MaxDegreeOfParallelism != value) { _model.MaxDegreeOfParallelism = value; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets the batch size for sync operations. /// public int BatchSize { get => _model.BatchSize; set { if (_model.BatchSize != value) { _model.BatchSize = value; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets the bulk copy batch size. /// public int BulkCopyBatchSize { get => _model.BulkCopyBatchSize; set { if (_model.BulkCopyBatchSize != value) { _model.BulkCopyBatchSize = value; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets the lookback multiplier. /// public double LookbackMultiplier { get => _model.LookbackMultiplier; set { if (Math.Abs(_model.LookbackMultiplier - value) > 0.001) { _model.LookbackMultiplier = value; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets the purge retention days. /// public int PurgeRetentionDays { get => _model.PurgeRetentionDays; set { if (_model.PurgeRetentionDays != value) { _model.PurgeRetentionDays = value; OnPropertyChanged(); _onChanged(); } } } /// /// Gets or sets the sync timeout in seconds. /// public int SyncTimeoutSeconds { get => _model.SyncTimeoutSeconds; set { if (_model.SyncTimeoutSeconds != value) { _model.SyncTimeoutSeconds = value; OnPropertyChanged(); _onChanged(); } } } }