protected void btnSubmit_Click(object sender, EventArgs e) { string notice_content = this.txtContent.Text.Trim(); if (notice_content.Length <= 0 || notice_content.Length > 250) { JscriptMsg("文字通知内容必须在1~250个字符之间!!", "", "Error"); return; } var bll = new BLL.CCOM.Notice(); var notice_model = bll.GetModel(" Notice_flag=1"); if (notice_model == null) { Model.CCOM.Notice model = new Model.CCOM.Notice(); model.Notice_date = DateTime.Now; model.Notice_flag = true; model.Notice_sender_id = GetAdminInfo_CCOM().User_id; model.Notice_last_editor = GetAdminInfo_CCOM().User_id; model.Notice_type = false; model.Notice_receiver_id = "all_user"; model.Notice_title = "[系统通知]"; model.Notice_content = notice_content; long _id = bll.Add(model); if (_id > 0) { JscriptMsg("默认通知编辑成功", "", "Success"); } } else { notice_model.Notice_date = DateTime.Now; notice_model.Notice_last_editor = GetAdminInfo_CCOM().User_id; notice_model.Notice_content = notice_content; if (bll.Update(notice_model)) { JscriptMsg("默认通知编辑成功", "", "Success"); } } }
private void DoEdit(long id) { int totalUserCount = 0; Int32.TryParse(this.hidTotalUserCount.Value, out totalUserCount); if (totalUserCount == 0) { JscriptMsg("选择的推送用户数不能为0!", "", "Error"); return; } BLL.CCOM.Notice bll = new BLL.CCOM.Notice(); var model = bll.GetModel(id); model.Notice_last_editor = GetAdminInfo_CCOM().User_id; model.Notice_receiver_id = this.hidUserList.Value.ToString(); int type = this.hidIsImagePush.Value == "1" ? 1 : 0; if (type == 0) { model.Notice_content = txtContent.Text.Trim().Replace("'", ""); } else { //图文通知 model.Notice_title = this.txtTitle.Text.Trim(); model.Notice_content = this.hidEditorCnt.Value.Replace("'", ""); new BLL.CCOM.Notice_attach().Delete(" Notice_id=" + id); AddAttach(id); } bool result = bll.Update(model); //修改推送用户的阅读状态为未读,相当于重新推送覆盖之前 if (result) { var userIdList = this.hidUserList.Value.ToString().Split(',').ToList(); string[] receiver_ids = this.hidUserList.Value.ToString().Split(','); if (receiver_ids != null && receiver_ids.Length > 0) { var bll1 = new BLL.CCOM.User_notice(); for (int i = 0; i < receiver_ids.Length; i++) { var user_notice_model = bll1.GetModel(" User_id= " + receiver_ids[i]); if (user_notice_model != null) { string[] notice_ids = user_notice_model.Notice_id.Split(','); string[] notice_read_ids = user_notice_model.Notice_read_id.Split(','); //新加的用户 if (!notice_ids.Contains(model.Notice_id.ToString()) && !notice_read_ids.Contains(model.Notice_id.ToString())) { if (user_notice_model.Notice_id == null || user_notice_model.Notice_id.Length <= 0)//暂无未读通知 { user_notice_model.Notice_id = model.Notice_id.ToString(); } else { user_notice_model.Notice_id = user_notice_model.Notice_id + "," + model.Notice_id.ToString(); } bll1.Update(user_notice_model); } else//之前发送过的用户 { if (notice_read_ids.Contains(model.Notice_id.ToString()))//已经阅读过,从已读移到未读 { //从已读去掉 List <string> read_ids = notice_read_ids.ToList(); read_ids.Remove(model.Notice_id.ToString()); string temp = string.Empty; for (int j = 0; j < read_ids.Count; j++) { temp = temp + read_ids[j] + ","; } temp = temp.Substring(0, temp.Length - 1); user_notice_model.Notice_read_id = temp; //加入未读 if (user_notice_model.Notice_id == null || user_notice_model.Notice_id.Length <= 0) { user_notice_model.Notice_id = model.Notice_id.ToString(); } else { user_notice_model.Notice_id = user_notice_model.Notice_id + "," + model.Notice_id.ToString(); } //更新 bll1.Update(user_notice_model); } } } else { //表中暂无该用户记录,创建该用户记录 Model.CCOM.User_notice mod = new Model.CCOM.User_notice(); mod.Notice_id = model.Notice_id.ToString(); mod.User_id = long.Parse(receiver_ids[i]); bll1.Add(mod); } } } if (this.chbSmsSend.Checked) { SmsHelper.SendSmsNotice(userIdList, model.Notice_content, GetAdminInfo_CCOM().User_id); //if (new BLL.CCOM.User_sms().GetModel(GetAdminInfo_CCOM().User_id).User_sms_left < userIdList.Count) //{ // JscriptMsg("您的剩余短信已不足,请申请短信!!", "", "Error"); // return; //} } //生成静态页 NoticeHtml.CreateHtml(id, false); string pageUrl = Utils.CombUrlTxt("Notice_list_manager.aspx", "fun_id={0}&pushId={1}", get_fun_id("CCOM/notice/Notice_list_manager.aspx"), pushId.ToString()); JscriptMsg("修改成功 ,跳转至结果页面...", pageUrl, "Success"); } }