public SendingMsg(IList <string> strToSIDs, string strRoomSID, int nContentType, string strContent, string strFromSID, ICommunicationMsgInfo communicationMsg) { this.ToSIDs = strToSIDs; this.RoomSID = strRoomSID; this.ContentType = nContentType; this.Content = strContent; this.FromSID = strFromSID; this.CommunicationMsg = communicationMsg; }
private void UpdateSendMessage(SendingMsgResult result, ICommunicationMsgInfo communicationMsg, MongoCollection <MessageEntity> msgCollection, string strContent, string strSendMsgId) { var FindMsgQuery = Query <MessageEntity> .EQ(m => m.Id, new ObjectId(strSendMsgId)); if (200 == result.Status) { CommunicationMsg SentMsg = communicationMsg as CommunicationMsg; try { var RecentSuccessMsg = this.Messages.OfType <CommunicationMsg>().Last(m => m.MsgStatus != MsgStatus.Failed && m.MsgStatus != MsgStatus.Sending); Application.Current.Dispatcher.Invoke(() => { this.Messages.Remove(SentMsg); int nIndexOfRecentSuccessdMsg = this.Messages.IndexOf(RecentSuccessMsg); this.Messages.Insert(nIndexOfRecentSuccessdMsg + 1, SentMsg); }); } catch (InvalidOperationException) { //If you cannot find RecentSuccessMsg Application.Current.Dispatcher.Invoke(() => { this.Messages.Remove(SentMsg); this.Messages.Insert(0, SentMsg); }); } communicationMsg.MsgStatus = MsgStatus.Sent; communicationMsg.SendTime = result.SentTime; var UpdateMsgQuery = Update <MessageEntity> .Set(m => m.State, (int)MsgStatus.Sent) .Set(m => m.SendTime, result.SentTime) .Set(m => m.Sid, result.MsgSid); msgCollection.Update(FindMsgQuery, UpdateMsgQuery); this.m_RoomsController.UpdateLastMsg(this.RoomSID, strContent, result.SentTime); } else { communicationMsg.MsgStatus = MsgStatus.Failed; var UpdateMsgQuery = Update <MessageEntity> .Set(m => m.State, (int)MsgStatus.Failed); msgCollection.Update(FindMsgQuery, UpdateMsgQuery); } }