protected void btnReplyReplyReceivedMessages_Click(object sender, EventArgs e) { SendMessageInfo target = new SendMessageInfo(); ReceiveMessageInfo receiveMessage = NoticeHelper.GetReceiveMessage(receiveMessageId); target.Title = txtTitle.Text; target.PublishContent = txtContes.Text; target.ReceiveMessageId = new long?(receiveMessageId); target.Addresser = "admin"; target.Addressee = receiveMessage.Addresser; ValidationResults results = Hishop.Components.Validation.Validation.Validate<SendMessageInfo>(target, new string[] { "ValSendMessage" }); string msg = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable<ValidationResult>)results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } ShowMsg(msg, false); } else if (NoticeHelper.ReplyMessage(target)) { txtTitle.Text = ""; txtContes.Text = ""; ShowMsg("成功回复客户消息", true); BindReplyReceivedMessages(); txtTitle.Text = string.Empty; txtContes.Text = string.Empty; } else { ShowMsg("回复客户消息失败", false); } }
protected void btnReplyReplyReceivedMessages_Click(object sender, EventArgs e) { SendMessageInfo target = new SendMessageInfo(); ReceiveMessageInfo receiveMessage = SubsiteCommentsHelper.GetReceiveMessage(this.receiveMessageId); target.Title = this.txtReplyTitle.Text; target.PublishContent = this.txtContes.Text.Trim(); target.ReceiveMessageId = new long?(this.receiveMessageId); target.Addresser = HiContext.Current.User.Username; target.Addressee = receiveMessage.Addresser; ValidationResults results = Hishop.Components.Validation.Validation.Validate<SendMessageInfo>(target, new string[] { "ValSendMessage" }); string msg = string.Empty; if (!results.IsValid) { foreach (ValidationResult result in (IEnumerable<ValidationResult>) results) { msg = msg + Formatter.FormatErrorMessage(result.Message); } this.ShowMsg(msg, false); } else if (SubsiteCommentsHelper.ReplyMessage(target)) { this.ShowMsg("成功回复客户消息", true); this.BindReplyReceivedMessages(); this.txtReplyTitle.Text = string.Empty; this.txtContes.Text = string.Empty; } else { this.ShowMsg("回复客户消息失败", false); } }
void btnReplyReceivedMessage_Click(object sender, EventArgs e) { string str = ""; if (string.IsNullOrEmpty(this.txtReplyTitle.Text) || (this.txtReplyTitle.Text.Length > 60)) { str = str + Formatter.FormatErrorMessage("标题不能为空,长度限制在1-60个字符内"); } if (string.IsNullOrEmpty(this.txtReplyContent.Text) || (this.txtReplyContent.Text.Length > 300)) { str = str + Formatter.FormatErrorMessage("内容不能为空,长度限制在1-300个字符内"); } if (!string.IsNullOrEmpty(str)) { this.ShowMessage(str, false); } else { SendMessageInfo reply = new SendMessageInfo(); reply.Addresser = HiContext.Current.User.Username; reply.Addressee = CommentsHelper.GetReceiveMessage(this.receiveMessageId).Addresser; reply.Title = this.txtReplyTitle.Text; reply.PublishContent = this.txtReplyContent.Text; reply.PublishDate = DateTime.Now; reply.ReceiveMessageId = new long?(this.receiveMessageId); if (CommentsHelper.ReplyMessage(reply)) { this.ShowMessage("回复成功", true); } else { this.ShowMessage("回复失败", false); } } }
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); } } }
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 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 InsertSendMessage(SendMessageInfo message) { DbCommand sqlStringCommand = database.GetSqlStringCommand("Insert into Hishop_SendedMessages(Addresser,Addressee,Title,PublishContent,PublishDate,ReceiveMessageId) values(@Addresser,@Addressee,@Title,@PublishContent,@PublishDate,@ReceiveMessageId)"); database.AddInParameter(sqlStringCommand, "Addresser", DbType.String, message.Addresser); database.AddInParameter(sqlStringCommand, "Addressee", DbType.String, message.Addressee); database.AddInParameter(sqlStringCommand, "Title", DbType.String, message.Title); database.AddInParameter(sqlStringCommand, "PublishContent", DbType.String, message.PublishContent); database.AddInParameter(sqlStringCommand, "PublishDate", DbType.DateTime, DataHelper.GetSafeDateTimeFormat(DateTime.Now)); database.AddInParameter(sqlStringCommand, "ReceiveMessageId", DbType.Int64, message.ReceiveMessageId); return (database.ExecuteNonQuery(sqlStringCommand) > 0); }
public static SendMessageInfo PopulateSendMessage(IDataRecord reader) { if (null == reader) { return null; } SendMessageInfo info = new SendMessageInfo(); info.SendMessageId = (long) reader["SendMessageId"]; info.Addressee = (string) reader["Addressee"]; info.Addresser = (string) reader["Addresser"]; info.PublishContent = (string) reader["PublishContent"]; info.Title = (string) reader["Title"]; info.PublishDate = (DateTime) reader["PublishDate"]; if (DBNull.Value != reader["ReceiveMessageId"]) { info.ReceiveMessageId = new long?((long) reader["ReceiveMessageId"]); } 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 InsertSendMessage(SendMessageInfo sendMessage);
public static bool InsertSendMessageToAdmin(SendMessageInfo message, ReceiveMessageInfo receiveMessage) { return (SubsiteCommentsProvider.Instance().InsertSendMessageToAdmin(message) && SubsiteCommentsProvider.Instance().InsertReceiveMessageToAdmin(receiveMessage)); }
public abstract bool InsertSendMessageToAdmin(SendMessageInfo message);
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 InsertSendMessage(SendMessageInfo message) { Distributor user = Users.GetUser(HiContext.Current.SiteSettings.UserId.Value, false) as Distributor; DbCommand sqlStringCommand = database.GetSqlStringCommand("Insert into distro_SendedMessages(Addresser,Addressee,Title,PublishContent,PublishDate,ReceiveMessageId) values(@Addresser,@Addressee,@Title,@PublishContent,@PublishDate,@ReceiveMessageId)"); database.AddInParameter(sqlStringCommand, "Addresser", DbType.String, message.Addresser); database.AddInParameter(sqlStringCommand, "Addressee", DbType.String, user.Username); database.AddInParameter(sqlStringCommand, "Title", DbType.String, message.Title); database.AddInParameter(sqlStringCommand, "PublishContent", DbType.String, message.PublishContent); database.AddInParameter(sqlStringCommand, "PublishDate", DbType.DateTime, DateTime.Now); database.AddInParameter(sqlStringCommand, "ReceiveMessageId", DbType.Int64, message.ReceiveMessageId); 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); } } }