Esempio n. 1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        NG.CachHelper.Redis.RedisHelper redis = new NG.CachHelper.Redis.RedisHelper();
        string v = this.fckBodyFooter.Text;

        redis.SetStringCash("News_Footer", v);
        redis.Close();
    }
Esempio n. 2
0
 protected void InitFooter()
 {
     NG.CachHelper.Redis.RedisHelper redis = new NG.CachHelper.Redis.RedisHelper();
     this.fckBodyFooter.Text = redis.GetStringCash("News_Footer");
     redis.Close();
 }
Esempio n. 3
0
    /// <summary>
    /// 确定提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strError = Validates();

        if (!string.IsNullOrEmpty(strError))
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('" + strError + "');</script>");
            return;
        }
        model.CategoryId      = Convert.ToInt32(this.ddlType.SelectedValue);
        model.Title           = SafeRequest.GetFormString("txtTitle");
        model.SubHead         = SafeRequest.GetFormString("txtSubHead");
        model.PublicationUnit = SafeRequest.GetFormString("txtUnit");
        model.FromSource      = SafeRequest.GetFormString("txtFromSouce");
        // model.KeyWord = SafeRequest.GetFormString("txtKeyWord");
        model.ReleaseDate  = !string.IsNullOrEmpty(this.txtReleaseDate.Text.Trim()) ? Convert.ToDateTime(this.txtReleaseDate.Text.Trim()) : System.DateTime.Now;
        model.IsTop        = 0; //SafeRequest.GetFormInt("radioTopList", 0);
        model.IndexCommend = 0; //SafeRequest.GetFormInt("radioIndexCommentList", 0);
        model.HotPic       = SafeRequest.GetFormString("radioHotList");
        model.HotDays      = SafeRequest.GetFormInt("txtHotDays", 3);
        //model.ArticleType = SafeRequest.GetFormInt("radioArticleTypeList", 0);
        model.Body = this.fckBody.Text;

        //追加底部
        if (cbFooter.Checked)
        {
            if (model.Body.IndexOf("start_auto_footer") == -1 && model.Body.IndexOf("end_auto_footer") == -1)
            {
                string autoFooter = "<!--start_auto_footer-->" + this.fckBodyFooter.Text + "<!--end_auto_footer-->";
                model.Body = model.Body + autoFooter;
            }
            //写入缓存
            NG.CachHelper.Redis.RedisHelper redis = new NG.CachHelper.Redis.RedisHelper();
            redis.SetStringCash("News_Footer", this.fckBodyFooter.Text);
            redis.Close();
        }

        //   model.IsComment = 0;// SafeRequest.GetFormInt("radioIsComment", 0);
        model.Approved   = SafeRequest.GetFormInt("radioApproved", 0);
        model.Sort       = SafeRequest.GetFormInt("txtSort", 99);
        model.AddedDate  = System.DateTime.Now;
        model.ExpireDate = System.DateTime.Now;
        model.ViewCount  = 0;
        // model.IsScrool = 0;
        // model.AddedUserId = Convert.ToInt32(_userId);//默认登录进来人的编号
        model.AddedUserId = 1;
        //~/upload/News/
        #region 保存图片
        if (!this.picUpload.Value.Equals("") && this.picUpload.PostedFile.ContentLength > 10)
        {
            string FileTZM = this.picUpload.PostedFile.FileName.Substring(this.picUpload.PostedFile.FileName.LastIndexOf(".") + 1);//得到文件的扩展名

            if (!IsPic(FileTZM.ToLower()))
            {
                JSUtility.Alert("上传图片格式不正确!");
                return;
            }
            if (this.picUpload.PostedFile.ContentLength > 1048576)
            {
                JSUtility.Alert("上传图片过大!");
                return;
            }
            Random rnd            = new Random();
            string UpLoadFileTime = DateTime.Now.ToString("yyMMddHHmmss") + rnd.Next(9999).ToString("0000"); //生成一个新的数图片名称
            string fileName       = UpLoadFileTime + "." + FileTZM;                                          //产生上传图片的名称
            if (!Directory.Exists(Request.MapPath("~/upload/News/")))
            {
                Directory.CreateDirectory(Request.MapPath("~/upload/News/"));
            }
            string Url = Request.MapPath("~/upload/News/" + fileName);
            picUpload.PostedFile.SaveAs(Url);
            model.ImgLink = "/upload/News/" + fileName;
        }
        else
        {
            model.ImgLink = ViewState["ImgLink"].ToString();
        }
        #endregion


        if (_Pid != "")
        {
            model.NewsID = _Pid;
            if (bll.Update(model))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>");
            }
        }
        else
        {
            model.NewsID = IdCreator.CreateId("T_News", "NewsId");
            if (bll.Add(model))
            {
                JSUtility.AlertAndRedirect("添加成功,请继续添加!", Request.RawUrl.ToString());
            }
        }
    }