//绑定通知类别
        //private void BindPushType()
        //{
        //    var typeList = new BLL.CCOM.Notice_type().GetModelList("");

        //    if(typeList!=null&&typeList.Count>0)
        //    {
        //        StringBuilder sb = new StringBuilder();
        //        var className = "btn btn-success";
        //        var className1 = "btn";
        //        string noticeTypeId = MyRequest.GetQueryString("notice_type_id");
        //        if(noticeTypeId==null||noticeTypeId.Length==0)//若为传值则默认为未分类
        //        {
        //            sb.Append("<a href=\"Notice_list_manager.aspx?notice_type_id=" + DESEncrypt.Encrypt("0") + "&notice_type=" + this.NoticeType + "&fun_id=" + DESEncrypt.Encrypt(this.fun_id) + "\" class='" + className + "'>");
        //            sb.Append("未分类</a>&nbsp;&nbsp;");
        //            for(int i=0;i<typeList.Count;i++)
        //            {
        //                sb.Append("<a href=\"Notice_list_manager.aspx?notice_type_id=" + DESEncrypt.Encrypt(typeList[i].Notice_type_id.ToString()) + "&notice_type=" + this.NoticeType + "&fun_id=" + DESEncrypt.Encrypt(this.fun_id) + "\" class='" + className1 + "'>");
        //                sb.Append(typeList[i].Notice_type_name + "</a>&nbsp;&nbsp;");
        //            }
        //            this.NoticeTypeDiv.InnerHtml = sb.ToString();
        //        }
        //        else
        //        {
        //            try
        //            {
        //                long notice_type_id = long.Parse(DESEncrypt.Decrypt(noticeTypeId));
        //                if(notice_type_id==0)
        //                {
        //                    sb.Append("<a href=\"Notice_list_manager.aspx?notice_type_id=" + DESEncrypt.Encrypt("0") + "&notice_type=" + this.NoticeType + "&fun_id=" + DESEncrypt.Encrypt(this.fun_id) + "\" class='" + className + "'>");
        //                    sb.Append("未分类</a>&nbsp;&nbsp;");
        //                    for (int i = 0; i < typeList.Count; i++)
        //                    {
        //                        sb.Append("<a href=\"Notice_list_manager.aspx?notice_type_id=" + DESEncrypt.Encrypt(typeList[i].Notice_type_id.ToString()) + "&notice_type=" + this.NoticeType + "&fun_id=" + DESEncrypt.Encrypt(this.fun_id) + "\" class='" + className1 + "'>");
        //                        sb.Append(typeList[i].Notice_type_name + "</a>&nbsp;&nbsp;");
        //                    }
        //                }
        //                else
        //                {
        //                    sb.Append("<a href=\"Notice_list_manager.aspx?notice_type_id=" + DESEncrypt.Encrypt("0") + "&notice_type=" + this.NoticeType + "&fun_id=" + DESEncrypt.Encrypt(this.fun_id) + "\" class='" + className1 + "'>");
        //                    sb.Append("未分类</a>&nbsp;&nbsp;");
        //                    for (int i = 0; i < typeList.Count; i++)
        //                    {
        //                        if(typeList[i].Notice_type_id==notice_type_id)
        //                        {
        //                            sb.Append("<a href=\"Notice_list_manager.aspx?notice_type_id=" + DESEncrypt.Encrypt(typeList[i].Notice_type_id.ToString())+"&notice_type="+this.NoticeType + "&fun_id=" + DESEncrypt.Encrypt(this.fun_id) + "\" class='" + className + "'>");
        //                            sb.Append(typeList[i].Notice_type_name + "</a>&nbsp;&nbsp;");
        //                        }
        //                        else
        //                        {
        //                            sb.Append("<a href=\"Notice_list_manager.aspx?notice_type_id=" + DESEncrypt.Encrypt(typeList[i].Notice_type_id.ToString()) + "&notice_type=" + this.NoticeType + "&fun_id=" + DESEncrypt.Encrypt(this.fun_id) + "\" class='" + className1 + "'>");
        //                            sb.Append(typeList[i].Notice_type_name + "</a>&nbsp;&nbsp;");
        //                        }
        //                    }
        //                }
        //                this.NoticeTypeDiv.InnerHtml = sb.ToString();
        //            }
        //            catch
        //            {

        //            }
        //        }
        //    }

        //}

        #region 数据绑定=================================
        private void RptBind(string _strWhere, string _order)
        {
            int    pageSize    = GetPageSize(10); //每页数量
            int    page        = MyRequest.GetQueryInt("page", 1);
            string keywords    = MyRequest.GetQueryString("keywords");
            int    start_index = pageSize * (page - 1) + 1;
            int    end_index   = pageSize * page;

            this.txtKeywords.Text = keywords;

            var bll = new BLL.CCOM.Notice();

            //计算数量
            int totalCount = bll.GetRecordCount(_strWhere);

            //绑定当页
            var ds = bll.GetListByPage(_strWhere, _order, start_index, end_index);

            this.rptList.DataSource = ds;
            this.rptList.DataBind();

            //绑定页码
            txtPageNum.Text = pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("Notice_list_manager.aspx", "fun_id={0}&keywords={1}&page={2}&notice_type_id={3}", DESEncrypt.Encrypt(this.fun_id), this.keywords, "__id__", DESEncrypt.Encrypt(this.ptId.ToString()));

            this.PageContent.InnerHtml = Utils.OutPageList(pageSize, page, totalCount, pageUrl, 8, true);
        }
        //显示图文通知部分内容
        protected String WrapPushContent(string id)
        {
            var content   = "";
            int maxLength = 60;

            try
            {
                var model = new BLL.CCOM.Notice().GetModel(long.Parse(id));
                if ((bool)model.Notice_type)
                {
                    content   = model.Notice_content;
                    maxLength = 30;
                }
                else
                {
                    content = model.Notice_content;
                }
            }
            catch
            {
            }

            if (content.Length > maxLength)
            {
                var shortContent = content.Substring(0, maxLength) + "...";

                var toolTip = "<a style=\"cursor:pointer;\" onmouseover=\"layer.tips('" + content + "', this, {";
                toolTip += "style: ['background-color:#e8e8e8; color:#000', '#e8e8e8'], maxWidth:385, time: 3,closeBtn:[0, true]});\">详细</a>";
                return(shortContent + toolTip);
            }
            return(content);
        }
 //获取通知类别名称
 protected string GetPushType(int Notice_id)
 {
     Model.CCOM.Notice model = new BLL.CCOM.Notice().GetModel(Notice_id);
     if (model.Notice_type_id != null && model.Notice_type_id > 0)
     {
         return(new BLL.CCOM.Notice_type().GetModel((long)model.Notice_type_id).Notice_type_name);
     }
     return("未分类");
 }
Exemplo n.º 4
0
        /// <summary>
        /// 获取通知生成的日期目录
        /// </summary>
        /// <param name="pushId">通知Id</param>
        private static string GetPushDatePath(long pushId)
        {
            var m = new BLL.CCOM.Notice().GetModel(pushId);

            if (m == null || m.Notice_date == null)
            {
                return("");
            }

            //按年月/日存入不同的文件夹
            DateTime dt = Convert.ToDateTime(m.Notice_date);

            return(dt.ToString("yyyyMM") + "/" + dt.ToString("dd") + "/");
        }
        //批量删除
        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");
            }
        }
Exemplo n.º 6
0
        //绑定类别
        //protected void BindPushType()
        //{
        //    //默认选中未分类
        //    string strNoType = "<a href=\"javascript:;\" class='btn btn-success' onclick='selectPushType(this,\"" + DESEncrypt.Encrypt("0") + "\")'>未分类</a>&nbsp;&nbsp;";
        //    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");
                }
            }
        }
Exemplo n.º 9
0
        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>");
            }
        }
Exemplo n.º 10
0
        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");
            }
        }
Exemplo n.º 11
0
        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");
            }
        }
Exemplo n.º 12
0
        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 + "&nbsp;&nbsp;" + ((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();
        }
 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&&notice_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("[]");
     }
 }
 /// <summary>
 /// 根据与用户相关的推送通知
 /// </summary>
 /// <param name="context"></param>
 public void GetUserNotice(HttpContext context)
 {
     try
     {
         if (!IsAdminLogin())
         {
             FlushResponse(context, JsonConvert.SerializeObject(new ReturnObject() { Result = ERROR, Msg = "error" }));
             return;
         }
         var userId = GetAdminInfo().User_id;
         //var topN = 10;
         //var pushNewsItemList = new List<NoticeItem>();
         string notice_type = context.Request.Params["notice_type"];
         int page = int.Parse(context.Request.Params["page"]);
         var model = new BLL.CCOM.User_notice().GetModel("User_id=" + userId);
         if(notice_type!=null&&notice_type!="")
         {
             StringBuilder ulSb = new StringBuilder();
             string[] notice_ids=null;
             if (notice_type == "no_read")
             {
                 string ids = model.Notice_id;
                 if(ids!=null&&ids.Length>0&&ids!="")
                 {
                     notice_ids = ids.Split(','); 
                 } 
             }
             else
             {
                 string ids =model.Notice_read_id;
                 if (ids != null && ids.Length > 0 && ids != "")
                 {
                     notice_ids = ids.Split(',');
                 }
             }
             var sb = new StringBuilder();
             if (notice_ids!=null&&notice_ids.Length > 0)
             {
                 for (int i = 0; i < notice_ids.Length; i++)
                 {
                     if (i == 0)
                     {
                         sb.Append("Notice_id=" + notice_ids[i]);
                     }
                     else
                     {
                         sb.Append(" or Notice_id=" + notice_ids[i]);
                     }
                 }
                 int start_index = pageSize * (page - 1) + 1;
                 int end_index = pageSize * page;
                 DataTable dt = new BLL.CCOM.Notice().GetListByPage(sb.ToString(), "Notice_date DESC ", start_index, end_index).Tables[0];
                 
                 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 + "&nbsp;&nbsp;" + ((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>");
                     }
                 }
                 else
                 {
                     ulSb.Append("<li style=\"height:40px;font-size:18px;text-align:center;padding-top:21px;\">暂无通知消息!</li>");
                 }
                 
             }
             else
             {
                 ulSb.Append("<li style=\"height:40px;font-size:18px;text-align:center;padding-top:21px;\">暂无通知消息!</li>");
             }
             context.Response.Write(ulSb.ToString());
             //string json = ToJson(dt);
         }
         else//传参不正确
         {
             
         }  
     }
     catch (Exception ex)
     {
         String logContent = "GetUserNotice-";
         logContent += "Ex:" + ex.ToString() + "\r\n";
         Common.FileOperate.WriteFile(context.Server.MapPath("error-" + DateTime.Now.ToString("yyyyMMdd") + ".txt"), logContent);
         FlushResponse(context, JsonConvert.SerializeObject(new ReturnObject() { Result = ERROR, Msg = "error" }));
     }
 }
Exemplo n.º 15
0
        public static void CreateWebPushHtml(String pushId, String fileName, bool checkExists)
        {
            if ((!checkExists) || (!System.IO.File.Exists(fileName)))
            {
                var push = new BLL.CCOM.Notice().GetModel(Int64.Parse(pushId));
                if (push != null)
                {
                    //根据通知类型,读取对应的模板文件
                    string temp = HttpContext.Current.Server.MapPath("/AdminMetro/CCOM/notice/Notice_temp.html");
                    //图文通知
                    if (push.Notice_type != null && (bool)push.Notice_type)
                    {
                        temp = HttpContext.Current.Server.MapPath("/AdminMetro/CCOM/notice/Notice_image_temp.html");
                    }

                    String pushStr = FileOperate.ReadFile(temp);

                    //替换推送者
                    string realname = new BLL.CCOM.User_information().GetModel(push.Notice_sender_id).User_realname;
                    pushStr = pushStr.Replace("authorxxx", realname);

                    //替换发布日期
                    pushStr = pushStr.Replace("pubdatexxx", push.Notice_date.ToString());

                    //替换通知内容
                    String content = HttpContext.Current.Server.HtmlDecode(push.Notice_content);
                    pushStr = pushStr.Replace("contentxxx", content);

                    //替换标题
                    pushStr = pushStr.Replace("titlexxx", push.Notice_title);

                    //图文通知还需要替换附件
                    if (push.Notice_type != null && (bool)push.Notice_type)
                    {
                        //替换附件
                        StringBuilder sb = new StringBuilder();

                        var attachList = new BLL.CCOM.Notice_attach().GetModelList("Notice_id = " + pushId);
                        if (attachList.Count > 0)
                        {
                            sb.Append("<p class='attachTitle'>附件:</p>");
                            var itemCnt = 1;
                            foreach (var item in attachList)
                            {
                                sb.Append("<p class='attachItem'>(").Append(itemCnt).Append(")&nbsp;<a href='")
                                .Append("/home/push/Attach.aspx?id=").Append(DESEncrypt.Encrypt(item.Notice_attach_id.ToString()))
                                .Append("&address=").Append(HttpUtility.UrlEncode(item.Notice_attach_address))
                                .Append("&name=").Append(HttpUtility.UrlEncode(item.Notice_attach_name))
                                .Append("' target='_blank' >")
                                .Append(item.Notice_attach_name)
                                .Append("</a>")
                                .Append(OnlineViewHelper.GetOnlineViewWrapLink(item.Notice_attach_address, item.Notice_attach_name))
                                .Append("</p>");
                                itemCnt++;
                            }
                        }
                        pushStr = pushStr.Replace("attachxxx", sb.ToString());
                    }

                    //写文件
                    FileOperate.WriteNewFile(fileName, pushStr);
                }
            }
        }