private void btnSendToRank_Click(object sender, EventArgs e) { IList <MessageBoxInfo> messageBoxInfos = new List <MessageBoxInfo>(); if (this.rdoName.Checked) { if (string.IsNullOrEmpty(this.txtDistributorNames.Text.Trim())) { this.ShowMsg("请输入您要发送的用户", false); return; } string[] strArray = this.txtDistributorNames.Text.Trim().Replace("\r\n", "\n").Replace("\n", "*").Split(new char[] { '*' }); for (int i = 0; i < strArray.Length; i++) { Distributor distributor = this.GetDistributor(strArray[i]); if (distributor != null) { MessageBoxInfo item = new MessageBoxInfo(); item.Accepter = strArray[i]; item.Sernder = "admin"; item.Title = this.MessageTitle; item.Content = this.Content; messageBoxInfos.Add(item); if (this.chkIsSendEmail.Checked && Regex.IsMatch(distributor.Email, @"([a-zA-Z\.0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,4}){1,2})")) { string str2; Messenger.SendMail(this.MessageTitle, this.Content, distributor.Email, HiContext.Current.SiteSettings, out str2); } } } if (messageBoxInfos.Count <= 0) { this.ShowMsg("没有要发送的对象", false); return; } NoticeHelper.SendMessageToDistributor(messageBoxInfos); this.ShowMsg(string.Format("成功给{0}个用户发送了消息.", messageBoxInfos.Count), true); } if (this.rdoRank.Checked) { IList <Distributor> list2 = new List <Distributor>(); foreach (Distributor distributor2 in NoticeHelper.GetDistributorsByRank(this.rankList.SelectedValue)) { MessageBoxInfo info2 = new MessageBoxInfo(); info2.Accepter = distributor2.Username; info2.Sernder = "admin"; info2.Title = this.MessageTitle; info2.Content = this.Content; messageBoxInfos.Add(info2); if (this.chkIsSendEmail.Checked && Regex.IsMatch(distributor2.Email, @"([a-zA-Z\.0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,4}){1,2})")) { string str3; Messenger.SendMail(this.MessageTitle, this.Content, distributor2.Email, HiContext.Current.SiteSettings, out str3); } } if (messageBoxInfos.Count > 0) { NoticeHelper.SendMessageToDistributor(messageBoxInfos); this.ShowMsg(string.Format("成功给{0}个用户发送了消息.", messageBoxInfos.Count), true); } else { this.ShowMsg("没有要发送的对象", false); } } }
private void btnSendToRank_Click(object sender, EventArgs e) { IList <Distributor> list = new List <Distributor>(); IList <SendMessageInfo> sendMessageList = new List <SendMessageInfo>(); IList <ReceiveMessageInfo> receiveMessageList = new List <ReceiveMessageInfo>(); if (rdoName.Checked) { if (string.IsNullOrEmpty(txtDistributorNames.Text.Trim())) { ShowMsg("请输入您要发送的用户", false); return; } IList <string> names = new List <string>(); string[] strArray = txtDistributorNames.Text.Trim().Replace("\r\n", "\n").Replace("\n", "*").Split(new char[] { '*' }); for (int i = 0; i < strArray.Length; i++) { if (IsMembers(strArray[i])) { names.Add(strArray[i]); } } foreach (Distributor distributor in NoticeHelper.GetDistributorsByNames(names)) { SendMessageInfo item = new SendMessageInfo(); ReceiveMessageInfo info2 = new ReceiveMessageInfo(); item.Addressee = info2.Addressee = distributor.Username; item.Addresser = info2.Addresser = "admin"; item.Title = info2.Title = MessageTitle; item.PublishContent = info2.PublishContent = Content; sendMessageList.Add(item); receiveMessageList.Add(info2); if (chkIsSendEmail.Checked) { string str; Messenger.SendMail(MessageTitle, Content, distributor.Email, HiContext.Current.SiteSettings, out str); } } if (sendMessageList.Count <= 0) { ShowMsg("没有要发送的对象", false); return; } NoticeHelper.SendMessage(sendMessageList, receiveMessageList); ShowMsg(string.Format("成功给{0}个用户发送了消息.", sendMessageList.Count), true); } if (rdoRank.Checked) { foreach (Distributor distributor2 in NoticeHelper.GetDistributorsByRank(rankList.SelectedValue)) { SendMessageInfo info3 = new SendMessageInfo(); ReceiveMessageInfo info4 = new ReceiveMessageInfo(); info3.Addressee = info4.Addressee = distributor2.Username; info3.Addresser = info4.Addresser = "admin"; info3.Title = info4.Title = MessageTitle; info3.PublishContent = info4.PublishContent = Content; sendMessageList.Add(info3); receiveMessageList.Add(info4); if (chkIsSendEmail.Checked) { string str2; Messenger.SendMail(MessageTitle, Content, distributor2.Email, HiContext.Current.SiteSettings, out str2); } } if (sendMessageList.Count > 0) { NoticeHelper.SendMessage(sendMessageList, receiveMessageList); ShowMsg(string.Format("成功给{0}个用户发送了消息.", sendMessageList.Count), true); } else { ShowMsg("没有要发送的对象", false); } } }
private void btnSendToRank_Click(object sender, System.EventArgs e) { System.Collections.Generic.IList <MessageBoxInfo> list = new System.Collections.Generic.List <MessageBoxInfo>(); if (this.rdoName.Checked) { if (string.IsNullOrEmpty(this.txtDistributorNames.Text.Trim())) { this.ShowMsg("请输入您要发送的用户", false); return; } string text = this.txtDistributorNames.Text.Trim().Replace("\r\n", "\n"); string[] array = text.Replace("\n", "*").Split(new char[] { '*' }); for (int i = 0; i < array.Length; i++) { Hidistro.Membership.Context.Distributor distributor = this.GetDistributor(array[i]); if (distributor != null) { list.Add(new MessageBoxInfo { Accepter = array[i], Sernder = "admin", Title = this.MessageTitle, Content = this.Content }); if (this.chkIsSendEmail.Checked && System.Text.RegularExpressions.Regex.IsMatch(distributor.Email, "([a-zA-Z\\.0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,4}){1,2})")) { string text2; Messenger.SendMail(this.MessageTitle, this.Content, distributor.Email, Hidistro.Membership.Context.HiContext.Current.SiteSettings, out text2); } } } if (list.Count <= 0) { this.ShowMsg("没有要发送的对象", false); return; } NoticeHelper.SendMessageToDistributor(list); this.ShowMsg(string.Format("成功给{0}个用户发送了消息.", list.Count), true); } if (this.rdoRank.Checked) { System.Collections.Generic.IList <Hidistro.Membership.Context.Distributor> list2 = new System.Collections.Generic.List <Hidistro.Membership.Context.Distributor>(); list2 = NoticeHelper.GetDistributorsByRank(this.rankList.SelectedValue); foreach (Hidistro.Membership.Context.Distributor current in list2) { list.Add(new MessageBoxInfo { Accepter = current.Username, Sernder = "admin", Title = this.MessageTitle, Content = this.Content }); if (this.chkIsSendEmail.Checked && System.Text.RegularExpressions.Regex.IsMatch(current.Email, "([a-zA-Z\\.0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,4}){1,2})")) { string text3; Messenger.SendMail(this.MessageTitle, this.Content, current.Email, Hidistro.Membership.Context.HiContext.Current.SiteSettings, out text3); } } if (list.Count > 0) { NoticeHelper.SendMessageToDistributor(list); this.ShowMsg(string.Format("成功给{0}个用户发送了消息.", list.Count), true); return; } this.ShowMsg("没有要发送的对象", false); } }