/// <summary> /// 发布知会消息 /// </summary> /// <param name="billType">单据类型</param> /// <param name="billNo">单据编号</param> /// <param name="content">知会内容</param> /// <param name="sender">发布人</param> /// <param name="noticeRoles">知会角色</param> /// <param name="noticeUserCodes">知会用户编码列表</param> public void NotifyMessage(string billType, string billNo, string content, string sender, List <string> noticeRoles, List <string> noticeUserCodes) { List <string> userCodes = GetUserCodes(noticeRoles, noticeUserCodes); for (int i = 0; i < userCodes.Count; i++) { // 去除自己给自己发的现象 if (sender == userCodes[i]) { continue; } Flow_Notice notice = new Flow_Notice(); notice.标题 = billType; notice.单据流水号 = billNo; notice.优先级 = TransactionPriority.中.ToString(); notice.来源 = NoticeSource.单据处理后知会.ToString(); notice.内容 = content; notice.发送时间 = ServerModule.ServerTime.Time; notice.发送人 = sender; notice.状态 = NoticeStatus.未读.ToString(); notice.接收人 = userCodes[i]; m_flowNotice.SendNotice(notice); } }
/// <summary> /// 发布知会消息 /// </summary> /// <param name="noticeInfo">知会信息</param> /// <param name="noticeRoles">知会角色</param> /// <param name="noticeUserCodes">知会用户编码列表</param> public void NotifyMessage(NoticePublicInfo noticeInfo, List <string> noticeRoles, List <string> noticeUserCodes) { List <string> userCodes = GetUserCodes(noticeRoles, noticeUserCodes); for (int i = 0; i < userCodes.Count; i++) { // 去除自己给自己发的现象 if (noticeInfo.Sender == userCodes[i]) { continue; } Flow_Notice notice = new Flow_Notice(); notice.标题 = noticeInfo.Title; notice.优先级 = noticeInfo.Priority.ToString(); notice.来源 = noticeInfo.Source.ToString(); notice.内容 = noticeInfo.Content; notice.发送时间 = ServerModule.ServerTime.Time; notice.发送人 = noticeInfo.Sender; notice.状态 = NoticeStatus.未读.ToString(); notice.接收人 = userCodes[i]; m_flowNotice.SendNotice(notice); } }
/// <summary> /// 发布通知 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSend_Click(object sender, EventArgs e) { if (!CheckData()) { return; } try { if (m_notice == null) { m_notice = new Flow_Notice(); m_notice.发送人 = BasicInfo.LoginID; } string[] users = txtReceivedPersonal.Text.Split(new char[] { ',' }); foreach (var user in users) { Flow_Notice notice = new Flow_Notice(); notice.发送人 = BasicInfo.LoginID; notice.接收人 = user; notice.来源 = cmbSource.Text; notice.标题 = txtTitle.Text; notice.优先级 = cmbPriority.Text; notice.内容 = txtContent.Text; notice.状态 = NoticeStatus.未读.ToString(); if (GlobalObject.GeneralFunction.IsNullOrEmpty(m_oldReceivedPersonal)) { m_flowNoticeManagement.SendNotice(notice); } else if (user == m_oldReceivedPersonal) { notice.序号 = m_notice.序号; m_flowNoticeManagement.UpdateNotice(BasicInfo.LoginID, notice); } } txtReceivedPersonal.Text = ""; txtTitle.Text = ""; txtContent.Text = ""; MessageDialog.ShowPromptMessage("发送成功!"); } catch (Exception err) { MessageDialog.ShowErrorMessage(err.Message); } }
/// <summary> /// 修改通知 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnModifyNotice_Click(object sender, EventArgs e) { if (CheckOperation(sender as ToolStripDropDownItem)) { try { Flow_Notice notice = (dataGridView1.Tag as List <Flow_Notice>)[dataGridView1.SelectedRows[0].Index]; FormUpdateNotice form = new FormUpdateNotice(NoticeSource.日常事务, notice); form.ShowDialog(); InitForm(InitMode.刷新数据显示, m_currentNode); } catch (Exception err) { MessageDialog.ShowErrorMessage(err.Message); } } }
/// <summary> /// 删除消息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { if (CheckOperation(sender as ToolStripDropDownItem)) { try { for (int i = 0; i < dataGridView1.SelectedRows.Count; i++) { Flow_Notice notice = (dataGridView1.Tag as List <Flow_Notice>)[dataGridView1.SelectedRows[i].Index]; m_flowNotice.DeleteNotice(BasicInfo.LoginID, notice.序号); } InitForm(InitMode.刷新数据显示, m_currentNode); } catch (Exception err) { MessageDialog.ShowErrorMessage(err.Message); } } }
/// <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> /// <param name="source">通知来源</param> /// <param name="notice">如果此参数不为空表示是更新通知,否则为添加</param> public FormUpdateNotice(NoticeSource source, Flow_Notice notice) { InitializeComponent(); cmbSource.Enabled = false; cmbSource.Items.AddRange(Enum.GetNames(typeof(NoticeSource))); cmbSource.Text = source.ToString(); m_notice = notice; if (notice != null) { this.Text = "更新通知"; cmbPriority.Text = notice.优先级; m_oldReceivedPersonal = txtReceivedPersonal.Text = notice.接收人; txtTitle.Text = notice.标题; txtContent.Text = notice.内容.Substring(notice.内容.IndexOf(":") + 1); } else { cmbPriority.SelectedIndex = 0; } }
/// <summary> /// 获取通知类消息字符串 /// </summary> /// <param name="notice">知会消息</param> /// <returns>返回获取到的字符串</returns> private string GetNoticeMessage(Flow_Notice notice) { return(string.Format("{0} 优先级:{1} {2}, 内容:{3}", notice.来源, notice.优先级, notice.标题, notice.内容)); }