public static Message Map(Data.Msg msg) { if (msg == null) { return(null); } return(new Message(msg.SenderId, msg.ReceiverId, msg.Msg1, msg.Dtime.Value, msg.Id)); }
public void TestDataMsg() { Data.Msg msg = new Data.Msg() { SenderId = 1, ReceiverId = 2, Msg1 = "Hello", Dtime = DateTime.Now }; var expected = Mapper.Map(msg); Assert.NotNull(expected); }
public static Data.Msg Map(Message message) { if (message == null) { return(null); } var m = new Data.Msg { SenderId = message.FromId, ReceiverId = message.ToId, Msg1 = message.Content, Dtime = message.Time }; if (message.Id > -1) { m.Id = message.Id; } return(m); }
/// <summary> /// 发送临时消息 /// </summary> /// <param name="text">要发送的文本</param> /// <param name="key">你的Session</param> /// <param name="host">Http服务器地址</param> /// <param name="port">Http服务器端口</param> /// <param name="qq">好友QQ号</param> public string sendTempMessage(string host, int port, uint qq, string key, string text) { var m = new Data.MessageChain() { type = "Plain", text = text }; var msg = new List <Data.MessageChain>(); msg.Add(m); var messgae = new Data.Msg() { sessionKey = key, target = qq, messageChain = msg }; string newmsg = JsonConvert.SerializeObject(messgae); return(HttpPost("http://" + host + ":" + port + "/sendTempMessage", newmsg)); }