protected void Page_Load(object sender, EventArgs e) { this.fun_id = MyRequest.GetQueryString("fun_id"); this.keywords = MyRequest.GetQueryString("keywords"); if (!Page.IsPostBack) { RptBind(CombSqlTxt(this.keywords), " SMS_apply_time desc"); SmsHelper.ShowSmsLeftNumberNoApply(this.lblSms, GetAdminInfo_CCOM().User_id); } }
private void DoAdd() { int totalUserCount = 0; Int32.TryParse(this.hidTotalUserCount.Value, out totalUserCount); if (totalUserCount == 0) { JscriptMsg("选择的推送用户数不能为0!", "", "Error"); return; } var model = new Model.CCOM.Notice(); int type = this.hidIsImagePush.Value == "1" ? 1 : 0; if (type == 0) { //文字通知 model.Notice_title = "通知[" + GetAdminInfo_CCOM().User_realname + "]"; model.Notice_content = txtContent.Text.Trim().Replace("'", ""); model.Notice_type = false; } else { //图文通知 model.Notice_title = this.txtTitle.Text.Trim(); model.Notice_content = this.hidEditorCnt.Value.Replace("'", ""); model.Notice_type = true; } model.Notice_date = DateTime.Now; model.Notice_flag = false; StringBuilder list = new StringBuilder(); if (!string.IsNullOrEmpty(this.hidUserList.Value.ToString())) { list.Append(this.hidUserList.Value.ToString()); } //string group = this.hidGroupList.Value.ToString(); //if (!string.IsNullOrEmpty(group)) //{ // string[] agency_id_list = group.Split(','); // for(int i=0;i<agency_id_list.Length;i++) // { // var model_list = new BLL.CCOM.User_property().GetModelList(" Agency_id=" + agency_id_list[i]); // if(model_list!=null&&model_list.Count>0) // { // for(int j=0;j<model_list.Count;j++) // { // if(list.ToString().Length>0) // { // list.Append(","); // list.Append(model_list[j].User_id); // } // else if (list.ToString().Length == 0) // { // list.Append(model_list[j].User_id); // } // } // } // } //} model.Notice_receiver_id = list.ToString(); if (model.Notice_receiver_id.Length <= 0) { JscriptMsg("请选择推送人员!!", "", "Error"); return; } model.Notice_sender_id = GetAdminInfo_CCOM().User_id; long notice_id = new BLL.CCOM.Notice().Add(model); if (notice_id > 0) { string[] receiver_ids = list.ToString().Split(','); if (receiver_ids != null && receiver_ids.Length > 0) { var bll = new BLL.CCOM.User_notice(); for (int i = 0; i < receiver_ids.Length; i++) { var user_notice_model = bll.GetModel(" User_id= " + receiver_ids[i]); if (user_notice_model != null) { string _id = user_notice_model.Notice_id; if (_id != null && _id.Length > 0) { user_notice_model.Notice_id = _id + "," + notice_id; } else { user_notice_model.Notice_id = notice_id.ToString(); } bll.Update(user_notice_model); } else { Model.CCOM.User_notice user_model = new Model.CCOM.User_notice(); user_model.User_id = long.Parse(receiver_ids[i]); user_model.Notice_id = notice_id.ToString(); bll.Add(user_model); } } } else { JscriptMsg("通知推送出错!!", "", "Error"); return; } AddAttach(notice_id); var userIdList = list.ToString().Split(',').ToList(); if (this.chbSmsSend.Checked) { //var User_sms_model=new BLL.CCOM.User_sms().GetModel(GetAdminInfo_CCOM().User_id); //if (User_sms_model == null||User_sms_model.User_sms_left < userIdList.Count) //{ // JscriptMsg("您的剩余短信已不足,请申请短信!!", "", "Error"); // return; //} SmsHelper.SendSmsNotice(userIdList, model.Notice_content, GetAdminInfo_CCOM().User_id); } //生成静态页 CreateHtmlPage(notice_id); 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"); } }
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"); } }