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 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 GetStatisticData(HttpContext context) { if (!IsAdminLogin()) { FlushResponse(context, "[]"); return; } int count = 0; var model = new BLL.CCOM.User_notice().GetModel(" User_id="+GetUserId()); if(model!=null) { string notice_ids = model.Notice_id; var bll = new BLL.CCOM.Notice(); Model.CCOM.Notice notice_model = null; DataTable dt = new DataTable(); dt.Columns.Add("Notice_id"); dt.Columns.Add("Notice_content"); dt.Columns.Add("Notice_date"); dt.Columns.Add("Notice_read_status");//0:未读,1:已读 if (notice_ids!=null&¬ice_ids.Length > 0) { string[] _ids = notice_ids.Split(','); for(int i=_ids.Length-1;i>=0;i--)//反序则时间递减 { notice_model = bll.GetModel(long.Parse(_ids[i])); if(notice_model!=null) { DataRow dr = dt.NewRow(); dr["Notice_id"] =DESEncrypt.Encrypt(notice_model.Notice_id.ToString()); if(notice_model.Notice_type!=null&&(bool)notice_model.Notice_type) { dr["Notice_content"] = notice_model.Notice_title; } else { dr["Notice_content"] = notice_model.Notice_content; } dr["Notice_date"] = notice_model.Notice_date; dr["Notice_read_status"] = 0; dt.Rows.Add(dr); dt.AcceptChanges(); count++; if(count>=10) { break; } } } } if (count < 10)//未读不足10条,从已读取 { string read_ids = model.Notice_read_id; if (read_ids != null && read_ids.Length > 0) { string[] _read = read_ids.Split(','); if (_read.Length > 0) { for (int i = _read.Length - 1; i >= 0; i--) { notice_model = bll.GetModel(long.Parse(_read[i])); if (notice_model != null) { DataRow dr = dt.NewRow(); dr["Notice_id"] = DESEncrypt.Encrypt(notice_model.Notice_id.ToString()); if (notice_model.Notice_type != null && (bool)notice_model.Notice_type) { dr["Notice_content"] = notice_model.Notice_title; } else { dr["Notice_content"] = notice_model.Notice_content; } dr["Notice_date"] = notice_model.Notice_date; dr["Notice_read_status"] = 1; dt.Rows.Add(dr); dt.AcceptChanges(); count++; if (count >= 10) { break; } } } } } } string result=ToJson(dt); context.Response.Write(result); } else { context.Response.Write("[]"); } }