Add project files.

This commit is contained in:
2026-02-21 10:30:14 -07:00
parent 398161da53
commit f662d576d1
28 changed files with 1127 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace paperless_ngx_export.Models
{
public class CustomFieldParsed
{
public string Name { get; set; }
public object? Value { get; set; }
public Type DataType { get; set; }
public string StringValue => (string)Value;
public DateTime DateValue => Value != null && DataType == typeof(DateTime) ? (DateTime)Value : DateTime.MinValue;
public static CustomFieldParsed FromCustomFieldKeyValuePair(CustomFieldKeyValuePair pair, IEnumerable<CustomField> customFields)
{
if (pair.value != null && customFields.FirstOrDefault(cf => cf.Id == pair.field) is CustomField field)
{
try
{
switch (field.data_type)
{
case CustomField_DataType.date:
return new CustomFieldParsed
{
Name = field.name,
Value = DateTime.Parse(pair.value),
DataType = typeof(DateTime)
};
break;
case CustomField_DataType.select:
return new CustomFieldParsed
{
Name = field.name,
Value = field.extra_data.select_options.First(so => so.id == pair.value).label,
DataType = typeof(string)
};
break;
default:
return new CustomFieldParsed
{
Name = field.name,
Value = pair.value,
DataType = typeof(string)
};
break;
}
}
catch (Exception ex)
{
;
}
}
return null;
}
public override string ToString()
{
return $"{Name}: {Value} ({DataType.Name})";
}
}
}