using System; using System.Collections.Generic; using System.Linq; using System.Data; using System.Text; using System.Threading.Tasks; using Dapper; namespace RDH.PharmacyPlatform.Sync.Core { internal class MessageDataInDAL : BaseDAL { public MessageDataInDAL() { this.TableName = "T_Message_Data_In"; } internal override Dictionary InitMaps() { Dictionary maps = new Dictionary(); maps.Add("Create_Time", "CreateTime"); maps.Add("Source_Id", "SourceId"); maps.Add("Message_Content", "MessageContent"); maps.Add("Message_Content_Type", "MessageContentType"); maps.Add("Filter_Type", "FilterType"); maps.Add("Target_Id", "TargetId"); return maps; } public override bool DeleteModel(MessageData obj) { return SqlMapper.Execute(ConnectionSessionFactory.GetConnection(), String.Format("DELETE FROM {0} WHERE Create_Time=:CreateTime AND Source_Id=:SourceId", this.TableName), obj) > 0; } internal MessageData DeQueue() { IDbConnection conn = ConnectionSessionFactory.GetConnection(); MessageData message = SqlMapper.Query(conn, String.Format("{0} ORDER BY Create_Time DESC", BuildSelectSql())).FirstOrDefault(); if (message != null) { DeleteModel(message); } return message; } internal MessageData Peek() { IDbConnection conn = ConnectionSessionFactory.GetConnection(); MessageData message = SqlMapper.Query(conn, String.Format("{0} ORDER BY Create_Time LIMIT 1", BuildSelectSql())).FirstOrDefault(); return message; } } }