mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-28 16:55:32 +00:00
46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using System.Text;
|
|
using Microsoft.Extensions.FileProviders;
|
|
|
|
namespace HaWeb.Models;
|
|
|
|
public class FileModel {
|
|
public string FileName { get; private set; }
|
|
public IFileInfo File { get; private set; }
|
|
|
|
// This affects only repo files
|
|
public bool IsValid { get; private set; } = false;
|
|
public List<XMLRootDocument>? Content { get; set; }
|
|
public List<(string, string?)>? Fields { get; set; }
|
|
public string? Prefix { get; set; }
|
|
|
|
private StringBuilder? _log;
|
|
|
|
public FileModel(string name, IFileInfo file) {
|
|
FileName = name;
|
|
File = file;
|
|
}
|
|
|
|
public string? GetLog() {
|
|
if (_log == null) return null;
|
|
return _log.ToString();
|
|
}
|
|
|
|
public void Log(string msg) {
|
|
if (_log == null) _log = new StringBuilder();
|
|
var prefix = DateTime.Now.ToShortTimeString() + " ";
|
|
if (File != null) prefix += File.Name + ": ";
|
|
_log.AppendLine(prefix + msg);
|
|
}
|
|
|
|
public void ResetLog() {
|
|
if (_log != null) _log.Clear();
|
|
}
|
|
|
|
public void Validate() {
|
|
IsValid = true;
|
|
}
|
|
|
|
public DateTime GetLastModified() {
|
|
return File.LastModified.ToLocalTime().DateTime;
|
|
}
|
|
} |