修改BUG:站内消息字段转换异常,更改数据库结构,增加数据默认值

This commit is contained in:
Argo-Lenovo 2016-11-15 15:00:17 +08:00
parent 270d70b538
commit d191da612c
3 changed files with 83 additions and 72 deletions

View File

@ -37,10 +37,9 @@ namespace Bootstrap.DataAccess
/// </summary> /// </summary>
public DateTime SendTime { get; set; } public DateTime SendTime { get; set; }
/// <summary> /// <summary>
/// 消息状态0-未读1-已读 /// 消息状态0-未读1-已读 和Dict表的通知消息关联
/// 和Dict表的通知消息关联
/// </summary> /// </summary>
public string Status { get; set; } public string Status { get; set; }
/// <summary> /// <summary>
/// 标旗状态0-未标旗1-已标旗 /// 标旗状态0-未标旗1-已标旗
/// </summary> /// </summary>
@ -50,11 +49,14 @@ namespace Bootstrap.DataAccess
/// </summary> /// </summary>
public int IsDelete { get; set; } public int IsDelete { get; set; }
/// <summary> /// <summary>
/// 消息标签0-一般1-紧要 /// 消息标签0-一般1-紧要 和Dict表的消息标签关联
/// 和Dict表的消息标签关联
/// </summary> /// </summary>
public string Label { get; set; } public string Label { get; set; }
/// <summary> /// <summary>
/// 获得/设置 标签名称
/// </summary>
public string LabelName { get; set; }
/// <summary>
/// 获得/设置 时间描述 2分钟内为刚刚 /// 获得/设置 时间描述 2分钟内为刚刚
/// </summary> /// </summary>
public string Period { get; set; } public string Period { get; set; }

View File

@ -27,7 +27,7 @@ namespace Bootstrap.DataAccess
{ {
var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageDataKey), key => var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageDataKey), key =>
{ {
string sql = "select * from [Messages] where [To]=@UserName or [From]=@UserName"; string sql = "select m.*, d.Name from [Messages] m left join Dicts d on m.Label = d.Code and d.Category = N'消息状态' and d.Define = 0 where[To] = @UserName or [From] = @UserName";
List<Message> messages = new List<Message>(); List<Message> messages = new List<Message>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try try
@ -46,10 +46,10 @@ namespace Bootstrap.DataAccess
To = (string)reader[4], To = (string)reader[4],
SendTime = LgbConvert.ReadValue(reader[5], DateTime.MinValue), SendTime = LgbConvert.ReadValue(reader[5], DateTime.MinValue),
Status = (string)reader[6], Status = (string)reader[6],
Mark=(int)reader[7], Mark = (int)reader[7],
IsDelete=(int)reader[8], IsDelete = (int)reader[8],
Label=(string)reader[9] Label = (string)reader[9],
LabelName = LgbConvert.ReadValue(reader[10], string.Empty)
}); });
} }
} }
@ -88,7 +88,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable<Message> Trash(string userName) public static IEnumerable<Message> Trash(string userName)
{ {
var messageRet = RetrieveMessages(userName); var messageRet = RetrieveMessages(userName);
return messageRet.Where(n => n.IsDelete==1).Select(n => n); return messageRet.Where(n => n.IsDelete == 1).Select(n => n);
} }
/// <summary> /// <summary>
/// 标旗 /// 标旗
@ -98,7 +98,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable<Message> Mark(string userName) public static IEnumerable<Message> Mark(string userName)
{ {
var messageRet = RetrieveMessages(userName); var messageRet = RetrieveMessages(userName);
return messageRet.Where(n => n.Mark==1).Select(n => n); return messageRet.Where(n => n.Mark == 1).Select(n => n);
} }
/// <summary> /// <summary>
/// 获取Header处显示的消息列表 /// 获取Header处显示的消息列表

View File

@ -331,7 +331,7 @@ CREATE TABLE [dbo].[Messages](
[To] [varchar](50) NOT NULL, [To] [varchar](50) NOT NULL,
[SendTime] [datetime] NOT NULL, [SendTime] [datetime] NOT NULL,
[Status] [nvarchar](50) NOT NULL, [Status] [nvarchar](50) NOT NULL,
[Mark] [nvarchar](50) NOT NULL, [Flag] [int] NOT NULL,
[IsDelete] [int] NOT NULL, [IsDelete] [int] NOT NULL,
[Label] [nvarchar](50) NOT NULL, [Label] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED
@ -344,3 +344,12 @@ GO
SET ANSI_PADDING OFF SET ANSI_PADDING OFF
GO GO
ALTER TABLE [dbo].[Messages] ADD CONSTRAINT [DF_Messages_Mark] DEFAULT ((0)) FOR [Flag]
GO
ALTER TABLE [dbo].[Messages] ADD CONSTRAINT [DF_Messages_IsDelete] DEFAULT ((0)) FOR [IsDelete]
GO
ALTER TABLE [dbo].[Messages] ADD CONSTRAINT [DF_Messages_Label] DEFAULT ((0)) FOR [Label]
GO