//更新阅读状态 private void UpdateReadStatus(long userId, string noticeId) { BLL.CCOM.User_notice bll = new BLL.CCOM.User_notice(); Model.CCOM.User_notice model = bll.GetModel("User_id=" + userId); string[] notices = model.Notice_id.Split(','); string readNotice = model.Notice_read_id; int index = -1; if (notices != null && notices.Length > 0) { for (int i = 0; i < notices.Length; i++) { if (notices[i] == noticeId) { index = i; break; } } if (index >= 0) { string notice_id = string.Empty; for (int i = 0; i < notices.Length; i++) { if (i != index) { notice_id += notices[i] + ","; } } //从未读中去除 if (notice_id.Length > 0) { notice_id = notice_id.Substring(0, notice_id.Length - 1);//去除最后一个分隔符 } //加入已读中 if (readNotice != null) { if (readNotice.Length == 0) { readNotice = notices[index]; } else { readNotice = readNotice + "," + notices[index]; } } model.Notice_id = notice_id; model.Notice_read_id = readNotice; bll.Update(model); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string phoneNumber = this.txtPhoneNumber.Text.Trim(); string password = this.txtUserPwd.Text.Trim(); string password_confer = this.txtUser_pasword_confer.Text.Trim(); if (phoneNumber.Length <= 0) { lblTip.Visible = true; lblTip.Text = "请填写手机号"; return; } if (phoneNumber.Length > 14 || !IsNumber(phoneNumber)) { lblTip.Visible = true; lblTip.Text = "请正确填写手机号"; return; } if (Tools.CheckParams(phoneNumber)) { lblTip.Visible = true; lblTip.Text = "手机号包含非法字符,请修改"; return; } //查询数据库中是否已经注册过 BLL.CCOM.User_infomation bll = new BLL.CCOM.User_infomation(); if (bll.GetRecordCount(" User_mobile='" + phoneNumber + "'") > 0) { lblTip.Visible = true; lblTip.Text = "该账号已被注册"; return; } if (password.Length <= 0) { lblTip.Visible = true; lblTip.Text = "请填写密码"; return; } if (password.Length < 6 || password.Length > 16 || !IsNumAndEnCh(password)) { lblTip.Visible = true; lblTip.Text = "请正确填写密码"; return; } if (Tools.CheckParams(password)) { lblTip.Visible = true; lblTip.Text = "密码包含非法字符,请修改"; return; } if (!password.Equals(password_confer)) { lblTip.Visible = true; lblTip.Text = "密码前后不一,请确认"; return; } if (Session[MyKeys.SESSION_PHONE_CODE] == null) { lblTip.Visible = true; lblTip.Text = "请获取手机验证码"; return; } if (Session[MyKeys.SESSION_PHONE_CODE].ToString() != this.txtSmsCode.Text) { lblTip.Visible = true; lblTip.Text = "手机验证码不正确"; return; } BLL.CCOM.Period period_bll = new BLL.CCOM.Period(); int open_year = DateTime.Now.Year; var period_model = period_bll.GetModel(" Period_state=1"); if (period_model != null) { try { open_year = int.Parse(period_model.Period_year); } catch { } } else { lblTip.Visible = true; lblTip.Text = "当前暂未开启注册"; return; } Model.CCOM.User_infomation UserModel = new Model.CCOM.User_infomation(); UserModel.User_mobile = phoneNumber; UserModel.User_password = DESEncrypt.MD5Encrypt(password); UserModel.User_type = 1; //默认为大陆考生 UserModel.User_status = true; //默认为启用状态 UserModel.User_addtime = DateTime.Now; UserModel.User_gender = false; //默认为男 UserModel.User_realname = "请填写姓名"; BLL.CCOM.User_infomation user_bll = new BLL.CCOM.User_infomation(); long _id = user_bll.Add(UserModel);//这里不知为什么返回值不是User_id; if (_id > 0) { //鉴于上述问题,这里重新查询User_id; DataTable user_table = user_bll.GetList(1, "", " User_id DESC").Tables[0]; _id = long.Parse(user_table.Rows[0]["User_id"].ToString()); lblTip.Visible = false; BLL.CCOM.User_property User_property_bll = new BLL.CCOM.User_property(); Model.CCOM.User_property User_property_model = new Model.CCOM.User_property(); User_property_model.User_id = _id; User_property_model.Period_id = period_bll.GetModel(" Period_year=" + open_year).Period_id; BLL.CCOM.Temp_record temp_record_bll = new BLL.CCOM.Temp_record(); var temp_record_model = temp_record_bll.GetModel(" Period_year=" + open_year); //临时表中无该年度记录,则需创建该年度记录 if (temp_record_model == null) { string last_record = open_year + "B" + "0001"; Model.CCOM.Temp_record record_model = new Model.CCOM.Temp_record(); record_model.Last_CCOM_number = last_record; record_model.Period_year = open_year + ""; DataTable table = User_property_bll.GetList(1, "", "UP_id DESC").Tables[0]; if (table != null && table.Rows.Count > 0) { DataRow dr = table.Rows[0]; last_record = dr["UP_CCOM_number"].ToString(); record_model.Last_CCOM_number = open_year + "B" + (int.Parse(last_record.Substring(5)) + 1).ToString("0000"); } //插入最后一条记录到临时表 temp_record_bll.Add(record_model); //插入个人属性表 User_property_model.UP_CCOM_number = record_model.Last_CCOM_number; User_property_model.UP_calculation_status = 0; User_property_bll.Add(User_property_model); } else//临时表中有该年度记录,则直接取该年度记录 { int last_record = int.Parse(temp_record_model.Last_CCOM_number.Substring(5)); //更新临时表 temp_record_model.Last_CCOM_number = open_year + "B" + (last_record + 1).ToString("0000"); temp_record_bll.Update(temp_record_model); //插入个人属性表 User_property_model.UP_CCOM_number = temp_record_model.Last_CCOM_number; User_property_model.UP_calculation_status = 0; User_property_bll.Add(User_property_model); } //JscriptMsg("注册成功!", "/AdminMetro/login_page.aspx", "Success"); var user_notice_bll = new BLL.CCOM.User_notice(); var user_notice_model = new Model.CCOM.User_notice(); user_notice_model.User_id = _id; var notice_model = new BLL.CCOM.Notice().GetModel(" Notice_flag=1"); user_notice_model.Notice_id = notice_model.Notice_id.ToString(); user_notice_bll.Add(user_notice_model); Response.Write("<script>window.location.href='/AdminMetro/login_page.aspx';</script>"); } else { //JscriptMsg("注册失败!", "/AdminMetro/CCOM/register/Register.aspx", "Error"); Response.Write("<script>window.location.href='/AdminMetro/CCOM/register/Register.aspx';</script>"); } }
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 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 RptBind() { int pageSize = 10; //每页数量 int page = MyRequest.GetQueryInt("page", 1); string keywords = this.keywords; //MyRequest.GetQueryString("keywords"); int start_index = pageSize * (page - 1) + 1; int end_index = pageSize * page; this.txtKeywords.Value = keywords; StringBuilder ulSb = new StringBuilder(); //获取该用户的所有未读通知Id BLL.CCOM.User_notice bll = new BLL.CCOM.User_notice(); Model.CCOM.User_notice model = bll.GetModel(" User_id=" + GetAdminInfo_CCOM().User_id); if (model != null) { string all_news_id = string.Empty; if (type == 0) { all_news_id = model.Notice_id; this.no_read.Style.Value = "background-color:#a5d16c"; this.read.Style.Value = "background-color:lightgrey"; } else { all_news_id = model.Notice_read_id; this.read.Style.Value = "background-color:#a5d16c"; this.no_read.Style.Value = "background-color:lightgrey"; } if (all_news_id.Length > 0) { string[] ids = all_news_id.Split(','); string strWhere = string.Empty; if (keywords != null && keywords.Length > 0) { strWhere += " Notice_content like '%" + keywords + "%' "; } else { strWhere += " 1=1"; } if (ids.Length > 0) { for (int i = 0; i < ids.Length; i++) { if (i == 0) { strWhere += " and ( Notice_id=" + ids[i]; } else { strWhere += " or Notice_id=" + ids[i]; } } strWhere += " )"; //获取通知信息 BLL.CCOM.Notice bll_notice = new BLL.CCOM.Notice(); int totalCount = bll_notice.GetRecordCount(strWhere); //计算数量 DataTable dt = bll_notice.GetListByPage(strWhere, "Notice_date DESC", start_index, end_index).Tables[0]; //绑定当页 long userId = GetAdminInfo_CCOM().User_id; if (dt.Rows.Count > 0) { BLL.CCOM.User_information user_bll = new BLL.CCOM.User_information(); string realname = string.Empty; foreach (DataRow dr in dt.Rows) { var content = ""; content = "<a href=\"ViewNotice.aspx?id=" + DESEncrypt.Encrypt(dr["Notice_id"].ToString()) + "\" target=\"_blank\">"; content += dr["Notice_title"] + "</a>"; content += "<br />"; content += dr["Notice_content"]; try { realname = user_bll.GetModel(Convert.ToInt32(dr["Notice_sender_id"])).User_realname; } catch { realname = "---"; } ulSb.Append("<li>"); ulSb.Append("<div class=\"media\">"); ulSb.Append("<span class=\"label pull-left label-success\"><i class=\"icon-bell\"></i></span>"); ulSb.Append("<div class=\"media-body\">"); ulSb.Append("<div class=\"notice-collapse\" style=\"padding: 5px;\">"); ulSb.Append("<div class=\"text\" style=\"padding: 2px 4px; text-decoration: none;\">"); ulSb.Append(" <p style=\"font-weight:bold;\">" + content + "</p>"); ulSb.Append(" <p class=\"attribution\">" + realname + " " + ((DateTime)dr["Notice_date"]).ToString("yyyy-MM-dd HH:mm") + "</p>"); ulSb.Append("</div>"); ulSb.Append("</div>"); ulSb.Append("</div>"); ulSb.Append("</div>"); ulSb.Append("</li>"); } //this.page_size.Style.Add("display", ""); } else { //this.page_size.Style.Add("display", "none"); ulSb.Append("<li style=\"height:40px;font-size:18px;text-align:center;padding-top:21px;\">暂无通知消息!</li>"); } //绑定页码 string pageUrl = Utils.CombUrlTxt("Notice_list.aspx", "keywords={0}&page={1}&fun_id={2}&type={3}", this.keywords, "__id__", DESEncrypt.Encrypt(this.fun_id), DESEncrypt.Encrypt(this.type.ToString())); this.PageContent.InnerHtml = Utils.OutPageList(pageSize, page, totalCount, pageUrl, 8, true); } } else { ulSb.Append("<li style=\"height:40px;font-size:18px;text-align:center;padding-top:21px;\">暂无通知消息!</li>"); //this.page_size.Style.Add("display", "none"); } } else//为空则创建该用户 { Model.CCOM.User_notice user_notice_model = new Model.CCOM.User_notice(); user_notice_model.User_id = GetAdminInfo_CCOM().User_id; bll.Add(user_notice_model); } this.noticeList.InnerHtml = ulSb.ToString(); }