/// <summary> /// 发送完成标志信息到消息提示窗体 /// </summary> /// <param name="billNo">单据编号</param> private void SendFinishedFlagToMessagePromptForm(string billNo) { WndMsgData msgData = new WndMsgData(); msgData.MessageType = MessageTypeEnum.单据消息; msgData.MessageContent = string.Format("{0},{1}", labelTitle.Text, billNo); m_wndMsgSender.SendMessage(StapleInfo.MessagePromptForm.Handle, WndMsgSender.FinishedMsg, msgData); }
private void lblMsg_Click(object sender, EventArgs e) { WndMsgData sendData = new WndMsgData(); sendData.MessageType = this.MessageType; sendData.NoticeSource = this.NoticeSource; sendData.MessageContent = this.MessageID.ToString(); m_wndMsgSender.SendMessage(m_noticeForm.Handle, WndMsgSender.PositioningMsg, sendData); if (OnControlClick != null) { OnControlClick(sender, e); } }
/// <summary> /// 将通知类消息批示已阅 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnReadNotice_Click(object sender, EventArgs e) { if (CheckOperation(sender as ToolStripDropDownItem)) { try { for (int i = 0; i < dataGridView1.SelectedRows.Count; i++) { if ((dataGridView1.Tag as List <Flow_Notice>) != null) { Flow_Notice notice = (dataGridView1.Tag as List <Flow_Notice>)[dataGridView1.SelectedRows[i].Index]; m_flowNotice.ReadNotice(BasicInfo.LoginID, notice.序号); WndMsgData msgData = new WndMsgData(); msgData.MessageType = MessageTypeEnum.知会消息; msgData.NoticeSource = (NoticeSource)Enum.Parse(typeof(NoticeSource), notice.来源); msgData.MessageContent = notice.序号.ToString(); m_wndMsgSender.SendMessage(StapleInfo.MessagePromptForm.Handle, WndMsgSender.FinishedMsg, msgData); } else if ((dataGridView1.Tag as List <Flow_WarningNotice>) != null) { Flow_WarningNotice notice = (dataGridView1.Tag as List <Flow_WarningNotice>)[dataGridView1.SelectedRows[i].Index]; PlatformFactory.GetObject <IWarningNotice>().ReadWarningNotice(BasicInfo.LoginID, notice.序号); } } InitForm(InitMode.刷新数据显示, m_currentNode); } catch (Exception err) { MessageDialog.ShowErrorMessage(err.Message); } } }
/// <summary> /// 检查是否有新的知会类消息 /// </summary> private void CheckNoticeMessage() { // 发消息到主窗体的标志 bool sendMsgToMainForm = false; foreach (NoticeSource noticeEnum in Enum.GetValues(typeof(NoticeSource))) { IQueryable <Flow_Notice> noticeData = m_flowNotice.GetNotice(BasicInfo.LoginID, noticeEnum); List <Flow_Notice> dataSource = new List <Flow_Notice>(); // 按时间顺序逆向排序 noticeData = from r in noticeData orderby r.发送时间 descending select r; // 剔除自己发送的信息 if (noticeData.Count() > 0) { dataSource = (from r in noticeData where r.发送人 != BasicInfo.LoginID select r).Take(20).ToList(); } string prefix = noticeEnum.ToString().Substring(0, 2); foreach (var item in dataSource) { if (m_dicMsgLabel.ContainsKey(prefix + item.序号.ToString())) { continue; } UserControlMessageLabel msgLabel = new UserControlMessageLabel(StapleInfo.MainForm, GetNoticeMessage(item)); msgLabel.Name = prefix + item.序号.ToString(); msgLabel.MessageID = item.序号; msgLabel.MessageType = MessageTypeEnum.知会消息; msgLabel.NoticeSource = noticeEnum; msgLabel.Date = item.发送时间; if (!GlobalObject.GeneralFunction.IsNullOrEmpty(item.发送人)) { if (!m_dicUserName.ContainsKey(item.发送人)) { m_dicUserName.Add(item.发送人, m_user.GetUser(item.发送人).姓名); } } msgLabel.UserName = m_dicUserName[item.发送人]; if (item.优先级 == "高") { msgLabel.ForeColor = Color.Red; } msgLabel.Dock = DockStyle.Top; this.Controls.Add(msgLabel); m_dicMsgLabel.Add(msgLabel.Name, msgLabel); msgLabel.OnControlClick += new EventHandler(this.UserControlMessageLabel_Clicked); if (!sendMsgToMainForm) { sendMsgToMainForm = true; WndMsgData sendData = new WndMsgData(); sendData.MessageType = msgLabel.MessageType; sendData.NoticeSource = msgLabel.NoticeSource; sendData.MessageContent = msgLabel.MessageID.ToString(); m_wndMsgSender.SendMessage(StapleInfo.MainForm.Handle, WndMsgSender.NewFlowMsg, sendData); } } for (int i = 0; i < this.Controls.Count; i++) { Control msgLabel = this.Controls[i]; if (msgLabel.Name.Contains(prefix)) { int findIndex = Convert.ToInt32(msgLabel.Name.Substring(2)); if (dataSource.FindIndex(p => p.序号 == findIndex) < 0) { this.Controls.RemoveAt(i--); m_dicMsgLabel.Remove(msgLabel.Name); msgLabel.Dispose(); } } } } }