first commit
This commit is contained in:
98
DCIT.Core/Models/AppConfig.cs
Normal file
98
DCIT.Core/Models/AppConfig.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
|
||||
namespace DCIT.Core.Models
|
||||
{
|
||||
public class AppConfig
|
||||
{
|
||||
public string Format { get; set; } = "dcit.config";
|
||||
|
||||
public string Version { get; set; } = "1.0";
|
||||
|
||||
public DateTime SavedAt { get; set; } = DateTime.Now;
|
||||
|
||||
public AppSettings Settings { get; set; } = new AppSettings();
|
||||
|
||||
public ReplacePageState ReplacePage { get; set; } = new ReplacePageState();
|
||||
|
||||
public RestorePageState RestorePage { get; set; } = new RestorePageState();
|
||||
}
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
public bool JsonDiffEncryption { get; set; } = true;
|
||||
|
||||
public bool EnableImageReplacement { get; set; } = true;
|
||||
|
||||
public bool UseFixedImageSeed { get; set; }
|
||||
|
||||
public int FixedImageSeed { get; set; } = 20260424;
|
||||
|
||||
public AutoExtractSettings AutoExtract { get; set; } = new AutoExtractSettings();
|
||||
}
|
||||
|
||||
public class AutoExtractSettings
|
||||
{
|
||||
public bool ExtractKeywords { get; set; } = true;
|
||||
|
||||
public bool ExtractHighFrequencyWords { get; set; } = true;
|
||||
|
||||
public bool ExtractHighFrequencySentences { get; set; } = true;
|
||||
|
||||
public bool UseKeywordFrequency { get; set; } = true;
|
||||
|
||||
public bool UseKeywordTfIdf { get; set; } = true;
|
||||
|
||||
public bool UseKeywordTextRank { get; set; } = true;
|
||||
|
||||
public int MaxKeywordCount { get; set; } = 10;
|
||||
|
||||
public int MaxWordCount { get; set; } = 10;
|
||||
|
||||
public int MaxSentenceCount { get; set; } = 10;
|
||||
|
||||
public bool CountChineseWords { get; set; } = true;
|
||||
|
||||
public bool CountEnglishWords { get; set; } = true;
|
||||
|
||||
public bool CountChineseSentences { get; set; } = true;
|
||||
|
||||
public bool CountEnglishSentences { get; set; } = true;
|
||||
|
||||
public int MinChineseWordLength { get; set; } = 1;
|
||||
|
||||
public int MinEnglishWordLength { get; set; } = 1;
|
||||
|
||||
public string SentenceDelimiters { get; set; } = "。!?;.!?;\r\n";
|
||||
|
||||
public bool ExcludeEmailAddresses { get; set; }
|
||||
}
|
||||
|
||||
public class ReplacePageState
|
||||
{
|
||||
public string SourceDirectory { get; set; } = string.Empty;
|
||||
|
||||
public string OutputDirectory { get; set; } = string.Empty;
|
||||
|
||||
public string RuleFilePath { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class RestorePageState
|
||||
{
|
||||
public string ReplaceDirectory { get; set; } = string.Empty;
|
||||
|
||||
public string RestoreDirectory { get; set; } = string.Empty;
|
||||
|
||||
public string DiffInputFormat { get; set; } = ".diff";
|
||||
}
|
||||
|
||||
public class ConfigurationLoadResult
|
||||
{
|
||||
public AppConfig Config { get; set; } = new AppConfig();
|
||||
|
||||
public bool IsMissing { get; set; }
|
||||
|
||||
public bool IsCorrupted { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
}
|
||||
99
DCIT.Core/Models/AutoExtractModels.cs
Normal file
99
DCIT.Core/Models/AutoExtractModels.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DCIT.Core.Models
|
||||
{
|
||||
public class ExtractionProgress
|
||||
{
|
||||
public int Current { get; set; }
|
||||
|
||||
public int Total { get; set; }
|
||||
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
public class ExtractedDocumentText
|
||||
{
|
||||
public string FilePath { get; set; }
|
||||
|
||||
public string VisibleText { get; set; }
|
||||
}
|
||||
|
||||
public class ExtractionCandidate : INotifyPropertyChanged
|
||||
{
|
||||
private bool _append = true;
|
||||
private AutoExtractCategory _primaryCategory;
|
||||
private string _categoryDisplay;
|
||||
private string _originalText;
|
||||
private string _statisticDisplay;
|
||||
private string _firstDocumentPath;
|
||||
private int _firstOccurrenceOrder;
|
||||
|
||||
public bool Append
|
||||
{
|
||||
get { return _append; }
|
||||
set { SetField(ref _append, value); }
|
||||
}
|
||||
|
||||
public AutoExtractCategory PrimaryCategory
|
||||
{
|
||||
get { return _primaryCategory; }
|
||||
set { SetField(ref _primaryCategory, value); }
|
||||
}
|
||||
|
||||
public string CategoryDisplay
|
||||
{
|
||||
get { return _categoryDisplay; }
|
||||
set { SetField(ref _categoryDisplay, value); }
|
||||
}
|
||||
|
||||
public string OriginalText
|
||||
{
|
||||
get { return _originalText; }
|
||||
set { SetField(ref _originalText, value); }
|
||||
}
|
||||
|
||||
public string StatisticDisplay
|
||||
{
|
||||
get { return _statisticDisplay; }
|
||||
set { SetField(ref _statisticDisplay, value); }
|
||||
}
|
||||
|
||||
public string FirstDocumentPath
|
||||
{
|
||||
get { return _firstDocumentPath; }
|
||||
set { SetField(ref _firstDocumentPath, value); }
|
||||
}
|
||||
|
||||
public int FirstOccurrenceOrder
|
||||
{
|
||||
get { return _firstOccurrenceOrder; }
|
||||
set { SetField(ref _firstOccurrenceOrder, value); }
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(field, value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
field = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
public class AutoExtractResult
|
||||
{
|
||||
public List<ExtractionCandidate> Candidates { get; } = new List<ExtractionCandidate>();
|
||||
|
||||
public List<string> Warnings { get; } = new List<string>();
|
||||
|
||||
public int DocumentsProcessed { get; set; }
|
||||
|
||||
public int DocumentsSkipped { get; set; }
|
||||
}
|
||||
}
|
||||
51
DCIT.Core/Models/BatchExecutionModels.cs
Normal file
51
DCIT.Core/Models/BatchExecutionModels.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DCIT.Core.Models
|
||||
{
|
||||
public enum BatchExecutionSkipReason
|
||||
{
|
||||
DuplicateSourcePath = 0,
|
||||
DuplicateOutputPath = 1,
|
||||
DuplicateDiffPath = 2
|
||||
}
|
||||
|
||||
public sealed class BatchExecutionSkipItem
|
||||
{
|
||||
public FileScanItem Item { get; set; }
|
||||
|
||||
public BatchExecutionSkipReason Reason { get; set; }
|
||||
|
||||
public string ConflictingPath { get; set; }
|
||||
|
||||
public string ExistingPath { get; set; }
|
||||
|
||||
public string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (Reason)
|
||||
{
|
||||
case BatchExecutionSkipReason.DuplicateSourcePath:
|
||||
return "源文件与批次中已有任务重复,已跳过。";
|
||||
case BatchExecutionSkipReason.DuplicateOutputPath:
|
||||
return "输出目标与批次中已有任务冲突,已跳过。";
|
||||
case BatchExecutionSkipReason.DuplicateDiffPath:
|
||||
return "差异文件目标与批次中已有任务冲突,已跳过。";
|
||||
default:
|
||||
return "批处理任务冲突,已跳过。";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class BatchExecutionPlan
|
||||
{
|
||||
public IList<FileScanItem> ExecutionItems { get; set; } = new List<FileScanItem>();
|
||||
|
||||
public IList<BatchExecutionSkipItem> SkippedItems { get; set; } = new List<BatchExecutionSkipItem>();
|
||||
|
||||
public int DegreeOfParallelism { get; set; } = 1;
|
||||
|
||||
public bool RequiresSerialExecution { get; set; }
|
||||
}
|
||||
}
|
||||
222
DCIT.Core/Models/DiffModels.cs
Normal file
222
DCIT.Core/Models/DiffModels.cs
Normal file
@@ -0,0 +1,222 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DCIT.Core.Models
|
||||
{
|
||||
public class DiffDocument
|
||||
{
|
||||
public string Format { get; set; } = "dcit-diff";
|
||||
|
||||
public string Version { get; set; } = "1.0";
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.Now;
|
||||
|
||||
public bool Encrypted { get; set; }
|
||||
|
||||
public DiffAppInfo App { get; set; } = new DiffAppInfo();
|
||||
|
||||
public DiffAlgorithmInfo Algorithm { get; set; } = new DiffAlgorithmInfo();
|
||||
|
||||
public DiffDocumentInfo SourceDocument { get; set; } = new DiffDocumentInfo();
|
||||
|
||||
public DiffDocumentInfo ReplacedDocument { get; set; } = new DiffDocumentInfo();
|
||||
|
||||
public DiffRuleFileInfo RuleFile { get; set; } = new DiffRuleFileInfo();
|
||||
|
||||
public DiffIntegrityInfo Integrity { get; set; } = new DiffIntegrityInfo();
|
||||
|
||||
public DiffEncryptionInfo Encryption { get; set; }
|
||||
|
||||
public string PayloadCiphertext { get; set; }
|
||||
|
||||
public DiffPayload Payload { get; set; }
|
||||
}
|
||||
|
||||
public class DiffAppInfo
|
||||
{
|
||||
public string Name { get; set; } = "DCIT";
|
||||
|
||||
public string Version { get; set; } = "1.0.0";
|
||||
}
|
||||
|
||||
public class DiffAlgorithmInfo
|
||||
{
|
||||
public string DiffVersion { get; set; } = "1.0";
|
||||
|
||||
public string BmpCodecVersion { get; set; } = "1.0";
|
||||
}
|
||||
|
||||
public class DiffDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string RelativePath { get; set; }
|
||||
|
||||
public string Extension { get; set; }
|
||||
|
||||
public string FingerprintAlgorithm { get; set; } = "SHA-256";
|
||||
|
||||
public string Fingerprint { get; set; }
|
||||
}
|
||||
|
||||
public class DiffRuleFileInfo
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string Version { get; set; } = "1.0";
|
||||
|
||||
public string FingerprintAlgorithm { get; set; } = "SHA-256";
|
||||
|
||||
public string Fingerprint { get; set; }
|
||||
}
|
||||
|
||||
public class DiffIntegrityInfo
|
||||
{
|
||||
public string HashAlgorithm { get; set; } = "SHA-256";
|
||||
|
||||
public string PayloadHash { get; set; }
|
||||
|
||||
public string TamperProtectionAlgorithm { get; set; } = "HMAC-SHA256";
|
||||
|
||||
public string TamperProtectionValue { get; set; }
|
||||
}
|
||||
|
||||
public class DiffEncryptionInfo
|
||||
{
|
||||
public string Algorithm { get; set; } = "AES-256-CBC+HMAC-SHA256";
|
||||
|
||||
public string KeyId { get; set; } = "default";
|
||||
|
||||
public string Nonce { get; set; }
|
||||
|
||||
public string Tag { get; set; }
|
||||
}
|
||||
|
||||
public class DiffPayload
|
||||
{
|
||||
public DiffStatistics Statistics { get; set; } = new DiffStatistics();
|
||||
|
||||
public List<DiffOperation> Operations { get; set; } = new List<DiffOperation>();
|
||||
}
|
||||
|
||||
public class DiffStatistics
|
||||
{
|
||||
public int TextReplaceCount { get; set; }
|
||||
|
||||
public int ImageReplaceCount { get; set; }
|
||||
}
|
||||
|
||||
public class DiffOperation
|
||||
{
|
||||
public string OperationId { get; set; }
|
||||
|
||||
public string Type { get; set; }
|
||||
|
||||
public string ObjectType { get; set; }
|
||||
|
||||
public string ContainerKind { get; set; }
|
||||
|
||||
public string EmbeddedProgramId { get; set; }
|
||||
|
||||
public string EmbeddedPackageExtension { get; set; }
|
||||
|
||||
public DiffPosition Position { get; set; } = new DiffPosition();
|
||||
|
||||
public DiffRuleHitInfo Rule { get; set; }
|
||||
|
||||
public string OriginalText { get; set; }
|
||||
|
||||
public string ReplacementTemplateResult { get; set; }
|
||||
|
||||
public string WrittenText { get; set; }
|
||||
|
||||
public int? DisplayWidthOriginal { get; set; }
|
||||
|
||||
public int? DisplayWidthWritten { get; set; }
|
||||
|
||||
public bool? Truncated { get; set; }
|
||||
|
||||
public bool? PaddingApplied { get; set; }
|
||||
|
||||
public string SourceKind { get; set; }
|
||||
|
||||
public DiffImageData OriginalImage { get; set; }
|
||||
|
||||
public DiffImageData ConvertedBitmapImage { get; set; }
|
||||
|
||||
public DiffImageData NewImage { get; set; }
|
||||
|
||||
public int? Seed { get; set; }
|
||||
|
||||
public DiffNoiseSummary NoiseSummary { get; set; }
|
||||
|
||||
public DiffImageLayout Layout { get; set; }
|
||||
}
|
||||
|
||||
public class DiffPosition
|
||||
{
|
||||
public string StoryType { get; set; }
|
||||
|
||||
public string ContainerPath { get; set; }
|
||||
|
||||
public int ParagraphIndex { get; set; }
|
||||
|
||||
public int ParagraphTextLength { get; set; } = -1;
|
||||
|
||||
public string ParagraphTextHash { get; set; }
|
||||
|
||||
public int StartTextOffset { get; set; } = -1;
|
||||
|
||||
public int EndTextOffset { get; set; } = -1;
|
||||
|
||||
public int StartRunIndex { get; set; }
|
||||
|
||||
public int StartCharOffset { get; set; }
|
||||
|
||||
public int EndRunIndex { get; set; }
|
||||
|
||||
public int EndCharOffset { get; set; }
|
||||
|
||||
public int? ObjectIndex { get; set; }
|
||||
}
|
||||
|
||||
public class DiffRuleHitInfo
|
||||
{
|
||||
public string Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string MatchMode { get; set; }
|
||||
|
||||
public string Pattern { get; set; }
|
||||
|
||||
public int HitIndex { get; set; }
|
||||
}
|
||||
|
||||
public class DiffImageData
|
||||
{
|
||||
public string Format { get; set; }
|
||||
|
||||
public int WidthPx { get; set; }
|
||||
|
||||
public int HeightPx { get; set; }
|
||||
|
||||
public string Data { get; set; }
|
||||
}
|
||||
|
||||
public class DiffNoiseSummary
|
||||
{
|
||||
public double ModifiedPixelRatio { get; set; }
|
||||
}
|
||||
|
||||
public class DiffImageLayout
|
||||
{
|
||||
public long DisplayWidthEmu { get; set; }
|
||||
|
||||
public long DisplayHeightEmu { get; set; }
|
||||
|
||||
public string WrapMode { get; set; }
|
||||
|
||||
public double RotationDegree { get; set; }
|
||||
}
|
||||
}
|
||||
53
DCIT.Core/Models/Enums.cs
Normal file
53
DCIT.Core/Models/Enums.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
|
||||
namespace DCIT.Core.Models
|
||||
{
|
||||
public enum RuleMatchMode
|
||||
{
|
||||
PlainText = 0,
|
||||
RegularExpression = 1
|
||||
}
|
||||
|
||||
public enum ProcessingStatus
|
||||
{
|
||||
Pending = 0,
|
||||
InProgress = 1,
|
||||
Success = 2,
|
||||
Failed = 3,
|
||||
Stopped = 4
|
||||
}
|
||||
|
||||
public enum LogLevel
|
||||
{
|
||||
Info = 0,
|
||||
Warning = 1,
|
||||
Error = 2
|
||||
}
|
||||
|
||||
public enum AutoExtractCategory
|
||||
{
|
||||
Keyword = 0,
|
||||
HighFrequencyWord = 1,
|
||||
HighFrequencySentence = 2
|
||||
}
|
||||
|
||||
public enum KeywordAlgorithm
|
||||
{
|
||||
Frequency = 0,
|
||||
TfIdf = 1,
|
||||
TextRank = 2
|
||||
}
|
||||
|
||||
public enum RuleValidationSeverity
|
||||
{
|
||||
Info = 0,
|
||||
Warning = 1,
|
||||
Error = 2
|
||||
}
|
||||
|
||||
public enum RuleTarget
|
||||
{
|
||||
DocumentContent = 0,
|
||||
FileName = 1
|
||||
}
|
||||
}
|
||||
72
DCIT.Core/Models/FileScanItem.cs
Normal file
72
DCIT.Core/Models/FileScanItem.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DCIT.Core.Models
|
||||
{
|
||||
public class FileScanItem : INotifyPropertyChanged
|
||||
{
|
||||
private bool _isSelected = true;
|
||||
private string _sourcePath;
|
||||
private string _outputPath;
|
||||
private string _diffPath;
|
||||
private int _textOperationCount;
|
||||
private int _imageOperationCount;
|
||||
private ProcessingStatus _status = ProcessingStatus.Pending;
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return _isSelected; }
|
||||
set { SetField(ref _isSelected, value); }
|
||||
}
|
||||
|
||||
public string SourcePath
|
||||
{
|
||||
get { return _sourcePath; }
|
||||
set { SetField(ref _sourcePath, value); }
|
||||
}
|
||||
|
||||
public string OutputPath
|
||||
{
|
||||
get { return _outputPath; }
|
||||
set { SetField(ref _outputPath, value); }
|
||||
}
|
||||
|
||||
public string DiffPath
|
||||
{
|
||||
get { return _diffPath; }
|
||||
set { SetField(ref _diffPath, value); }
|
||||
}
|
||||
|
||||
public int TextOperationCount
|
||||
{
|
||||
get { return _textOperationCount; }
|
||||
set { SetField(ref _textOperationCount, value); }
|
||||
}
|
||||
|
||||
public int ImageOperationCount
|
||||
{
|
||||
get { return _imageOperationCount; }
|
||||
set { SetField(ref _imageOperationCount, value); }
|
||||
}
|
||||
|
||||
public ProcessingStatus Status
|
||||
{
|
||||
get { return _status; }
|
||||
set { SetField(ref _status, value); }
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(field, value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
field = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
17
DCIT.Core/Models/LogEntry.cs
Normal file
17
DCIT.Core/Models/LogEntry.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace DCIT.Core.Models
|
||||
{
|
||||
public class LogEntry
|
||||
{
|
||||
public DateTime Timestamp { get; set; } = DateTime.Now;
|
||||
|
||||
public LogLevel Level { get; set; }
|
||||
|
||||
public string EventCode { get; set; }
|
||||
|
||||
public string Message { get; set; }
|
||||
|
||||
public string Detail { get; set; }
|
||||
}
|
||||
}
|
||||
20
DCIT.Core/Models/LogWriteFailureEventArgs.cs
Normal file
20
DCIT.Core/Models/LogWriteFailureEventArgs.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace DCIT.Core.Models
|
||||
{
|
||||
public sealed class LogWriteFailureEventArgs : EventArgs
|
||||
{
|
||||
public LogWriteFailureEventArgs(LogEntry entry, string logFilePath, Exception exception)
|
||||
{
|
||||
Entry = entry;
|
||||
LogFilePath = logFilePath;
|
||||
Exception = exception;
|
||||
}
|
||||
|
||||
public LogEntry Entry { get; private set; }
|
||||
|
||||
public string LogFilePath { get; private set; }
|
||||
|
||||
public Exception Exception { get; private set; }
|
||||
}
|
||||
}
|
||||
72
DCIT.Core/Models/ProcessingModels.cs
Normal file
72
DCIT.Core/Models/ProcessingModels.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
|
||||
namespace DCIT.Core.Models
|
||||
{
|
||||
public class ReplaceFileRequest
|
||||
{
|
||||
public string SourcePath { get; set; }
|
||||
|
||||
public string OutputPath { get; set; }
|
||||
|
||||
public string DiffPath { get; set; }
|
||||
|
||||
public string SourceRootDirectory { get; set; }
|
||||
|
||||
public string RuleFilePath { get; set; }
|
||||
|
||||
public RuleFile RuleFile { get; set; }
|
||||
|
||||
public bool EncryptDiff { get; set; }
|
||||
|
||||
public bool EnableImageReplacement { get; set; } = true;
|
||||
|
||||
public int? FixedImageSeed { get; set; }
|
||||
}
|
||||
|
||||
public class RestoreFileRequest
|
||||
{
|
||||
public string ReplacedPath { get; set; }
|
||||
|
||||
public string DiffPath { get; set; }
|
||||
|
||||
public string OutputPath { get; set; }
|
||||
|
||||
public string ReplaceRootDirectory { get; set; }
|
||||
|
||||
public string CurrentRuleFilePath { get; set; }
|
||||
}
|
||||
|
||||
public class FileProcessProgress
|
||||
{
|
||||
public string FilePath { get; set; }
|
||||
|
||||
public int FilePercent { get; set; }
|
||||
|
||||
public string CurrentRuleId { get; set; }
|
||||
|
||||
public string CurrentRuleName { get; set; }
|
||||
|
||||
public int CurrentFileTextCount { get; set; }
|
||||
|
||||
public int TotalTextCount { get; set; }
|
||||
|
||||
public string Message { get; set; }
|
||||
|
||||
public bool IsWarning { get; set; }
|
||||
}
|
||||
|
||||
public class FileProcessResult
|
||||
{
|
||||
public string OutputPath { get; set; }
|
||||
|
||||
public string DiffPath { get; set; }
|
||||
|
||||
public string BmpPath { get; set; }
|
||||
|
||||
public int TextOperationCount { get; set; }
|
||||
|
||||
public int ImageOperationCount { get; set; }
|
||||
|
||||
public bool Stopped { get; set; }
|
||||
}
|
||||
}
|
||||
125
DCIT.Core/Models/RuleDefinition.cs
Normal file
125
DCIT.Core/Models/RuleDefinition.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DCIT.Core.Models
|
||||
{
|
||||
public class RuleDefinition : INotifyPropertyChanged
|
||||
{
|
||||
private string _id;
|
||||
private string _name;
|
||||
private bool _isEnabled = true;
|
||||
private RuleMatchMode _matchMode = RuleMatchMode.PlainText;
|
||||
private bool _isCaseSensitive;
|
||||
private bool _isWholeWord;
|
||||
private RuleTarget _target = RuleTarget.DocumentContent;
|
||||
private string _searchText;
|
||||
private string _replacementText;
|
||||
private string _note;
|
||||
|
||||
public string Id
|
||||
{
|
||||
get { return _id; }
|
||||
set { SetField(ref _id, value); }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { SetField(ref _name, value); }
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get { return _isEnabled; }
|
||||
set { SetField(ref _isEnabled, value); }
|
||||
}
|
||||
|
||||
public RuleMatchMode MatchMode
|
||||
{
|
||||
get { return _matchMode; }
|
||||
set { SetField(ref _matchMode, value); }
|
||||
}
|
||||
|
||||
public RuleTarget Target
|
||||
{
|
||||
get { return _target; }
|
||||
set { SetField(ref _target, value); }
|
||||
}
|
||||
|
||||
public bool IsCaseSensitive
|
||||
{
|
||||
get { return _isCaseSensitive; }
|
||||
set { SetField(ref _isCaseSensitive, value); }
|
||||
}
|
||||
|
||||
public bool IsWholeWord
|
||||
{
|
||||
get { return _isWholeWord; }
|
||||
set { SetField(ref _isWholeWord, value); }
|
||||
}
|
||||
|
||||
public string SearchText
|
||||
{
|
||||
get { return _searchText; }
|
||||
set { SetField(ref _searchText, value); }
|
||||
}
|
||||
|
||||
public string ReplacementText
|
||||
{
|
||||
get { return _replacementText; }
|
||||
set { SetField(ref _replacementText, value); }
|
||||
}
|
||||
|
||||
public string Note
|
||||
{
|
||||
get { return _note; }
|
||||
set { SetField(ref _note, value); }
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(field, value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
field = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
public class RuleFile
|
||||
{
|
||||
public string Format { get; set; } = "dcit.rule";
|
||||
|
||||
public string Version { get; set; } = "1.0";
|
||||
|
||||
public List<RuleDefinition> Rules { get; set; } = new List<RuleDefinition>();
|
||||
}
|
||||
|
||||
public class RuleValidationIssue
|
||||
{
|
||||
public RuleValidationSeverity Severity { get; set; }
|
||||
|
||||
public int Index { get; set; }
|
||||
|
||||
public string RuleId { get; set; }
|
||||
|
||||
public string RuleName { get; set; }
|
||||
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
public class RuleValidationReport
|
||||
{
|
||||
public List<RuleValidationIssue> Issues { get; } = new List<RuleValidationIssue>();
|
||||
|
||||
public bool HasErrors
|
||||
{
|
||||
get { return Issues.Exists(item => item.Severity == RuleValidationSeverity.Error); }
|
||||
}
|
||||
}
|
||||
}
|
||||
24
DCIT.Core/Models/RuntimeEnvironmentValidationModels.cs
Normal file
24
DCIT.Core/Models/RuntimeEnvironmentValidationModels.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DCIT.Core.Models
|
||||
{
|
||||
public sealed class RuntimeEnvironmentValidationResult
|
||||
{
|
||||
public string StartupDirectory { get; set; }
|
||||
|
||||
public bool IsStartupDirectoryWritable { get; set; }
|
||||
|
||||
public string ResolvedAutomationProgId { get; set; }
|
||||
|
||||
public string ResolvedDocToPath { get; set; }
|
||||
|
||||
public IList<string> BlockingIssues { get; } = new List<string>();
|
||||
|
||||
public IList<string> Warnings { get; } = new List<string>();
|
||||
|
||||
public bool HasBlockingIssues
|
||||
{
|
||||
get { return BlockingIssues.Count > 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user