Files
SunlightAggregationTerminal/Models/DataSource.cs
T

121 lines
4.2 KiB
C#
Raw Normal View History

using CommunityToolkit.Mvvm.ComponentModel;
using System;
2026-05-01 14:44:49 +08:00
using System.Collections.Generic;
using System.ComponentModel;
2026-05-01 14:44:49 +08:00
using System.Data;
using System.Linq;
using System.Text;
2026-05-01 14:44:49 +08:00
namespace SunlightAggregationTerminal.Models
{
// 定义枚举
public enum MsgType
{
Notice, // 通知
Message, // 信息
System // 系统
}
// 定义显示用的模型
public class NotificationItem
{
public Int64 Id { get; set; }
public string? Title { get; set; }
public string? Content { get; set; }
public DateTime Time { get; set; }
public MsgType Type { get; set; }
}
2026-05-11 02:25:45 +08:00
public partial class InfoItem
2026-05-09 22:38:04 +08:00
{
public string? Name { get; set; }
public string? State { get; set; }
public string? MachineName { get; set; }
2026-05-09 22:38:04 +08:00
public string? Machine { get; set; }
public string? Information { get; set; }
public string? Model { get; set; }
public string? Type { get; set; }
public string? ModelA { get; set; }
public string? ModelB { get; set; }
public string? ModelC { get; set; }
public string? ModelD { get; set; }
public string? ModelE { get; set; }
public string? ModelF { get; set; }
2026-05-09 22:38:04 +08:00
}
2026-05-14 01:29:47 +08:00
public partial class ProbuctItem
{
public string? ProductName { get; set; }
public string? ProductCode { get; set; }
public string? ProductState { get; set; }
public string? ProductInf { get; set; }
}
public class DyelotItem
{
public string? Dyelot { get; set; }
public int? ReDye { get; set; }
2026-05-19 01:34:43 +08:00
public int? Color { get; set; }
public string? Machine { get; set; }
2026-05-19 01:34:43 +08:00
public string? Program { get; set; }
public string? CreationTime { get; set; }
public string? FabricName { get; set; }
public string? ColorName { get; set; }
public string? CustomerName { get; set; }
2026-05-19 01:34:43 +08:00
public string? Notes { get; set; }
2026-05-16 00:03:36 +08:00
}
public class DyelotDetailsItem
{
public string? Dyelot { get; set; }
public int? ReDye { get; set; }
2026-05-19 01:34:43 +08:00
public int? StepNumber { get; set; }
2026-05-16 00:03:36 +08:00
public string? ProductName { get; set; }
public string? ProductCode { get; set; }
2026-05-19 01:34:43 +08:00
public int? ProductType { get; set; }
public string? Process { get; set; }
public double? Grams { get; set; }
public string GramsDisplay => Grams?.ToString("F2") ?? "";
public string? Created { get; set; }
public string? DispenseStartTime { get; set; }
public string? DispenseEndTime { get; set; }
public string? DispenseTime { get; set; }
public string? CallTime { get; set; }
public string? UsageTime { get; set; }
public string? Tank { get; set; }
public object? PowderTargetTank { get; set; }
2026-05-19 01:34:43 +08:00
public double? DispenseGrams { get; set; }
public string DispenseGramsDisplay => DispenseGrams?.ToString("F2") ?? "";
public int? DispenseResult { get; set; }
public string? Notes { get; set; }
}
2026-05-01 14:44:49 +08:00
public static class DataService
{
// 直接返回 List
public static List<NotificationItem> _NotificationData = new List<NotificationItem>();
public static List<NotificationItem> GetAllItems()
{
2026-05-04 01:01:23 +08:00
DataSet? data = AppModels.Select("select * from Notification Where Time > '" +
DateTime.Now.AddDays(-60).ToString("yyyy-MM-dd HH:mm:ss.fff") + "'");
2026-05-04 01:01:23 +08:00
2026-05-01 14:44:49 +08:00
_NotificationData.Clear();
if (data != null)
{
foreach (DataRow dr in data.Tables[0].Rows)
{
_NotificationData.Add(new NotificationItem
{
Id = dr.Field<Int64>("Id"),
Title = dr.Field<string>("Title") ,
Content = dr.Field<string>("Content"),
Time = DateTime.Parse(dr.Field<string>("Time")!),
Type = (MsgType)dr.Field<Int64>("Type")
});
}
}
// 倒序返回
return _NotificationData.OrderByDescending(x => x.Time).ToList();
}
}
}