void btnRefer_Click(object sender, EventArgs e) { string str = ""; if (string.IsNullOrEmpty(this.txtTitle.Text) || (this.txtTitle.Text.Length > 60)) { str = str + Formatter.FormatErrorMessage("标题不能为空,长度限制在1-60个字符内"); } if (string.IsNullOrEmpty(this.txtContent.Text) || (this.txtContent.Text.Length > 300)) { str = str + Formatter.FormatErrorMessage("内容不能为空,长度限制在1-300个字符内"); } if (!string.IsNullOrEmpty(str)) { this.ShowMessage(str, false); } else { IList<SendMessageInfo> sendMessageList = new List<SendMessageInfo>(); IList<ReceiveMessageInfo> receiveMessageList = new List<ReceiveMessageInfo>(); SendMessageInfo item = new SendMessageInfo(); ReceiveMessageInfo info2 = new ReceiveMessageInfo(); item.Addresser = info2.Addresser = HiContext.Current.User.Username; item.Addressee = info2.Addressee = "admin"; item.Title = info2.Title = this.txtTitle.Text.Replace("~", ""); item.PublishContent = info2.PublishContent = this.txtContent.Text.Replace("~", ""); sendMessageList.Add(item); receiveMessageList.Add(info2); this.txtTitle.Text = string.Empty; this.txtContent.Text = string.Empty; if (CommentsHelper.SendMessage(sendMessageList, receiveMessageList) > 0) { this.ShowMessage("发送信息成功", true); } else { this.ShowMessage("发送信息失败", true); } } }
private void btnRefer_Click(object sender, EventArgs e) { if (this.ValidateValues()) { string str = this.txtTitle.Text.Trim(); string str2 = this.txtContent.Text.Trim(); SendMessageInfo message = new SendMessageInfo(); ReceiveMessageInfo receiveMessage = new ReceiveMessageInfo(); message.Addressee = receiveMessage.Addressee = "admin"; message.Addresser = receiveMessage.Addresser = HiContext.Current.User.Username; message.Title = receiveMessage.Title = str; message.PublishContent = receiveMessage.PublishContent = str2; if (!SubsiteCommentsHelper.InsertSendMessageToAdmin(message, receiveMessage)) { this.ShowMsg("发送失败", false); } else { this.ShowMsg("发送成功", true); } } }
private void btnSendToRank_Click(object sender, EventArgs e) { IList<Member> list = new List<Member>(); IList<SendMessageInfo> sendMessageList = new List<SendMessageInfo>(); IList<ReceiveMessageInfo> receiveMessageList = new List<ReceiveMessageInfo>(); if (rdoName.Checked) { if (string.IsNullOrEmpty(txtMemberNames.Text.Trim())) { ShowMsg("请输入您要发送的用户", false); return; } IList<string> names = new List<string>(); string[] strArray = txtMemberNames.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 (Member member in PromoteHelper.GetMemdersByNames(names)) { SendMessageInfo item = new SendMessageInfo(); ReceiveMessageInfo info2 = new ReceiveMessageInfo(); item.Addressee = info2.Addressee = member.Username; item.Addresser = info2.Addresser = "admin"; item.Title = info2.Title = MessageTitle; item.PublishContent = info2.PublishContent = Content; sendMessageList.Add(item); receiveMessageList.Add(info2); } if (sendMessageList.Count <= 0) { ShowMsg("没有要发送的对象", false); return; } NoticeHelper.SendMessage(sendMessageList, receiveMessageList); ShowMsg(string.Format("成功给{0}个用户发送了消息.", sendMessageList.Count), true); } if (rdoRank.Checked) { foreach (Member member2 in PromoteHelper.GetMembersByRank(rankList.SelectedValue)) { SendMessageInfo info3 = new SendMessageInfo(); ReceiveMessageInfo info4 = new ReceiveMessageInfo(); info3.Addressee = info4.Addressee = member2.Username; info3.Addresser = info4.Addresser = "admin"; info3.Title = info4.Title = MessageTitle; info3.PublishContent = info4.PublishContent = Content; sendMessageList.Add(info3); receiveMessageList.Add(info4); } if (sendMessageList.Count > 0) { NoticeHelper.SendMessage(sendMessageList, receiveMessageList); ShowMsg(string.Format("成功给{0}个用户发送了消息.", sendMessageList.Count), true); } else { ShowMsg("没有要发送的对象", false); } } }
public override bool InsertReceiveMessage(ReceiveMessageInfo receiveMessage) { DbCommand sqlStringCommand = database.GetSqlStringCommand("Insert into Hishop_ReceivedMessages(Addresser,Addressee,Title,PublishContent,PublishDate,LastTime,IsRead) values(@Addresser,@Addressee,@Title,@PublishContent,@PublishDate,@LastTime,@IsRead)"); database.AddInParameter(sqlStringCommand, "Addresser", DbType.String, receiveMessage.Addresser); database.AddInParameter(sqlStringCommand, "Addressee", DbType.String, receiveMessage.Addressee); database.AddInParameter(sqlStringCommand, "Title", DbType.String, receiveMessage.Title); database.AddInParameter(sqlStringCommand, "PublishContent", DbType.String, receiveMessage.PublishContent); database.AddInParameter(sqlStringCommand, "PublishDate", DbType.DateTime, DataHelper.GetSafeDateTimeFormat(DateTime.Now)); database.AddInParameter(sqlStringCommand, "LastTime", DbType.DateTime, DataHelper.GetSafeDateTimeFormat(DateTime.Now)); database.AddInParameter(sqlStringCommand, "IsRead", DbType.Boolean, false); return (database.ExecuteNonQuery(sqlStringCommand) > 0); }
public override ReceiveMessageInfo GetReceiveMessage(long receiveMessageId) { ReceiveMessageInfo info = new ReceiveMessageInfo(); DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_ReceivedMessages WHERE ReceiveMessageId=@ReceiveMessageId;"); database.AddInParameter(sqlStringCommand, "ReceiveMessageId", DbType.Int64, receiveMessageId); using (IDataReader reader = database.ExecuteReader(sqlStringCommand)) { if (reader.Read()) { info = DataMapper.PopulateReceiveMessage(reader); } } return info; }
public static ReceiveMessageInfo PopulateReceiveMessage(IDataRecord reader) { if (null == reader) { return null; } ReceiveMessageInfo info = new ReceiveMessageInfo(); info.ReceiveMessageId = (long) reader["ReceiveMessageId"]; info.Addresser = (string) reader["Addresser"]; info.Addressee = (string) reader["Addressee"]; info.Title = (string) reader["Title"]; info.PublishContent = (string) reader["PublishContent"]; info.PublishDate = (DateTime) reader["PublishDate"]; info.LastTime = (DateTime) reader["LastTime"]; info.IsRead = (bool) reader["IsRead"]; return info; }
public static bool ReplyMessage(SendMessageInfo reply) { IList<SendMessageInfo> sendMessageList = new List<SendMessageInfo>(); IList<ReceiveMessageInfo> receiveMessageList = new List<ReceiveMessageInfo>(); ReceiveMessageInfo item = new ReceiveMessageInfo(); item.Addressee = reply.Addressee; item.Addresser = reply.Addresser; item.Title = reply.Title; item.PublishContent = reply.PublishContent; item.PublishDate = DateTime.Now; sendMessageList.Add(reply); receiveMessageList.Add(item); if (SendMessage(sendMessageList, receiveMessageList) > 0) { CommentsProvider.Instance().PostMessageLastTime(reply.ReceiveMessageId.Value, item.PublishDate); } return true; }
public abstract bool InsertReceiveMessage(ReceiveMessageInfo receiveMessage);
public static bool InsertSendMessageToAdmin(SendMessageInfo message, ReceiveMessageInfo receiveMessage) { return (SubsiteCommentsProvider.Instance().InsertSendMessageToAdmin(message) && SubsiteCommentsProvider.Instance().InsertReceiveMessageToAdmin(receiveMessage)); }
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); } }
public override bool InsertReceiveMessage(ReceiveMessageInfo receiveMessage) { Distributor user = Users.GetUser(HiContext.Current.SiteSettings.UserId.Value, false) as Distributor; DbCommand sqlStringCommand = database.GetSqlStringCommand("Insert into distro_ReceivedMessages(Addresser,Addressee,Title,PublishContent,PublishDate,LastTime,IsRead) values(@Addresser,@Addressee,@Title,@PublishContent,@PublishDate,@LastTime,@IsRead)"); database.AddInParameter(sqlStringCommand, "Addresser", DbType.String, receiveMessage.Addresser); database.AddInParameter(sqlStringCommand, "Addressee", DbType.String, user.Username); database.AddInParameter(sqlStringCommand, "Title", DbType.String, receiveMessage.Title); database.AddInParameter(sqlStringCommand, "PublishContent", DbType.String, receiveMessage.PublishContent); database.AddInParameter(sqlStringCommand, "PublishDate", DbType.DateTime, DateTime.Now); database.AddInParameter(sqlStringCommand, "LastTime", DbType.DateTime, DateTime.Now); database.AddInParameter(sqlStringCommand, "IsRead", DbType.Boolean, false); return (database.ExecuteNonQuery(sqlStringCommand) > 0); }
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); } } }