private List <int> ProcessSM() { SM_MsgBLL smBLL = new SM_MsgBLL(); smBLL.Model.Sender = (string)Session["UserName"]; smBLL.Model.SendTime = DateTime.Now; smBLL.Model.Content = "您从" + (string)Session["UserName"] + "处收到了一封新的邮件"; smBLL.Model.Type = 1; smBLL.Model.IsDelete = "N"; int id = smBLL.Add(); string recipients = Request.Form["hdnTxtSendTo"].ToString() + Request.Form["hdnTxtCcTo"].ToString() + Request.Form["hdnTxtBccTo"].ToString(); string[] separators = new string[] { "," }; string[] senders; senders = recipients.Split(separators, StringSplitOptions.RemoveEmptyEntries); SM_ReceiverBLL _bll = new SM_ReceiverBLL(); List <int> receiverList = new List <int>(); foreach (string s in senders) { _bll.Model.MsgID = id; _bll.Model.IsRead = "N"; _bll.Model.IsDelete = "N"; _bll.Model.Receiver = s; receiverList.Add(_bll.Add()); } return(receiverList); }
/// <summary> /// 发送短讯 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSend_Click(object sender, EventArgs e) { SendTo = Request.Form["hdnTxtSendTo"].ToString(); string recipients = this.SendTo; if (recipients.EndsWith(",")) recipients = recipients.Substring(0, recipients.Length - 1); recipients = recipients.Replace(",", ","); string[] separators = new string[] { "," }; string[] senders; senders = recipients.Split(separators, StringSplitOptions.RemoveEmptyEntries); SM_MsgBLL bll = new SM_MsgBLL(); bll.Model.Sender = (string)Session["UserName"]; bll.Model.Content = this.ckedit_content.Text; bll.Model.SendTime = DateTime.Now; bll.Model.Type = 1; bll.Model.IsDelete = "N"; int id = bll.Add(); SM_ReceiverBLL _receiverbll = new SM_ReceiverBLL(); foreach (string s in senders) { _receiverbll.Model.MsgID = id; _receiverbll.Model.IsRead = "N"; _receiverbll.Model.IsDelete = "N"; _receiverbll.Model.Receiver = s; int i = _receiverbll.Add(); } MessageBox.ShowAndClose(this, "站内短讯发送成功!"); }
/// <summary> /// 查询我的消息(仅1个月以内的消息) /// </summary> /// <param name="AuthKey"></param> /// <returns></returns> public static List <Message> GetMyMessageList(UserInfo User) { LogWriter.WriteLog("NoticeService.GetMyMessageList:UserName="******"SendTime > '" + DateTime.Today.AddMonths(-1).ToString("yyyy-MM-01") + "'"; List <Message> lists = new List <Message>(dt.DefaultView.Count); foreach (DataRowView row in dt.DefaultView) { Message m = new Message(); m.MsgID = (int)row["MsgID"]; m.Sender = (string)row["Sender"]; m.SenderRealName = (string)row["SenderRealName"]; m.Content = (string)row["Content"]; m.SendTime = (DateTime)row["SendTime"]; m.IsRead = (string)row["IsRead"]; m.KeyType = (string)row["KeyType"]; m.KeyValue = (string)row["KeyValue"]; lists.Add(m); } return(lists); }
/// <summary> /// 设置消息已读 /// </summary> /// <param name="AuthKey"></param> /// <param name="MsgID"></param> /// <returns></returns> public static int SetMessageRead(UserInfo User, int MsgID) { LogWriter.WriteLog("NoticeService.SetMessageRead:UserName="******",MsgID=" + MsgID.ToString()); SM_ReceiverBLL.IsRead(MsgID, User.UserName); return(0); }
/// <summary> /// 回复按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnReply_Click(object sender, EventArgs e) { string receiver = (string)Session["UserName"]; SM_ReceiverBLL.IsRead((int)ViewState["MsgID"], receiver); Response.Redirect("MsgSender.aspx?SendTo=" + txtRealName.Text); }
/// <summary> /// 新信息页面 /// </summary> /// protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["ID"] == null) { int _id = 0; ViewState["ID"] = SM_ReceiverBLL.GetNextID(_id, (string)Session["UserName"]); } else { ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]); } if ((int)ViewState["ID"] > 0) { hasNext(); SM_ReceiverBLL r = new SM_ReceiverBLL((int)ViewState["ID"]); SM_MsgBLL _m = new SM_MsgBLL(r.Model.MsgID); ViewState["MsgID"] = r.Model.MsgID; this.txtRealName.Text = _m.Model.Sender.ToString(); this.ltlContent.Text = _m.Model.Content.ToString(); this.txt_msgtime.Text = _m.Model.SendTime.ToString(); this.btnReply.Enabled = true; } else { MessageBox.Show(this, "没有新短讯需要读取!"); RegisterClientScriptBlock("Close", "<script language='JavaScript'>window.close();</script>"); } }
protected void ud_Grid_Recv_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { int id = int.Parse(ud_Grid_Recv.DataKeys[e.NewSelectedIndex]["MsgID"].ToString()); SM_ReceiverBLL.IsRead(id, (string)Session["UserName"]); BindGridRecvMsg(); }
protected void bt_AllRead_Click(object sender, EventArgs e) { foreach (GridViewRow gr in ud_Grid_Recv.Rows) { if (((CheckBox)gr.FindControl("chk_Msg_ID")).Checked == true) { int id = int.Parse(ud_Grid_Recv.DataKeys[gr.RowIndex]["MsgID"].ToString()); SM_ReceiverBLL.IsRead(id, (string)Session["UserName"]); } } BindGridRecvMsg(); }
/// <summary> /// 通过当前的ID获取Msg信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnNext_Click(object sender, EventArgs e) { int id = SM_ReceiverBLL.GetNextID((int)ViewState["ID"], (string)Session["UserName"]); if (id > 0) { Response.Redirect("MsgDetail.aspx?ID=" + id); } else { MessageBox.Show(this, "没有下一条新短讯需要读取!"); btnNext.Visible = false; } }
/// <summary> /// 是否还有新信息 /// </summary> public void hasNext() { string receiver = (string)Session["UserName"]; int count = SM_ReceiverBLL.HasNewMsg(receiver); if (count >= 2) { this.btnNext.Enabled = true; } else { this.btnNext.Enabled = false; } }
/// <summary> /// 获取未读消息的数量 /// </summary> /// <param name="AuthKey"></param> /// <returns></returns> public static int GetNewMessageCount(UserInfo User) { LogWriter.WriteLog("NoticeService.GetNewMessageCount:UserName="******"SendTime > '" + DateTime.Today.AddMonths(-1).ToString("yyyy-MM-01") + "' AND IsRead='N'"; return(dt.DefaultView.Count); }
/// <summary> /// 设定是否已读 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnRead_Click(object sender, EventArgs e) { string receiver = (string)Session["UserName"]; SM_ReceiverBLL.IsRead((int)ViewState["MsgID"], receiver); int id = SM_ReceiverBLL.GetNextID((int)ViewState["ID"], (string)Session["UserName"]); if (id > 0) { Response.Redirect("MsgDetail.aspx?ID=" + id); } else { Response.Write("<script language=javascript>window.close();</script>"); } }
private void SendSM(string Receiver, string Content) { SM_MsgBLL bll = new SM_MsgBLL(); bll.Model.Sender = Session["UserName"].ToString(); bll.Model.Content = Content; bll.Model.SendTime = DateTime.Now; bll.Model.Type = 1; bll.Model.IsDelete = "N"; int id = bll.Add(); SM_ReceiverBLL _receiverbll = new SM_ReceiverBLL(); _receiverbll.Model.MsgID = id; _receiverbll.Model.IsRead = "N"; _receiverbll.Model.IsDelete = "N"; _receiverbll.Model.Receiver = Receiver; _receiverbll.Add(); }
/// <summary> /// 绑定接受信息ReceiverMsg /// </summary> public void BindGridRecvMsg() { string receiver = (string)Session["UserName"]; DataTable dt = SM_ReceiverBLL.GetMyMsg(receiver); if (ViewState["Sort"] != null) { dt.DefaultView.Sort = ViewState["Sort"].ToString() + " " + ViewState["SortDirect"]; } if (ViewState["PageIndex"] != null) { ud_Grid_Recv.PageIndex = Int32.Parse(ViewState["PageIndex"].ToString()); } if (tbx_SelectContent.Text != "") { dt.DefaultView.RowFilter = "" + ddl_sampleSelect.SelectedValue + " like '" + tbx_SelectContent.Text.Trim() + "%'"; } ud_Grid_Recv.DataSource = dt.DefaultView; ud_Grid_Recv.DataBind(); }
/// <summary> /// 发送短讯 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSend_Click(object sender, EventArgs e) { SendTo = Request.Form["hdnTxtSendTo"].ToString(); string recipients = this.SendTo; if (recipients.EndsWith(",")) { recipients = recipients.Substring(0, recipients.Length - 1); } recipients = recipients.Replace(",", ","); string[] separators = new string[] { "," }; string[] senders; senders = recipients.Split(separators, StringSplitOptions.RemoveEmptyEntries); SM_MsgBLL bll = new SM_MsgBLL(); bll.Model.Sender = (string)Session["UserName"]; bll.Model.Content = this.ckedit_content.Text; bll.Model.SendTime = DateTime.Now; bll.Model.Type = 1; bll.Model.IsDelete = "N"; int id = bll.Add(); SM_ReceiverBLL _receiverbll = new SM_ReceiverBLL(); foreach (string s in senders) { _receiverbll.Model.MsgID = id; _receiverbll.Model.IsRead = "N"; _receiverbll.Model.IsDelete = "N"; _receiverbll.Model.Receiver = s; int i = _receiverbll.Add(); } MessageBox.ShowAndClose(this, "站内短讯发送成功!"); }
private List<int> ProcessSM() { SM_MsgBLL smBLL = new SM_MsgBLL(); smBLL.Model.Sender = (string)Session["UserName"]; smBLL.Model.SendTime = DateTime.Now; smBLL.Model.Content = "您从" + (string)Session["UserName"] + "处收到了一封新的邮件"; smBLL.Model.Type = 1; smBLL.Model.IsDelete = "N"; int id = smBLL.Add(); string recipients = Request.Form["hdnTxtSendTo"].ToString() + Request.Form["hdnTxtCcTo"].ToString() + Request.Form["hdnTxtBccTo"].ToString(); string[] separators = new string[] { "," }; string[] senders; senders = recipients.Split(separators, StringSplitOptions.RemoveEmptyEntries); SM_ReceiverBLL _bll = new SM_ReceiverBLL(); List<int> receiverList = new List<int>(); foreach (string s in senders) { _bll.Model.MsgID = id; _bll.Model.IsRead = "N"; _bll.Model.IsDelete = "N"; _bll.Model.Receiver = s; receiverList.Add(_bll.Add()); } return receiverList; }
protected void bt_MsgDeleteAll_Click(object sender, EventArgs e) { SM_ReceiverBLL.DeleteAll((string)Session["UserName"]); BindGridRecvMsg(); }