整合管理器应用端(MAUI跨平台)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.8 KiB

using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
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; }
}
public partial class InfoItem
{
public string? Name { get; set; }
public string? State { get; set; }
public string? MachineName { get; set; }
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; }
}
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 string? ReDye { get; set; }
public string? Machine { get; set; }
public string? CreationTime { get; set; }
public string? FabricName { get; set; }
public string? ColorName { get; set; }
public string? CustomerName { get; set; }
public string? Information { get; set; }
}
public class DyelotDetailsItem
{
public string? Dyelot { get; set; }
public string? ReDye { get; set; }
public string? Step { get; set; }
public string? ProductName { get; set; }
public string? ProductCode { get; set; }
public string? ProductType { get; set; }
public string? ProductProgram { get; set; }
public string? DispenserGram { get; set; }
public string? Gram { get; set; }
public string? Machine { get; set; }
public string? CreationTime { get; set; }
public string? CallTime { get; set; }
public string? EndTime { get; set; }
public string? StartTime { get; set; }
public string? Information { get; set; }
}
public static class DataService
{
// 直接返回 List
public static List<NotificationItem> _NotificationData = new List<NotificationItem>();
public static List<NotificationItem> GetAllItems()
{
DataSet? data = AppModels.Select("select * from Notification Where Time > '" +
DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd HH:mm:ss.fff") + "'");
_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();
}
}
}