/// <summary> /// 实例化一个新的聊天信息 /// </summary> /// <param name="message">聊天信息的数据封装</param> /// <param name="isSelf">一个布尔值 表示是否自己的发言</param> public MessageResult(Message message, bool isSelf) { this.From = message.From; this.To = message.To; this.Content = message.Content; this.IsOfficial = message.IsOfficial; this.SendTime = message.CreatedTime; this.IsSelf = isSelf; this.Ip = message.Ip; this.Address = message.Address; }
/// <summary> /// 发送一个新的聊天信息 /// </summary> /// <param name="_from">发件人</param> /// <param name="_to">收件人</param> /// <param name="content">正文</param> /// <param name="ip">来源地址</param> /// <param name="address">来源地址</param> /// <param name="readed">已经阅读</param> /// <param name="isOfficial">一个布尔值 表示是否官方信息</param> /// <returns>返回被创建的聊天信息的封装</returns> public static Message Send(string _from, string _to, string content, string ip, string address , bool readed, bool isOfficial = false) { using (Model2DataContext db = new Model2DataContext()) { Message message = new Message(_from, _to, content, ip, address, readed, isOfficial); db.PondOfMessage.Add(message); db.SaveChanges(); return message; } }