//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { var bll = new BLL.CCOM.Notice(); var result = true; int iCnt = 0; for (int i = 0; i < rptList.Items.Count; i++) { long id = Convert.ToInt64(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { iCnt++; try { var m = bll.GetModel(id); if (IsSelfPush(m.Notice_sender_id.ToString()) == false) { JscriptMsg("您无权进行删除!", "", "Error"); return; } bll.Delete(id); } catch { result = false; } } } if (iCnt < 1) { JscriptMsg("请您选择需要删除的信息!", "", "Error"); return; } string keywords = MyRequest.GetQueryString("keywords"); int page = MyRequest.GetQueryInt("page", 1); if (result == true) { JscriptMsg("批量删除成功!", Utils.CombUrlTxt("Notice_list_manager.aspx", "fun_id={0}&ptId={1}&keywords={2}&page={3}", DESEncrypt.Encrypt(this.fun_id), this.ptId.ToString(), keywords, page.ToString()), "Success"); } else { JscriptMsg("批量删除失败!", Utils.CombUrlTxt("Notice_list_manager.aspx", "fun_id={0}&ptId={1}&keywords={2}&page={3}", DESEncrypt.Encrypt(this.fun_id), this.ptId.ToString(), keywords, page.ToString()), "Error"); } }
//绑定类别 //protected void BindPushType() //{ // //默认选中未分类 // string strNoType = "<a href=\"javascript:;\" class='btn btn-success' onclick='selectPushType(this,\"" + DESEncrypt.Encrypt("0") + "\")'>未分类</a> "; // this.divPushType.InnerHtml = strNoType; // var ml = new BLL.CCOM.Notice_type().GetModelList(""); // var sb = new StringBuilder(); // foreach (var m in ml) // { // sb.Append("<a href=\"javascript:;\" class='btn' onclick='selectPushType(this,\"" + DESEncrypt.Encrypt(m.Notice_type_id.ToString()) + "\")'>" + m.Notice_type_name + "</a>"); // } // sb.Append("<a href=\"javascript:;\" class='btn' style='font-size: 18px;' onclick='addPushType()'><i class=\"icon-plus\"></i></a>"); // this.divPushType.InnerHtml += sb.ToString(); //} private void ShowInfo(long _id) { var bll = new BLL.CCOM.Notice(); var model = bll.GetModel(_id); this.btnSubmit.Visible = false; this.divSave.Visible = true; //********** 0(false)表示文字通知,1(true)表示图文通知****************// if (model.Notice_type != null) { if ((bool)model.Notice_type)//图文通知 { this.txtTitle.Text = model.Notice_title; this.hidEditorCnt.Value = model.Notice_content; //绑定附件 var attachList = new BLL.CCOM.Notice_attach().GetModelList("Notice_id=" + _id); if (attachList != null && attachList.Count > 0) { this.rptAttach.DataSource = attachList; this.rptAttach.DataBind(); } //选择通知类型 ScriptManager.RegisterStartupScript(this, this.Page.GetType(), "setParam", "selectImagePush();", true); } else//文字通知 { this.txtContent.Text = model.Notice_content; } //绑定推送人员 if (model.Notice_receiver_id != null && model.Notice_receiver_id.Length > 0) { string receiver = model.Notice_receiver_id; if (receiver != null && receiver.Length > 0) { BindNoticeUser(receiver); } } } }
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"); } } }
//删除单条通知 protected void lbtSingleDelete_Click(object sender, EventArgs e) { var bll = new BLL.CCOM.Notice(); var lbtn = sender as LinkButton; if (lbtn != null) { var id = Int64.Parse(DESEncrypt.Decrypt(lbtn.ToolTip.ToString())); bool result = true; try { var m = bll.GetModel(id); if (IsSelfPush(m.Notice_sender_id.ToString()) == false) { JscriptMsg("您无权进行删除!", "", "Error"); return; } bll.Delete(id); } catch { result = false; } string keywords = MyRequest.GetQueryString("keywords"); int page = MyRequest.GetQueryInt("page", 1); if (result == true) { JscriptMsg("删除成功!", Utils.CombUrlTxt("Notice_list_manager.aspx", "fun_id={0}&ptId={1}&keywords={2}&page={3}", DESEncrypt.Encrypt(this.fun_id), this.ptId.ToString(), keywords, page.ToString()), "Success"); } else { JscriptMsg("删除失败!", Utils.CombUrlTxt("Notice_list_manager.aspx", "fun_id={0}&ptId={1}&keywords={2}&page={3}", DESEncrypt.Encrypt(this.fun_id), this.ptId.ToString(), keywords, page.ToString()), "Error"); } } }
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"); } }
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("[]"); } }