添加添加数据库服务器表
修改扫码连接修复扫码闪退问题
This commit is contained in:
1 parent
6c0af56ea9
commit
0801e4875c
64 files changed
+3265
No files matched your search
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
|
||||
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 static class DataService
|
||||
{
|
||||
public static DataSet? data = AppModels.Select("select * from Notification Where Time > '" + DateTime.Now.AddDays(-30) + "'");
|
||||
|
||||
// 直接返回 List
|
||||
public static List<NotificationItem> _NotificationData = new List<NotificationItem>();
|
||||
public static List<NotificationItem> GetAllItems()
|
||||
{
|
||||
_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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user