private void AddMessage(Message message) { Block[] blocks = message.MessageBlocks; if (blocks != null && blocks.Length > 0) { Staff staff = this.dataService.GetStaff((long)((ulong)Jid.GetUid(message.FromJid))); if (staff != null) { if (!string.IsNullOrEmpty(message.Url) && !string.IsNullOrEmpty(message.Icon) && !string.IsNullOrEmpty(message.FileName) && staff.Uid == this.sessionService.Uid) { System.IO.FileInfo file = new System.IO.FileInfo(message.FileName); OpenFileControl openFile = new OpenFileControl(new FileItem(file) { FileName = message.Url + message.FileName, IconBase64 = message.Icon }, true); if (openFile != null && !string.IsNullOrEmpty(staff.Name)) { Paragraph p = new Paragraph(); FlowDocument doc = this.ViewMessageBoxViewer.Document; TableRow tableRow = new TableRow(); TableCell tableCell = new TableCell(); tableRow.Cells.Add(tableCell); tableCell.Blocks.Add(this.GetNameInfo(staff.Name, message.CreateTime, staff.Uid == this.sessionService.Uid)); p.Inlines.Add(openFile); doc.Blocks.Add(p); tableCell.Blocks.Add(doc.Blocks.LastBlock); this.trgMessageTable.Rows.Add(tableRow); } } else { TableRow tableRow = this.CreateTableRow(message, blocks, staff); this.trgMessageTable.Rows.Add(tableRow); this.ScroolToEnd(); } } else { TableRow tableRow = new TableRow(); TableCell tableCell = new TableCell(); tableRow.Cells.Add(tableCell); tableCell.Blocks.Add(this.GetNameInfo("此人已离职", message.CreateTime, (long)int.Parse(message.FromJid.Substring(0, message.FromJid.IndexOf("@"))) == this.sessionService.Uid)); Block[] array = blocks; for (int i = 0; i < array.Length; i++) { Paragraph block = (Paragraph)array[i]; this.SetParagraphStyle(block, message.Style); tableCell.Blocks.Add(block); } this.trgMessageTable.Rows.Add(tableRow); } } this.DataSelect.Text = message.CreateTime.Substring(0, 10); }
private void RosterNewMessage(Message msg) { RosterTab item = this.dataService.GetRosterChatTab((long)((ulong)Jid.GetUid(msg.FromJid))) as RosterTab; if (item == null) { Roster roster = this.dataService.GetRoster((long)((ulong)Jid.GetUid(msg.FromJid))); if (roster != null) { item = new RosterTab(roster); item.SetDefaultStyle(); ((INWindow)this.dataService.INWindow).ContentTab.Items.Add(item); this.dataService.AddRosterChatTab(roster.Uid, item); } } this.baseTab = item; FriendsChatTabControl tab = item.TabContent; if (tab != null) { tab.ChatComponent.AddMessageRoster(msg, false); tab.ChatComponent.inputMsgBox.Focus(); } }
private void StaffNewMessage(Message message) { EntStaffTab item = this.dataService.GetStaffChatTab((long)((ulong)Jid.GetUid(message.FromJid))) as EntStaffTab; if (item == null) { Staff staff = this.dataService.GetStaff((long)((ulong)Jid.GetUid(message.FromJid))); if (staff != null) { item = new EntStaffTab(staff); item.SetDefaultStyle(); ((INWindow)this.dataService.INWindow).ContentTab.Items.Add(item); this.dataService.AddStaffChatTab(staff.Uid, item); } } this.baseTab = item; PersonalChatTabControl tab = item.TabContent; if (tab != null) { tab.ChatComponent.AddMessageStaff(message, false); tab.ChatComponent.inputMsgBox.Focus(); } }
private void CooperationStaffNewMessage(Message message) { CoopStaffTab item = this.dataService.GetCooperationStaffChatTab((long)((ulong)Jid.GetUid(message.FromJid)), message.ProjectId) as CoopStaffTab; if (item == null) { CooperationStaff staff = this.dataService.GetCooperationStaff((long)((ulong)Jid.GetUid(message.FromJid)), message.ProjectId); CooperationProjectWrapper cooperationProjectWrapper = this.dataService.GetCooperationProjectWrapper(message.ProjectId); if (staff != null && cooperationProjectWrapper != null) { item = new CoopStaffTab(staff, cooperationProjectWrapper); item.SetDefaultStyle(); ((INWindow)this.dataService.INWindow).ContentTab.Items.Add(item); this.dataService.AddCooperationStaffChatTab(staff.Uid, staff.UnitedProjectid, item); } } this.baseTab = item; CoopStaffChatTabControl tab = item.TabContent; if (tab != null) { tab.ChatComponent.AddCooperationMessageStaff(message, false); tab.ChatComponent.inputMsgBox.Focus(); } }
public void Refresh() { try { this.lbMessageBox.Items.Clear(); if (!this.dataModel.HasMessage()) { NotifyIconUtil.Instance.SetFlashIcon(FlashIconType.Default); base.Close(); } foreach (string key in this.dataModel.MessageBoxSort) { if (!string.IsNullOrEmpty(key)) { System.Collections.Generic.List <Message> list = this.dataModel.GetMessage(key); if (list != null && list.Count > 0) { Message message = list[0]; if (message != null) { if (message.MessageObjectType == MessageActorType.EntStaff) { Staff staff = this.dataService.GetStaff((long)((ulong)Jid.GetUid(message.FromJid))); if (staff != null) { MessageBoxItem mbi = new MessageBoxItem(MessageActorType.EntStaff, staff.Uid, staff.Name, list.Count.ToString(), staff.HeaderImage); this.lbMessageBox.Items.Add(mbi); } } if (message.MessageObjectType == MessageActorType.EntGroup) { EntGroup group = this.dataService.GetEntGroup(message.Gid); if (group != null) { MessageBoxItem mbi = new MessageBoxItem(MessageActorType.EntGroup, group.Gid, group.Name, list.Count.ToString(), this.imageService.GetIcon(ImageTypeIcon.Group)); this.lbMessageBox.Items.Add(mbi); } } if (message.MessageObjectType == MessageActorType.Roster) { Roster roster = this.dataService.GetRoster((long)((ulong)Jid.GetUid(message.FromJid))); if (roster != null) { MessageBoxItem mbi = new MessageBoxItem(MessageActorType.Roster, roster.Uid, roster.Name, list.Count.ToString(), roster.HeaderImage); this.lbMessageBox.Items.Add(mbi); } } if (message.MessageObjectType == MessageActorType.AddRoster) { RosterAddRequest request = message.MessageObject as RosterAddRequest; if (request != null && request.user != null) { MessageBoxItem mbi = new MessageBoxItem(MessageActorType.AddRoster, request.uid, "验证消息", list.Count.ToString(), null); this.lbMessageBox.Items.Add(mbi); } } if (message.MessageObjectType == MessageActorType.AddRosterAsk) { RosterAddResponse response = message.MessageObject as RosterAddResponse; if (response != null && response.user != null) { MessageBoxItem mbi = new MessageBoxItem(MessageActorType.AddRosterAsk, response.uid, "验证消息", list.Count.ToString(), null); this.lbMessageBox.Items.Add(mbi); } } if (message.MessageObjectType == MessageActorType.CooperationStaff) { CooperationStaff staff2 = this.dataService.GetCooperationStaff((long)((ulong)Jid.GetUid(message.FromJid)), message.ProjectId); if (staff2 != null) { MessageBoxItem mbi = new MessageBoxItem(MessageActorType.CooperationStaff, staff2.Uid, staff2.UnitedProjectid, staff2.Name, list.Count.ToString(), staff2.HeaderImage); this.lbMessageBox.Items.Add(mbi); } } } } } } base.Top = SystemParameters.WorkArea.Height - 47.0 - (double)(this.lbMessageBox.Items.Count * 30); } catch (System.Exception e) { this.logger.Error(e.ToString()); } }
private void EntStaffMessageRecordMessageCenter(System.Collections.Generic.List <MessageRecord> records) { try { if (records.Count > 0) { Message[] messages = new Message[records.Count]; MessageStyle ms = null; for (int i = 0; i < messages.Length; i++) { ms = this.StaffMessageRecordProcessor(records, ms, i); messages[i] = new Message(); messages[i].FromJid = records[i].from_uid + "@null/null"; messages[i].CreateTime = records[i].createTime; messages[i].MessageBlocks = this.utilService.MessageDecode(records[i].message); messages[i].Style = ms; messages[i].RecordId = records[i].id; messages[i].IsMark = records[i].isMark; messages[i].Gid = records[i].from_uid; messages[i].FileName = records[i].fileName; messages[i].Icon = records[i].icon; messages[i].Url = records[i].url; if (this.sessionService.Uid == records[i].to_uid) { messages[i].ToJid = records[i].from_uid.ToString(); } else { messages[i].ToJid = records[i].to_uid.ToString(); } messages[i].Style = ms; } IDKin.IM.Core.Staff staff = this.dataService.GetStaff((long)((ulong)Jid.GetUid(messages[0].FromJid))); if (staff != null && WindowModel.Instance.IsOpenMessageCenterWindow()) { WindowModel.Instance.MsgRecordPage.MessageCenterRecordStaff(messages, staff, records[0].total); System.GC.Collect(); } } else { WindowModel.Instance.MsgRecordPage.ClearPage(); } } catch (System.Exception e) { System.Console.WriteLine(e.ToString()); } }
//internal Image imgHead; //internal FlowDocumentScrollViewer MessageContent; //internal Image imgIsMarked; //private bool _contentLoaded; public MsgRecordItem(Message message, EntGroup gp) { this.InitializeComponent(); Staff fromStaff = this.dataService.GetStaff((long)((ulong)Jid.GetUid(message.FromJid))); if (!string.IsNullOrEmpty(message.Url) && !string.IsNullOrEmpty(message.Icon) && !string.IsNullOrEmpty(message.FileName) && fromStaff != null && fromStaff.Uid == this.sessionService.Uid) { System.IO.FileInfo file = new System.IO.FileInfo(message.FileName); this.MessageContent.Document.Blocks.Add(this.GetNameInfo(this.sessionService.Name, message.CreateTime, true)); this.imgHead.Source = this.sessionService.HeaderImage; OpenFileControl openFile = new OpenFileControl(new FileItem(file) { FileName = message.Url + message.FileName, IconBase64 = message.Icon }, true); if (openFile != null && !string.IsNullOrEmpty(this.sessionService.Name)) { Paragraph p = new Paragraph(); FlowDocument doc = this.MessageContent.Document; p.Inlines.Add(openFile); doc.Blocks.Add(p); } } else { if (!string.IsNullOrEmpty(message.Url) && !string.IsNullOrEmpty(message.Icon) && !string.IsNullOrEmpty(message.FileName) && fromStaff == null) { System.IO.FileInfo file = new System.IO.FileInfo(message.FileName); this.MessageContent.Document.Blocks.Add(this.GetNameInfo("此人已离职", message.CreateTime, true)); this.imgHead.Source = this.imageService.GetHeader(ImageTypeHeader.Gary48); OpenFileControl openFile = new OpenFileControl(new FileItem(file) { FileName = message.Url + message.FileName, IconBase64 = message.Icon }, true); if (openFile != null && !string.IsNullOrEmpty(this.sessionService.Name)) { Paragraph p = new Paragraph(); FlowDocument doc = this.MessageContent.Document; p.Inlines.Add(openFile); doc.Blocks.Add(p); } } else { if ((long)int.Parse(message.FromJid.Substring(0, message.FromJid.IndexOf("@"))) == this.sessionService.Uid) { this.MessageContent.Document.Blocks.Add(this.GetNameInfo(this.sessionService.Name, message.CreateTime, true)); this.imgHead.Source = this.sessionService.HeaderImage; } else { if (fromStaff != null) { this.MessageContent.Document.Blocks.Add(this.GetNameInfo(fromStaff.Name, message.CreateTime, false)); this.imgHead.Source = fromStaff.HeaderImageOnline; } else { this.MessageContent.Document.Blocks.Add(this.GetNameInfo("此人已离职", message.CreateTime, false)); this.imgHead.Source = this.imageService.GetHeader(ImageTypeHeader.Gary48); } } Block[] messageBlocks = message.MessageBlocks; for (int i = 0; i < messageBlocks.Length; i++) { Paragraph block = (Paragraph)messageBlocks[i]; this.SetParagraphStyle(block, message.Style); this.MessageContent.Document.Blocks.Add(block); } } } this.message = message; this.group = gp; this.MouseEvent = true; this.InitUI(); }