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(); } }
private void CloseCooperationTab() { System.Collections.Generic.ICollection <TabItem> staffChatTabs = this.dataService.GetCooperationStaffChatTabList(); System.Collections.Generic.List <TabItem> temTabItemList = new System.Collections.Generic.List <TabItem>(staffChatTabs); for (int i = temTabItemList.Count - 1; i >= 0; i--) { CoopStaffTab temCoopStaffTab = temTabItemList[i] as CoopStaffTab; if (temCoopStaffTab != null) { CooperationStaff temCooperationStaff = this.dataService.GetCooperationStaff(temCoopStaffTab.Staff.Uid, temCoopStaffTab.Staff.UnitedProjectid); if (temCooperationStaff == null) { this.dataService.RemoveCooperationStaffChatTab(temCoopStaffTab.Staff.Uid, temCoopStaffTab.Staff.UnitedProjectid); if (this.INWindow.ContentTab.Items.Contains(temCoopStaffTab)) { this.INWindow.ContentTab.Items.Remove(temCoopStaffTab); } } else { temCoopStaffTab.Staff = temCooperationStaff; CooperationProjectWrapper temCooperationProjectWrapper = this.dataService.GetCooperationProjectWrapper(temCooperationStaff.UnitedProjectid); if (temCooperationProjectWrapper != null) { temCoopStaffTab.CooperationProjectWrapper = temCooperationProjectWrapper; } } } } }
private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { if (e.LeftButton == MouseButtonState.Pressed && this.staff.Uid != this.sessionService.Uid) { CoopStaffTab item = this.dataService.GetCooperationStaffChatTab(this.staff.Uid, this.staff.UnitedProjectid) as CoopStaffTab; if (item != null) { ((INWindow)this.dataService.INWindow).ContentTab.SelectedItem = item; } else { item = new CoopStaffTab(this.staff, this.cooperationProjectWrapper); item.SetDefaultStyle(); ((INWindow)this.dataService.INWindow).ContentTab.Items.Add(item); this.dataService.AddCooperationStaffChatTab(this.staff.Uid, this.staff.UnitedProjectid, item); ((INWindow)this.dataService.INWindow).ContentTab.SelectedItem = item; this.MessageProcessor(item); } } } catch (System.Exception) { } }
private void DisplayCooperationMessageRecordToChatPanel(System.Collections.Generic.List <CooperationMessageRecord> records, int total) { string projectid = records[0].project_id; long staffUid; if (records[0].from_uid != this.sessionService.Uid) { staffUid = records[0].from_uid; } else { staffUid = records[0].to_uid; } Message[] messages = new Message[records.Count]; MessageStyle ms = null; for (int i = 0; i < messages.Length; i++) { ms = this.CooperationMessageRecordProcessor(records, ms, i); messages[i] = new Message(); messages[i].FromJid = records[i].from_uid + "@null/null"; messages[i].CreateTime = records[i].createTime; messages[i].FileName = records[i].fileName; messages[i].Icon = records[i].icon; messages[i].Url = records[i].url; messages[i].toUid = records[i].to_uid; messages[i].ProjectId = records[i].project_id; 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].MessageBlocks = this.utilService.MessageDecode(records[i].message); messages[i].Style = ms; } CoopStaffTab item = this.dataService.GetCooperationStaffChatTab(staffUid, projectid) as CoopStaffTab; if (item != null) { CoopStaffChatTabControl tab = item.TabContent; if (tab != null) { tab.ChatComponent.AddCooperationStaffMessageRecords(messages, total); } } }
public void CooperationStaffMessageRecordEvent(CooperationMessageRecordResponse response) { try { if (response != null || response.cooperationMessageRecord.Count != 0) { this.DisplayCooperationMessageRecordToChatPanel(response.cooperationMessageRecord, response.total); } else { if (response.cooperationMessageRecord.Count == 0) { if (response.messageRecordType == 3) { INWindow inWindow = this.dataService.INWindow as INWindow; if (inWindow != null) { EntStaffTab pctc = inWindow.ContentTab.SelectedItem as EntStaffTab; EntGroupTab gctc = inWindow.ContentTab.SelectedItem as EntGroupTab; RosterTab rost = inWindow.ContentTab.SelectedItem as RosterTab; CoopStaffTab coopStaffTab = inWindow.ContentTab.SelectedItem as CoopStaffTab; if (pctc != null) { pctc.TabContent.ChatComponent.MsgRecordComp.setShowPage(); } if (gctc != null) { gctc.TabContent.ChatComponent.MsgRecordComp.setShowPage(); } if (rost != null) { rost.TabContent.ChatComponent.MsgRecordComp.setShowPage(); } if (coopStaffTab != null) { coopStaffTab.TabContent.ChatComponent.MsgRecordComp.setShowPage(); } } } } } } catch (System.Exception e) { System.Console.WriteLine(e.ToString()); } }
private void MessageProcessor(CoopStaffTab item) { if (item != null) { System.Collections.Generic.List <Message> list = DataModel.Instance.GetCooperationStaffMessage(this.staff.Uid, this.staff.UnitedProjectid, MessageActorType.CooperationStaff); if (list != null && list.Count > 0) { foreach (Message message in list) { item.TabContent.ChatComponent.AddCooperationMessageStaff(message, false); item.TabContent.ChatComponent.inputMsgBox.Focus(); } } DataModel.Instance.RemoveCooperationStatffMessage(this.staff.Uid, this.staff.UnitedProjectid, MessageActorType.CooperationStaff); MessageBoxWindow mbw = DataModel.Instance.GetMessageBox(); if (mbw != null) { mbw.Refresh(); } } }