e3530e5342
Introduces new models, services, and view models for process monitoring, power plan association, application settings, and enhanced logging. Updates main application files and views to support new features. Adds developer and architecture documentation.
75 lines
2.2 KiB
C#
75 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using ThreadPilot.Models.Core;
|
|
|
|
namespace ThreadPilot.Models
|
|
{
|
|
public partial class ProfileModel : ObservableObject, IModel
|
|
{
|
|
[ObservableProperty]
|
|
private string id = Guid.NewGuid().ToString();
|
|
|
|
[ObservableProperty]
|
|
private DateTime createdAt = DateTime.UtcNow;
|
|
|
|
[ObservableProperty]
|
|
private DateTime updatedAt = DateTime.UtcNow;
|
|
|
|
[ObservableProperty]
|
|
private string name = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
private string processName = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
private ProcessPriorityClass priority = ProcessPriorityClass.Normal;
|
|
|
|
[ObservableProperty]
|
|
private long processorAffinity = -1; // All cores
|
|
|
|
[ObservableProperty]
|
|
private string description = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
private bool isEnabled = true;
|
|
|
|
// IModel implementation - properties are auto-generated by ObservableProperty
|
|
|
|
public ValidationResult Validate()
|
|
{
|
|
var errors = new List<string>();
|
|
|
|
if (string.IsNullOrWhiteSpace(Name))
|
|
errors.Add("Profile name is required");
|
|
|
|
if (string.IsNullOrWhiteSpace(ProcessName))
|
|
errors.Add("Process name is required");
|
|
|
|
return errors.Count == 0 ? ValidationResult.Success() : ValidationResult.Failure(errors.ToArray());
|
|
}
|
|
|
|
public IModel Clone()
|
|
{
|
|
return new ProfileModel
|
|
{
|
|
id = Guid.NewGuid().ToString(), // New ID for clone
|
|
Name = this.Name,
|
|
ProcessName = this.ProcessName,
|
|
Priority = this.Priority,
|
|
ProcessorAffinity = this.ProcessorAffinity,
|
|
Description = this.Description,
|
|
IsEnabled = this.IsEnabled,
|
|
createdAt = DateTime.UtcNow,
|
|
updatedAt = DateTime.UtcNow
|
|
};
|
|
}
|
|
|
|
partial void OnUpdatedAtChanged(DateTime value)
|
|
{
|
|
updatedAt = DateTime.UtcNow;
|
|
}
|
|
}
|
|
} |