public ConversationModel(EMConversation mConversation) { conversation = mConversation; if (conversation == null) { throw new AggregateException("The conversation not be null"); } conversationType = conversation.conversationType(); if (conversation.conversationType() == EMConversationType.CHAT) { var friend = DBHelper.Instance.getFriend(conversation.conversationId()); if (friend != null) { name = string.IsNullOrEmpty(friend.target_user_nickname) ? friend.friend_self_name : friend.target_user_nickname; avatarURL = friend.portrait; DCWebImageMaanager.shard.downloadImageAsync(avatarURL, (image, b) => { avatarImage = image; }); isWorkGroup = false; if (friend.is_shield == 1) { isSheild = true; } else { isSheild = false; } } else { var stonger = DBHelper.Instance.GetStronger(conversation.conversationId()); if (stonger != null) { name = stonger.nickName; avatarURL = stonger.avatar; DCWebImageMaanager.shard.downloadImageAsync(avatarURL, (image, b) => { avatarImage = image; }); isWorkGroup = false; isSheild = false; } else { avatarImage = Properties.Resources.moren; } } } else { var group = DBHelper.Instance.GetGroup(conversation.conversationId()); if (group != null) { name = group.groupName; avatarURL = group.avatar; DCWebImageMaanager.shard.downloadImageAsync(avatarURL, (image, b) => { avatarImage = image; }); if (group.is_pingbi == 1) { isSheild = true; } else { isSheild = false; } if (group.group_type == 1) { isWorkGroup = true; } else { isWorkGroup = false; } } else { var gt = DBHelper.Instance.GetGroupCache(conversation.conversationId()); if (gt != null) { name = gt.groupName; avatarURL = gt.avatar; DCWebImageMaanager.shard.downloadImageAsync(avatarURL, (image, b) => { avatarImage = image; }); isSheild = false; isWorkGroup = false; } else { avatarImage = Properties.Resources.moren; } } } if (avatarImage == null) { avatarImage = Properties.Resources.moren; } time = DCUtilTool.GetMessageTime(conversation.latestMessage()); lastMessageText = DCUtilTool.getMessageShowTest(conversation.latestMessage()); }
public UnreadTipsItem(EMConversation conversation) { InitializeComponent(); if (conversation.conversationType() == EMConversationType.GROUPCHAT) { var group = DBHelper.Instance.GetGroup(conversation.conversationId()); if (group != null) { DCWebImageMaanager.shard.downloadImageAsync(group.avatar, (image, b) => { if (image != null) { this.BeginInvoke(() => { duiPictureBox1.Image = image; }); } }); this.BeginInvoke(() => { duiLabel1.Text = group.groupName; duiLabel2.Text = DCUtilTool.getMessageShowTest(conversation.latestMessage()); }); } else { var g = DBHelper.Instance.GetGroupCache(conversation.conversationId()); if (g != null) { DCWebImageMaanager.shard.downloadImageAsync(g.avatar, (image, b) => { if (image != null) { this.BeginInvoke(() => { duiPictureBox1.Image = image; }); } }); this.BeginInvoke(() => { duiLabel1.Text = g.groupName; duiLabel2.Text = DCUtilTool.getMessageShowTest(conversation.latestMessage()); }); } } } else { var friend = DBHelper.Instance.getFriend(conversation.conversationId()); if (friend != null) { DCWebImageMaanager.shard.downloadImageAsync(friend.portrait, (image, b) => { if (image != null) { this.BeginInvoke(() => { duiPictureBox1.Image = image; }); } }); this.BeginInvoke(() => { duiLabel1.Text = string.IsNullOrEmpty(friend.target_user_nickname) ? friend.friend_self_name : friend.target_user_nickname; duiLabel2.Text = DCUtilTool.getMessageShowTest(conversation.latestMessage()); }); } else { var user = DBHelper.Instance.GetStronger(conversation.conversationId()); if (user != null) { DCWebImageMaanager.shard.downloadImageAsync(user.avatar, (image, b) => { if (image != null) { this.BeginInvoke(() => { duiPictureBox1.Image = image; }); } }); this.BeginInvoke(() => { duiLabel1.Text = user.nickName; duiLabel2.Text = DCUtilTool.getMessageShowTest(conversation.latestMessage()); }); } } } }