private void GetDistributorsByNames(IList <string> distributorIds, string productIds) { string productNameByProductIds = ""; int sumcount = 0; if (!string.IsNullOrEmpty(productIds)) { productNameByProductIds = ProductHelper.GetProductNameByProductIds(productIds, out sumcount); IList <Distributor> list = new List <Distributor>(); IList <SendMessageInfo> sendMessageList = new List <SendMessageInfo>(); IList <ReceiveMessageInfo> receiveMessageList = new List <ReceiveMessageInfo>(); IList <int> userids = new List <int>(); foreach (string str2 in distributorIds) { userids.Add(Convert.ToInt32(str2)); } foreach (Distributor distributor in NoticeHelper.GetDistributorsByNames(userids)) { SendMessageInfo item = new SendMessageInfo(); ReceiveMessageInfo info2 = new ReceiveMessageInfo(); item.Addressee = info2.Addressee = distributor.Username; item.Addresser = info2.Addresser = "admin"; item.Title = info2.Title = "供应商转移了" + sumcount + "个商品的产品线"; item.PublishContent = info2.PublishContent = "尊敬各位分销商,有如下商品已被供应商转移了产品线:" + productNameByProductIds; sendMessageList.Add(item); receiveMessageList.Add(info2); } if (sendMessageList.Count > 0) { NoticeHelper.SendMessage(sendMessageList, receiveMessageList); } } }
private void GetDistributorsByNames(Dictionary <int, IList <string> > distributorIds) { IList <Distributor> list = new List <Distributor>(); IList <SendMessageInfo> sendMessageList = new List <SendMessageInfo>(); IList <ReceiveMessageInfo> receiveMessageList = new List <ReceiveMessageInfo>(); IList <int> userids = new List <int>(); foreach (int num in distributorIds.Keys) { userids.Add(num); } foreach (Distributor distributor in NoticeHelper.GetDistributorsByNames(userids)) { int count = distributorIds[distributor.UserId].Count; IList <string> list5 = distributorIds[distributor.UserId]; string str = "尊敬各位分销商,有如下商品已被取消铺货: "; foreach (string str2 in list5) { str = str + str2 + " "; } SendMessageInfo item = new SendMessageInfo(); ReceiveMessageInfo info2 = new ReceiveMessageInfo(); item.Addressee = info2.Addressee = distributor.Username; item.Addresser = info2.Addresser = "admin"; item.Title = info2.Title = "取消了" + count + "个商品的铺货"; item.PublishContent = info2.PublishContent = str; sendMessageList.Add(item); receiveMessageList.Add(info2); } if (sendMessageList.Count > 0) { NoticeHelper.SendMessage(sendMessageList, receiveMessageList); } }
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); } } }
public static void SendMessageToDistributors(string productId, int type) { string format = ""; string str2 = ""; string str3 = ""; string str4 = ""; int sumcount = 0; string productNameByProductIds = ""; IList <string> userIdByProductId = new List <string>(); switch (type) { case 1: { productNameByProductIds = ProductHelper.GetProductNameByProductIds(productId, out sumcount); userIdByProductId = ProductHelper.GetUserIdByProductId(productId.ToString()); format = "供应商下架了{0}个商品"; str2 = "尊敬的各位分销商,供应商已下架了{0}个商品,如下:"; break; } case 2: { productNameByProductIds = ProductHelper.GetProductNameByProductIds(productId, out sumcount); userIdByProductId = ProductHelper.GetUserIdByProductId(productId.ToString()); format = "供应商入库了{0}个商品"; str2 = "尊敬的各位分销商,供应商已入库了{0}个商品,如下:"; break; } case 3: { productNameByProductIds = ProductHelper.GetProductNameByProductIds(productId, out sumcount); userIdByProductId = ProductHelper.GetUserIdByProductId(productId.ToString()); format = "供应商删除了{0}个商品"; str2 = "尊敬的各位分销商,供应商已删除了{0}个商品,如下:"; break; } case 4: { str3 = productId.Split(new char[] { '|' })[1].ToString(); str4 = productId.Split(new char[] { '|' })[2].ToString(); productNameByProductIds = ProductHelper.GetProductNamesByLineId(Convert.ToInt32(productId.Split(new char[] { '|' })[0].ToString()), out sumcount); userIdByProductId = ProductHelper.GetUserIdByLineId(Convert.ToInt32(productId.Split(new char[] { '|' })[0].ToString())); format = "供应商转移了{0}个商品"; str2 = "尊敬的各位分销商,供应商已将整个产品线" + str3 + "的商品转移移至产品线" + str4 + "目录下,共{0}个,如下:"; break; } case 5: { productNameByProductIds = ProductHelper.GetProductNameByProductIds(productId, out sumcount); userIdByProductId = ProductHelper.GetUserIdByProductId(productId.ToString()); format = "供应商取消了{0}个商品的铺货状态"; str2 = "尊敬的各位分销商,供应商已取消了{0}个商品的铺货,如下:"; break; } default: { str4 = productId.Split(new char[] { '|' })[1].ToString(); productNameByProductIds = ProductHelper.GetProductNameByProductIds(productId.Split(new char[] { '|' })[0].ToString(), out sumcount); userIdByProductId = ProductHelper.GetUserIdByProductId(productId.Split(new char[] { '|' })[0].ToString()); format = "供应商转移了{0}个商品至产品线" + str4; str2 = "尊敬的各位分销商,供应商已转移了{0}个商品至产品线" + str4 + ",如下:"; break; } } if (sumcount > 0) { IList <Distributor> distributorsByNames = new List <Distributor>(); IList <SendMessageInfo> sendMessageList = new List <SendMessageInfo>(); IList <ReceiveMessageInfo> receiveMessageList = new List <ReceiveMessageInfo>(); IList <int> userids = new List <int>(); foreach (string str6 in userIdByProductId) { userids.Add(Convert.ToInt32(str6)); } if (userids.Count > 0) { distributorsByNames = NoticeHelper.GetDistributorsByNames(userids); } foreach (Distributor distributor in distributorsByNames) { SendMessageInfo item = new SendMessageInfo(); ReceiveMessageInfo info2 = new ReceiveMessageInfo(); item.Addressee = info2.Addressee = distributor.Username; item.Addresser = info2.Addresser = "admin"; item.Title = info2.Title = string.Format(format, sumcount); item.PublishContent = info2.PublishContent = string.Format(str2, sumcount) + productNameByProductIds; sendMessageList.Add(item); receiveMessageList.Add(info2); } if (sendMessageList.Count > 0) { NoticeHelper.SendMessage(sendMessageList, receiveMessageList); } } }